i use a PCAN USB Dongle with driver version 4.1.3. Initializing a channel works fine until the application is closed during debugging with the 'Stop Debugging' button in Visual Studio. Afterwards, CAN_Initialize always returns PCAN_ERROR_INITIALIZE. The only workaround i found so far is restarting Visual Studio. Probably this is due to the not uninitialized channel of the closed application. Is there some way to uninitialize all open channels at the start of the application? Calling CAN_uninitialize(PCAN_USBBUS1) or CAN_uninitialize(PCAN_NONEBUS) does not help. I used this code from the examples:
Code: Select all
int main()
{
TPCANStatus result;
char strMsg[256];
// Der PCI Kanal wird initialisiert.
//
result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
if (result != PCAN_ERROR_OK)
{
// Ein Fehler ist aufgetreten. Die Rückgabewert wird in Text umgewandelt und angezeigt.
//
CAN_GetErrorText(result, 0, strMsg);
std::cout << strMsg << std::endl;
}
else
std::cout << "OK" << std::endl;
Sleep(3000);
return 0;
}