Solved Problem on Barcode Scanner using serial port
-
@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 -
@jsulm pushButtton mean open Button
-
@SURYA-P Please show me the code where you send data over 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...
-
@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 ?
-
@SGaist sorry this is correct slot
connect(BSerial, &QSerialPort::readyRead, this, &MainWindow::SerialReceived);but i am not getting output
-
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.