|
|
@ -16,10 +16,11 @@ void ZExCanChannel::initialize() { |
|
|
|
m_zcanreceiverhost.reset(new ZCanReceiverHost()); |
|
|
|
m_zcanreceiverhost->initialize(m_can_if_name, m_baudrate); |
|
|
|
|
|
|
|
m_zcanreceiverhost->registerListener([this](uint8_t fromboardid, uint8_t* packet, size_t len) { |
|
|
|
string hexStr = StringUtils().bytesToString((uint8_t*)packet, len); |
|
|
|
logger->info("RX:<- {}({})", m_chname, hexStr, len); |
|
|
|
if (m_ondata) m_ondata(this, false, (const char*)hexStr.data(), len); |
|
|
|
m_zcanreceiverhost->registerListener([this](uint8_t fromboardid, uint8_t* packet, size_t packetlen) { |
|
|
|
string hexStr = StringUtils().bytesToString((uint8_t*)packet, packetlen); |
|
|
|
|
|
|
|
logger->info("RX:<- {}({})", m_chname, hexStr, hexStr.size()); |
|
|
|
if (m_ondata) m_ondata(this, false, (const char*)hexStr.data(), hexStr.size()); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -27,9 +28,9 @@ void ZExCanChannel::senddata(bool binary, const char* data, size_t len) { |
|
|
|
string txdata = string(data, len); |
|
|
|
|
|
|
|
logger->info("{} TX:-> {}({})", m_chname, txdata, len); |
|
|
|
vector<uint8_t> rxbyte; |
|
|
|
StringUtils().hexStringToBytes(txdata, "", rxbyte); |
|
|
|
m_zcanreceiverhost->sendPacket(rxbyte.data(), rxbyte.size()); |
|
|
|
vector<uint8_t> txbyte; |
|
|
|
StringUtils().hexStringToBytes(txdata, "", txbyte); |
|
|
|
m_zcanreceiverhost->sendPacket(txbyte.data(), txbyte.size()); |
|
|
|
} |
|
|
|
void ZExCanChannel::registerOnDataCallback(OnData_t ondata) { m_ondata = ondata; } |
|
|
|
void ZExCanChannel::callcmd(string cmd, unordered_map<string, string> param, json& receipt) { |
|
|
|