aboutsummaryrefslogtreecommitdiff
path: root/examples/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/std/src')
-rw-r--r--examples/std/src/serial_port.rs10
-rw-r--r--examples/std/src/tuntap.rs16
2 files changed, 10 insertions, 16 deletions
diff --git a/examples/std/src/serial_port.rs b/examples/std/src/serial_port.rs
index 6825cbebc..c41abd4d0 100644
--- a/examples/std/src/serial_port.rs
+++ b/examples/std/src/serial_port.rs
@@ -1,18 +1,16 @@
1use std::io;
2use std::os::unix::io::{AsRawFd, RawFd};
3
1use nix::errno::Errno; 4use nix::errno::Errno;
2use nix::fcntl::OFlag; 5use nix::fcntl::OFlag;
3use nix::sys::termios; 6use nix::sys::termios;
4use std::io;
5use std::os::unix::io::{AsRawFd, RawFd};
6 7
7pub struct SerialPort { 8pub struct SerialPort {
8 fd: RawFd, 9 fd: RawFd,
9} 10}
10 11
11impl SerialPort { 12impl SerialPort {
12 pub fn new<P: ?Sized + nix::NixPath>( 13 pub fn new<P: ?Sized + nix::NixPath>(path: &P, baudrate: termios::BaudRate) -> io::Result<Self> {
13 path: &P,
14 baudrate: termios::BaudRate,
15 ) -> io::Result<Self> {
16 let fd = nix::fcntl::open( 14 let fd = nix::fcntl::open(
17 path, 15 path,
18 OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, 16 OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs
index b70767a3a..a0cace7f7 100644
--- a/examples/std/src/tuntap.rs
+++ b/examples/std/src/tuntap.rs
@@ -1,9 +1,10 @@
1use async_io::Async;
2use log::*;
3use std::io; 1use std::io;
4use std::io::{Read, Write}; 2use std::io::{Read, Write};
5use std::os::unix::io::{AsRawFd, RawFd}; 3use std::os::unix::io::{AsRawFd, RawFd};
6 4
5use async_io::Async;
6use log::*;
7
7pub const SIOCGIFMTU: libc::c_ulong = 0x8921; 8pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
8pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; 9pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933;
9pub const _ETH_P_ALL: libc::c_short = 0x0003; 10pub const _ETH_P_ALL: libc::c_short = 0x0003;
@@ -32,11 +33,7 @@ fn ifreq_for(name: &str) -> ifreq {
32 ifreq 33 ifreq
33} 34}
34 35
35fn ifreq_ioctl( 36fn ifreq_ioctl(lower: libc::c_int, ifreq: &mut ifreq, cmd: libc::c_ulong) -> io::Result<libc::c_int> {
36 lower: libc::c_int,
37 ifreq: &mut ifreq,
38 cmd: libc::c_ulong,
39) -> io::Result<libc::c_int> {
40 unsafe { 37 unsafe {
41 let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); 38 let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq);
42 if res == -1 { 39 if res == -1 {
@@ -141,11 +138,10 @@ impl TunTapDevice {
141} 138}
142 139
143use core::task::Waker; 140use core::task::Waker;
144use embassy_net::{
145 Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf,
146};
147use std::task::Context; 141use std::task::Context;
148 142
143use embassy_net::{Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf};
144
149impl Device for TunTapDevice { 145impl Device for TunTapDevice {
150 fn is_transmit_ready(&mut self) -> bool { 146 fn is_transmit_ready(&mut self) -> bool {
151 true 147 true