Results 1 to 4 of 4

Thread: How many bytes did i send?

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Question How many bytes did i send?

    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:
    Qt Code:
    1. connect(serial, SIGNAL(QIODevice::bytesWritten(qint64)),this,SLOT(writtenBytes(qint64)));
    To copy to clipboard, switch view to plain text mode 

    That is the slot definition:
    Qt Code:
    1. qint64 SerialPort::writtenBytes(qint64 bytes)
    2. {
    3. allWrittenBytes = bytes;
    4. return bytes;
    5. }
    To copy to clipboard, switch view to plain text mode 

    I printed it on QTextEdit.(I converted it to QString for compatibility)
    Qt Code:
    1. qint64 writtenBytes_x;
    2. writtenBytes_x = sp->allWrittenBytes;
    3. QString writtenBytesString = QString::number(writtenBytes_x,10);
    4. textEdit->append(writtenBytesString);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How many bytes did i send?

    Based on the number you get I suspect you have a signed/unigned issue somewhere. Are you using QExtSerialPort?

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How many bytes did i send?

    yes, i'm using qextserialport, what may be the problem?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How many bytes did i send?

    I wouldn't rely on its QIODevice interface too much.

Similar Threads

  1. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  2. Access Violation on Signal Emit
    By khagzan in forum Qt Programming
    Replies: 2
    Last Post: 25th September 2007, 22:51
  3. QGLWidget bug
    By Wizard in forum Qt Programming
    Replies: 11
    Last Post: 31st August 2007, 11:23
  4. How to construct Image from Bytes
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2007, 05:41
  5. Qt 4.1 Memory Leak
    By blackliteon in forum Qt Programming
    Replies: 14
    Last Post: 10th February 2006, 12:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.