I need help in sending a specific escape sequence, using Embedded C. This is my very first topic at stackoverflow!
I use this function to write commands through UART:
void UART_Write(UARTChannel* channel, uint8_t* data, uint32_t length)
The inputs, channel, data and length, correspond with the UART channel, the command to be send and the length of the command, respectively. This works great in general!
However, I have some difficulties in generating the correct escape sequence in C. I need to write the following escape sequence, using the UART_Write function:
EscR0,1,2,7;
Esc
being the Escape character (0x1b), R0
being the character command designator, 1,2,7
being the context specific parameters and ;
being the termination sign.
How can I make the input "data" to the function "UART_Write" be equal to the escape sequence EscR0,1,2,7; in Embedded C?
I suppose it can be done in many different ways, but any suggestions will do.
do you want to send 'esc' or do you want to send '1b' as a hex value?
just send the characters, just like you would any other character string
for instance for the example: EscR0,1,2,7;
:
char buffer[20] = {'\0'};
buffer[0] = 0x1b;
strcat( buffer, "R0,1,2,6;" );
....