Hello everyone, I'm having some problems sending my commands to the device through a serial port. So first, I create a Qlineedit that only takes integer, from 0 to 21, and then I create a pushButton with this code
Qt Code:
  1. void MainWindow::on_pushButton_2_clicked() //testing button
  2. {
  3. QString input = ui->lineEdit->text();
  4. bool ok;
  5. char data = input.toInt(&ok, 16);
  6. char checksum;
  7. char power[] = {0x01, 0x06, 0x08, data, checksum, 0x04};
  8. char result = 0x00;
  9. for (int i=0; i<4; i++) {
  10. result += power[i];
  11. };
  12. checksum = result;
  13. power[4]=checksum;
  14. serial->write(power,sizeof(power));
  15. }
To copy to clipboard, switch view to plain text mode 
so for example, if I put in "1" to the lineedit, it will generate a char array of 01, 06, 08, 01, 10, 04 and send it to the serial port. If I input "2", it's going to be 01, 06, 08, 02, 11, 04, and etc. The way I check if the data is sent correctly is that the device will send back an acknowledge line. I've tried this and successfully done it up to 15, then I don't know why but from 16 to 21, the data can't be sent correctly because the device doesn't send back anything. If it doesn't work at all then I know what to fix, but in this case, it works but only for 0-15, so I'm really confused. I will appreciate any help, thank you.