LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can two users share a COM port?

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?

 

0 Kudos
Message 1 of 6
(2,476 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 6
(2,470 Views)

Thanks for your quick reply.

Yes, I have a COM Port Semaphore subVI to avoid conflicts.

 

0 Kudos
Message 3 of 6
(2,468 Views)

(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.

0 Kudos
Message 4 of 6
(2,463 Views)

It sounds like you are running two indiepent appilcations. You will need some form of interprocess communications to synchronize the two applications.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 6
(2,456 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(2,425 Views)