//_____________________________________________________________________________________ u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len) { int n=0; do n+=sio_tryread(fd,data,len-n); while(n<len); return(len); }
/** * Static function for easy use of blockig or non-blocking * sio_read * * @param fd serial device handle * @param data pointer to data buffer for receiving * @param len maximum length (in bytes) of data to receive * @param block if 1, call sio_read; if 0, call sio_tryread * @return return value of sio_read of sio_tryread */ static u32_t slip_sio_read(sio_fd_t fd, u8_t* data, u32_t len, u8_t block) { if (block) { return sio_read(fd, data, len); } else { return sio_tryread(fd, data, len); } }
/** * Polls the serial device and feeds the IP layer with incoming packets. * * @param netif The lwip network interface structure for this slipif */ void slipif_poll(struct netif *netif) { u8_t c; struct slipif_priv *priv; LWIP_ASSERT("netif != NULL", (netif != NULL)); LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); priv = (struct slipif_priv *)netif->state; while (sio_tryread(priv->sd, &c, 1) > 0) { slipif_rxbyte_input(netif, c); } }