I have the following piece of code that works well on Windows 10 and Windows 11 intel x86 machines. It basically checks whether the PCAN-USB device is connected.
On Debian/Linux intel x86, I'm having the following output most of the time when I plug out and then replug the PCAN-USB.
I see that there are macros, from 1 to 16 for specifying the handle (i.e PCAN_USBBUS1, PCAN_USBBUS2...PCAN_USBBUS16). Am I suppose to try all these values to see which one is correct?The value of a PCAN-Hardware handle is invalid
Code: Select all
{
std::lock_guard<std::mutex> lock(mainMutex);
status = CAN_Initialize(PcanHandle, Bitrate);
}
CANstsProcessedFlag = false;
caller->CANStatusWorkerNotify();
while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(CAN_CONN_RECHECK_TIMEOUT_MS));
if (CANstsProcessedFlag) {
{
std::lock_guard<std::mutex> lock(mainMutex);
prevStatus = status;
status = CAN_GetStatus(PcanHandle);
if (status != PCAN_ERROR_OK) {
status = CAN_Initialize(PcanHandle, Bitrate);
}
}
CANstsProcessedFlag = false;
caller->CANStatusWorkerNotify();
}
}