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.4k 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.
  • SURYA PS SURYA P

    @jsulm pushButtton mean open Button

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on 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

    SURYA PS 1 Reply Last reply
    1
    • jsulmJ jsulm

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

      SURYA PS Offline
      SURYA PS Offline
      SURYA P
      wrote on 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

      jsulmJ 1 Reply Last reply
      0
      • SURYA PS SURYA P

        @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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on 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

        SURYA PS 1 Reply Last reply
        1
        • jsulmJ jsulm

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

          SURYA PS Offline
          SURYA PS Offline
          SURYA P
          wrote on 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

          jsulmJ 1 Reply Last reply
          0
          • SURYA PS SURYA P

            @jsulm void MainWindow::SerialReceived()
            {

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

            }

            this is for read data

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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

            SURYA PS 1 Reply Last reply
            0
            • jsulmJ jsulm

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

              this is for read data

              I asked about writing data...

              SURYA PS Offline
              SURYA PS Offline
              SURYA P
              wrote on last edited by
              #14

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

              mrjjM 1 Reply Last reply
              0
              • SURYA PS SURYA P

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

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on 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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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

                  SURYA PS 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    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 ?

                    SURYA PS Offline
                    SURYA PS Offline
                    SURYA P
                    wrote on 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
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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