Results 1 to 2 of 2

Thread: Permission error while locking the device when writing to QSerialPort

  1. #1
    Join Date
    Feb 2016
    Location
    S. Stefano di Sessanio
    Posts
    11
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Permission error while locking the device when writing to QSerialPort

    Hi,
    I'm working on a Qt5.7 application cross-compiled for my device. I added the serialport module to read and write to the serialport.
    After opening the QSerialPort, when I try to write to it, the following error message (attached to the thread) appears in the GUI: "Permission error while locking the device", and the message is not sent to the serial port.
    This is the way I open and try to write to the serial port:

    Qt Code:
    1. serialport->setPortName("/dev/ttymxc2");
    2. serialport->setBaudRate(QSerialPort::Baud9600);
    3. serialport->setDataBits(QSerialPort::Data8);
    4. serialport->setParity(QSerialPort::NoParity);
    5. serialport->setStopBits(QSerialPort::OneStop);
    6. serialport->setFlowControl(QSerialPort::NoFlowControl);
    7. //serial->setFlowControl(QSerialPort::HardwareControl);
    8. if (serialport->open(QIODevice::ReadWrite))
    9. //opened
    To copy to clipboard, switch view to plain text mode 
    ...

    The write section:

    Qt Code:
    1. ba.resize(50);
    2. ...
    3. const qint64 bytesWritten = serialport->write(ba);
    To copy to clipboard, switch view to plain text mode 


    Could anyone help to find the solution? What am I missing?
    Thank you!
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Permission error while locking the device when writing to QSerialPort

    Try in system console this command : ls /dev/tty*
    Here is output from my system :
    Qt Code:
    1. crw-rw-rw- 1 root tty 5, 0 06-01 22:06 /dev/tty
    2. crw--w---- 1 root tty 4, 0 06-01 22:06 /dev/tty0
    3. crw------- 1 root root 4, 1 06-01 22:08 /dev/tty1
    4. crw--w---- 1 root tty 4, 10 06-01 22:06 /dev/tty10
    5. crw--w---- 1 root tty 4, 11 06-01 22:06 /dev/tty11
    6. crw--w---- 1 root tty 4, 12 06-01 22:06 /dev/tty12
    To copy to clipboard, switch view to plain text mode 
    As You see only root and tty group have permision to use tty devices.
    A problem with system configuration not with application.

Similar Threads

  1. Reading/writing long values to BLE device via Qt
    By WereWind in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2015, 14:49
  2. Replies: 5
    Last Post: 17th April 2015, 08:09
  3. Replies: 5
    Last Post: 15th August 2014, 04:04
  4. Permission denied error during linking
    By bashamehboob in forum Newbie
    Replies: 2
    Last Post: 15th April 2006, 14:02
  5. Reading/Writing data from/to usb device
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 6th March 2006, 14:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.