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. Issue with QSerialPort (ubuntu)
Forum Updated to NodeBB v4.3 + New Features

Issue with QSerialPort (ubuntu)

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.9k 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.
  • RSC9421R Offline
    RSC9421R Offline
    RSC9421
    wrote on last edited by VRonin
    #1

    Hello, I am writing a simple serial program that works fine on Windows, but not on Linux (Ubuntu) here is the code

    Port1 = new QSerialPort ();
    Foreach (const QSerialPortInfo & info, QSerialPortInfo :: availablePorts ()) {
    Port_name = info.portName ();}
    Port1-> setPortName (port_name);
    Port1-> setBaudRate (38400);
    Port1-> setDataBits (QSerialPort :: Data8);
    Port1-> setStopBits (QSerialPort :: OneStop);
    Port1-> setParity (QSerialPort :: NoParity);
    Port1-> setFlowControl (QSerialPort :: NoFlowControl);
    
    If (port1-> open (QIODevice :: ReadWrite)) {
    Ui-> textEdit-> append ("Connected to" + port_name);
    } Else {
    Ui-> textEdit-> append ("Waiting ... \ n");}
    

    textEdit show me connected to /dev/ttyUSB0 for example, but after 1 second this program it freezes, what should I do? regards

    jsulmJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You first check with other serial program that
      /dev/ttyUSB0 does work.
      Could be access issues.

      1 Reply Last reply
      0
      • RSC9421R Offline
        RSC9421R Offline
        RSC9421
        wrote on last edited by
        #3

        yes, I try with cutecom and works

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then it sounds like you have a normal bug in your program. :)
          To test it, try the sample
          http://doc.qt.io/qt-5/qtserialport-terminal-example.html

          If that do not freeze,
          its not something with Qt
          but something you do in your own code and you
          just need to find out what.

          RSC9421R 1 Reply Last reply
          0
          • RSC9421R RSC9421

            Hello, I am writing a simple serial program that works fine on Windows, but not on Linux (Ubuntu) here is the code

            Port1 = new QSerialPort ();
            Foreach (const QSerialPortInfo & info, QSerialPortInfo :: availablePorts ()) {
            Port_name = info.portName ();}
            Port1-> setPortName (port_name);
            Port1-> setBaudRate (38400);
            Port1-> setDataBits (QSerialPort :: Data8);
            Port1-> setStopBits (QSerialPort :: OneStop);
            Port1-> setParity (QSerialPort :: NoParity);
            Port1-> setFlowControl (QSerialPort :: NoFlowControl);
            
            If (port1-> open (QIODevice :: ReadWrite)) {
            Ui-> textEdit-> append ("Connected to" + port_name);
            } Else {
            Ui-> textEdit-> append ("Waiting ... \ n");}
            

            textEdit show me connected to /dev/ttyUSB0 for example, but after 1 second this program it freezes, what should I do? regards

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @RSC9421 What do you do after connecting (after if (port1-> open (QIODevice :: ReadWrite)))?
            It looks like your app is able to connect.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • mrjjM mrjj

              Then it sounds like you have a normal bug in your program. :)
              To test it, try the sample
              http://doc.qt.io/qt-5/qtserialport-terminal-example.html

              If that do not freeze,
              its not something with Qt
              but something you do in your own code and you
              just need to find out what.

              RSC9421R Offline
              RSC9421R Offline
              RSC9421
              wrote on last edited by
              #6

              @mrjj The example run fine @jsulm After this I do not do anything, the code above is everything

              jsulmJ 1 Reply Last reply
              0
              • RSC9421R RSC9421

                @mrjj The example run fine @jsulm After this I do not do anything, the code above is everything

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @RSC9421 Can you show the whole source code of your program?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • RSC9421R Offline
                  RSC9421R Offline
                  RSC9421
                  wrote on last edited by
                  #8

                  Sorry for the delay, I did not have the internet ^^ Fortunately, I could fix it
                  I was compiling a similar project
                  The error was in the signal function "readyRead"
                  Thank you

                  1 Reply Last reply
                  1

                  • Login

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