fixed warnings

This commit is contained in:
lkoester 2023-02-15 14:02:05 +01:00
parent ba31154990
commit 2c0c7a4655
8 changed files with 75 additions and 83 deletions

View File

@ -4,3 +4,17 @@
[2023-02-15][09:16:43][main][INFO] Starting TMTC task
[2023-02-15][09:16:43][main][INFO] Starting power task
[2023-02-15][09:16:43][main][INFO] Starting AOCS task
[2023-02-15][11:05:33][main][INFO] Starting TMTC task
[2023-02-15][11:05:33][main][INFO] Starting CAN Socket listening task
[2023-02-15][11:05:33][main][INFO] Starting CAN Socket writing task
[2023-02-15][11:05:33][main][INFO] Starting power task
[2023-02-15][11:05:33][main][INFO] Starting AOCS task
[2023-02-15][11:10:52][main][INFO] Starting TMTC task
[2023-02-15][11:10:52][main][INFO] Starting power task
[2023-02-15][11:10:52][main][INFO] Starting AOCS task
[2023-02-15][11:11:09][main][INFO] Starting TMTC task
[2023-02-15][11:11:09][main][INFO] Starting power task
[2023-02-15][11:11:09][main][INFO] Starting AOCS task
[2023-02-15][11:11:37][main][INFO] Starting TMTC task
[2023-02-15][11:11:37][main][INFO] Starting power task
[2023-02-15][11:11:37][main][INFO] Starting AOCS task

View File

@ -1,7 +1,7 @@
{
"com_if": "udp",
"tcpip_udp_ip_addr_raspi": "192.168.1.116",
"tcpip_udp_ip_addr": "192.168.1.5",
"tcpip_udp_ip_addr": "192.168.1.116",
"tcpip_udp_ip_addr_windows": "192.168.1.5",
"tcpip_udp_port": 7301,
"tcpip_udp_recv_max_size": 1500
}

View File

@ -3,7 +3,6 @@ use crate::can_ids::{DeviceId, PackageId, PackageModel};
use crate::hk::HkRequest;
use crate::power_handler::{DeviceState, PowerSwitcher};
use crate::requests::{Request, RequestWithToken};
use crate::ActionRequest;
use satrs_core::power::SwitchId;
use std::sync::mpsc::{Receiver, Sender};
use serde::{Deserialize, Serialize};
@ -98,7 +97,7 @@ impl AocsSensorHandler for MGMHandler {
}
fn send_message(&mut self, id: PackageId, buf: &[u8]) -> Result<(), Self::Error> {
self.can_tx.send(PackageModel::new(id, buf).unwrap());
self.can_tx.send(PackageModel::new(id, buf).unwrap()).unwrap();
return Ok(());
}
}
@ -151,7 +150,7 @@ impl MGMHandler {
Request::HkRequest(hk_req) => {
self.handle_hk_request(hk_req);
}
Request::ActionRequest(action_request) => {
Request::ActionRequest(_action_request) => {
//self.handle_action_request(action_request);
}
}

View File

@ -39,21 +39,11 @@ impl CanRxHandler {
}
}
/*
pub fn new_socket_with_filter(
interface: &'static str,
can_id_to_sender_id: HashMap<embedded_can::Id, u32>,
can_senders: HashMap<u32, Sender<Vec<u8>>>,
can_filters: &[socket::CanFilter],
) -> Result<CanRxHandler, ()> {
let can_wrapper = Self::new_socket(interface, can_id_to_sender_id, can_senders)?;
let filter_result = can_wrapper.socket.set_filters(can_filters);
if let Err(e) = filter_result {
warn!("Can Bus set filter error: {}", e);
pub fn process_incoming(&mut self) {
if let Some(frame) = self.rx_socket() {
self.forward_frame(frame);
}
Ok(can_wrapper)
}
*/
pub fn read_frame(&self) -> io::Result<frame::CanFrame> {
let frame = self.socket.read_frame();
@ -67,13 +57,6 @@ impl CanRxHandler {
let frame = self.socket.read_frame().ok()?;
info!("Can Frame read: {:?}.", frame);
return Some(frame);
/*
if let Ok(frame) = frame {
println!("Frame received: {:?}", frame);
return Some(frame);
}
None
*/
}
pub fn forward_frame(&self, frame: CanFrame) {
@ -96,17 +79,6 @@ impl CanRxHandler {
}
}
}
/*
pub fn set_filter(&self, filters: &[socket::CanFilter]) -> io::Result<()> {
info!("Setting filter with filter {:?}", filters);
let result = self.socket.set_filters(filters);
if let Err(e) = result {
warn!("Can bus socket filter set error: {}", e);
}
Ok(())
}
*/
}
pub struct CanTxHandler {

View File

@ -1,3 +1,7 @@
#![allow(dead_code)]
#![allow(unused_variables)]
// remove this, just here for now since application isn't fully developed
mod action;
mod aocs;
mod aocs_handler;
@ -46,7 +50,6 @@ use std::sync::mpsc::channel;
use std::sync::{mpsc, Arc, Mutex, RwLock};
use std::thread;
//use libc::time64_t;
use crate::action::ActionRequest;
use crate::aocs_handler::MGMData;
#[cfg(feature = "can")]
use crate::can::CanTxHandler;
@ -135,12 +138,12 @@ fn main() {
let mut event_man = EventManagerWithMpscQueue::new(Box::new(event_recv));
let event_reporter = EventReporter::new(PUS_APID, 128).unwrap();
let pus_tm_backend = DefaultPusMgmtBackendProvider::<EventU32>::default();
let mut pus_event_dispatcher =
let pus_event_dispatcher =
PusEventDispatcher::new(event_reporter, Box::new(pus_tm_backend));
let (pus_event_man_tx, pus_event_man_rx) = channel();
let pus_event_man_send_provider = MpscEventU32SendProvider::new(1, pus_event_man_tx);
let mut reporter_event_handler = verif_reporter.clone();
let mut reporter_aocs = verif_reporter.clone();
let reporter_event_handler = verif_reporter.clone();
let reporter_aocs = verif_reporter.clone();
let mut reporter_pld = verif_reporter.clone();
event_man.subscribe_all(pus_event_man_send_provider.id());
@ -196,6 +199,28 @@ fn main() {
let (can_tx_sender, can_tx_receiver) = channel();
#[cfg(feature = "can")]
let mut can_rx_socket = can::CanRxHandler::new_socket("can0", can_senders.clone(), package_ids_rx.clone()).unwrap();
#[cfg(feature = "can")]
info!("Starting CAN Socket listening task");
let builder1 = thread::Builder::new().name("CanRxHandler".into());
let jh1 = builder1.spawn(move || loop {
#[cfg(feature = "can")]
can_rx_socket.process_incoming();
});
#[cfg(feature = "can")]
let mut can_tx_socket = CanTxHandler::new_socket("can0", package_ids_rx.clone(), can_tx_receiver).unwrap();
#[cfg(feature = "can")]
info!("Starting CAN Socket writing task");
let builder_can_tx = thread::Builder::new().name("TxHandler".into());
let jh_can_tx = builder_can_tx.spawn( move || loop {
#[cfg(feature = "can")]
can_tx_socket.process_incoming();
});
let (pcdu_tx, pcdu_rx) = mpsc::channel::<(SwitchId, SwitchState)>();
let pcdu_can_tx_sender =
can_tx_sender.clone();
@ -206,7 +231,7 @@ fn main() {
}
let clonable_device_state_map = Arc::new(Mutex::new(device_state_map));
let mut power_switcher = PowerSwitcher::new(pcdu_tx, clonable_device_state_map.clone());
let power_switcher = PowerSwitcher::new(pcdu_tx, clonable_device_state_map.clone());
info!("Starting power task");
let builder2 = thread::Builder::new().name("PowerThread".into());
@ -313,7 +338,7 @@ fn main() {
let package_map_pld_tx = load_package_ids();
let pld_tm_funnel_tx = tm_funnel_tx.clone();
let mut pld_tm_store = tm_store.clone();
let pld_tm_store = tm_store.clone();
let pld_can_tx_sender =
can_tx_sender.clone();
@ -350,9 +375,9 @@ fn main() {
let package_map_aocs_tx = load_package_ids();
let aocs_tm_funnel_tx = tm_funnel_tx.clone();
let mut aocs_tm_store = tm_store.clone();
let aocs_tm_store = tm_store.clone();
let mut mgm_shared_data: Arc<Mutex<MGMData>> = Arc::default();
let mgm_shared_data: Arc<Mutex<MGMData>> = Arc::default();
let aocs_sensor_data = Arc::new(Mutex::new(AocsSensorData::new()));
@ -375,32 +400,14 @@ fn main() {
jh0.unwrap()
.join()
.expect("Joining UDP TMTC server thread failed");
#[cfg(feature = "can")]
{
let can_rx_socket = can::CanRxHandler::new_socket("can0", can_senders.clone(), package_ids_rx.clone()).unwrap();
info!("Starting CAN Socket listening task");
let builder1 = thread::Builder::new().name("CanRxHandler".into());
let jh1 = builder1.spawn(move || loop {
let frame = can_rx_socket.rx_socket();
if let Some(frame) = frame {
let forward = can_rx_socket.forward_frame(frame);
}
});
let mut can_tx_socket = CanTxHandler::new_socket("can0", package_ids_rx.clone(), can_tx_receiver).unwrap();
info!("Starting CAN Socket writing task");
let builderCanTx = thread::Builder::new().name("TxHandler".into());
let jhCanTx = builderCanTx.spawn( move || loop {
can_tx_socket.process_incoming();
});
jh1.unwrap()
.join()
.expect("Joining CAN Bus Listening thread failed");
jhCanTx.unwrap()
.join()
.expect("Joining CAN Bus Writing thread failed");
}
jh1.unwrap()
.join()
.expect("Joining CAN Bus Listening thread failed");
jh_can_tx.unwrap()
.join()
.expect("Joining CAN Bus Writing thread failed");
jh2.unwrap().join().expect("Joining power thread failed");
jh3.unwrap().join().expect("Joining PLD thread failed");
jh4.unwrap()

View File

@ -147,7 +147,7 @@ impl CameraHandler {
}
}
if self.device_state == DeviceState::On {
self.can_tx.send(PackageModel::new(PackageId::CameraImageRequest, &[1]).unwrap());
self.can_tx.send(PackageModel::new(PackageId::CameraImageRequest, &[1]).unwrap()).unwrap();
info!("sent camera request");
self.mode = CameraMode::Verification;
}

View File

@ -108,12 +108,12 @@ impl PCDU {
return if let Ok(dev_id) = DeviceId::try_from(switch_id) {
let dev_id_bytes = dev_id as u8;
let buf: &[u8] = &dev_id_bytes.to_be_bytes();
self.can_tx.send(PackageModel::new(PackageId::DevicePowerOnRequest, buf).unwrap());
self.can_tx.send(PackageModel::new(PackageId::DevicePowerOnRequest, buf).unwrap()).unwrap();
let mut map_lock = self.device_state_map.lock().unwrap();
*map_lock.get_mut(&dev_id).unwrap() = SwitchState::Unknown;
// TODO: potentially change bus logic -> remove acceptance and verification of power off/on, since status is simply called in next step anyway
self.can_rx.recv();
self.can_rx.recv();
self.can_rx.recv().unwrap();
self.can_rx.recv().unwrap();
Ok(())
} else {
Err(())
@ -124,11 +124,11 @@ impl PCDU {
return if let Ok(dev_id) = DeviceId::try_from(switch_id) {
let dev_id_bytes = dev_id as u8;
let buf: &[u8] = &dev_id_bytes.to_be_bytes();
self.can_tx.send(PackageModel::new(PackageId::DevicePowerOffRequest, buf).unwrap());
self.can_tx.send(PackageModel::new(PackageId::DevicePowerOffRequest, buf).unwrap()).unwrap();
let mut map_lock = self.device_state_map.lock().unwrap();
*map_lock.get_mut(&dev_id).unwrap() = SwitchState::Unknown;
self.can_rx.recv();
self.can_rx.recv();
self.can_rx.recv().unwrap();
self.can_rx.recv().unwrap();
Ok(())
} else {
Err(())
@ -136,10 +136,10 @@ impl PCDU {
}
pub fn update_states_helper(&mut self, dev_id: &DeviceId) -> Result<(), ()> {
let switch_id: SwitchId = *dev_id as u16;
let _switch_id: SwitchId = *dev_id as u16;
let dev_id_bytes = *dev_id as u8;
let buf: &[u8] = &dev_id_bytes.to_be_bytes();
self.can_tx.send(PackageModel::new(PackageId::DevicePowerStatusRequest, buf).unwrap());
self.can_tx.send(PackageModel::new(PackageId::DevicePowerStatusRequest, buf).unwrap()).unwrap();
match self.can_rx.recv_timeout(Duration::from_secs(10)) {
Ok(msg) => {
if msg.package_id() == PackageId::DevicePowerStatusResponse
@ -147,7 +147,7 @@ impl PCDU {
{
info!("received power status response");
let mut map_lock = self.device_state_map.lock().unwrap();
let mut state: SwitchState;
let state: SwitchState;
match msg.data()[1] {
0 => state = SwitchState::Off,
1 => state = SwitchState::On,
@ -168,7 +168,7 @@ impl PCDU {
}
pub fn update_all_states_helper(&mut self) -> Result<(), ()> {
let mut map_lock = self.device_state_map.lock().unwrap();
let map_lock = self.device_state_map.lock().unwrap();
let mut device_list = vec::Vec::new();
for key in map_lock.keys() {
device_list.push(key.clone());
@ -213,7 +213,7 @@ impl PCDU {
},
_ => {}
}
self.update_switch_states(switch_id);
self.update_switch_states(switch_id).unwrap();
}
return Ok(i);
}

View File

@ -161,11 +161,11 @@ impl ReceivesCcsdsTc for PusTcSource {
}
}
pub fn core_tmtc_task(args: OtherArgs, mut tc_args: TcArgs, tm_args: TmArgs) {
let mut scheduler = Rc::new(RefCell::new(
let scheduler = Rc::new(RefCell::new(
PusScheduler::new_with_current_init_time(Duration::from_secs(5)).unwrap(),
));
let mut sched_clone = scheduler.clone();
let sched_clone = scheduler.clone();
let mut pus_receiver = PusReceiver::new(
PUS_APID,
tm_args.tm_sink_sender,
@ -196,7 +196,7 @@ pub fn core_tmtc_task(args: OtherArgs, mut tc_args: TcArgs, tm_args: TmArgs) {
let mut tc_buf: [u8; 4096] = [0; 4096];
loop {
let mut tmtc_sched = scheduler.clone();
let tmtc_sched = scheduler.clone();
core_tmtc_loop(
&mut udp_tmtc_server,
&mut tc_args,