Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Shaing DIO ports between apps, locking or buffers?

Hello!

I'm having trouble sharing DIO ports when running 2 or more copies of the same app.  Every once in a while I run into a collision where two apps I've written try to either read/write to the same port simultaneously .  I end up getting the -200587 error. I will have many instances where multiple copies of my app will be running each has random access to any of the 12 ports on our DIO board.  The reads and writes are for only one sample at a time. 

Is there any type of locking/retry mechanism built into the libs?  Or any other ideas?

thanks!

-David

Message Edited by SiGGy on 01-25-2007 08:57 AM

Message Edited by SiGGy on 01-25-2007 09:03 AM

0 Kudos
Message 1 of 2
(3,013 Views)
Hello David. 
 
What DIO board are you using in this application?  This information may allow us to utilize special features that the board offers to give you a more elegant solution. 
 
The -200587 error is caused when the specified digital lines are reserved by another task.  The error message recommends that if you are using the lines with another task, you will need to wait for the task to complete. 
 
Since a random process is being used to determine what channel is to be used for the DIO operation, there will need to be some type of action if this random process causes 2 apps to attempt to access the same line.  The first way to deal with this is via error handling.  If you receive this error, you could simply disregard it and go back to normal operation by using the 'Clear Errors' VI.  This would work, but it doesn't attempt to execute the DIO operation after the first operation completes. 
 
Another way to resolve this is by using semaphores.  Semaphores are very helpful "when you want other VIs or parts of block diagram to wait until another VI or part of a block diagram is finished with the execution of a critical section."  There is a great tutorial on semaphores available at:
 
Using Semaphores
 
Let us know if you require further assistance.  We will be happy to help!
 
Brian F
Applications Engineer
National Instruments
 
 
 
0 Kudos
Message 2 of 2
(2,990 Views)