Browse Source

fix some can bug

master
zhaohe 12 months ago
parent
commit
1542db409a
  1. 11
      src/iflytop/components/zcanreceiver/socket_can/socket_can.cpp
  2. 2
      src/iflytop/components/zcanreceiver/zcanreceiverhost.cpp

11
src/iflytop/components/zcanreceiver/socket_can/socket_can.cpp

@ -30,14 +30,17 @@ SocketCan::SocketCanError_t SocketCan::sendFrame(shared_ptr<SocketCanFrame> fram
canfd_frame_t canframe = frame->getCanFrame();
return writeFrame(canframe);
}
SocketCan::SocketCanError_t SocketCan::writeFrame(const canfd_frame_t &frame) {
SocketCan::SocketCanError_t SocketCan::writeFrame(const canfd_frame_t &_frame) {
if (!m_canBusIsReady) {
return kDeviceBusy;
}
setTxStateToTxing(frame);
int ret = write(m_socketCanFd, &frame, frame.len + 8);
if (ret != (frame.len + 8)) {
canfd_frame_t txframe = _frame;
txframe.can_id |= 0x10000000;
setTxStateToTxing(txframe);
int ret = write(m_socketCanFd, &txframe, 16);
if (ret != (16)) {
logger->error("write fail,{}", strerror(errno));
unsetTxStateToTxing();
return kWriteError;

2
src/iflytop/components/zcanreceiver/zcanreceiverhost.cpp

@ -7,7 +7,7 @@ using namespace iflytop;
#define TAG "ZCanReceiver"
#define OVER_TIME_MS 5
#define OVER_TIME_MS 20
using namespace iflytop;
ZCanReceiverHost::ZCanReceiverHost() {}

Loading…
Cancel
Save