Problem on Barcode Scanner using serial port
-
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 -
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 -
https://paste.ofcode.org/79eEqkQe7zuXvYMbWWFqrP
this is my code -
https://paste.ofcode.org/79eEqkQe7zuXvYMbWWFqrP
this is my code@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://i.postimg.cc/HsRpbjdY/Screenshot-57.png
if i click the scan button that command should work . and give output like that -
@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? -
@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
-
@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
-
@jsulm void MainWindow::SerialReceived()
{serialData+=BSerial->readAll(); receivedData = QString::fromStdString(serialData.toStdString()); ui->textEdit_2->setText(serialData);
}
this is for read data
@SURYA-P said in Problem on Barcode Scanner using serial port:
this is for read data
I asked about writing data...
-
@SURYA-P said in Problem on Barcode Scanner using serial port:
this is for read data
I asked about writing data...
-
@jsulm i wrote a command on file(0x7E 0x00 0x08 0x01 0x00 0x02 0x01 0xAB 0xCD) this is the command ..
-
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 ?
-
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 ?
-
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.