Results 1 to 6 of 6

Thread: how to open the serial port of my pc from the qt app

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: how to open the serial port of my pc from the qt app

    There are two possibilities straight from the error message:
    • Attempting to open an already opened device by another process. If there is another process with the port already open then this might happen. Minicom should not be running when you try to run this.
    • User not having enough permission and credentials to open. The permissions are those of the file representing the serial port: probably "/dev/ttyS0" but it may be in a subdirectory of /dev. Often only root and a group called "uucp" have write access to the device.
      Qt Code:
      1. $ ls -l /dev/ttyS0
      2. crw-rw---- 1 root uucp 4, 64 Feb 27 07:15 /dev/ttyS0
      3. $ groups
      4. wheel audio cdrom video games cdrw users wireshark vboxusers truecrypt uucp
      To copy to clipboard, switch view to plain text mode 
      Your Linux user should be generally placed in the "uucp" group (recommended) although you can alter the serial port permissions directly (not recommended).


    Here is a User Management tutorial.
    Here is a Linux File Permissions tutorial.
    Last edited by ChrisW67; 27th February 2014 at 08:35.

  2. #2
    Join Date
    Feb 2014
    Posts
    31
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    7

    Default Re: how to open the serial port of my pc from the qt app

    Thanks for the quick reply sir,
    First of all sorry for my english.

    I was running my code in 'root' and it is getting data from serial port....
    I written the code for reading data as shown below,
    Qt code:
    if(port->waitForReadyRead(5000)){
    QByteArray readdata=port->readAll();
    //textEdit->append(readdata);
    while(port->waitForReadyRead(1000)){
    readdata +=port->readAll();
    }

    textEdit->append(readdata);
    }
    It is reading one time and displaying on the textEdit.. but i want to monitor and read the data from the port continuously whenever the data available...what should i have to do...
    Thanks in advance...

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: how to open the serial port of my pc from the qt app

    Don't "wait for readyRead", connect a slot to the readyRead() signal and read the data in the slot.

    Btw, running a GUI program as root is usually a bad idea. At some point you should invest a bit of time to get the permissions right for a normal user account.

    Cheers,
    _

Similar Threads

  1. qt serial port
    By saman_artorious in forum Newbie
    Replies: 9
    Last Post: 24th April 2013, 17:19
  2. Best serial port library?
    By Momergil in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2013, 07:38
  3. Serial Port communication
    By mgurbuz in forum Qt Programming
    Replies: 12
    Last Post: 22nd January 2011, 03:38
  4. data from serial port
    By bhe in forum Newbie
    Replies: 4
    Last Post: 3rd May 2009, 11:19
  5. Serial Port
    By b1 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 03:05

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
  •  
Qt is a trademark of The Qt Company.