0

So.. I am using this code to read some informations from a powertek pa4400a, and sometimes I can read it without any problems but sometimes I'm getting weird answers. I'm not even able to understand what does characters mean.

QSerialPort asd;
asd.setBaudRate(QSerialPort::Baud19200);
asd.setDataBits(QSerialPort::Data8);
asd.setFlowControl(QSerialPort::NoFlowControl);
asd.setParity(QSerialPort::NoParity);
asd.setStopBits(QSerialPort::OneStop);
asd.setPortName("ttyUSB0");
asd.open(QSerialPort::ReadWrite);
asd.write(com);
asd.waitForReadyRead(10000);
QString ans = asd.readAll();

The ans string should look like this:

"00.00E+0; 00.00E+0;+00.00E+0; 00.00E+0; 000:00:00;<<END OF DATA>>"

But I am getting things like this:

"\xFB"

Or any other stuff that's not right.

I did get the right answer a lot of times but something happened and I can't read the information anymore.

Alex
  • 97
  • 1
  • 13
  • You're not doing anything obviously wrong, but I have no good experience with pseudo-synchronous code that uses any `waitForXxx` methods. See if you could implement your command-and-response system using the approach from [this answer](http://stackoverflow.com/a/32595398/1329652), perhaps. What platform is this on? – Kuba hasn't forgotten Monica Feb 05 '16 at 13:25
  • Windows, but the problem was at flow control. I switched to HardwareControl and now it's working. – Alex Feb 06 '16 at 09:40

1 Answers1

1

The problem here it was that the machine I was sending commands to was using HardwareControl, but I used NoFlowControl, and that messed up my answers.

Alex
  • 97
  • 1
  • 13