Results 1 to 3 of 3

Thread: QSerialPort :: read - Serial Comms noob.

  1. #1
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default QSerialPort :: read - Serial Comms noob.

    Hi - I am using QSerialPort to talk to a Basic Stamp microprocessor spitting out 2 byte values (pbasic WORD) read from an accelerometer.

    I am a complete serial comms noob.

    I am able to set up the comms fine, but I'm not sure what exactly CSerialPort :: read() gives me when passed an array of char.

    So

    bytesRead = SerialPort.read( bytes, 50 );

    reads up to 50 chars into the array specified by "bytes". But what those bytes? The port is set to readonly, 9500 baud, 8 data bits, no parity bit, one stop bit, no flow control.

    Are the bytes read those read off the serial port as is, i.e., 1 start bit, 8 data bits, one stop bit (So that the frame is split across multiple bytes, and my 2 byte word is split across 3 bytes)

    Or is the char the data bits only (and my 2 byte word is split across 2 bytes only ?)

    Thanks

    Griff

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,688
    Thanks
    13
    Thanked 1,598 Times in 1,526 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSerialPort :: read - Serial Comms noob.

    It is the data only.

    You probably should not be using read(), just readAll() in the slot you connect to readyRead().

  3. The following user says thank you to ChrisW67 for this useful post:

    llaregyb (8th January 2014)

  4. #3
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QSerialPort :: read - Serial Comms noob.

    So my WORD from the stamp will be returned as successive bytes.

    I'll consider readAll - currently, it's at the 'hack' stage, and it's just running in a subthread.

    Thanks for your help.

Similar Threads

  1. read data from serial port and display it
    By vanduongbk in forum Newbie
    Replies: 1
    Last Post: 30th June 2013, 04:46
  2. read data from serial port
    By amitpatel22 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 20th July 2011, 18:11
  3. Serial comms on Windows Pc (Qextserialport)
    By SteveH in forum Qt Programming
    Replies: 19
    Last Post: 11th June 2010, 00:05
  4. Replies: 1
    Last Post: 16th June 2009, 10:09
  5. How to write bytes read from serial port to a QFile
    By shamik in forum Qt Programming
    Replies: 19
    Last Post: 25th June 2007, 15:12

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.