9 static uint8_t escape_state
= 0;
10 static uint8_t state
= 0;
11 static uint16_t pos
= 0;
12 static uint16_t funcid
= 0;
13 static uint16_t crcbuf
= 0;
14 static uint8_t argbuf
[ARGBUF_SIZE
];
15 static uint16_t arglen
= 0;
17 uint16_t v
= uart_getc_nonblocking();
20 if(!v
){ //a character was successfully received
33 //escape sequence handling completed. 'c' now contains the next char of the payload.
35 case 0: //receive funcid, payload length
56 case 1: //receive arg payload
62 case 2: //receive and check payload crc. finally, call the function and send the return value
66 //successfully received the crc
67 //FIXME add crc checking
68 if(funcid
< NUM_CALLBACKS
){
69 //HACK: The argument buffer is currently passed as the response buffer for ram efficiency.
70 //Only write to the response buffer *after* you are done reading from it.
71 comm_callbacks
[funcid
](arglen
, argbuf
);
73 //FIXME error handling
81 void putc_escaped(char c
){