mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
pings working with smoltcp (can originate and respond)
This commit is contained in:
parent
b93109cad2
commit
ec34b01bd9
5 changed files with 12 additions and 13 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2050,6 +2050,7 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smoltcp"
|
name = "smoltcp"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
source = "git+https://github.com/smoltcp-rs/smoltcp.git#35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
|
||||||
|
|
@ -773,7 +773,7 @@ fn xmain() -> ! {
|
||||||
retbuf[word_index * 2] = be_bytes[0];
|
retbuf[word_index * 2] = be_bytes[0];
|
||||||
retbuf[word_index * 2 + 1] = be_bytes[1];
|
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");
|
buffer.replace(retbuf).expect("couldn't return packet");
|
||||||
}
|
}
|
||||||
Some(Opcode::WlanSendPacket) => {
|
Some(Opcode::WlanSendPacket) => {
|
||||||
|
|
@ -790,7 +790,7 @@ fn xmain() -> ! {
|
||||||
log::error!("invalid packet send length: {}, aborting without send", len_bytes);
|
log::error!("invalid packet send length: {}, aborting without send", len_bytes);
|
||||||
continue;
|
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);
|
com.txrx(ComState::NET_FRAME_SEND_0.verb | len_bytes);
|
||||||
for word_index in 0..len_words as usize {
|
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]];
|
let be_bytes: [u8; 2] = [txbuf[2 + word_index * 2], txbuf[2 + word_index * 2 + 1]];
|
||||||
|
|
|
||||||
|
|
@ -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
|
# 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.
|
# of the worked examples match the actual documentation now.
|
||||||
# pin at a commit, at least, so we aren't building on shifting sand
|
# pin at a commit, at least, so we aren't building on shifting sand
|
||||||
#git = "https://github.com/smoltcp-rs/smoltcp.git"
|
git = "https://github.com/smoltcp-rs/smoltcp.git"
|
||||||
#commit = "35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
|
commit = "35e833e33dfd3e4efc3eb7d5de06bec17c54b011"
|
||||||
path = "../../../smoltcp"
|
#path = "../../../smoltcp"
|
||||||
features = ["verbose"]
|
#features = ["verbose"]
|
||||||
#version = "0.7.5"
|
#version = "0.7.5"
|
||||||
#features = ["proto-ipv4"]
|
#features = ["proto-ipv4"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ impl<'a> phy::TxToken for NetPhyTxToken<'a> {
|
||||||
where F: FnOnce(&mut [u8]) -> Result<R>
|
where F: FnOnce(&mut [u8]) -> Result<R>
|
||||||
{
|
{
|
||||||
let result = f(&mut self.buf[..len]);
|
let result = f(&mut self.buf[..len]);
|
||||||
log::info!("txlen: {}", len);
|
//log::info!("txlen: {}", len);
|
||||||
|
|
||||||
if result.is_ok() {
|
if result.is_ok() {
|
||||||
self.com.wlan_send_packet(&self.buf[..len]).map_err(|_| smoltcp::Error::Dropped)?;
|
self.com.wlan_send_packet(&self.buf[..len]).map_err(|_| smoltcp::Error::Dropped)?;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ mod device;
|
||||||
use byteorder::{ByteOrder, NetworkEndian};
|
use byteorder::{ByteOrder, NetworkEndian};
|
||||||
use xous::msg_scalar_unpack;
|
use xous::msg_scalar_unpack;
|
||||||
use xous::{send_message, Message};
|
use xous::{send_message, Message};
|
||||||
use std::cmp;
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
@ -99,7 +98,7 @@ enum WaitOp {
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
log_server::init_wait().unwrap();
|
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());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
|
@ -256,7 +255,7 @@ fn xmain() -> ! {
|
||||||
// iface.routes_mut().remove_default_ipv4_route();
|
// iface.routes_mut().remove_default_ipv4_route();
|
||||||
match iface.routes_mut().add_default_ipv4_route(default_v4_gw) {
|
match iface.routes_mut().add_default_ipv4_route(default_v4_gw) {
|
||||||
Ok(route) => log::info!("routing table updated successfully: {:?}", route),
|
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 => {
|
ComIntSources::WlanRxReady => {
|
||||||
|
|
@ -316,7 +315,7 @@ fn xmain() -> ! {
|
||||||
ping_remote_addr
|
ping_remote_addr
|
||||||
);
|
);
|
||||||
icmp_repr.emit(&mut icmp_packet, &device_caps.checksum);
|
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);
|
waiting_queue.insert(seq_no, timestamp);
|
||||||
seq_no += 1;
|
seq_no += 1;
|
||||||
|
|
@ -324,9 +323,8 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
if socket.can_recv() {
|
if socket.can_recv() {
|
||||||
log::info!("socket can_recv()");
|
|
||||||
let (payload, _) = socket.recv().expect("couldn't receive on socket despite asserting availability");
|
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_packet = Icmpv4Packet::new_checked(&payload).expect("couldn't make icmp payload");
|
||||||
let icmp_repr =
|
let icmp_repr =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue