feat():modify spi
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
install/tmp/lib/libboost_thread.so
Executable file
BIN
install/tmp/lib/libboost_thread.so
Executable file
Binary file not shown.
BIN
install/tmp/lib/libboost_thread.so.1.75.0
Executable file
BIN
install/tmp/lib/libboost_thread.so.1.75.0
Executable file
Binary file not shown.
@@ -277,6 +277,8 @@ public:
|
||||
{
|
||||
|
||||
someip_log_i("Start event [0x%04x] notify thread.",_event);
|
||||
|
||||
std::vector<byte_t> lastData; // 用于 on-change 模式去重
|
||||
|
||||
while (running_)
|
||||
{
|
||||
@@ -289,23 +291,16 @@ public:
|
||||
|
||||
if (_update_on_change || (0U == _cycle))
|
||||
{
|
||||
// for update on change
|
||||
/* If data is not empty and changed, to notify */
|
||||
static std::vector<byte_t> lastData;
|
||||
std::vector<byte_t> notify_data;
|
||||
notify_data.clear();
|
||||
notify_data = _notify_data_func();
|
||||
// for update on change: only notify when data changes
|
||||
std::vector<byte_t> notify_data = _notify_data_func();
|
||||
|
||||
if ((nullptr != _notify_data_func) && (lastData != notify_data))
|
||||
if (lastData != notify_data)
|
||||
{
|
||||
lastData = notify_data;
|
||||
std::shared_ptr<payload> _payload = runtime::get()->create_payload();
|
||||
_payload->set_data(notify_data);
|
||||
|
||||
someip_log_d("Notify event[0x%04x] with data size[%d] payload length[%d].", _event,notify_data.size(), _payload->get_length());
|
||||
|
||||
someip_log_d("Notify event[0x%04x] with data size[%d] payload length[%d].", _event, notify_data.size(), _payload->get_length());
|
||||
app_->notify(_service, _instance, _event, _payload);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -168,12 +168,12 @@ void my_spi_server_thread_func(void* arg) {
|
||||
// 调用SpiProtocol_Unpack解析SPI数据
|
||||
SpiProtocol_RxResultType result;
|
||||
int32_t unpack_ret = SpiProtocol_Unpack(buf, sizeof(buf), SPI_PROTO_FRAME_SIZE, &result);
|
||||
if (unpack_ret != SPI_PROTO_ERR_NONE)
|
||||
if (unpack_ret < 0)
|
||||
{
|
||||
printf("SpiProtocol_Unpack error: %d\n", unpack_ret);
|
||||
continue;
|
||||
}
|
||||
printf("SpiProtocol_Unpack success\n");
|
||||
printf("SpiProtocol_Unpack success, tlv_count=%d\n", unpack_ret);
|
||||
|
||||
// 处理解包后的数据:提取 CAN0~CAN5 数据分发到对应缓冲区
|
||||
for (uint8_t i = 0; i < result.tlv_count; i++)
|
||||
@@ -187,6 +187,10 @@ void my_spi_server_thread_func(void* arg) {
|
||||
g_can_data[can_ch].assign(result.tlvs[i].value,
|
||||
result.tlvs[i].value + result.tlvs[i].length);
|
||||
printf("CAN%d data updated, length=%u\n", can_ch, result.tlvs[i].length);
|
||||
printf(" HEX: ");
|
||||
for (size_t j = 0; j < g_can_data[can_ch].size(); j++)
|
||||
printf("%02X ", g_can_data[can_ch][j]);
|
||||
printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user