Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Waveshare barcode scanner module
Forum Updated to NodeBB v4.3 + New Features

Waveshare barcode scanner module

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 3 Posters 1.2k 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.
  • T Offline
    T Offline
    Thananjeyan
    wrote on last edited by
    #1

    I'm using Waveshare barcode scanner module with raspberri pi for that I developed a code given below and i using wiring pi library .My barcode reader reads the data but don't get output in console

    
    int MainWindow::on_pushButton_4_clicked()
    {
        // Create a QSerialPort object for the scanner
    
        scanner.setPortName("/dev/ttyS0");
        scanner.setBaudRate(QSerialPort::Baud9600); // Adjust the baud rate to match your scanner
        scanner.setDataBits(QSerialPort::Data8);
        scanner.setParity(QSerialPort::NoParity);
        scanner.setStopBits(QSerialPort::OneStop);
        scanner.setFlowControl(QSerialPort::NoFlowControl);
    
        if (!scanner.open(QIODevice::ReadOnly)) {
            qDebug() << "Error opening the serial port for the barcode scanner.";
            return 1;
        }
    
        qDebug() << "Listening for barcode scanner data on" << scanner.portName() << "...";
    
    
         connect(&scanner, SIGNAL(readyRead()), this, SLOT(readBarcodeData()));
    
        return 0;
    
    }
    
    void MainWindow::on_pushButton_5_clicked()
    {
    
        QByteArray data = scanner.readAll();
        qDebug() << "Received data from barcode scanner:" << data;
    }
    
    void MainWindow::readBarcodeData()
    {
        QByteArray data = scanner.readAll(); // Read data from the scanner
    
            // Process the received data
            QString barcodeData = QString::fromUtf8(data);
            qDebug() << "Received data from barcode scanner:" << barcodeData;
    
            // Perform any additional processing or actions with the barcode data here
    
            // Update your UI or perform other actions as needed
            ui->label->setText(barcodeData);
    }
    
    void MainWindow::on_pushButton_6_clicked()
    {
        readBarcodeData();
    }
    
    
    jsulmJ JonBJ 2 Replies Last reply
    0
    • T Thananjeyan

      I'm using Waveshare barcode scanner module with raspberri pi for that I developed a code given below and i using wiring pi library .My barcode reader reads the data but don't get output in console

      
      int MainWindow::on_pushButton_4_clicked()
      {
          // Create a QSerialPort object for the scanner
      
          scanner.setPortName("/dev/ttyS0");
          scanner.setBaudRate(QSerialPort::Baud9600); // Adjust the baud rate to match your scanner
          scanner.setDataBits(QSerialPort::Data8);
          scanner.setParity(QSerialPort::NoParity);
          scanner.setStopBits(QSerialPort::OneStop);
          scanner.setFlowControl(QSerialPort::NoFlowControl);
      
          if (!scanner.open(QIODevice::ReadOnly)) {
              qDebug() << "Error opening the serial port for the barcode scanner.";
              return 1;
          }
      
          qDebug() << "Listening for barcode scanner data on" << scanner.portName() << "...";
      
      
           connect(&scanner, SIGNAL(readyRead()), this, SLOT(readBarcodeData()));
      
          return 0;
      
      }
      
      void MainWindow::on_pushButton_5_clicked()
      {
      
          QByteArray data = scanner.readAll();
          qDebug() << "Received data from barcode scanner:" << data;
      }
      
      void MainWindow::readBarcodeData()
      {
          QByteArray data = scanner.readAll(); // Read data from the scanner
      
              // Process the received data
              QString barcodeData = QString::fromUtf8(data);
              qDebug() << "Received data from barcode scanner:" << barcodeData;
      
              // Perform any additional processing or actions with the barcode data here
      
              // Update your UI or perform other actions as needed
              ui->label->setText(barcodeData);
      }
      
      void MainWindow::on_pushButton_6_clicked()
      {
          readBarcodeData();
      }
      
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Thananjeyan said in Waveshare barcode scanner module:

      but don't get output in console

      What part of your code do you mean?
      If you're talking about on_pushButton_5_clicked() then of course it will only work if there is something to read at the time it is called.

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

      T 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Thananjeyan said in Waveshare barcode scanner module:

        but don't get output in console

        What part of your code do you mean?
        If you're talking about on_pushButton_5_clicked() then of course it will only work if there is something to read at the time it is called.

        T Offline
        T Offline
        Thananjeyan
        wrote on last edited by
        #3

        @jsulm yes its working when I click pushbutton 5 my barcode reader reads the data but I don't get output in console is there any other way to get the output in console or there is any proper library for this barcode scanner module

        jsulmJ 1 Reply Last reply
        0
        • T Thananjeyan

          @jsulm yes its working when I click pushbutton 5 my barcode reader reads the data but I don't get output in console is there any other way to get the output in console or there is any proper library for this barcode scanner module

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

          @Thananjeyan If you can read data from barcode scanner then you should also see something in console. So, how do you know that you're actually able to read? What data do you read - is it text or some binary data?

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

          T 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Thananjeyan If you can read data from barcode scanner then you should also see something in console. So, how do you know that you're actually able to read? What data do you read - is it text or some binary data?

            T Offline
            T Offline
            Thananjeyan
            wrote on last edited by
            #5

            @jsulm 3f1225b5-d709-4207-ad33-fbdeec9020e0-image.png I want to get this welcome output in my console

            fb700c96-e78e-4ef9-bf07-b8b1dad9b4e8-image.pngand this is my barcode scanner module

            for this I used the above code

            jsulmJ 1 Reply Last reply
            0
            • T Thananjeyan

              @jsulm 3f1225b5-d709-4207-ad33-fbdeec9020e0-image.png I want to get this welcome output in my console

              fb700c96-e78e-4ef9-bf07-b8b1dad9b4e8-image.pngand this is my barcode scanner module

              for this I used the above code

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

              @Thananjeyan So, the question is: what data does the barcode scanner actually return? Is it a picture? You first need to clarify that...

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

              T 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Thananjeyan So, the question is: what data does the barcode scanner actually return? Is it a picture? You first need to clarify that...

                T Offline
                T Offline
                Thananjeyan
                wrote on last edited by
                #7

                @jsulm I want the data as output in console not the picture

                jsulmJ 1 Reply Last reply
                0
                • T Thananjeyan

                  @jsulm I want the data as output in console not the picture

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

                  @Thananjeyan Once more: what data format is sent from this barcode scanner?! If it is a picture then you can't output it in a text console...

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

                  1 Reply Last reply
                  0
                  • T Thananjeyan

                    I'm using Waveshare barcode scanner module with raspberri pi for that I developed a code given below and i using wiring pi library .My barcode reader reads the data but don't get output in console

                    
                    int MainWindow::on_pushButton_4_clicked()
                    {
                        // Create a QSerialPort object for the scanner
                    
                        scanner.setPortName("/dev/ttyS0");
                        scanner.setBaudRate(QSerialPort::Baud9600); // Adjust the baud rate to match your scanner
                        scanner.setDataBits(QSerialPort::Data8);
                        scanner.setParity(QSerialPort::NoParity);
                        scanner.setStopBits(QSerialPort::OneStop);
                        scanner.setFlowControl(QSerialPort::NoFlowControl);
                    
                        if (!scanner.open(QIODevice::ReadOnly)) {
                            qDebug() << "Error opening the serial port for the barcode scanner.";
                            return 1;
                        }
                    
                        qDebug() << "Listening for barcode scanner data on" << scanner.portName() << "...";
                    
                    
                         connect(&scanner, SIGNAL(readyRead()), this, SLOT(readBarcodeData()));
                    
                        return 0;
                    
                    }
                    
                    void MainWindow::on_pushButton_5_clicked()
                    {
                    
                        QByteArray data = scanner.readAll();
                        qDebug() << "Received data from barcode scanner:" << data;
                    }
                    
                    void MainWindow::readBarcodeData()
                    {
                        QByteArray data = scanner.readAll(); // Read data from the scanner
                    
                            // Process the received data
                            QString barcodeData = QString::fromUtf8(data);
                            qDebug() << "Received data from barcode scanner:" << barcodeData;
                    
                            // Perform any additional processing or actions with the barcode data here
                    
                            // Update your UI or perform other actions as needed
                            ui->label->setText(barcodeData);
                    }
                    
                    void MainWindow::on_pushButton_6_clicked()
                    {
                        readBarcodeData();
                    }
                    
                    
                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @Thananjeyan
                    You do realise that you do a standalone scanner.readAll() in on_pushButton_5_clicked(), right? You're not expecting that to output the data from a previous readBarcodeData(), are you?

                    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