Play with single chip microcomputer, from a serial port receives the data, data length is unknown, but had to FF FF FF
From the serial port to receive according to the law of intercepting the end of a string of characters, assigned to the variable b, then perform different procedures, in accordance with the contents of b
Example: SBUF=02 02, 03 04 05 06 FF FF FF 01
B=01
(void) USART_SBUF (void)
{
Char STR [];
STR=SBUF;
/* intercept a byte from STR assigned to b,
Byte is located in the "FF FF FF" after */
If (b==01)
{
//to execute a program
}
}
CodePudding user response:
Unknown data length that is irresponsible,After you receive to count the length, or you write a function call every receiving one byte of a,