Compare commits

..

3 Commits

Author SHA1 Message Date
linuswck 51913f2e2f net: fix incorrect poll_iface() calls
- poll_iface might be called by interrupt while poll_iface was being called in main loop
- Disable interrupt when poll_iface is being processed
- Only use IfacePollTimer to poll_iface
2024-08-27 18:49:43 +08:00
linuswck c86d67b15c firmware: do not display smoltcp log 2024-08-27 18:49:43 +08:00
linuswck 3d2294a90c driver: fix incorrect recv_response behavior 2024-08-27 18:49:13 +08:00
4 changed files with 15 additions and 13 deletions

1
Cargo.lock generated
View File

@ -878,7 +878,6 @@ dependencies = [
"byteorder",
"cfg-if",
"heapless 0.8.0",
"log",
"managed",
]

View File

@ -25,7 +25,7 @@ cortex-m-log = { version = "0.7.0", features = ["log-integration", "semihosting"
stm32f4xx-hal = { version = "0.20.0", features = ["stm32f407", "otg-fs", "usb_fs"] }
stm32-eth = { version = "0.6.0", features = ["stm32f407", "smoltcp-phy", "smoltcp"] }
ieee802_3_miim = "0.8.0"
smoltcp = { version = "0.11.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log", "medium-ethernet", "iface-neighbor-cache-count-16"] }
smoltcp = { version = "0.11.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "medium-ethernet", "iface-neighbor-cache-count-16"] }
uom = { version = "0.30", default-features = false, features = ["autoconvert", "si", "f32", "use_serde"] }
num-traits = { version = "0.2.15", default-features = false, features = ["libm"] }
usb-device = "0.3.2"

View File

@ -835,11 +835,15 @@ class Kirdy:
self._connected_sig.emit(True)
async def _read_response(self, buffer_size=16384):
raw_response = b''
while len(raw_response) == 0:
# Ignore 0 size packet
raw_response = await self._reader.read(buffer_size)
response = raw_response.decode('utf-8', errors='ignore').split("\n")
response.reverse()
response = response[:-1]
items = []
for item in response[1:]:
for item in response:
items.append(json.loads(item))
return items

View File

@ -220,7 +220,9 @@ impl ServerHandle {
}
pub fn poll_iface(&mut self) {
cortex_m::interrupt::free(|_| {
self.iface.poll(now_fn(), &mut &mut self.dma, &mut self.socket_set);
});
}
pub fn poll_at_iface(&mut self) -> Option<Instant> {
@ -246,8 +248,7 @@ impl ServerHandle {
if num_bytes > 0 {
match socket.send_slice(&buffer[..num_bytes]) {
Ok(_) => {
self.poll_iface();
info!("Sent {} bytes.", num_bytes);
info!("Enqueued {} bytes.", num_bytes);
}
Err(err) => {
info!("Bytes cannot be sent. Error: {:?}", err)
@ -515,11 +516,9 @@ pub fn for_each<F: FnMut(SocketHandle, usize)>(mut callback: F) {
#[interrupt]
fn ETH() {
let interrupt_reason = stm32_eth::eth_interrupt_handler();
cortex_m::interrupt::free(|_| {
if interrupt_reason.rx {
eth_poll_iface();
}
});
debug!("Ethernet Interrupt{:?}", interrupt_reason);
}