Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN command over XNET not always transmitted

Solved!
Go to solution

I am attempting to send a CAN message using a PXI-8512.  I have a database set up.  When I write the data to CAN, it turns on an icon on a display.   This works 90% of the time on a known good unit.  However, 10% of the time, I call this sub-vi (shown below) which is supposed to turn on the icon, and the icon never turns on.  I thought perhaps I wasn't giving it enough time before I closed the session, so I increased the loop timer to 1500 ms, but that didn't help.  (I believe the loop timer was 500 ms before I increased it).  Does anyone have any ideas as to why this message isn't being received correctly some of the time?

CAN write.png

0 Kudos
Message 1 of 5
(3,364 Views)

You are using a single-point session. If the frame isn't transmitted before you call write again, the prior one will not be transmitted. Also, closing the session will abort the last frame if it isn't sent. Your timer isn't guaranteed to run after the frame write. If you really want to wait the 1.5s , you may add a delay before the "close", outside of the loop.

0 Kudos
Message 2 of 5
(3,341 Views)

What would prevent the frame from being transmitted before I call write again?  And why isn't my timer guaranteed to run?  I'm still fairly new to Labview and very new to CAN, so I appreciate the information.

 

I ended up putting the write VI in a for loop to run 3x.  This seems to be working - I haven't experienced the same issue since I added that to the code.  But, it still doesn't explain why this is happening, and I'd like to understand rather than just putting a band aid on it.

0 Kudos
Message 3 of 5
(3,332 Views)
Solution
Accepted by topic author KDillon

The timer will run, but it could be first or last as you don't sequence them at all.

 

The CAN bus is a shared bus. Presumably 1.5s between frames is sufficiently long, but if you are running a slow baud rate and the bus is very busy, you could get squeezed out.

 

Your other option, if you want every frame to transmit, is to use a queued session instead of a single point session. And you can wait for transmit to be complete before closing.

Message 4 of 5
(3,328 Views)

Very helpful, thanks.  I appreciate your time.

0 Kudos
Message 5 of 5
(3,322 Views)