Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using a /dev/tty as if it were a serial port
Forum Updated to NodeBB v4.3 + New Features

Using a /dev/tty as if it were a serial port

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RogueWarrior
    wrote on 27 Jun 2014, 17:00 last edited by
    #1

    So, somewhat complex setup: I have written a bunch of code to talk to an external device that's connected with a USB-serial interface such as an FTDI adapter. I'm using QSerialPort to do all this. Works great. Now what I'd like to do is access this stuff remotely over a network. I've got a Linux single-board computer with serial ports. I've managed to figure out how to do this with socat. On my desktop machine, socat creates a pseudo terminal in the form of /dev/ttys001. I've tested this with a simple modem-style terminal program on the remote end and cat'ing the /dev/ttys001. So this part works.

    Where I'm having trouble is that QSerialPort doesn't work with just any /dev entry. Even though I tried hacking the module to remove file name filtering, opening the port fails because configuration functions such as setting the baud rate or parity don't work.

    So, the question is: How do you talk to a /dev/tty without completely throwing away all the QSerialPort code I've written? I don't really need flow control stuff but I do need waitForReadyRead and peek functionality.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Jun 2014, 20:27 last edited by
      #2

      Hi,

      In your case, wouldn't a QFile be enough ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RogueWarrior
        wrote on 27 Jun 2014, 20:58 last edited by
        #3

        Apparently not.

        I did manage to figure out a workable solution. I run ser2net on the embedded computer which makes things like /dev/ttyUSB0 available as TCP ports on the network. That's only half the solution though. I had to modify my Qt code to use a QTcpSocket instead of QSerialPort. This works since ser2net takes care of the serial protocol and since I don't need flow control or DTR/CTS lines.

        Kudos to the Qt designers for structuring the QIODevice system the way it is.

        Tested two hardware devices now. So far, so good.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 27 Jun 2014, 21:19 last edited by
          #4

          That was going to be my next suggestion :)

          Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          27 Jun 2014, 17:00

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved