Browse Source

update

storage-in-realtime
zhaohe 12 months ago
parent
commit
5541a19018
  1. 8
      README.md
  2. 23
      appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp
  3. 2
      appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp
  4. 0
      doc/硬件测试指令.md

8
README.md

@ -62,9 +62,11 @@ TODO:
1. 整理大空间,小空间,管道式的单片机代码,满足多设备编码规范。(按照真实的设备情况编写代码)OK 1. 整理大空间,小空间,管道式的单片机代码,满足多设备编码规范。(按照真实的设备情况编写代码)OK
2. 整理大空间,小空间,管道式的ID路由代码。
3. 填充硬件测试页面。
4. 指令重发代码功能。
2. 整理大空间,小空间,管道式的ID路由代码。OK
3. 填充硬件测试页面。OK
4. 指令重发代码功能。OK
5. 硬件测试 OK
6. 所有后台程序添加异常检查,当异常发生过,则设置全局标志位(硬件异常)。此时后台程序相应的线程将不再继续工作。(直到设备重启) 6. 所有后台程序添加异常检查,当异常发生过,则设置全局标志位(硬件异常)。此时后台程序相应的线程将不再继续工作。(直到设备重启)
7. 所有后台程序(有前端启动的),则是检查全局标志位,如果触发错误,则报错。 7. 所有后台程序(有前端启动的),则是检查全局标志位,如果触发错误,则报错。
8. 添加消毒日志打印程序 8. 添加消毒日志打印程序

23
appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp

@ -9,7 +9,6 @@ using namespace zscanprotocol;
#define TAG "ZScanProtocolCom" #define TAG "ZScanProtocolCom"
void ZSCanProtocolCom::initialize(const char *canname, int baudrate, bool enableLoopBack) { // void ZSCanProtocolCom::initialize(const char *canname, int baudrate, bool enableLoopBack) { //
m_channel = make_shared<SocketCan>(); m_channel = make_shared<SocketCan>();
m_channel->initialize(canname, baudrate, enableLoopBack); m_channel->initialize(canname, baudrate, enableLoopBack);
@ -73,7 +72,7 @@ void ZSCanProtocolCom::sendframe(int32_t from, int32_t to, uint8_t *frame, size_
int npacket = len / 8 + (len % 8 == 0 ? 0 : 1); int npacket = len / 8 + (len % 8 == 0 ? 0 : 1);
if (npacket > 255) { if (npacket > 255) {
THROW_APP_EXCEPTION(err::kerr_invalid_param, "param error: packet too long");
THROW_APP_EXCEPTION(err::kerr_invalid_param, "param error: packet too long");
} }
int finalpacketlen = len % 8 == 0 ? 8 : len % 8; int finalpacketlen = len % 8 == 0 ? 8 : len % 8;
@ -140,7 +139,7 @@ CanPacketRxBuffer *ZSCanProtocolCom::findRxBuff(int deviceId) {
return nullptr; return nullptr;
} }
shared_ptr<Receipt> ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t *param, int32_t paramLen, int32_t overtime) {
shared_ptr<Receipt> ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, uint8_t *param, int32_t paramLen, int32_t overtime) {
m_txindex++; m_txindex++;
if (m_txindex < 200) m_txindex = 200; if (m_txindex < 200) m_txindex = 200;
@ -193,6 +192,24 @@ shared_ptr<Receipt> ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t
receipt->receiptLen = m_receipt_len; receipt->receiptLen = m_receipt_len;
return receipt; return receipt;
} }
shared_ptr<Receipt> ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t *param, int32_t paramLen, int32_t overtime) {
shared_ptr<Receipt> receipt;
for (size_t i = 0; i <= 3; i++) {
try {
if (i != 0) logger->warn("callcmd overtime, retry %d", i);
receipt = base_callcmd(to, cmdid, param, paramLen, overtime);
} catch (const appexception &e) {
if (e.ecode() == err::kerr_overtime) {
continue;
}
throw;
}
}
if(receipt == nullptr) THROW_APP_EXCEPTION(err::kerr_overtime, "overtime");
return receipt;
}
shared_ptr<Receipt> ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); } shared_ptr<Receipt> ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); }
shared_ptr<Receipt> ZSCanProtocolCom::callcmd1(int32_t device_id, int32_t cmdid, int32_t param0, int32_t overtime) { shared_ptr<Receipt> ZSCanProtocolCom::callcmd1(int32_t device_id, int32_t cmdid, int32_t param0, int32_t overtime) {
int32_t param[4]; int32_t param[4];

2
appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp

@ -113,6 +113,8 @@ class ZSCanProtocolCom {
private: private:
CanPacketRxBuffer *findRxBuff(int deviceId); CanPacketRxBuffer *findRxBuff(int deviceId);
string ecode2str(int ecode); string ecode2str(int ecode);
shared_ptr<Receipt> base_callcmd(int32_t to, int32_t cmdid, uint8_t *param, int32_t paramLen, int32_t overtime);
}; };
} // namespace zscanprotocol } // namespace zscanprotocol

0
doc/硬件测试指令.md

Loading…
Cancel
Save