|
@@ -159,7 +159,6 @@ void nvcan::threadrun()
|
|
for (i=0; i<currmax; i++) { /* check all CAN RAW sockets */
|
|
for (i=0; i<currmax; i++) { /* check all CAN RAW sockets */
|
|
|
|
|
|
if (FD_ISSET(s[i], &rdfs)) {
|
|
if (FD_ISSET(s[i], &rdfs)) {
|
|
-
|
|
|
|
nLastRecv = std::chrono::system_clock::now().time_since_epoch().count()/1e6;
|
|
nLastRecv = std::chrono::system_clock::now().time_since_epoch().count()/1e6;
|
|
/* these settings may be modified by recvmsg() */
|
|
/* these settings may be modified by recvmsg() */
|
|
iov.iov_len = sizeof(frame);
|
|
iov.iov_len = sizeof(frame);
|
|
@@ -181,6 +180,7 @@ void nvcan::threadrun()
|
|
// return 1;
|
|
// return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
if ((size_t)nbytes == CAN_MTU)
|
|
if ((size_t)nbytes == CAN_MTU)
|
|
maxdlen = CAN_MAX_DLEN;
|
|
maxdlen = CAN_MAX_DLEN;
|
|
else if ((size_t)nbytes == CANFD_MTU)
|
|
else if ((size_t)nbytes == CANFD_MTU)
|
|
@@ -193,18 +193,22 @@ void nvcan::threadrun()
|
|
nrecvcount++;
|
|
nrecvcount++;
|
|
// qDebug("receive msg.");
|
|
// qDebug("receive msg.");
|
|
mMutex.lock();
|
|
mMutex.lock();
|
|
|
|
+
|
|
|
|
|
|
basecan_msg msg;
|
|
basecan_msg msg;
|
|
msg.id = frame.can_id&0x1fffffff;
|
|
msg.id = frame.can_id&0x1fffffff;
|
|
|
|
+
|
|
if((frame.can_id&0x80000000)!= 0)msg.isExtern = true;
|
|
if((frame.can_id&0x80000000)!= 0)msg.isExtern = true;
|
|
else msg.isExtern = false;
|
|
else msg.isExtern = false;
|
|
if((frame.can_id&0x40000000)!= 0)msg.isRemote = true;
|
|
if((frame.can_id&0x40000000)!= 0)msg.isRemote = true;
|
|
else msg.isRemote = false;
|
|
else msg.isRemote = false;
|
|
msg.nLen = frame.len;
|
|
msg.nLen = frame.len;
|
|
|
|
+ int ndl = msg.nLen;
|
|
// if(msg.id == 0x1c2)qDebug("id = %08x",msg.id);
|
|
// if(msg.id == 0x1c2)qDebug("id = %08x",msg.id);
|
|
- if((frame.len<=64)&&(frame.len>0))memcpy(msg.data,frame.data,frame.len);
|
|
|
|
|
|
+ if((frame.len<=64)&&(frame.len>0))memcpy(msg.data,frame.data,ndl);
|
|
|
|
|
|
msg.frecvtime = 0.0;
|
|
msg.frecvtime = 0.0;
|
|
|
|
+
|
|
for (cmsg = CMSG_FIRSTHDR(&xmsghdr);
|
|
for (cmsg = CMSG_FIRSTHDR(&xmsghdr);
|
|
cmsg && (cmsg->cmsg_level == SOL_SOCKET);
|
|
cmsg && (cmsg->cmsg_level == SOL_SOCKET);
|
|
cmsg = CMSG_NXTHDR(&xmsghdr,cmsg)) {
|
|
cmsg = CMSG_NXTHDR(&xmsghdr,cmsg)) {
|
|
@@ -233,6 +237,7 @@ void nvcan::threadrun()
|
|
std::cout<<" type is SO_RXQ_OVFL"<<std::endl;
|
|
std::cout<<" type is SO_RXQ_OVFL"<<std::endl;
|
|
// memcpy(&dropcnt[i], CMSG_DATA(cmsg), sizeof(__u32));
|
|
// memcpy(&dropcnt[i], CMSG_DATA(cmsg), sizeof(__u32));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
if(mMsgRecvBuf[i].size()<BUF_SIZE)
|
|
if(mMsgRecvBuf[i].size()<BUF_SIZE)
|
|
{
|
|
{
|
|
@@ -244,6 +249,7 @@ void nvcan::threadrun()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
if((std::chrono::steady_clock::now().time_since_epoch().count()/1e6 - nLastRecv)> 1000)
|
|
if((std::chrono::steady_clock::now().time_since_epoch().count()/1e6 - nLastRecv)> 1000)
|
|
{
|
|
{
|
|
if(nRecvState == 0)
|
|
if(nRecvState == 0)
|