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. Problem on Barcode Scanner using serial port
Forum Updated to NodeBB v4.3 + New Features

Problem on Barcode Scanner using serial port

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 1.5k Views 2 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.
  • S SURYA P
    22 Jan 2021, 04:53

    alt text
    if i click the scan button the command won't send .that command will use for read a barcode value .but i did not get .pleas can you give any ideas

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 22 Jan 2021, 06:36 last edited by
    #2

    @SURYA-P Don't you think that you should provide more information if you want to get a meaningful answer? Or how are others supposed to find out what the problem is?

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

    1 Reply Last reply
    1
    • S Offline
      S Offline
      SURYA P
      wrote on 22 Jan 2021, 06:47 last edited by
      #3

      if i click the scan button the sending data (command) will go to the barcode scanner .and the barcode scanner will scan some barcode and the barcode value will show on the receiving data.
      But i did not get it .please give me any idea

      J 1 Reply Last reply 22 Jan 2021, 06:49
      0
      • S SURYA P
        22 Jan 2021, 06:47

        if i click the scan button the sending data (command) will go to the barcode scanner .and the barcode scanner will scan some barcode and the barcode value will show on the receiving data.
        But i did not get it .please give me any idea

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 22 Jan 2021, 06:49 last edited by
        #4

        @SURYA-P Sorry, but this is not helpful. Please show your code, people here are not mind readers...

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SURYA P
          wrote on 22 Jan 2021, 06:50 last edited by
          #5

          https://paste.ofcode.org/79eEqkQe7zuXvYMbWWFqrP
          this is my code

          J 1 Reply Last reply 22 Jan 2021, 06:57
          0
          • S SURYA P
            22 Jan 2021, 06:50

            https://paste.ofcode.org/79eEqkQe7zuXvYMbWWFqrP
            this is my code

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 22 Jan 2021, 06:57 last edited by
            #6

            @SURYA-P Where in that code do you send anything over serial port?
            What did you try so far?
            Was on_pushButton_clicked() called?
            Was BSerial->open(QIODevice::ReadWrite) successful?
            Was inputFile.open(QIODevice::ReadOnly) successful?

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

            S 1 Reply Last reply 22 Jan 2021, 07:01
            1
            • S Offline
              S Offline
              SURYA P
              wrote on 22 Jan 2021, 07:00 last edited by
              #7

              https://i.postimg.cc/HsRpbjdY/Screenshot-57.png
              if i click the scan button that command should work . and give output like that

              1 Reply Last reply
              0
              • J jsulm
                22 Jan 2021, 06:57

                @SURYA-P Where in that code do you send anything over serial port?
                What did you try so far?
                Was on_pushButton_clicked() called?
                Was BSerial->open(QIODevice::ReadWrite) successful?
                Was inputFile.open(QIODevice::ReadOnly) successful?

                S Offline
                S Offline
                SURYA P
                wrote on 22 Jan 2021, 07:01 last edited by
                #8

                @jsulm pushButtton mean open Button

                J 1 Reply Last reply 22 Jan 2021, 07:01
                0
                • S SURYA P
                  22 Jan 2021, 07:01

                  @jsulm pushButtton mean open Button

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 22 Jan 2021, 07:01 last edited by
                  #9

                  @SURYA-P Please show me the code where you send data over serial port...

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

                  S 1 Reply Last reply 22 Jan 2021, 07:04
                  1
                  • J jsulm
                    22 Jan 2021, 07:01

                    @SURYA-P Please show me the code where you send data over serial port...

                    S Offline
                    S Offline
                    SURYA P
                    wrote on 22 Jan 2021, 07:04 last edited by
                    #10

                    @jsulm BSerial = new QSerialPort(this);
                    BSerial->setPortName(ui->comboBox->currentText());
                    BSerial->setBaudRate(QSerialPort::Baud9600);
                    BSerial->setDataBits(QSerialPort::Data8);
                    BSerial->setParity(QSerialPort::NoParity);
                    BSerial->setStopBits(QSerialPort::OneStop);
                    BSerial->setFlowControl(QSerialPort::NoFlowControl);
                    if(BSerial->open(QIODevice::ReadWrite)){
                    qDebug() << "port open ok";
                    connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::on_pushButton_2_clicked);

                    }
                    

                    //this is the command for connect the serial port

                    J 1 Reply Last reply 22 Jan 2021, 07:05
                    0
                    • S SURYA P
                      22 Jan 2021, 07:04

                      @jsulm BSerial = new QSerialPort(this);
                      BSerial->setPortName(ui->comboBox->currentText());
                      BSerial->setBaudRate(QSerialPort::Baud9600);
                      BSerial->setDataBits(QSerialPort::Data8);
                      BSerial->setParity(QSerialPort::NoParity);
                      BSerial->setStopBits(QSerialPort::OneStop);
                      BSerial->setFlowControl(QSerialPort::NoFlowControl);
                      if(BSerial->open(QIODevice::ReadWrite)){
                      qDebug() << "port open ok";
                      connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::on_pushButton_2_clicked);

                      }
                      

                      //this is the command for connect the serial port

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 22 Jan 2021, 07:05 last edited by
                      #11

                      @SURYA-P Please show me the code where you send data over serial port...

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

                      S 1 Reply Last reply 22 Jan 2021, 07:06
                      1
                      • J jsulm
                        22 Jan 2021, 07:05

                        @SURYA-P Please show me the code where you send data over serial port...

                        S Offline
                        S Offline
                        SURYA P
                        wrote on 22 Jan 2021, 07:06 last edited by
                        #12

                        @jsulm void MainWindow::SerialReceived()
                        {

                        serialData+=BSerial->readAll();
                        receivedData = QString::fromStdString(serialData.toStdString());
                        ui->textEdit_2->setText(serialData);
                        

                        }

                        this is for read data

                        J 1 Reply Last reply 22 Jan 2021, 07:06
                        0
                        • S SURYA P
                          22 Jan 2021, 07:06

                          @jsulm void MainWindow::SerialReceived()
                          {

                          serialData+=BSerial->readAll();
                          receivedData = QString::fromStdString(serialData.toStdString());
                          ui->textEdit_2->setText(serialData);
                          

                          }

                          this is for read data

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 22 Jan 2021, 07:06 last edited by
                          #13

                          @SURYA-P said in Problem on Barcode Scanner using serial port:

                          this is for read data

                          I asked about writing data...

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

                          S 1 Reply Last reply 22 Jan 2021, 07:08
                          0
                          • J jsulm
                            22 Jan 2021, 07:06

                            @SURYA-P said in Problem on Barcode Scanner using serial port:

                            this is for read data

                            I asked about writing data...

                            S Offline
                            S Offline
                            SURYA P
                            wrote on 22 Jan 2021, 07:08 last edited by
                            #14

                            @jsulm i wrote a command on file(0x7E 0x00 0x08 0x01 0x00 0x02 0x01 0xAB 0xCD) this is the command ..

                            M 1 Reply Last reply 22 Jan 2021, 07:09
                            0
                            • S SURYA P
                              22 Jan 2021, 07:08

                              @jsulm i wrote a command on file(0x7E 0x00 0x08 0x01 0x00 0x02 0x01 0xAB 0xCD) this is the command ..

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 22 Jan 2021, 07:09 last edited by
                              #15

                              @SURYA-P

                              Hi
                              but to send it to device we are after code that is like
                              BSerial->write ( xxx );

                              1 Reply Last reply
                              1
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 22 Jan 2021, 07:26 last edited by
                                #16

                                Hi,

                                Beside what my fellows already asked:
                                @SURYA-P said in Problem on Barcode Scanner using serial port:

                                connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::on_pushButton_2_clicked);

                                Are you sure it's the right slot your are connecting ?

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

                                S 1 Reply Last reply 22 Jan 2021, 07:37
                                1
                                • S SGaist
                                  22 Jan 2021, 07:26

                                  Hi,

                                  Beside what my fellows already asked:
                                  @SURYA-P said in Problem on Barcode Scanner using serial port:

                                  connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::on_pushButton_2_clicked);

                                  Are you sure it's the right slot your are connecting ?

                                  S Offline
                                  S Offline
                                  SURYA P
                                  wrote on 22 Jan 2021, 07:37 last edited by
                                  #17

                                  @SGaist sorry this is correct slot
                                  connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::SerialReceived);

                                  but i am not getting output

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 22 Jan 2021, 19:43 last edited by
                                    #18

                                    As my fellows already requested, please show the part where you actually write to the serial port.

                                    On a side note, if you call on_pushButton_clicked several times, you are going to leak objects and not properly release them.

                                    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
                                    2

                                    11/18

                                    22 Jan 2021, 07:05

                                    • Login

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