Prusa MINI Firmware overview
|
#include "netif/slipif.h"
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/sys.h"
#include "lwip/sio.h"
◆ SLIP_END
#define SLIP_END 0xC0 /* 0300: start and end of every packet */ |
◆ SLIP_ESC
#define SLIP_ESC 0xDB /* 0333: escape start (one byte escaped data follows) */ |
◆ SLIP_ESC_END
#define SLIP_ESC_END 0xDC /* 0334: following escape: original byte is 0xC0 (END) */ |
◆ SLIP_ESC_ESC
#define SLIP_ESC_ESC 0xDD /* 0335: following escape: original byte is 0xDB (ESC) */ |
◆ SLIP_MAX_SIZE
#define SLIP_MAX_SIZE 1500 |
Maximum packet size that is received by this netif
◆ SLIP_SIO_SPEED
#define SLIP_SIO_SPEED |
( |
|
sio_fd | ) |
0 |
Define this to the interface speed for SNMP (sio_fd is the sio_fd_t returned by sio_open). The default value of zero means 'unknown'.
◆ slipif_recv_state
Enumerator |
---|
SLIP_RECV_NORMAL | |
SLIP_RECV_ESCAPE | |
◆ slipif_output()
Send a pbuf doing the necessary SLIP encapsulation
Uses the serial layer's sio_send()
- Parameters
-
netif | the lwip network interface structure for this slipif |
p | the pbuf chain packet to send |
- Returns
- always returns ERR_OK since the serial layer does not provide return values
◆ slipif_rxbyte()
static struct pbuf* slipif_rxbyte |
( |
struct netif * |
netif, |
|
|
u8_t |
c |
|
) |
| |
|
static |
Handle the incoming SLIP stream character by character
- Parameters
-
netif | the lwip network interface structure for this slipif |
c | received character (multiple calls to this function will return a complete packet, NULL is returned before - used for polling) |
- Returns
- The IP packet when SLIP_END is received
217 switch (priv->
state) {
262 if (priv->
p ==
NULL) {
267 if (priv->
p ==
NULL) {
274 if (priv->
q !=
NULL) {
288 if (priv->
i >= priv->
p->
len) {
◆ slipif_rxbyte_input()
Like slipif_rxbyte, but passes completed packets to netif->input
- Parameters
-
netif | The lwip network interface structure for this slipif |
c | received character |
◆ slipif_init()
SLIP netif initialization
Call the arch specific sio_open and remember the opened device in the state field of the netif.
- Parameters
-
netif | the lwip network interface structure for this slipif |
- Returns
- ERR_OK if serial line could be opened, ERR_MEM if no memory could be allocated, ERR_IF is serial line couldn't be opened
- Note
- netif->num must contain the number of the serial port to open (0 by default). If netif->state is != NULL, it is interpreted as an u8_t pointer pointing to the serial port number instead of netif->num.
377 netif->output = slipif_output_v4;
380 netif->output_ip6 = slipif_output_v6;
405 priv->rxpackets =
NULL;
413 #if SLIP_USE_RX_THREAD
◆ slipif_poll()
Polls the serial device and feeds the IP layer with incoming packets.
- Parameters
-
netif | The lwip network interface structure for this slipif |
u16_t recved
Definition: slipif.c:100
u16_t len
Definition: pbuf.h:159
#define PBUF_LINK_ENCAPSULATION_HLEN
Definition: opt.h:1364
#define SLIP_SIO_SPEED(sio_fd)
Definition: slipif.c:87
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
u16_t i
Definition: slipif.c:100
#define PBUF_LINK_HLEN
Definition: opt.h:1355
#define SLIPIF_THREAD_PRIO
Definition: opt.h:1599
uint16_t u16_t
Definition: arch.h:121
netif_input_fn input
Definition: netif.h:244
u16_t tot_len
Definition: pbuf.h:156
#define SLIP_ESC
Definition: slipif.c:73
void * state
Definition: netif.h:279
uint8_t i
Definition: screen_test_graph.c:72
struct pbuf * next
Definition: pbuf.h:144
#define LINK_STATS_INC(x)
Definition: stats.h:384
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
Definition: sys_arch.c:376
u16_t mtu
Definition: netif.h:299
#define SLIP_DEBUG
Definition: opt.h:2821
#define SLIP_END
Definition: slipif.c:72
#define SLIP_ESC_ESC
Definition: slipif.c:75
#define NULL
Definition: usbd_def.h:53
#define PBUF_POOL_BUFSIZE
Definition: opt.h:1373
#define SLIPIF_THREAD_NAME
Definition: opt.h:1581
u8_t num
Definition: netif.h:309
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
Definition: pbuf.c:248
uint8_t u8_t
Definition: arch.h:119
#define SLIP_MAX_SIZE
Definition: slipif.c:79
#define MIB2_INIT_NETIF(netif, type, speed)
Definition: snmp.h:138
void pbuf_realloc(struct pbuf *p, u16_t new_len)
Definition: pbuf.c:493
sio_fd_t sd
Definition: slipif.c:96
char name[2]
Definition: netif.h:307
while(sofevent)
Definition: USB_HOST_SHIELD.h:456
void pbuf_cat(struct pbuf *h, struct pbuf *t)
Definition: pbuf.c:840
u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)
#define U16_F
Definition: arch.h:143
struct pbuf * p
Definition: slipif.c:98
sio_fd_t sio_open(u8_t devnum)
static void slipif_rxbyte_input(struct netif *netif, u8_t c)
Definition: slipif.c:310
struct pbuf * q
Definition: slipif.c:98
void * mem_malloc(mem_size_t size)
Definition: mem.c:603
#define SLIPIF_THREAD_STACKSIZE
Definition: opt.h:1590
void sio_send(u8_t c, sio_fd_t fd)
void mem_free(void *rmem)
Definition: mem.c:419
u8_t state
Definition: slipif.c:99
static struct pbuf * slipif_rxbyte(struct netif *netif, u8_t c)
Definition: slipif.c:207
#define SLIP_ESC_END
Definition: slipif.c:74
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:164
void * payload
Definition: pbuf.h:147