Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Preserving a reference to a XNET Session with a Global Variable?

I have a VI that is implemented as a state machine. I attempt to preserve a reference to one XNET "out" session and one XNET "in" session with one global variable for each. I am getting an error:-1074384740. I believe it is related and it only occurs when I call xnet write in the Run state. The sessions are acquired in the Init state.

 

Is it possible to use globals to preserve references to XNET sessions?

0 Kudos
Message 1 of 5
(4,631 Views)

BTW, I am using LabVIEW...

0 Kudos
Message 2 of 5
(4,630 Views)

swbpnole wrote: 

Is it possible to use globals to preserve references to XNET sessions?


Technically?  Yes this is possible.  Practically? Well you probably shouldn't do this.  You are putting a reference to hardware in a place that can be overwritten, closed, read, and manipulated without control, or having any reasonable way of finding where changes are being made.  I'd suggest a design where you have some kind of read-only access, or have some kind of control over who gets to do what with the reference.  Some say the answer is classes, some would say a VI wrapping the reference into a read is enough, and some might suggest a VIG where you can have methods that do things on the reference in a way that is a little easier to track.  Post your code if you can.

0 Kudos
Message 3 of 5
(4,625 Views)
0 Kudos
Message 4 of 5
(4,621 Views)

 

That being said that snippet is not the most useful, but what is is the whole application, seeing where else you read and write that global, and where references are closed.

0 Kudos
Message 5 of 5
(4,601 Views)