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. Multi serial port application

Multi serial port application

Scheduled Pinned Locked Moved Unsolved General and Desktop
49 Posts 5 Posters 14.0k Views
  • 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.
  • V Offline
    V Offline
    veera
    wrote on last edited by
    #12

    @aha_1980
    How would you know the which port is sending the port information ,how i need to handle this problem????

    aha_1980A 1 Reply Last reply
    0
    • V veera

      @aha_1980
      How would you know the which port is sending the port information ,how i need to handle this problem????

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #13

      @veera said in multi serial port application:

      @aha_1980
      How would you know the which port is sending the port information ,how i need to handle this problem????

      Sorry, but I don't understand your question.

      As said, I would start creating ONE object (maybe a QPanel) configuring ONE serial port, sending data to ONE serial port and receiving data from ONE serial port. If you have this working, it's easy to have three of them so you can communicate with all serial ports.

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veera
        wrote on last edited by
        #14

        Hi @aha_1980 ,
        I am working for single port now ,its not able to open the port here is my code by using send pushbutton and connect()

        void Dialog :: open_serialport()
        {
        QSerialPort serial;
        QString portName = ui->port_comboBox->currentText();
        qDebug() << "The portName is " << portName;
        bool currentPortNameChanged = false;
        QString currentPortName;
        if(currentPortName != portName)
        {
        currentPortName = portName;
        currentPortNameChanged = true;
        }

        if(currentPortName.isEmpty())
        {
            qDebug() << "No port name specified";
        }
        
        if(currentPortNameChanged)
        {
            serial.close();
            serial.setPortName(portName);
            qDebug() << "portName" << portName;
        
            if(!serial.open(QIODevice::ReadWrite))
            {
                qDebug() << "can not able to open the serial port";
            }
        }
        

        }
        its giving error i am passing from gui ,please help me out....

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

          @veera said in multi serial port application:

          void Dialog :: open_serialport()
          {
          QSerialPort serial; <<<< WRONG ! its local variable

          make it a class member of Dialog

          1 Reply Last reply
          3
          • V Offline
            V Offline
            veera
            wrote on last edited by
            #16

            @mrjj ,
            just now declared a QSerialPort as data members of the dialog class in dialog.h still also i am getting same error...

            here is the declaration of the QSerialPort

            #ifndef DIALOG_H
            #define DIALOG_H

            #include <QDialog>
            #include <stdio.h>
            #include <QtSerialPort/QSerialPort>
            
            
            namespace Ui {
            class Dialog;
            }
            
            class Dialog : public QDialog
            {
                Q_OBJECT
            
            public:
                QSerialPort serial;
            
            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #17

              Super
              but what error ?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                veera
                wrote on last edited by
                #18

                can not able to open the serial port..what was the type its receiving whether its ttyS4 or /dev/ttyS4?

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  veera
                  wrote on last edited by
                  #19

                  @mrjj ,
                  I am directly assigning the portname from gui qcombox is it correct way for accessing the port name ?

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

                    Hi
                    normally its ttyS4
                    for
                    serial->setPortName(p.name);

                    Did you see the sample
                    http://doc.qt.io/qt-5/qtserialport-terminal-example.html

                    Its available directly in Creator and you can use to test.

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      veera
                      wrote on last edited by
                      #21

                      yes i have refer that example only.....

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        veera
                        wrote on last edited by
                        #22

                        i have tried both the things not able to open the port .....

                        mrjjM 1 Reply Last reply
                        0
                        • V veera

                          i have tried both the things not able to open the port .....

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #23

                          @veera

                          so are you sure PC has that port ?

                          if using a serial usb adapter, it has other name.

                          If you cannot open port using the Terminal sample then
                          something is wrong outside Qt.

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            veera
                            wrote on last edited by
                            #24

                            yes having two ports only ttyS4 and ttyS5 i am not using any usb to serial converter i am directly connecting with serial port only .....i have tried terminal example its giving the permission error means sudo permission .....

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              veera
                              wrote on last edited by
                              #25

                              permission is denied error while opening the port in Terminal Sample...

                              jsulmJ 1 Reply Last reply
                              0
                              • V veera

                                permission is denied error while opening the port in Terminal Sample...

                                jsulmJ Online
                                jsulmJ Online
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #26

                                @veera What does

                                ls -lh /dev/ttyS4
                                

                                say?

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

                                1 Reply Last reply
                                1
                                • mrdebugM Offline
                                  mrdebugM Offline
                                  mrdebug
                                  wrote on last edited by
                                  #27

                                  Are you in dialout group?

                                  Need programmers to hire?
                                  www.labcsp.com
                                  www.denisgottardello.it
                                  GMT+1
                                  Skype: mrdebug

                                  1 Reply Last reply
                                  1
                                  • V Offline
                                    V Offline
                                    veera
                                    wrote on last edited by
                                    #28

                                    i tried using this command on the qt project path also not able to open the serial ports.....

                                    1 Reply Last reply
                                    0
                                    • V Offline
                                      V Offline
                                      veera
                                      wrote on last edited by
                                      #29

                                      yes i am in dialout group....

                                      1 Reply Last reply
                                      0
                                      • V Offline
                                        V Offline
                                        veera
                                        wrote on last edited by
                                        #30

                                        crw-rw---- 1 root dialout 4, 68 Dec 11 13:22 /dev/ttyS4

                                        1 Reply Last reply
                                        0
                                        • V Offline
                                          V Offline
                                          veera
                                          wrote on last edited by
                                          #31

                                          @jsulm said in multi serial port application:

                                          ls -lh /dev/ttyS4

                                          crw-rw---- 1 root dialout 4, 68 Dec 11 13:22 /dev/ttyS4

                                          1 Reply Last reply
                                          0

                                          • Login

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