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,392 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,338 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,313 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,300 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,268 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?"

0 Kudos
Message 6 of 15
(4,254 Views)

In addition to Hooovahh's suggestion, are you sure you're sending the correct Frame Type? (i.e. maybe you're sending an extended ID when you mean to be sending a standard ID.)

0 Kudos
Message 7 of 15
(4,247 Views)

Actually i'm not sure if i really send the frame out. How can i see that?

0 Kudos
Message 8 of 15
(4,241 Views)

@mexaviesta wrote:

Actually i'm not sure if i really send the frame out. How can i see that?


If you've got another CAN device you can attach to your bus you can just use NI-XNET Monitor.

If not, you can use NI I/O trace to make sure the I/O calls have the data you expect to see in them.

Or you can hook up a mixed signal oscilloscope which reads CAN.

0 Kudos
Message 9 of 15
(4,236 Views)

Thanks, now i'm sure that i am not sending any frame out, because i'm using an external transeiver to connect to the CAN bus. Thus i should have configured the Interface to 'External'. So i have used the propertynode to set the transeivertype to external, but it still dosen't work.  Does anyone know how to solve it? ThxXnet-konfig.PNG

0 Kudos
Message 10 of 15
(4,204 Views)