|
|
@ -27,9 +27,22 @@ SocketCan::SocketCanError_t SocketCan::sendFrame(shared_ptr<SocketCanFrame> fram |
|
|
|
return writeFrame(canframe); |
|
|
|
} |
|
|
|
SocketCan::SocketCanError_t SocketCan::writeFrame(const canfd_frame_t &frame) { |
|
|
|
setTxStateToTxing(frame); |
|
|
|
int ret = write(m_socketCanFd, &frame, sizeof(frame)); |
|
|
|
if (ret != sizeof(frame)) { |
|
|
|
canfd_frame_t txframe = frame; |
|
|
|
txframe.can_id |= 0x10000000; |
|
|
|
setTxStateToTxing(txframe); |
|
|
|
/**
|
|
|
|
* @TODO |
|
|
|
* 如果发送像下面这种ID时,底层代码会一直重发,目前原因未知,临时的解决办法是将ID的第29位设置为1 |
|
|
|
* ID DATA |
|
|
|
* 00000100#112233445566 |
|
|
|
* 00000200#112233445566 |
|
|
|
* 00000300#112233445566 |
|
|
|
* 00000400#112233445566 |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
int ret = write(m_socketCanFd, &txframe, 16 /*固定长度*/); |
|
|
|
if (ret != 16) { |
|
|
|
logger->error("write fail,{}", strerror(errno)); |
|
|
|
unsetTxStateToTxing(); |
|
|
|
return kWriteError; |
|
|
|