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 ?
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 ?
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.
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.
Bookmarks