diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp index 2e85d35..46a1ca3 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp @@ -165,6 +165,8 @@ shared_ptr ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, ui } sendframe(1, to, (uint8_t *)frame, paramLen + sizeof(zcanbus_packet_t)); + if (to == 0xff) return nullptr; // 广播包没有回执 + bool rxreceipt = false; for (int32_t i = 0; i < overtime; i++) { @@ -206,7 +208,7 @@ shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t for (size_t i = 0; i <= 3; i++) { try { - receipt = base_callcmd(to, cmdid, param, paramLen, overtime); + return base_callcmd(to, cmdid, param, paramLen, overtime); } catch (const appexception &e) { if (e.ecode == kerr_overtime) { if (i != 0) logger->warn("callcmd cmdid[{}] to [{}] overtime, retry {}", cmdid, to, i); @@ -222,8 +224,8 @@ shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t break; } - if (receipt == nullptr) THROW_APP_EXCEPTION(kerr_overtime, "overtime"); - return receipt; + THROW_APP_EXCEPTION(kerr_overtime, "overtime"); + return nullptr; } shared_ptr ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); } shared_ptr ZSCanProtocolCom::callcmd1(int32_t device_id, int32_t cmdid, int32_t param0, int32_t overtime) { diff --git a/appsrc/service/hardware/device_io_ctrl_service.cpp b/appsrc/service/hardware/device_io_ctrl_service.cpp index 91b8a78..aa40c63 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.cpp +++ b/appsrc/service/hardware/device_io_ctrl_service.cpp @@ -114,9 +114,12 @@ void DeviceIoControlService::initialize() { heartThread.reset(new Thread("heartThread", [this]() { while (true) { - std::this_thread::sleep_for(std::chrono::seconds(10)); - if (isInTestMode()) continue; + if (isInTestMode()) { + std::this_thread::sleep_for(std::chrono::seconds(60)); + continue; + } CAN_MASTER->pingAllBoard(); + std::this_thread::sleep_for(std::chrono::seconds(60)); } })); @@ -146,23 +149,24 @@ int DeviceIoControlService::forceStopDeviceWithoutExc() { } int DeviceIoControlService::processHeartReportMsg(uint8_t from, report_heatpacket_data_t *report) { + // if (from < 100) { logger->info(" REPORT [Heat ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{}", from, report->heartIndex, BoardTypeId2Str(report->boardType), report->flag); - -#define CHECK_BOARD_IS_REBOOT(boardid, ecode) \ - { \ - static bool firstReport = true; \ - if (report->flag != 0 && from == boardid) { \ - if (firstReport) { \ - CAN_MASTER->clearResetFlag(boardid); \ - firstReport = false; \ - } else { \ - AppEventBus::ins()->push(make_shared(ecode)); \ - } \ - } \ - } - - CHECK_BOARD_IS_REBOOT(kFixBoardId_LiquidCtrl, err::kappe_liquid_ctrl_reboot); - CHECK_BOARD_IS_REBOOT(kFixBoardId_PowerControl, err::kappe_power_control_reboot); + // } + // #define CHECK_BOARD_IS_REBOOT(boardid, ecode) \ + // { \ + // static bool firstReport = true; \ + // if (report->flag != 0 && from == boardid) { \ + // if (firstReport) { \ + // CAN_MASTER->clearResetFlag(boardid); \ + // firstReport = false; \ + // } else { \ + // logger->error("Detected board:{} is rebooting, push warning prompt.", boardid); \ + // AppEventBus::ins()->push(make_shared(ecode)); \ + // } \ + // } \ + // } + // CHECK_BOARD_IS_REBOOT(kFixBoardId_LiquidCtrl, err::kappe_liquid_ctrl_reboot); + // CHECK_BOARD_IS_REBOOT(kFixBoardId_PowerControl, err::kappe_power_control_reboot); return 0; } @@ -203,7 +207,15 @@ int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_ } else if (packet->function_id == kreport_device_reset) { - logger->info(" REPORT [DeviceReset][FROM:{}]", from); + logger->warn(" REPORT [DeviceReset][FROM:{}] reason:{}", from, packet->params[0]); + if (kFixBoardId_LiquidCtrl == from) { + logger->error("Detected board:{} is rebooting, push warning prompt.", from); + AppEventBus::ins()->push(make_shared(err::kappe_liquid_ctrl_reboot)); + } else if (kFixBoardId_PowerControl == from) { + logger->error("Detected board:{} is rebooting, push warning prompt.", from); + AppEventBus::ins()->push(make_shared(err::kappe_power_control_reboot)); + } + } else { logger->info(" REPORT [Unknow][FROM:{}] function_id:{:x}", from, packet->function_id); }