6 releases (3 breaking)

0.4.0 Jan 29, 2024
0.3.2 Sep 22, 2023
0.3.0 Dec 27, 2021
0.2.0 Nov 4, 2021
0.1.0 Nov 3, 2021

#277 in Embedded development

Download history 8/week @ 2024-01-25 3/week @ 2024-02-15 11/week @ 2024-02-22 5/week @ 2024-02-29 20/week @ 2024-03-07 95/week @ 2024-03-14 4/week @ 2024-03-28 1/week @ 2024-04-04

107 downloads per month

MIT license

16KB
348 lines

smoltcp-slip

This crates aims to provide an implementation of the SLIP protocol for smoltcp.

Usage

use linux_embedded_hal::Serial;
use smoltcp::iface::{Config, Interface};
use smoltcp::time::Instant;
use smoltcp::wire::{HardwareAddress, Ipv4Address, Ipv4Cidr};
use smoltcp_slip::SlipDevice;

// open a serial device
let device = Serial::open("/dev/ttyS0".to_string(), 9600)
    .expect("open serial port");

// create a SLIP device from this I/O device
let mut device = SlipDevice::from(device);

// create an interface from this IP device
let local_addr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 1]), 24);
let mut iface = Interface::new(Config::new(HardwareAddress::Ip), &mut device, Instant::now());
iface.update_ip_addrs(|ips| { ips.push(local_addr.into()); });

// At this point, iface.poll() and the likes can be called.

Dependencies

~2.5MB
~55K SLoC