02-04-2015 11:07 AM
I would like to check is a serial port availble (not already opened by another application) without opening and closing the port. Currently, the program opens and closes the serial port a lot. Sometimes, an port access deny error occurs. We suspect that after a the close command is issued, the port didn't close immediately and another application try to acces the port at the time, which generated the error. Any idea?
02-04-2015 11:41 AM - edited 02-04-2015 11:42 AM
You might want to ask yourself why your program opens and closes the serial port a lot.
You should open the serial port once at the beginning of your program, pass the VISA reference throughout, then close it once at the end of your program
02-04-2015 12:10 PM
Agree with suggestion to ask yourself why the port is closing and opening so much. That is going to a cause a lot of confusion.
If you still want to close and open it a lot, look at the error you get when trying to open the port. Error -1073807246 tells you that the VISA resource is valid, but it can't be accessed. That is a pretty good indicator that the port is in use somewhere else.
02-13-2015 10:05 AM
opening, pining, and closing is for searching through all the existing comm port to see which port I am communicating on.
02-13-2015 10:06 AM
The opening and closing is due by a custom .net DLL function.
02-13-2015 10:58 AM
02-13-2015 12:00 PM - edited 02-13-2015 12:01 PM
@jyang72211 wrote:
The opening and closing is due by a custom .net DLL function.
Well without any code to look at I have two suggestions...
1. Dump the DLL and either use LabVIEW to search for the port the device is on or just tell LabVIEW what port to use.
2. Put a delay in your program every time the DLL is called to make sure it is done with the ports before LabVIEW tries to access it.