From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), 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: 

How can i deal with XNET Write and Read without loop?

Hello guys,

 

i'm using XNET to write only one Frame and then to read its response on the same port. But as you see in the attached VI, i can't get any response at all. For example, i send a frame with ID "0X5F9" out, the response schould be "0X123", but i get nothing back.

Xnet Write Read.PNG

Could anyone tell me how to capture the response without using the loop. Thanks!

0 Kudos
Message 1 of 15
(4,528 Views)

Do you need a delay or a timeout before seeing your response? As set up you're immediately reading after transmission with a timeout of 0.

Try increasing the timeout on your read or adding a delay before reading.

0 Kudos
Message 2 of 15
(4,474 Views)

Thank you for your reply. But it still doesn't work. After i had set the timeout into 0,25s or some number else, i got always timeout error...

0 Kudos
Message 3 of 15
(4,449 Views)

@mexaviesta wrote:

Thank you for your reply. But it still doesn't work. After i had set the timeout into 0,25s or some number else, i got always timeout error...


Well then I'd say your device doesn't respond within that timeout.  I'd set the timeout to something large like on the order of multiple seconds.  If your device returns in 500ms then your function will return, because you are looking for one frame.  Can you put another node on the bus to see the traffic?  Are you actually sending the frame, and is you device actually responding?

 

Also you aren't closing your references and that can be very bad for trying to startup again.  It can also cause memory leaks.

0 Kudos
Message 4 of 15
(4,436 Views)

Thanks a lot, my device must work, because i was used to use the normal CAN VIs (see below) to send and receive the frame, it worked. Now i would just translate the old code to XNET code. Is there anything wrong?

 

normal CAN.PNG

0 Kudos
Message 5 of 15
(4,404 Views)

There's some old functions there I'm not familiar with like setting the Tranceiver type, RTR, and I've never used that wait timer function.

 

"Can you put another node on the bus to see the traffic?  Are you actually sending the frame, and is you device actually responding?"