pings working with smoltcp (can originate and respond)

This commit is contained in:
bunnie 2021-10-13 01:57:00 +08:00
parent b93109cad2
commit ec34b01bd9
5 changed files with 12 additions and 13 deletions

1
Cargo.lock generated
View file

@ -2050,6 +2050,7 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "smoltcp"
version = "0.8.0"
source = "git+https://github.com/smoltcp-rs/smoltcp.git#35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
dependencies = [
"bitflags",
"byteorder",

View file

@ -773,7 +773,7 @@ fn xmain() -> ! {
retbuf[word_index * 2] = be_bytes[0];
retbuf[word_index * 2 + 1] = be_bytes[1];
}
log::info!("rx: {:?}", &retbuf[..len_bytes as usize]);
log::trace!("rx: {:?}", &retbuf[..len_bytes as usize]);
buffer.replace(retbuf).expect("couldn't return packet");
}
Some(Opcode::WlanSendPacket) => {
@ -790,7 +790,7 @@ fn xmain() -> ! {
log::error!("invalid packet send length: {}, aborting without send", len_bytes);
continue;
}
log::info!("tx: {:?}", &txbuf[2..len_bytes as usize + 2]);
log::trace!("tx: {:?}", &txbuf[2..len_bytes as usize + 2]);
com.txrx(ComState::NET_FRAME_SEND_0.verb | len_bytes);
for word_index in 0..len_words as usize {
let be_bytes: [u8; 2] = [txbuf[2 + word_index * 2], txbuf[2 + word_index * 2 + 1]];

View file

@ -23,10 +23,10 @@ byteorder = { version = "1.0", default-features = false }
# ugh. have to reference `main` directly because they haven't pushed a new tag in months, and none
# of the worked examples match the actual documentation now.
# pin at a commit, at least, so we aren't building on shifting sand
#git = "https://github.com/smoltcp-rs/smoltcp.git"
#commit = "35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
path = "../../../smoltcp"
features = ["verbose"]
git = "https://github.com/smoltcp-rs/smoltcp.git"
commit = "35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
#path = "../../../smoltcp"
#features = ["verbose"]
#version = "0.7.5"
#features = ["proto-ipv4"]

View file

@ -88,7 +88,7 @@ impl<'a> phy::TxToken for NetPhyTxToken<'a> {
where F: FnOnce(&mut [u8]) -> Result<R>
{
let result = f(&mut self.buf[..len]);
log::info!("txlen: {}", len);
//log::info!("txlen: {}", len);
if result.is_ok() {
self.com.wlan_send_packet(&self.buf[..len]).map_err(|_| smoltcp::Error::Dropped)?;

View file

@ -11,7 +11,6 @@ mod device;
use byteorder::{ByteOrder, NetworkEndian};
use xous::msg_scalar_unpack;
use xous::{send_message, Message};
use std::cmp;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::str::FromStr;
@ -99,7 +98,7 @@ enum WaitOp {
#[xous::xous_main]
fn xmain() -> ! {
log_server::init_wait().unwrap();
log::set_max_level(log::LevelFilter::Trace);
log::set_max_level(log::LevelFilter::Info);
log::info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap();
@ -256,7 +255,7 @@ fn xmain() -> ! {
// iface.routes_mut().remove_default_ipv4_route();
match iface.routes_mut().add_default_ipv4_route(default_v4_gw) {
Ok(route) => log::info!("routing table updated successfully: {:?}", route),
Err(e) => log::info!("routing table update error: {}", e),
Err(e) => log::error!("routing table update error: {}", e),
}
},
ComIntSources::WlanRxReady => {
@ -316,7 +315,7 @@ fn xmain() -> ! {
ping_remote_addr
);
icmp_repr.emit(&mut icmp_packet, &device_caps.checksum);
log::info!("icmp pkt: {:?}", icmp_packet);
log::trace!("icmp pkt: {:?}", icmp_packet);
waiting_queue.insert(seq_no, timestamp);
seq_no += 1;
@ -324,9 +323,8 @@ fn xmain() -> ! {
}
if socket.can_recv() {
log::info!("socket can_recv()");
let (payload, _) = socket.recv().expect("couldn't receive on socket despite asserting availability");
log::info!("icmp payload: {:x?}", payload);
log::trace!("icmp payload: {:x?}", payload);
let icmp_packet = Icmpv4Packet::new_checked(&payload).expect("couldn't make icmp payload");
let icmp_repr =