Problem on Barcode Scanner using serial port
-
wrote on 22 Jan 2021, 04:53 last edited by
-
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@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?
-
wrote on 22 Jan 2021, 06:47 last edited by
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 -
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@SURYA-P Sorry, but this is not helpful. Please show your code, people here are not mind readers...
-
wrote on 22 Jan 2021, 06:50 last edited by
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? -
wrote on 22 Jan 2021, 07:00 last edited by
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? -
@SURYA-P Please show me the code where you send data over serial port...
-
wrote on 22 Jan 2021, 07:04 last edited by
@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
@SURYA-P Please show me the code where you send data over 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
but to send it to device we are after code that is like
BSerial->write ( xxx ); -
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.
1/18