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!



  • Hi,

    generally speaking Qt and QExtSerialPort use Guest Operating System services to access to the hardware.
    To obtain what do you wantn on MacOSX probabli you should use Apple API.



  • 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





  • hi to all

    IT IS POSSIBLE TO CONNECT QSOCKETDEVICE INTO BIOMETRICS DIRECTLY!


  • Lifetime Qt Champion

    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.



  • hi SGaist,

    Why QT 4.8 is not compatible to QT 5.0.,i am creating a payroll system QT 4.8 but i tried to run Qt 5.0 but not working. I'm put the dialog header QT 4.8 still working otherwise i tried to put dialog header QT 5.0 is not working.

    thanks


  • Lifetime Qt Champion

    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!



  • I found an easier solution. Just append O_EXLOCK into the open_sys() function in qextserialport_unix.cpp


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.