CAN lib not duplex in FlexCAN driver for VF61
The driver does not support transmitting while waiting for read to timeout.
Also, the send function does not distinguish between error and timeout.
I use the following construct:
void CANThread(LPVOID lpVoid){
tCanMsg canmsg;
while(!g_fExitApp){
canmsg.dataLen = 8;
if(VybCan_Read(g_hCAN, &canmsg)){
// process msg
}
}
}
BOOL SendCAN(DWORD dwMsgID, DWORD dwLen, BYTE* bData){
tCanMsg canmsg;
canmsg.id = dwMsgID;
canmsg.canMsgFlags = 0;
canmsg.dataLen = dwLen;
memcpy(canmsg.data, bData, dwLen);
return VybCan_Write(g_hCAN, &canmsg);
}
VybCan_Write() is a blocking call, and returns when VybCan_Read() times out. I have to set the timeout to a very short time, say 50ms, to give the appearance of duplex. Is this the best work around?