When I use pcan using Can_read and Can_write, sometimes this function execution time is more than 3~20ms over.
our using source code is
Code: Select all
int usbPCanDriver::Write(TPCANMsg msg)
{
std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now();
TPCANStatus status = CAN_Write(pcan_device_, &msg);
std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_time;
if(sec.count()*1000 > 3)
{
DBG_ERROR("PCANWRITE: %f ms",sec.count()*1000);
}
if (status != PCAN_ERROR_OK)
{
DBG_ERROR("Tx Error: %x",status);
}
return status;
}
void usbPCanDriver::Read_Loop()
{
TPCANMsg Message;
while (1)
{
std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now();
TPCANStatus status = CAN_Read(pcan_device_, &Message, NULL);
std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_time;
if (status == PCAN_ERROR_OK)
{
Notify("RxCANMsg_Callback", Message);
std::chrono::duration<double> sec2 = std::chrono::system_clock::now() - start_time;
if(sec.count()*1000 > 3)
{
DBG_ERROR("PCANREAD: %f ms",sec.count()*1000);
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
imformation about linux pcaninfo
PCAN driver version: 8.15.2
PCAN-Basic version: 4.6.2.36
* pcanusb32 "PCAN_USBBUS1" (0x051), PCAN-USB #1, devid=0x1E (/sys/class/pcan/pcanusb32)
There is only 1 usb for pcan-usb on the PC.
We use this model.
https://ko.aliexpress.com/item/10050028 ... pt=glo2kor
Is there any problem in our codes?