QExtSerialPort: How to determine if a serial port is in use by another application?
-
Hi,
I use QExtSerialPort V1.2rc and I have the following problem:
On Windows the function port.isOpen() returns TRUE if the serial port is in use by another or the same application, so you can not open it until it is released.
On Mac OSX isOpen() returns FALSE, if the port is opened by another application and it is possible to open the same serial port and to send and read data, although the port is in use, messing up the communication.
How can I avoid this? How can I determine if a serial port is in use by another application (opened for READ/WRITE) on Mac OSX?
Thanks!
-
QextSerialPort used POSIX API. But the design of the library is not incorporated this possibility.
For a solution of problem is need to use other library as QtSerialPort.
PS:
And indeed, to be honest it's very slippery POSIX solution, because not all applications adhere to the standards for locking already open serial ports. Therefore, if a some program opens a port, but did not set a "lock" (as TIOEXCL or using the lock file), then you are in any way you not will know that the device is already being used by someone.
-
[quote author="kuzulis" date="1367927829"]
And indeed, to be honest it's very slippery POSIX solution, because not all applications adhere to the standards for locking already open serial ports. Therefore, if a some program opens a port, but did not set a "lock" (as TIOEXCL or using the lock file), then you are in any way you not will know that the device is already being used by someone.
[/quote]That would be OK. I only need a lock for my own application, because the user can start several instances of my application to connect to all attached serial devices. If a port is locked by another instance, then the new instance has to search on the next available port.
Do you know how to set a lock and how to release it? If the application crashes then the lock must also be released. I do not really know much about POSIX standards, lock files and such things.Thanks
-
See e.g. http://linux.die.net/man/3/lockdev
-
Hi,
Please, don't highjack someone's thread with your own question, create a new thread, and for politeness don't use all caps phrase, this won't get you any help.
Additionally, you'll have to give more details about what you wan't to do.
-
-
As I said, please, open a new thread for your problem and provide more details about your problem. I won't answer on this thread about them.
-
[quote author="kuzulis" date="1367939084"]See e.g. http://linux.die.net/man/3/lockdev[/quote]
Many Thanks for this hint!