Waveshare barcode scanner module
-
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(); }
-
@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. -
@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
-
@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?
-
@Thananjeyan So, the question is: what data does the barcode scanner actually return? Is it a picture? You first need to clarify that...
-
@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...
-
@Thananjeyan
You do realise that you do a standalonescanner.readAll()
inon_pushButton_5_clicked()
, right? You're not expecting that to output the data from a previousreadBarcodeData()
, are you?