Microchip® Advanced Software Framework

slip.c File Reference
#include <stdio.h>
#include <string.h>
#include "contiki.h"
#include "net/ip/uip.h"
#include "net/ipv4/uip-fw.h"
#include "dev/slip.h"

Macros

#define BUF   ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
 
#define RX_BUFSIZE   (UIP_BUFSIZE - UIP_LLH_LEN + 16)
 
#define SLIP_END   0300
 
#define SLIP_ESC   0333
 
#define SLIP_ESC_END   0334
 
#define SLIP_ESC_ESC   0335
 
#define SLIP_STATISTICS(statement)
 

Enumerations

enum  {
  STATE_TWOPACKETS = 0,
  STATE_OK = 1,
  STATE_ESC = 2,
  STATE_RUBBISH = 3
}
 

Functions

 PROCESS (slip_process,"SLIP driver")
 
 PROCESS_THREAD (slip_process, ev, data)
 
static void rxbuf_init (void)
 
int slip_input_byte (unsigned char c)
 Input a SLIP byte. More...
 
static uint16_t slip_poll_handler (uint8_t *outbuf, uint16_t blen)
 
uint8_t slip_send (void)
 Send an IP packet from the uIP buffer with SLIP. More...
 
void slip_set_input_callback (void(*c)(void))
 Set a function to be called when there is activity on the SLIP interface; used for detecting if a node is a gateway node. More...
 
uint8_t slip_write (const void *_ptr, int len)
 

Variables

static uint16_t begin
 
static uint16_t end
 
static void(* input_callback )(void) = NULL
 
static uint16_t pkt_end
 
static uint8_t rxbuf [RX_BUFSIZE]
 
uint8_t slip_active
 
static uint8_t state = STATE_TWOPACKETS
 

#define BUF   ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])

Referenced by PROCESS_THREAD().

#define RX_BUFSIZE   (UIP_BUFSIZE - UIP_LLH_LEN + 16)
#define SLIP_END   0300
#define SLIP_ESC   0333
#define SLIP_ESC_END   0334
#define SLIP_ESC_ESC   0335
#define SLIP_STATISTICS (   statement)

Referenced by PROCESS_THREAD(), and slip_input_byte().

anonymous enum
Enumerator
STATE_TWOPACKETS 
STATE_OK 
STATE_ESC 
STATE_RUBBISH 

PROCESS ( slip_process  ,
"SLIP driver"   
)
static void rxbuf_init ( void  )
static

References begin, end, pkt_end, state, and STATE_OK.

Referenced by PROCESS_THREAD(), and slip_poll_handler().

int slip_input_byte ( unsigned char  c)

Input a SLIP byte.

This function is called by the RS232/SIO device driver to pass incoming bytes to the SLIP driver. The function can be called from an interrupt context.

For systems using low-power CPU modes, the return value of the function can be used to determine if the CPU should be woken up or not. If the function returns non-zero, the CPU should be powered up. If the function returns zero, the CPU can continue to be powered down.

Parameters
cThe data that is to be passed to the SLIP driver
Returns
Non-zero if the CPU should be powered up, zero otherwise.

References begin, c, end, pkt_end, process_poll(), RX_BUFSIZE, rxbuf, SLIP_END, SLIP_ESC, SLIP_ESC_END, SLIP_ESC_ESC, slip_overflow, slip_rubbish, SLIP_STATISTICS, slip_twopackets, state, STATE_ESC, STATE_OK, STATE_RUBBISH, and STATE_TWOPACKETS.

static uint16_t slip_poll_handler ( uint8_t *  outbuf,
uint16_t  blen 
)
static
uint8_t slip_send ( void  )

Send an IP packet from the uIP buffer with SLIP.

References c, i, ptr, slip_arch_writeb(), SLIP_END, SLIP_ESC, SLIP_ESC_END, SLIP_ESC_ESC, uip_appdata, uip_buf, UIP_FW_OK, uip_len, UIP_LLH_LEN, and UIP_TCPIP_HLEN.

Referenced by input_callback(), and output().

void slip_set_input_callback ( void(*)(void)  c)

Set a function to be called when there is activity on the SLIP interface; used for detecting if a node is a gateway node.

References c, and input_callback.

Referenced by init().

uint8_t slip_write ( const void *  _ptr,
int  len 
)

uint16_t begin
static
void(* input_callback)(void) = NULL
static
uint16_t pkt_end
static
uint8_t rxbuf[RX_BUFSIZE]
static
uint8_t slip_active

Referenced by PROCESS_THREAD().

uint8_t state = STATE_TWOPACKETS
static