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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XNET buffer problem

Solved!
Go to solution

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.

0 Kudos
Message 1 of 13
(4,612 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 13
(4,598 Views)

Could it be that you think that the buffer index is a decimal number, when it is a hex? 

0x8 + 0x8 = 0x10!

0 Kudos
Message 3 of 13
(4,575 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 13
(4,565 Views)

I agree with Crossrulz that you are probably not reading the frames fast enough. What type of xnet session are you using?

 

Ben64

0 Kudos
Message 5 of 13
(4,555 Views)

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".

0 Kudos
Message 6 of 13
(4,528 Views)

@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

0 Kudos
Message 7 of 13
(4,488 Views)

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...

 

 Unbenannt.PNG

IO trace.PNG

0 Kudos
Message 8 of 13
(4,476 Views)

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?

 

0 Kudos
Message 9 of 13
(4,461 Views)

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

 

 

 

 

0 Kudos
Message 10 of 13
(4,440 Views)