PDA

View Full Version : How many bytes did i send?



yagabey
24th January 2008, 08:21
Hello,

I want to check how many bytes are written on the port after I send an amount of data..

I connected bytesWritten signal of IODevice to a slot for viewing the amount of bytes written..

But when i print it on a textedit display, i see a value like:

-3617008641903833651

What does this mean? I was expecting something like 1024 (bytes)...

Here is the code:

Here I connected the slot to bytesWrittenSignal:

connect(serial, SIGNAL(QIODevice::bytesWritten(qint64)),this,SLOT( writtenBytes(qint64)));

That is the slot definition:

qint64 SerialPort::writtenBytes(qint64 bytes)
{
allWrittenBytes = bytes;
return bytes;
}

I printed it on QTextEdit.(I converted it to QString for compatibility)

qint64 writtenBytes_x;
writtenBytes_x = sp->allWrittenBytes;
QString writtenBytesString = QString::number(writtenBytes_x,10);
textEdit->append(writtenBytesString);

wysota
24th January 2008, 09:13
Based on the number you get I suspect you have a signed/unigned issue somewhere. Are you using QExtSerialPort?

yagabey
24th January 2008, 09:39
yes, i'm using qextserialport, what may be the problem?

wysota
24th January 2008, 11:12
I wouldn't rely on its QIODevice interface too much.