Hi,
My structure contains a variable of type quint16_t and before sending to a device through serial port, I am appending it to a QByteArray. As QByteArray holds byte, I see only one byte is sent. Actually I want len field should hold 2 bytes.
Qt Code:
typedef struct x_hdr { .... quint16_t len; }x; { tx_msg->append(sizeof(x)); }To copy to clipboard, switch view to plain text mode
serial data frame is : SOF (1 byte)| seq (1 byte) | len (2 bytes) [holds length of data] | payload (n bytes)| chksum (2 bytes) | eof (1 byte)
When I send this, only one byte is allocated for len & chksum field.
How can append 2 bytes in the serial frame. Could someone help me on this ?
Best Regards,
Anita
Bookmarks