Page 1 of 1

PCANBasic Receiving Data

Posted: Thu 19. Nov 2020, 04:19
by MansillSmithLICA
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:

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);
            }
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.

Re: PCANBasic Receiving Data

Posted: Thu 19. Nov 2020, 04:34
by MansillSmithLICA
Solved, was to do with how the thread was setup

Re: PCANBasic Receiving Data

Posted: Thu 19. Nov 2020, 10:14
by PEAK-Support
Thank“s for the feedback!