PDA

View Full Version : Sending raw data using QextSerialPort [solved]



DrDonut
7th January 2009, 11:02
Hello,

I'm trying to send data using QExtSerialPort. The data consits of integers. When I'm trying to send an integer like '9' the data actually sent is '57'. This is the ascii character for '9'.

The embedded device asks for numbers instead of ascii characters, so I need a way to send raw data over the serial port.

Does anyone know a way to do this?

I tried using QDataStream, but the problem is that there is no matching function call for QDataStream::QDataStream(QExtSerialPort**), so that didn't work.

Thanks in advance

DrDonut

OS: Windows xp
QT: 4.4.3
QExtSerial: 1.2-alpha

DrDonut
7th January 2009, 14:14
Hi all,

I've found a solution to the problem.



void Aansturing::sendPWM(int speedout)
{
if (port->isOpen()==0){
logwindow->append("Cannot send message (port closed)");}
else {
QByteArray signalout3;
signalout3.append(speedout);
port->write(signalout3, 1);
PWMdata=signalout2;}
}


So, when the string is declared as an QByteArray, the QExtSerial libary sends the data without converting it to ascii codes.

Just posting it here for anyone else who has the problem

Thank you all for your time.

DrDonut