From 111d9a4226310d3b42dc37801c7b7d19cee02865 Mon Sep 17 00:00:00 2001 From: linuswck Date: Mon, 4 Mar 2024 16:13:52 +0800 Subject: [PATCH] cleanup --- src/laser_diode/laser_diode.rs | 8 -------- src/net/net.rs | 23 +---------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/laser_diode/laser_diode.rs b/src/laser_diode/laser_diode.rs index bedfa2b..dc01280 100644 --- a/src/laser_diode/laser_diode.rs +++ b/src/laser_diode/laser_diode.rs @@ -105,10 +105,6 @@ impl LdDrive{ self.ld_short(); } - pub fn get_ld_drive_current(&mut self) -> ElectricCurrent{ - self.settings.ld_drive_current - } - pub fn set_ld_drive_current_limit(&mut self, i_limit: ElectricCurrent){ self.settings.ld_drive_current_limit = i_limit.min(Settings::LD_CURRENT_MAX); } @@ -167,10 +163,6 @@ impl LdDrive{ LdPwrExcProtector::set_calibrated_vdda(val_cal) } - pub fn pd_mon_status(&mut self) -> ld_pwr_exc_protector::Status { - LdPwrExcProtector::get_status() - } - pub fn pd_mon_clear_alarm(&mut self) { LdPwrExcProtector::clear_alarm_status(); } diff --git a/src/net/net.rs b/src/net/net.rs index d0b6b22..641e0dd 100644 --- a/src/net/net.rs +++ b/src/net/net.rs @@ -1,7 +1,7 @@ use crate::device::sys_timer; use core::cell::RefCell; use cortex_m::interrupt::{CriticalSection, Mutex}; -use log::{debug, info, warn}; +use log::{debug, info}; use smoltcp::{ iface::{ self, Interface, SocketHandle, SocketSet, SocketStorage @@ -40,7 +40,6 @@ const ADDRESS: (IpAddress, u16) = ( /// Interrupt pending flag: set by the `ETH` interrupt handler, should /// be cleared before polling the interface. static NET_PENDING: Mutex> = Mutex::new(RefCell::new(false)); -static mut INCOMING_BYTE: [u8; 512] = [0; 512]; pub struct ServerHandle { socket_handle: SocketHandle, @@ -172,26 +171,6 @@ impl ServerHandle { } } - pub fn echo(&mut self, buffer: &mut [u8]) { - self.iface.poll(now_fn(), &mut &mut self.dma, &mut self.socket_set); - let socket = self.socket_set.get_mut::(self.socket_handle); - - if let Ok(recv_bytes) = socket.recv_slice(buffer) { - if recv_bytes > 0 { - socket.send_slice(&buffer[..recv_bytes]).ok(); - info!("Echoed {} bytes.", recv_bytes); - } - } - - if !socket.is_listening() && !socket.is_open() || socket.state() == State::CloseWait { - socket.abort(); - socket.listen(ADDRESS).ok(); - warn!("Disconnected... Reopening listening socket."); - } - - self.iface.poll(now_fn(), &mut &mut self.dma, &mut self.socket_set); - } - pub fn recv(&mut self, buffer: &mut [u8])-> Result { self.iface.poll(now_fn(), &mut &mut self.dma, &mut self.socket_set); let socket = self.socket_set.get_mut::(self.socket_handle);