aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-02 21:20:00 +0100
committerDario Nieuwenhuis <[email protected]>2021-03-02 21:20:00 +0100
commit9bee576fd241f019c363919b0c29551c6b8ee4b2 (patch)
tree96bfb71546ab96b02cb5c26d6b754793e4bd64e9
parentf100383b3c094830fee4e54956795388bd5edec1 (diff)
Update embassy
-rw-r--r--.cargo/config2
-rw-r--r--.github/workflows/rust.yml2
-rw-r--r--.vscode/settings.json6
-rw-r--r--Cargo.toml1
-rwxr-xr-xci.sh (renamed from test-build.sh)2
-rw-r--r--embassy-net-examples/src/main.rs5
-rw-r--r--embassy-net-examples/src/tuntap.rs8
-rw-r--r--embassy-net/Cargo.toml3
-rw-r--r--embassy-net/src/config/dhcp.rs6
-rw-r--r--embassy-net/src/device.rs8
-rw-r--r--embassy-net/src/stack.rs8
-rw-r--r--embassy-net/src/tcp_socket.rs2
12 files changed, 32 insertions, 21 deletions
diff --git a/.cargo/config b/.cargo/config
deleted file mode 100644
index 93b20ab3f..000000000
--- a/.cargo/config
+++ /dev/null
@@ -1,2 +0,0 @@
1[unstable]
2namespaced-features = true \ No newline at end of file
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index f349f50ad..219a5e367 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -21,4 +21,4 @@ jobs:
21 target: thumbv7em-none-eabi 21 target: thumbv7em-none-eabi
22 override: true 22 override: true
23 - name: Build 23 - name: Build
24 run: ./test-build.sh 24 run: ./ci.sh
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..b0c623307
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,6 @@
1{
2 "editor.formatOnSave": true,
3 "rust-analyzer.procMacro.enable": true,
4 "rust-analyzer.cargo.loadOutDirsFromCheck": true,
5 "rust-analyzer.assist.importMergeBehavior": "last",
6} \ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 1b3012829..7ab99c2e9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -45,4 +45,5 @@ overflow-checks = false
45embassy = { git = "https://github.com/akiles/embassy" } 45embassy = { git = "https://github.com/akiles/embassy" }
46embassy-std = { git = "https://github.com/akiles/embassy" } 46embassy-std = { git = "https://github.com/akiles/embassy" }
47embassy-macros = { git = "https://github.com/akiles/embassy" } 47embassy-macros = { git = "https://github.com/akiles/embassy" }
48embassy-traits = { git = "https://github.com/akiles/embassy" }
48smoltcp = { git = "https://github.com/akiles/smoltcp" } \ No newline at end of file 49smoltcp = { git = "https://github.com/akiles/smoltcp" } \ No newline at end of file
diff --git a/test-build.sh b/ci.sh
index ec35f5da3..385379dec 100755
--- a/test-build.sh
+++ b/ci.sh
@@ -7,7 +7,7 @@ set -euxo pipefail
7 7
8# build for embedded 8# build for embedded
9(cd embassy-net; cargo build --target thumbv7em-none-eabi --features log) 9(cd embassy-net; cargo build --target thumbv7em-none-eabi --features log)
10(cd embassy-net; cargo build --target thumbv7em-none-eabi --features defmt) 10(cd embassy-net; cargo build --target thumbv7em-none-eabi --features defmt,smoltcp/defmt)
11 11
12# build examples 12# build examples
13(cd embassy-net-examples; cargo build) 13(cd embassy-net-examples; cargo build)
diff --git a/embassy-net-examples/src/main.rs b/embassy-net-examples/src/main.rs
index bc413f1a2..dba1415b7 100644
--- a/embassy-net-examples/src/main.rs
+++ b/embassy-net-examples/src/main.rs
@@ -1,8 +1,7 @@
1#![feature(type_alias_impl_trait)] 1#![feature(type_alias_impl_trait)]
2 2
3use embassy::executor::{Spawner, task}; 3use embassy::executor::{task, Spawner};
4use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; 4use embassy::io::AsyncWriteExt;
5use embassy::time::{Duration, Timer};
6use embassy::util::Forever; 5use embassy::util::Forever;
7use embassy_net::*; 6use embassy_net::*;
8use embassy_std::Executor; 7use embassy_std::Executor;
diff --git a/embassy-net-examples/src/tuntap.rs b/embassy-net-examples/src/tuntap.rs
index 5c138c069..b2117e81b 100644
--- a/embassy-net-examples/src/tuntap.rs
+++ b/embassy-net-examples/src/tuntap.rs
@@ -1,11 +1,11 @@
1use async_io::Async; 1use async_io::Async;
2use embassy::util::WakerRegistration; 2use embassy::util::WakerRegistration;
3use libc; 3use libc;
4use log::*;
4use smoltcp::wire::EthernetFrame; 5use smoltcp::wire::EthernetFrame;
5use std::io; 6use std::io;
6use std::io::{Read, Write}; 7use std::io::{Read, Write};
7use std::os::unix::io::{AsRawFd, RawFd}; 8use std::os::unix::io::{AsRawFd, RawFd};
8use log::*;
9 9
10pub const SIOCGIFMTU: libc::c_ulong = 0x8921; 10pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
11pub const SIOCGIFINDEX: libc::c_ulong = 0x8933; 11pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
@@ -142,8 +142,8 @@ impl TunTapDevice {
142 } 142 }
143} 143}
144 144
145use embassy_net::{LinkState, DeviceCapabilities, Packet, PacketBox, PacketBuf};
146use core::task::Waker; 145use core::task::Waker;
146use embassy_net::{DeviceCapabilities, LinkState, Packet, PacketBox, PacketBuf};
147 147
148impl crate::Device for TunTapDevice { 148impl crate::Device for TunTapDevice {
149 fn is_transmit_ready(&mut self) -> bool { 149 fn is_transmit_ready(&mut self) -> bool {
@@ -197,4 +197,8 @@ impl crate::Device for TunTapDevice {
197 fn link_state(&mut self) -> LinkState { 197 fn link_state(&mut self) -> LinkState {
198 LinkState::Up 198 LinkState::Up
199 } 199 }
200
201 fn ethernet_address(&mut self) -> [u8; 6] {
202 [0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
203 }
200} 204}
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml
index 185992ddc..de625018c 100644
--- a/embassy-net/Cargo.toml
+++ b/embassy-net/Cargo.toml
@@ -11,11 +11,10 @@ defmt-debug = []
11defmt-info = [] 11defmt-info = []
12defmt-warn = [] 12defmt-warn = []
13defmt-error = [] 13defmt-error = []
14defmt = [ "dep:defmt", "smoltcp/defmt" ]
15 14
16[dependencies] 15[dependencies]
17 16
18defmt = { version = "0.1.3", optional = true } 17defmt = { version = "0.2.0", optional = true }
19log = { version = "0.4.11", optional = true } 18log = { version = "0.4.11", optional = true }
20 19
21embassy = { version = "0.1.0" } 20embassy = { version = "0.1.0" }
diff --git a/embassy-net/src/config/dhcp.rs b/embassy-net/src/config/dhcp.rs
index f5d598bdf..0df67baf5 100644
--- a/embassy-net/src/config/dhcp.rs
+++ b/embassy-net/src/config/dhcp.rs
@@ -1,13 +1,13 @@
1use embassy::util::Forever; 1use embassy::util::Forever;
2use heapless::consts::*;
3use heapless::Vec; 2use heapless::Vec;
4use smoltcp::dhcp::Dhcpv4Client; 3use smoltcp::dhcp::Dhcpv4Client;
5use smoltcp::socket::{RawPacketMetadata, RawSocketBuffer}; 4use smoltcp::socket::{RawPacketMetadata, RawSocketBuffer};
6use smoltcp::time::Instant; 5use smoltcp::time::Instant;
7use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; 6use smoltcp::wire::Ipv4Address;
8 7
9use super::*; 8use super::*;
10use crate::{device::LinkState, fmt::*}; 9use crate::device::LinkState;
10use crate::fmt::*;
11use crate::{Interface, SocketSet}; 11use crate::{Interface, SocketSet};
12 12
13pub struct DhcpResources { 13pub struct DhcpResources {
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs
index 5a266f4ef..32b56e5be 100644
--- a/embassy-net/src/device.rs
+++ b/embassy-net/src/device.rs
@@ -1,11 +1,11 @@
1use core::task::{Poll, Waker}; 1use core::task::Waker;
2use smoltcp::phy::Device as SmolDevice; 2use smoltcp::phy::Device as SmolDevice;
3use smoltcp::phy::DeviceCapabilities; 3use smoltcp::phy::DeviceCapabilities;
4use smoltcp::time::Instant as SmolInstant; 4use smoltcp::time::Instant as SmolInstant;
5 5
6use crate::fmt::*; 6use crate::fmt::*;
7use crate::{Packet, PacketBox, PacketBuf};
8use crate::Result; 7use crate::Result;
8use crate::{Packet, PacketBox, PacketBuf};
9 9
10#[derive(PartialEq, Eq, Clone, Copy)] 10#[derive(PartialEq, Eq, Clone, Copy)]
11pub enum LinkState { 11pub enum LinkState {
@@ -21,7 +21,7 @@ pub trait Device {
21 fn register_waker(&mut self, waker: &Waker); 21 fn register_waker(&mut self, waker: &Waker);
22 fn capabilities(&mut self) -> DeviceCapabilities; 22 fn capabilities(&mut self) -> DeviceCapabilities;
23 fn link_state(&mut self) -> LinkState; 23 fn link_state(&mut self) -> LinkState;
24 fn ethernet_address(&mut self) -> [u8;6]; 24 fn ethernet_address(&mut self) -> [u8; 6];
25} 25}
26 26
27pub struct DeviceAdapter { 27pub struct DeviceAdapter {
@@ -92,7 +92,7 @@ pub struct TxToken<'a> {
92} 92}
93 93
94impl<'a> smoltcp::phy::TxToken for TxToken<'a> { 94impl<'a> smoltcp::phy::TxToken for TxToken<'a> {
95 fn consume<R, F>(mut self, _timestamp: SmolInstant, len: usize, f: F) -> Result<R> 95 fn consume<R, F>(self, _timestamp: SmolInstant, len: usize, f: F) -> Result<R>
96 where 96 where
97 F: FnOnce(&mut [u8]) -> Result<R>, 97 F: FnOnce(&mut [u8]) -> Result<R>,
98 { 98 {
diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs
index 8f63db971..f8a945a54 100644
--- a/embassy-net/src/stack.rs
+++ b/embassy-net/src/stack.rs
@@ -1,7 +1,7 @@
1use core::cell::RefCell;
1use core::future::Future; 2use core::future::Future;
2use core::task::Context; 3use core::task::Context;
3use core::task::Poll; 4use core::task::Poll;
4use core::{cell::RefCell, future};
5use embassy::time::{Instant, Timer}; 5use embassy::time::{Instant, Timer};
6use embassy::util::ThreadModeMutex; 6use embassy::util::ThreadModeMutex;
7use embassy::util::{Forever, WakerRegistration}; 7use embassy::util::{Forever, WakerRegistration};
@@ -110,7 +110,7 @@ impl Stack {
110 self.waker.register(cx.waker()); 110 self.waker.register(cx.waker());
111 111
112 let timestamp = instant_to_smoltcp(Instant::now()); 112 let timestamp = instant_to_smoltcp(Instant::now());
113 if let Err(e) = self.iface.poll(&mut self.sockets, timestamp) { 113 if let Err(_) = self.iface.poll(&mut self.sockets, timestamp) {
114 // If poll() returns error, it may not be done yet, so poll again later. 114 // If poll() returns error, it may not be done yet, so poll again later.
115 cx.waker().wake_by_ref(); 115 cx.waker().wake_by_ref();
116 return; 116 return;
@@ -174,6 +174,9 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
174 174
175 let sockets = SocketSet::new(&mut res.sockets[..]); 175 let sockets = SocketSet::new(&mut res.sockets[..]);
176 176
177 let local_port = LOCAL_PORT_MIN;
178
179 /*
177 let local_port = loop { 180 let local_port = loop {
178 let mut res = [0u8; 2]; 181 let mut res = [0u8; 2];
179 embassy::rand::rand(&mut res); 182 embassy::rand::rand(&mut res);
@@ -182,6 +185,7 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
182 break port; 185 break port;
183 } 186 }
184 }; 187 };
188 */
185 189
186 let stack = Stack { 190 let stack = Stack {
187 iface, 191 iface,
diff --git a/embassy-net/src/tcp_socket.rs b/embassy-net/src/tcp_socket.rs
index 84f096525..4f43bc611 100644
--- a/embassy-net/src/tcp_socket.rs
+++ b/embassy-net/src/tcp_socket.rs
@@ -111,7 +111,7 @@ impl<'a> TcpSocket<'a> {
111 } 111 }
112} 112}
113 113
114fn to_ioerr(e: Error) -> io::Error { 114fn to_ioerr(_err: Error) -> io::Error {
115 // todo 115 // todo
116 io::Error::Other 116 io::Error::Other
117} 117}