Send UART serial commands

You are here:
Estimated reading time: 1 min
For UART data transmission next configuration is required: 115200 bps – 8 data bits – no parity – 1 stop bit – no flow control. Refer to physical interfaces article to assure the electrical pin-out of the UART communication port.

The operation to send a command from an external host to a KTWM102 RF Module though the UART serial interface starts with creating the frame of the command that is going to be sent. Each command is composed by a header field and a payload field. The header field (five bytes) contains specific information about the command type, code, length… and the payload contains the data (up to 1232 bytes) needed for this command to be executed by the module.

Refer to KBI Reference Guide for more detailed frame format and syntax information.

Once the host system has composed the command frame it must be encoded using Consistent Overhead Byte Stuffing (COBS) before it can be transmitted to the module. COBS is a standard reversible codification/decodification process required to guarantee a proper serial data transmission. It controls and improves aspects like flow-control, error detection, frame delimiter escaping, frame compression, etc.

Finally, the encoded command frame can be sent through UART serial interface towards the module. Then the host system should wait for the command response which notifies the correct command reception, decoding and execution by the module and the result of this (success, command not found, parameter error, value read…). This is the only way to match a command with its response in a coherent way. With the response the host could take proper actions to do what is required by the application.

The use of serial RX interrupts is recommended to manage incoming serial data.