40 #define SLIP_ESC_END 0334 41 #define SLIP_ESC_ESC 0335 43 PROCESS(slip_process,
"SLIP driver");
45 static uint8_t slip_active;
47 #if SLIP_CONF_WITH_STATS 48 static uint16_t slip_rubbish, slip_twopackets, slip_overflow, slip_ip_drop;
49 #define SLIP_STATISTICS(statement) statement 51 #define SLIP_STATISTICS(statement) 55 #define RX_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN + 16) 74 static uint8_t state = STATE_TWOPACKETS;
75 static uint16_t begin, next_free;
76 static uint8_t rxbuf[RX_BUFSIZE];
77 static uint16_t pkt_end;
79 static void (*input_callback)(void) = NULL;
96 const uint8_t *ptr = _ptr;
102 for(i = 0; i < len; ++i) {
107 }
else if(c == SLIP_ESC) {
120 begin = next_free = pkt_end = 0;
125 slip_poll_handler(uint8_t *outbuf, uint16_t blen)
131 if(begin != pkt_end) {
133 uint16_t cur_next_free;
137 if(begin < pkt_end) {
140 for(i = begin; i < pkt_end; ++i) {
146 if(rxbuf[i] == SLIP_ESC_ESC) {
147 outbuf[len] = SLIP_ESC;
149 }
else if(rxbuf[i] == SLIP_ESC_END) {
150 outbuf[len] = SLIP_END;
154 }
else if(rxbuf[i] == SLIP_ESC) {
157 outbuf[len] = rxbuf[i];
164 for(i = begin; i < RX_BUFSIZE; ++i) {
170 if(rxbuf[i] == SLIP_ESC_ESC) {
171 outbuf[len] = SLIP_ESC;
173 }
else if(rxbuf[i] == SLIP_ESC_END) {
174 outbuf[len] = SLIP_END;
178 }
else if(rxbuf[i] == SLIP_ESC) {
181 outbuf[len] = rxbuf[i];
185 for(i = 0; i < pkt_end; ++i) {
191 if(rxbuf[i] == SLIP_ESC_ESC) {
192 outbuf[len] = SLIP_ESC;
194 }
else if(rxbuf[i] == SLIP_ESC_END) {
195 outbuf[len] = SLIP_END;
199 }
else if(rxbuf[i] == SLIP_ESC) {
202 outbuf[len] = rxbuf[i];
209 pkt_end = pkt_end + 1;
210 if(pkt_end == RX_BUFSIZE) {
213 if(pkt_end != next_free) {
214 cur_next_free = next_free;
216 while(cur_ptr != cur_next_free) {
217 if(rxbuf[cur_ptr] == SLIP_END) {
218 uint16_t tmp_begin = pkt_end;
226 if(cur_ptr == RX_BUFSIZE) {
230 if(cur_ptr == cur_next_free) {
281 if(c != SLIP_ESC_END && c != SLIP_ESC_ESC) {
282 state = STATE_RUBBISH;
283 SLIP_STATISTICS(slip_rubbish++);
297 next_free = next_free + 1;
298 if(next_free == RX_BUFSIZE) {
301 if(next_free == begin) {
302 state = STATE_RUBBISH;
303 SLIP_STATISTICS(slip_overflow++);
315 if(cur_end != pkt_end) {
316 if(begin == pkt_end) {
319 SLIP_STATISTICS(slip_twopackets++);
#define PROCESS(name, strname)
Declare a process.
uint16_t uip_len
The length of the packet in the uip_buf buffer.
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_END()
Define the end of a process.
#define UIP_BUFSIZE
The size of the uIP packet buffer.
void slip_arch_writeb(unsigned char c)
Write a single byte over SLIP.
void process_poll(struct process *p)
Request a process to be polled.
#define UIP_LLH_LEN
The link level header length.
#define uip_buf
Macro to access uip_aligned_buf as an array of bytes.
Header file for the uIP TCP/IP stack.
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
void tcpip_input(void)
Deliver an incoming packet to the TCP/IP stack.