11-17-2011 12:26 PM
I have a system services Labview executable that opens a VISA session on a COM port.
But I also have a User Interface VI that needs to communicate with the device on same COM port.
Is this possible? Can I use a Shared Variable to keep the VISA Resource name and have multiple users (one at a time) communicate with the device?
11-17-2011 12:45 PM
You can but a better approve would be to create a separate task that handles communication with the device. You could use a queue to send commands/requests to the process. The queue would include the command/data you want to send to the device and queue name/reference to return any data or response. This would ensure that all of the commands are processed correctly and the responses are handled properly as well. If you chose to have the read/writes in multiple places than you have to use some type of locking mechanism to ensure access by only one component at a time. If you don't you could end up with one process reading the response for another process's command.
11-17-2011 12:48 PM
Thanks for your quick reply.
Yes, I have a COM Port Semaphore subVI to avoid conflicts.
11-17-2011 12:51 PM
(continued)
The two VIs were working perfectly as long as both were running under my username. But now that the background task (mostly monitoring and storing data into database) is running under username 'system', I get errors when I use the UI VI.
11-17-2011 12:57 PM
It sounds like you are running two indiepent appilcations. You will need some form of interprocess communications to synchronize the two applications.
11-18-2011 08:23 AM - edited 11-18-2011 08:24 AM
LabVIEW semaphores and all other LabVIEW objects like queues, notifiers, events, etc are not only process local objects only but even application context local only. While this makes no difference for built applications it is important inside the development environment as each LabVIEW project lives in its own application context (and tools started from the Tools menu run in yet another context). To do what you want to do, you need to implement some form of interapplication communication as Mark already mentioned. Or you can access named OS semaphores by calling OS APIs.