PCANBasic Receiving Data
Posted: Thu 19. Nov 2020, 04:19
Hello,
I am able to write messages using the PCAN-USB, however it doesn't seem to be able to read messages.
I am attempting to do the following:
However, when I was stepping through the code and it got to the PCANBasic.Read line, the program would always exit with code 0, even though the code was in an infinite loop (the while true).
If I had done something wrong, I would've assumed that the error would repeatedly occur, due to the loop, but this is not the case.
Does anyone know what I'm doing wrong?
Thank You.
I am able to write messages using the PCAN-USB, however it doesn't seem to be able to read messages.
I am attempting to do the following:
Code: Select all
while (true)
{
TPCANStatus result = TPCANStatus.PCAN_ERROR_OK;
do
{
TPCANMsg msg;
TPCANTimestamp time;
Console.WriteLine(result.ToString());
result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1, out msg, out time);
if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
{
ProcessMessage(msg, time);
}
} while ((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) != TPCANStatus.PCAN_ERROR_QRCVEMPTY);
}
If I had done something wrong, I would've assumed that the error would repeatedly occur, due to the loop, but this is not the case.
Does anyone know what I'm doing wrong?
Thank You.