Results 1 to 5 of 5

Thread: Qt Serial seems to be deaf on Ubuntu 12.04

  1. #1
    Join Date
    Dec 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt Serial seems to be deaf on Ubuntu 12.04

    I have a continuous-duty program that polls an embedded RS-485 serial device periodically. It had been running fine on Ubuntu 10.04 with Qt 2010.05.1 and QExtSerial 1.1. That installation ran through an FTDI based USB to serial convertor. I found the FTDI device to be a little annoying in that it would spontaneously change the tty device it was listed under. I was able to work around that behavior and the program ran fine for a couple of years.

    I would now like to upgrade to Ubuntu 12.04. Initially I attempted to use the Ubuntu qt-sdk package and QExtSerial 1.2beta 2 from Google Code. I found that the FTDI driver issues seemed a lot worse and my program would occasionally freeze (about once per a week). So I gave up on the USB based serial converter and created a custom RS-232 to RS-485 convertor using the RTS line to toggle the RS-485 transmit enable.

    What I've found with that setup is that while transmission works just fine, the program never gets any bytes in return even though the embedded devices (and a logic analyzer) indicate bytes are in fact being sent to the RS-232 port in reply to the Qt program's transmissions. Further, they return to the RS-232 port within about 70ms. (My timeout is set to 300ms). Nonetheless, readyRead() never fires. When the time out fires, I check bytesAvailable and it always says zero.

    Maddeningly, on the command line, if I run 'cat /dev/ttyS0' I can clearly see the reply bytes from the embedded devices. So the reply bytes are definitely inside the operating system, they just don't make it to my program.

    I thought that perhaps QExtSerial might have some issue, so I dropped back a version. Same symptom. I then ported the code to use the newer QSerialDevice library. Again same symptom. I thought that perhaps the ubuntu spin of qt-sdk was bugged so I removed it and installed 2010.05.01 from the old binary installer. Once more, same symptom.

    On Windows XP this code works fine whether via the RS-232 port or via the USB port.

    My original code from 2010.

    Has anyone seen anything like this? Why can cat see the reply bytes but Qt is convinced there are no such bytes?

    Thanks for any tips or ideas on things I can try. I'm about to surrender and just require this program be hosted on windows. Its just that the whole point of writing it in Qt was to get cross platform functionality.

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Serial seems to be deaf on Ubuntu 12.04

    I then ported the code to use the newer QSerialDevice library. Again same symptom.
    1. Instead of QSerialDevice need use QtSerialPort.
    2. Provide your source code.
    3. Use "normal" RS-485 convertor with autodetecting I/O direction.

    Otherwise, all that you wrote is totally uninformative.

  3. #3
    Join Date
    Dec 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Serial seems to be deaf on Ubuntu 12.04

    1. Instead of QSerialDevice need use QtSerialPort.
    A third serial library? Ok. I'll give it a go. Any notion why QExtSerial works so well under Ubuntu 10.04 but so poorly under Ubuntu 12.04?

    2. Provide your source code.
    I did.

    3. Use "normal" RS-485 convertor with autodetecting I/O direction.
    I thought about that, but the thing is that I have not one but two mechanisms confirming to me that the reply bytes are in fact being properly received. First up is the logic analyzer which clearly shows the RS-232 data flowing to the machine. The logic analyzer has no problems decoding the data it sees on the PC's RX line. The second confirmation comes the command line utility cat. #cat /dev/ttyS0 prints out the received data from the serial port properly. The data is ASCII and its clearly visible. It's not corrupt and even if it were, it wouldn't result in a receive timeout.



    Anyway, thanks for your replies.

  4. #4
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Serial seems to be deaf on Ubuntu 12.04

    A third serial library?
    Not. This is the first and only "normal" library.

    Any notion why QExtSerial works so well under Ubuntu 10.04 but so poorly under Ubuntu 12.04?
    I have no idea.

  5. #5
    Join Date
    Dec 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Serial seems to be deaf on Ubuntu 12.04

    Not. This is the first and only "normal" library.
    That doesn't seem to be the case. From the QtSerialPort page you linked me to:

    QtSerialPort originated from the third-party library QSerialDevice [gitorious.org] (branch 2.0), which was recently moved to a repository on https://codereview.qt-project.org/
    From what I understood of QSerialDevice's web page, the QSerialDevice project itself started out as a re-factoring of QExtSerial that wound up becoming a re-write. I think QSerialDevice is simply the first serial class to be adopted into the official code. The class didn't exist in 2010 when I wrote the code. Only QExtSerial existed.

    Anyway, I'm now now more guarded about whether it will work, but since it does appear to be a newer version of the QSerialDevice library I tried previously, perhaps I'll find its been updated to reflect whatever may have changed in Ubuntu. Hopefully I'll be able to try this latest version out tomorrow. I'll report back.

    Thanks!

Similar Threads

  1. Qt on Ubuntu 10.04 from Ubuntu packages?
    By teele in forum Installation and Deployment
    Replies: 5
    Last Post: 28th March 2012, 08:41
  2. Serial
    By martxyz in forum Newbie
    Replies: 4
    Last Post: 16th November 2011, 22:40
  3. Get serial no from USB
    By FoleyX90 in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2010, 21:08
  4. USB / Serial
    By Vnuce in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2009, 07:21
  5. Parallel and serial I/O
    By Roberto in forum Qt Programming
    Replies: 3
    Last Post: 10th October 2007, 11:53

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.