08-22-2025 03:30 PM
I asked this question in the TestStand forum, but it really is more of a LabView question. So reposting here since no one replied in the other forum.
I'm calling a TestStand 2014 CAN sequence from Python. This sequence calls a CAN LabView VI which can perform initialization, enable the receiver, or read frames depending on the command passed in. Python is making separate calls to this sequence to do the CAN initialization, then to enable the CAN receiver, then Python runs the UUT to transmit CAN data, then the sequence (VI) is called to read the received frames. However, when Python calls the enable CAN receiver sequence it gives an error "Error -1074384740 occurred at XNET Start.vi:1790006 ... Solution: Defer clear (session close) until you are done using it".
From my research it appears that the XNET CAN session is automatically being closed after the VI is done executing after CAN initialization. Interestingly, if I call the CAN initialization sequence manually from TestStand, then run the Python code which enables the CAN hardware and reads received frames it works as expected.
Is there any way to keep the XNET session open between sequence calls from Python?
Solved! Go to Solution.
08-23-2025 03:32 AM
it would help to share the vi here.
However, I think you might pass a wrong can adapter identifier when initializing from python.
08-25-2025 01:38 AM
Change the Unload option to Unload after sequence file unloads to keep the VI in the memory.
08-26-2025 02:31 PM
The Unload option in the sequence file was already set to "Unload when sequence file is unloaded". However, you gave me a big clue. After Python was calling the sequence file, the code was calling NI Engine.ReleaseSequenceFileEx() to release the sequence file. Instead of releasing it, I save the sequence object from Engine.GetSequenceFileEx() and then release it at program exit by calling Engine.ReleaseSequenceFileEx() in the Python function that is registered with atexit.register().
It now works perfectly, thanks!