05-27-2006 05:02 PM
05-28-2006 08:47 AM
05-28-2006 09:00 AM
05-28-2006 11:32 AM
05-28-2006 12:35 PM
05-28-2006 02:43 PM
05-28-2006 06:30 PM
CDancer a écrit:
Thanks, guys, but I don't think you have understood my problem. Read the first sentence - 2 completely independant VIs, and 2 or more ports...
I have written a program today using the globals option, which works very well. There should be a better way though.
Chris
ViLabWorks a écrit:It isn't exactly clear to me why this is about one port. How much does one serial port cost versus programming time? Or even if it is about 4 serial ports the same applies. For me there is no question, doing something perhaps difficult versus spending next to nothing to solve the problem.
05-28-2006 10:07 PM
Chris, I really don't see why you would have a problem, most of the devices I know while surely give you an error if two seperate programs tried to access the same device while one session is open on the other program. So by default you don't need to do anything. Perhaps looking for errors..... Not only will you have device errors if you tried with most serial devices, but visa and windows will bark at you as well in most cases I suspect. I just don't see what you are fishing for really but I don't know your serial device. Also if extra ports help make the programming easy then most neighborhood PC shops can get you an extra port, and IT depts may have PC's lying around that you can get a port from too. Serial ports at computer shows go for nothing. I don't know your port situation, or real programming situation, but I don't see why simple regular careful visa programming in your LV 6.1 won't do the job.
Best of luck with it.
05-29-2006 02:02 PM
That was my first thought, it should generate an error if two VIs try to use the same port, but as I said, "it seems to be possible to have two VIs lock access to the same port, without generating an error".
Lack of serial ports is not the issue.
My solution is to have two global string arrays, one called Ports and one called Owners. When a VI takes control of a port, it adds the port name to Ports and adds its own name to Owners. Every VI checks these globals to make sure a port is free before trying to access it. The VIs can also release the port by deleting its name and port name from the arrays. I wrote one sub-vi to perform the functions "Check port is free", "Claim port if free" and "Release port if I own it".
It works very well. I just have to remember not to have two copies of the global variables VI 🙂
Chris