From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-25-2015 11:01 AM - edited 08-25-2015 11:01 AM
Hello,
i'm using XNET to communicate with our CAN device. I send and then receive several frame one by one. The sending and receiving of the first several frame succeed, but then after i had sent a frame, i received a unexpected response. So i have checked it in the NI-I/O-Trace Buffer content (see photo), and found that the frame i would receive is the frame with buffer No. "00000008", but actually i have received the frame with buffer No. "00000010". Anyone can help me to deal with this problem? Thx.
Solved! Go to Solution.
08-25-2015 11:42 AM
Do you have any code you can share that shows this issue? It sounds to me like you are not reading the buffer often enough and/or your device is sending out more data than you expect.
08-25-2015 02:18 PM
Could it be that you think that the buffer index is a decimal number, when it is a hex?
0x8 + 0x8 = 0x10!
08-25-2015 02:58 PM
@dkfire wrote:
Could it be that you think that the buffer index is a decimal number, when it is a hex?
0x8 + 0x8 = 0x10!
That display is just showing the entire buffer. On the side are the byte number in hex of the first element in the row. So you have more data than you expected to read. That tells me you are not reading your data fast enough.
08-25-2015 03:10 PM
08-26-2015 02:00 AM
thanks for all your reply. I attach here my VI, as you can see, all the frame-writing and the first two reading were good, i just got the unexpected frame at the last reading "read3".
08-26-2015 07:49 AM
@mexaviesta wrote:
thanks for all your reply. I attach here my VI, as you can see, all the frame-writing and the first two reading were good, i just got the unexpected frame at the last reading "read3".
The frame you received at read3 is what it is expected to read. In Frame Input Stream mode you are reading all available frames. The output of the read function is an array of frames. After Write1 you are reading 5F9 in read1. Then you write 2 frames, 7FC. Read2 output is an array of 2 7FC frames. Then in write4 you are sending frame7FB so this is the frame you should get in read3.
Ben64
08-26-2015 08:37 AM - edited 08-26-2015 08:40 AM
nop, it's not. The payload of the frame what i expected to receive must be "8C 6C 90 ....." but not "00 0C 6C 8C ...", you can see the following 2 photos: one of them is from the xnet-monitor, another one had been shown in my first message, it shows the last frame i've received. In my other read (read1 read2) i have received all the right frame with index '00000008', only in read´3, i've received it with '00000010'. How can i get the '00000008' frame is what i want to know...
08-26-2015 10:44 AM
So now the question is what is in the buffer and why do you think you'll get data from buffer index 0x8.
Lets try to do some math and understand some of the data.
So a CAN message will contain a lot more information other that the up to 8 bytes of payload.
It needs the ID of the message and the payload lenght and the payload. But the driver also needs a timestamp.
Now looking at you "log" from the XNET monitor, the message ID that you receive is 428895372 in decimal and in hex 0x19906C8C
Now that is very close to what you see in the buffer. So looking at the buffer in index 0x8 and forward you have the message ID with some extra bits set and the length of the payload.
(The first part of the buffer could be something regarding the timestamp)
That is how I read the buffer and the data that is displayed in the Monitor.
Now why do you think your payload should be different?
And what should be the message ID?
08-27-2015 02:05 AM
Thank you ´very much! I finally know why i got the "unexpected Frame" and the Error message.
Because our CAN device sends 30bits Identifier instead of 29bits, but the XNET Read (Frame CAN). vi reads only 29Bits arbitrartion, if i understood right. For example:the frame which is sent from our device is "x39906C8C", but we receive it as "x19906C8C", the 30th bit is lost.
I used to use the CAN bus Interface NI PXI-8464/2 and the normal CAN vi to communicate with our device, then with the ncReadNet.vi i can receive a 30bits arbitration . But now with XNET i would ask how how can i receive a 30bits ID frame? Thx