Solved 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 -
@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?
-
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...
-
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 -
@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.