Crates.io | smoltcp_null_modem |
lib.rs | smoltcp_null_modem |
version | |
source | src |
created_at | 2024-10-17 09:00:00.666443 |
updated_at | 2024-10-17 09:02:21.573041 |
description | smoltcp null modem drivers |
homepage | https://pub.npry.dev/interstice/about |
repository | https://pub.npry.dev/interstice |
max_upload_size | |
id | 1412808 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This crate provides "null modem" PHY drivers for smoltcp
in both allocating and
non-allocating variants.
You can see a null modem as a two-ended in-memory pipe, where both ends are smoltcp::phy::Device
and the TX of one is connected directly to the RX of the other (and vice versa).
use smoltcp::{
phy::{
Medium,
Device as _,
TxToken as _,
RxToken as _,
},
time::Instant,
};
const MTU: usize = 128;
const CAPACITY: usize = 4;
let mut modem = smoltcp_null_modem::noalloc::<CAPACITY, MTU>(Medium::Ethernet);
let (mut phy1, mut phy2) = modem.split();
// Send a frame into the first interface
let tok = phy1.transmit(Instant::now()).unwrap();
tok.consume(10, |buf| {
buf.copy_from_slice(&[0xa5; 10]);
});
// And it appears on the second
let (tok, _) = phy2.receive(Instant::now()).unwrap();
tok.consume(|buf| {
assert_eq!(buf, &[0xa5; 10]);
});