CAN_Read not reading the expected messages
CAN_Read not reading the expected messages
Hello ,
I am trying to read messages using CAN_Read in pcanbasic.
Setup:
PEAK usb is connected to Controller and controller continuously sending messages to a linux application.
the linux application is using CAN_Read function with 2000 Micro second interval to read those message coming from Controller.
As continuously messages are coming from controller, I am looking for some specific messages to be read by CAN_Read.
How I can ensure those message should be read by CAN_Read function?
Thankyou in Advance
I am trying to read messages using CAN_Read in pcanbasic.
Setup:
PEAK usb is connected to Controller and controller continuously sending messages to a linux application.
the linux application is using CAN_Read function with 2000 Micro second interval to read those message coming from Controller.
As continuously messages are coming from controller, I am looking for some specific messages to be read by CAN_Read.
How I can ensure those message should be read by CAN_Read function?
Thankyou in Advance
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: CAN_Read not reading the expected messages
Hello,
Have a look at the read-examples provided with the PCAN-Linux driver package
in the folder:
Furthermore also read the documentation provided for PCANbasic.
You'll need to read until the Reception queue is empty, for this purpose you can use the return
value "PCAN_ERROR_QRCVEMPTY".
This way no message should go unread.
Best Regards
Marvin
Have a look at the read-examples provided with the PCAN-Linux driver package
in the folder:
Code: Select all
peak-linux-driver-8.12.0\libpcanbasic\examples
You'll need to read until the Reception queue is empty, for this purpose you can use the return
value "PCAN_ERROR_QRCVEMPTY".
This way no message should go unread.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: CAN_Read not reading the expected messages
As per your comment I did the changes, please find the attachment.
I am having one doubt in it.
as per the code I have written all the message which have frame->id == 0x18D8DA32, will be read from the receive queue?
FYI "can_rx" function is being called periodically in every 2 ms.
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: CAN_Read not reading the expected messages
Hello,
This will not read all messages with ID= 0x18D8DA32 because you'll break
the while loop once one message with ID=0x18D8DA32 has been read:
Remove the break and it should print all instances of 0x18D8DA32.
You'll also have to read every message in the queue, there is no way around that.
You can process certain messages using an if condition, like you have done here, but then you cannot break the loop there if you intent to read all instances.
Best Regards
Marvin
This will not read all messages with ID= 0x18D8DA32 because you'll break
the while loop once one message with ID=0x18D8DA32 has been read:
Remove the break and it should print all instances of 0x18D8DA32.
You'll also have to read every message in the queue, there is no way around that.
You can process certain messages using an if condition, like you have done here, but then you cannot break the loop there if you intent to read all instances.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: CAN_Read not reading the expected messages
Thankyou for reply!!
As per your previous comment I removed the "Break" and now I think my expectation will be fulfill to read all the message from queue with message ID-0x18D8DA32.
but I am facing one weird behavior:
I am able to read the message 0x18D8DA32 from the queue which is not captured in pcanview. and at the same time I am not able to read the message 0x18D8DA32 which is captured in pcanview. how to resolve this issue?
Thankyou in Advance!
As per your previous comment I removed the "Break" and now I think my expectation will be fulfill to read all the message from queue with message ID-0x18D8DA32.
but I am facing one weird behavior:
I am able to read the message 0x18D8DA32 from the queue which is not captured in pcanview. and at the same time I am not able to read the message 0x18D8DA32 which is captured in pcanview. how to resolve this issue?
Thankyou in Advance!
Re: CAN_Read not reading the expected messages
Hi,
already described that behavior of the chardev driver in an other thread to you, do you remember? So why asking the same question again?
viewtopic.php?f=59&p=16239#p16209
regards
Michael
already described that behavior of the chardev driver in an other thread to you, do you remember? So why asking the same question again?
viewtopic.php?f=59&p=16239#p16209
regards
Michael
Re: CAN_Read not reading the expected messages
Hi
This is not the same question I asked before.
In this question I am looking for message coming from controller only.
So the question is like:
In pcanview I am able to see message with message ID-0x18D8DA32 and Data 00 1B 00 00 00 00 FF FF but this message is not received in Linux application.
but I am received a message with message ID-0x18D8DA32 and Data 0 11 FF FF FF FF FF FF in linux application with this message is not captured in pcanview.
Please let me know if question is still not clear.
Thankyou in advance !!
This is not the same question I asked before.
In this question I am looking for message coming from controller only.
So the question is like:
In pcanview I am able to see message with message ID-0x18D8DA32 and Data 00 1B 00 00 00 00 FF FF but this message is not received in Linux application.
but I am received a message with message ID-0x18D8DA32 and Data 0 11 FF FF FF FF FF FF in linux application with this message is not captured in pcanview.
Please let me know if question is still not clear.
Thankyou in advance !!
Re: CAN_Read not reading the expected messages
Hi,
looks like you mix up decimal with hex. While pcanview shows hex values, your application prints %u which is unsigned integer (decimal). Simply print as %x to see that it is the same message in hex format.
416864818 = 0x18D8DA32
regards
Michael
looks like you mix up decimal with hex. While pcanview shows hex values, your application prints %u which is unsigned integer (decimal). Simply print as %x to see that it is the same message in hex format.
416864818 = 0x18D8DA32
regards
Michael
Re: CAN_Read not reading the expected messages
Hi
Thankyou for reply!!
what you have mentioned is correct but still my question will be same.
the message id I am getting is -0x18D8DA32 only but the data is different as per pcanview reference? In the attachment if you see the in hex format the it will be -0 11 FF FF FF FF FF FF .
but in PCANVIEW the data is --> 00 1B 00 00 00 00 FF FF
Thankyou
Thankyou for reply!!
what you have mentioned is correct but still my question will be same.
the message id I am getting is -0x18D8DA32 only but the data is different as per pcanview reference? In the attachment if you see the in hex format the it will be -0 11 FF FF FF FF FF FF .
but in PCANVIEW the data is --> 00 1B 00 00 00 00 FF FF
Thankyou
Re: CAN_Read not reading the expected messages
Hi,
do you have your pcanbasic application and pcanview connected at the same time on the same device, or do you test separately?
regards
Michael
do you have your pcanbasic application and pcanview connected at the same time on the same device, or do you test separately?
regards
Michael