Hi all,
Recently, we found CANBus has an issue on i.MX6 DualLite. We used the following links to implement CANBus function.
Here is the process of CANBus.
↓
Flexcan/com_android_server_FlexcanService.cpp at master · zhangjie201412/Flexcan · GitHub
↓
Flexcan/flexcan.c at master · zhangjie201412/Flexcan · GitHub
Now the issue happened in _flexcan_send of flexcan.c When I call _flexcan_send this function frequently, it would return me an error.
But if I had a delay for waiting 5ms of every _flexcan_send), CANBus would be fine. It seems I couldn't call _flexcan_send too quick.
Has anyone met this issue before?
It would be grateful if there is any solution to it.
I have highlighted the code which returned me an error.
static int _flexcan_send(struct flexcan_device_t* flexcan_device,int *data, int id, int dlc, int extended,int rtr, int infinite, int loopcount)
{
int s = flexcan_device->s;
struct can_frame frame;
int i;
int ret;
for(i = 0; i < dlc; i++)
{
frame.data[i] = (char)data[i];
// LOGI("[flexcan]--%d = %d .",i,data[i]);
if(i == 8)
break;
}
frame.can_id = id;
frame.can_dlc = dlc;if (extended) {
frame.can_id &= CAN_EFF_MASK;
frame.can_id |= CAN_EFF_FLAG;
} else {
frame.can_id &= CAN_SFF_MASK;
}if (rtr)
frame.can_id |= CAN_RTR_FLAG;while (infinite || loopcount--) {
ret = write(s, &frame, sizeof(frame));
if (ret == -1) {
perror("write");
break;
}
}// close(s);
return 0;
}