LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coordinating LabVIEW and Windows Services

We're running some python scripts from LabVIEW.

 

Some scripts commanded in LV run only once with a a button press. Another script runs about every 500 ms except while one of the 'button push' scripts runs (We had to stop the periodic script because all the scripts send commads to the same USB device.)

 

We'd like to run another python script as a Windows service; that background script will address the same USB device as the scripts run in LV.

 

Since the scripts running from LV 'command prompt' VIs and the script running as a Windows service will address the same device, I'm wondering if we'll need to coordinate LV execution with Windows services. If so, how would we do that?

 

Thanks,

 

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 1 of 2
(2,903 Views)

If you want to access a global resource (here your USB device) asynchronously from multiple places you almost always have to do some resource reservation or arbitration. Unless you can guarantee that every operation is atomic, but for a device that you communicate over a serial channel that is almost never the case as you typically have a command-response operation that better can't get interrupted by other things or the device will get confused.

 

Since a Windows Service is a different process (and often doesn't even run in the same terminal session as the logged in user) you have to use Inter Application Communication. Popular choices are either a locking file on some well known location that one has to create and keep locked for the duration of the operation and afterwards delete it, or nowadays usually some TCP/IP communication link. Making the locking file atomically safe is a challenge as most file operations itself aren't atomic. Same about using a distributed resource locking scheme over TCP/IP or some other communcation channel.

 

Since you plan to write a service anyhow the most straightforward way would probably be to have this service do all the communication with the device and have the other scripts send their requests over TCP/IP or some other IAC means to this service.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 2
(2,866 Views)