Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi,

I'm using Device::SerialPort under linux and got into troubles, cause other processes are sniffing serial port and "stealing" bytes.... How can I prevent other apps to connect to serial port from Perl - or to get exclusive access to it ?

Thanks in advance,

regards,

Rob.

  • Comment on How to lock other users from using Serialport under Linux ?

Replies are listed 'Best First'.
Re: How to lock other users from using Serialport under Linux ?
by marto (Cardinal) on Dec 23, 2005 at 11:42 UTC
    Have you tried initialising the object with the lockfile parameter to obtain exclusive ownership of the port?
    $PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile) || die "Can't open $PortName: $!\n";
    This is from the Device::SerialPort documentation.

    Hope this helps

    Martin
Re: How to lock other users from using Serialport under Linux ?
by salva (Canon) on Dec 23, 2005 at 13:02 UTC
    and if locking the port doesn't work, because on Unix locks are not mandatory, you can always change the permisions of the device or even rename it to something that only your application will know.