forked from M-Labs/nac3
1
0
Fork 0

update dependencies, use new libasync smoltcp recv API

This commit is contained in:
Sebastien Bourdeauducq 2020-07-19 16:16:39 +08:00
parent 3ec9788eb1
commit f5db0e06f4
2 changed files with 36 additions and 28 deletions

43
src/Cargo.lock generated
View File

@ -37,9 +37,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "cc"
version = "1.0.57"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg-if"
@ -105,7 +105,7 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb"
dependencies = [
"nb",
"nb 0.1.3",
"void",
]
@ -200,11 +200,11 @@ dependencies = [
[[package]]
name = "libasync"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#074438c3c7becd30a08a59490754f3120a0650f0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#84f1380f4830055bfe69ca14b5ade527a5edef6b"
dependencies = [
"embedded-hal",
"libcortex_a9",
"nb",
"nb 0.1.3",
"pin-utils",
"smoltcp",
]
@ -212,14 +212,14 @@ dependencies = [
[[package]]
name = "libboard_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#074438c3c7becd30a08a59490754f3120a0650f0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#84f1380f4830055bfe69ca14b5ade527a5edef6b"
dependencies = [
"bit_field",
"embedded-hal",
"libcortex_a9",
"libregister",
"log",
"nb",
"nb 0.1.3",
"smoltcp",
"void",
"volatile-register",
@ -236,7 +236,7 @@ dependencies = [
[[package]]
name = "libcortex_a9"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#074438c3c7becd30a08a59490754f3120a0650f0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#84f1380f4830055bfe69ca14b5ade527a5edef6b"
dependencies = [
"bit_field",
"libregister",
@ -245,7 +245,7 @@ dependencies = [
[[package]]
name = "libregister"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#074438c3c7becd30a08a59490754f3120a0650f0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#84f1380f4830055bfe69ca14b5ade527a5edef6b"
dependencies = [
"bit_field",
"vcell",
@ -255,7 +255,7 @@ dependencies = [
[[package]]
name = "libsupport_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#074438c3c7becd30a08a59490754f3120a0650f0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#84f1380f4830055bfe69ca14b5ade527a5edef6b"
dependencies = [
"compiler_builtins",
"libboard_zynq",
@ -273,9 +273,9 @@ checksum = "e70e46c13c0e8374c26cec5752e3347ca1087d9711de8f45aa513a7700efd73d"
[[package]]
name = "log"
version = "0.4.8"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
"cfg-if",
]
@ -300,9 +300,18 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "nb"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1411551beb3c11dedfb0a90a0fa256b47d28b9ec2cdff34c25a2fa59e45dbdc"
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
dependencies = [
"nb 1.0.0",
]
[[package]]
name = "nb"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
[[package]]
name = "num-derive"
@ -407,7 +416,7 @@ dependencies = [
"libsupport_zynq",
"log",
"log_buffer",
"nb",
"nb 0.1.3",
"num-derive",
"num-traits",
"unwind",
@ -427,9 +436,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.33"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [
"proc-macro2",
"quote",

View File

@ -1,4 +1,3 @@
use core::task::Poll;
use core::cmp::min;
use core::cell::RefCell;
@ -22,14 +21,14 @@ pub async fn expect(stream: &TcpStream, pattern: &[u8]) -> Result<bool> {
consumed += 1;
if *b == pattern[cur_index] {
if cur_index + 1 == pattern.len() {
return Poll::Ready((consumed, RecvState::Completed(true)));
return (consumed, RecvState::Completed(true));
}
} else {
return Poll::Ready((consumed, RecvState::Completed(false)));
return (consumed, RecvState::Completed(false));
}
cur_index += 1;
}
Poll::Ready((consumed, RecvState::NeedsMore(cur_index, true)))
(consumed, RecvState::NeedsMore(cur_index, true))
} else {
unreachable!();
}
@ -42,13 +41,13 @@ pub async fn expect(stream: &TcpStream, pattern: &[u8]) -> Result<bool> {
pub async fn read_bool(stream: &TcpStream) -> Result<bool> {
Ok(stream.recv(|buf| {
Poll::Ready((1, buf[0] != 0))
(1, buf[0] != 0)
}).await?)
}
pub async fn read_i8(stream: &TcpStream) -> Result<i8> {
Ok(stream.recv(|buf| {
Poll::Ready((1, buf[0] as i8))
(1, buf[0] as i8)
}).await?)
}
@ -64,10 +63,10 @@ pub async fn read_i32(stream: &TcpStream) -> Result<i32> {
cur_value <<= 8;
cur_value |= *b as i32;
if cur_index == 4 {
return Poll::Ready((consumed, RecvState::Completed(cur_value)));
return (consumed, RecvState::Completed(cur_value));
}
}
Poll::Ready((consumed, RecvState::NeedsMore(cur_index, cur_value)))
(consumed, RecvState::NeedsMore(cur_index, cur_value))
} else {
unreachable!();
}
@ -90,10 +89,10 @@ pub async fn read_i64(stream: &TcpStream) -> Result<i64> {
cur_value <<= 8;
cur_value |= *b as i64;
if cur_index == 8 {
return Poll::Ready((consumed, RecvState::Completed(cur_value)));
return (consumed, RecvState::Completed(cur_value));
}
}
Poll::Ready((consumed, RecvState::NeedsMore(cur_index, cur_value)))
(consumed, RecvState::NeedsMore(cur_index, cur_value))
} else {
unreachable!();
}
@ -113,7 +112,7 @@ pub async fn read_chunk(stream: &TcpStream, destination: &mut [u8]) -> Result<()
let mut destination = destination.borrow_mut();
let count = min(total - done, buf.len());
destination[done..done + count].copy_from_slice(&buf[..count]);
Poll::Ready((count, count))
(count, count)
}).await?;
done += count;
}