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. I want make device execute command , when I press the radio-button in QT
Forum Updated to NodeBB v4.3 + New Features

I want make device execute command , when I press the radio-button in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 3 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.
  • dheerendraD dheerendra

    callme() is function name.

    S Offline
    S Offline
    segtteee
    wrote on last edited by segtteee
    #5

    @dheerendra

    ui->setupUi(this);
       mSerialport = new QSerialPort (this);
       connect(ui->pushButton_send,&QPushButton::clicked,[=](){
           sendMsg(ui->command->toPlainText())
       });
       connect(ui->radioButton_on,&QRadioButton::clicked,[=](){
           monitor_mode_on();
      });
    
    
    void MainWindow::monitor_mode_on()
    {
        "     "
    }
    
    
    //I have write this, but between " " I do not know what code to write.  is this 'mSerialport->"mon 1"' ?  (mon 1 is command)
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #6

      Hi
      I assume you want to have
      mSerialport->write("XXX");
      To write the command to the device.

      S 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        I assume you want to have
        mSerialport->write("XXX");
        To write the command to the device.

        S Offline
        S Offline
        segtteee
        wrote on last edited by
        #7

        @mrjj
        thank you for reply.

        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
            mSerialport = new QSerialPort (this);
            connect(ui->pushButton_send,&QPushButton::clicked,[=](){
                sendMsg(ui->command->toPlainText());
        
            });
            connect(ui->radioButton_on,&QRadioButton::clicked,[=](){
                monitor_mode_on();
            });
        
            connect(ui->radioButton_off,&QRadioButton::clicked,[=](){
                monitor_mode_off();
            });
        }
        

        Is this the right structure for the rules? Add two connectors below and it will not run . (Two sentences inclusing radio-button)

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

          Well on button you call sendMsg and for the
          radioButton_on you call monitor_mode_on() which will send a command and
          same does radioButton_off
          Which seem pretty ok if monitor_mode_on/off sends
          command to device to enable/disable something.

          S 1 Reply Last reply
          1
          • mrjjM mrjj

            Well on button you call sendMsg and for the
            radioButton_on you call monitor_mode_on() which will send a command and
            same does radioButton_off
            Which seem pretty ok if monitor_mode_on/off sends
            command to device to enable/disable something.

            S Offline
            S Offline
            segtteee
            wrote on last edited by
            #9

            @mrjj
            I think mSerialport->write("XXX"); is wrong.
            my device couldn't recognize command.

            mrjjM 1 Reply Last reply
            0
            • S segtteee

              @mrjj
              I think mSerialport->write("XXX"); is wrong.
              my device couldn't recognize command.

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

              @segtteee
              Hi
              In what way wrong?
              the XXX was just example
              you need
              mSerialport->write("mon 1");
              or what ever real command is. :)

              S 1 Reply Last reply
              1
              • mrjjM mrjj

                @segtteee
                Hi
                In what way wrong?
                the XXX was just example
                you need
                mSerialport->write("mon 1");
                or what ever real command is. :)

                S Offline
                S Offline
                segtteee
                wrote on last edited by
                #11

                @mrjj
                I wrote mSerialport-> write ("mon 1"); but device doesn't work.
                So is not the code wrong?

                mrjjM 1 Reply Last reply
                0
                • S segtteee

                  @mrjj
                  I wrote mSerialport-> write ("mon 1"); but device doesn't work.
                  So is not the code wrong?

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

                  @segtteee
                  Nope, should send the string if port is open etc.
                  The write function returns how many bytes written.

                  so you can do
                  qDebug() << "written->" << mSerialport->write("mon 1");
                  (#include <QDebug>)

                  Can you see on device if it gets the string?

                  S 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @segtteee
                    Nope, should send the string if port is open etc.
                    The write function returns how many bytes written.

                    so you can do
                    qDebug() << "written->" << mSerialport->write("mon 1");
                    (#include <QDebug>)

                    Can you see on device if it gets the string?

                    S Offline
                    S Offline
                    segtteee
                    wrote on last edited by
                    #13

                    @mrjj
                    i wrote qDebug() << "written->" << mSerialport->write("mon 1");
                    and i can see 'written-> 5' in application output window.
                    What does this mean?
                    The equipment does not carry out orders ("mon 1" or "mon 0") .

                    mrjjM 1 Reply Last reply
                    0
                    • S segtteee

                      @mrjj
                      i wrote qDebug() << "written->" << mSerialport->write("mon 1");
                      and i can see 'written-> 5' in application output window.
                      What does this mean?
                      The equipment does not carry out orders ("mon 1" or "mon 0") .

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

                      @segtteee
                      It means that it wrote 5 chars to the serial port.
                      so it seems it does send it :)

                      • The equipment does not carry out orders ("mon 1" or "mon 0") .
                        And you are sure that is the syntax for the command?
                        And board are ready to accept commands etc?
                        Who wrote the code on the board?
                      S 1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @segtteee
                        It means that it wrote 5 chars to the serial port.
                        so it seems it does send it :)

                        • The equipment does not carry out orders ("mon 1" or "mon 0") .
                          And you are sure that is the syntax for the command?
                          And board are ready to accept commands etc?
                          Who wrote the code on the board?
                        S Offline
                        S Offline
                        segtteee
                        wrote on last edited by
                        #15

                        @mrjj
                        By writing behind "\ N" I had solved the problem . Thank you!!

                        mrjjM 1 Reply Last reply
                        0
                        • S segtteee

                          @mrjj
                          By writing behind "\ N" I had solved the problem . Thank you!!

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

                          @segtteee
                          ahh, it was expecting a line. not just the text.
                          super :)

                          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