Results 1 to 6 of 6

Thread: Fail To Write byte to device via QSerialPort

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Fail To Write byte to device via QSerialPort

    1. Convert char* to QByteArray : use suitable QByteArray constructor.
    2. Convert qint8 to QByteArray : read about functions qToBigEndian and qToLitleEndian.
    3. COM port speed : what serial port library are You using ?

  2. #2
    Join Date
    Mar 2015
    Posts
    7
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Fail To Write byte to device via QSerialPort

    Thank you for the reply. Before I have posted the previous thread, I had tried your method
    " 1. Convert char* to QByteArray : use suitable QByteArray constructor."
    but nothing had improved. Then I thought maybe the problem was at the setting of baudrate.
    The high speed baudrate requirement is by MCU/ ARM via a UART from FTDI. Since I do not know how to set the such high speed in QT, I tried to use FTDI API yesterday. With correct setting, the communication is fine. By the way, could I ask a very simple question what qint32 really is? I want to set QSerialPort::setBaudRate as :serial->setBauRate(5000000) but it has compiler error. If I can make sure there is no problem in baudrate setting via QSerialPort, I probably can clarify whether my conversion from unsign char* to QByteArray is successful or not.

  3. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Fail To Write byte to device via QSerialPort

    qint32 is a signed 32-bit integer value whose possible range of values is +/- 2,147,483,647. One bit is used for the sign and the remaining 31 bits are used for the value. You may commonly see this also referred to as 2^31.

    You may also use QByteArray::append to append your unsigned char values to the QByteArray.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Fail To Write byte to device via QSerialPort

    Quote Originally Posted by leisha View Post
    I want to set QSerialPort::setBaudRate as :serial->setBauRate(5000000) but it has compiler error.
    And you didn't feel to include the error because you don't want help on that issue?

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 1st April 2014, 08:48
  2. How to write the BYTE* data to a QFile?
    By Gokulnathvc in forum Newbie
    Replies: 10
    Last Post: 23rd November 2011, 04:33
  3. Replies: 2
    Last Post: 2nd November 2010, 05:15
  4. Replies: 3
    Last Post: 19th April 2010, 14:16
  5. Replies: 1
    Last Post: 16th June 2009, 09:09

Tags for this Thread

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.