Skip to content

Commit

Permalink
prop gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
andtsa committed Jul 1, 2024
1 parent c1684e0 commit 7695cda
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
10 changes: 9 additions & 1 deletion app/src/core/states/idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use defmt::info;

use crate::core::finite_state_machine::Fsm;
use crate::core::finite_state_machine::State;
use crate::transit;
use crate::{Info, transit};
use crate::Event;

impl Fsm {
Expand All @@ -12,6 +12,14 @@ impl Fsm {

pub async fn react_idle(&mut self, event: Event) {
match event {
Event::DisablePropulsionCommand => {
self.peripherals.propulsion_controller.disable();
self.log(Info::DisablePropulsionGpio).await;
}
Event::EnablePropulsionCommand => {
self.peripherals.propulsion_controller.enable();
self.log(Info::EnablePropulsionGpio).await;
}
Event::TurnOnHVCommand => {
self.pod_unsafe().await;
//todo check for preconditions
Expand Down
12 changes: 11 additions & 1 deletion app/src/core/states/run_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use defmt::info;
use crate::core::controllers::breaking_controller::BRAKE;
use crate::core::finite_state_machine::Fsm;
use crate::core::finite_state_machine::State;
use crate::transit;
use crate::{Info, transit};
use crate::Event;

impl Fsm {
Expand Down Expand Up @@ -56,6 +56,16 @@ impl Fsm {
transit!(self, State::Exit);
todo!();
}

// TODO: delete these two
Event::DisablePropulsionCommand => {
self.peripherals.propulsion_controller.disable();
self.log(Info::DisablePropulsionGpio).await;
}
Event::EnablePropulsionCommand => {
self.peripherals.propulsion_controller.enable();
self.log(Info::EnablePropulsionGpio).await;
}
_ => {
info!("The current state ignores {}", event.to_str());
}
Expand Down
14 changes: 13 additions & 1 deletion config/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[gs]
ip = [192,168,0,93]
ip = [192,168,0,232]
force = true
port = 6942
udp_port = 6943
Expand Down Expand Up @@ -82,6 +82,18 @@ colour = "green"
label = "Unsafe"
colour = "magenta"

[[Info]]
label = "EnablePropulsionGpio"
colour = "yellow"


[[Info]]
label = "DisablePropulsionGpio"
colour = "yellow"


[[Info]]
label = "SetPropulsionSpeed"
colour = "yellow"


12 changes: 11 additions & 1 deletion config/events.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ priority = 0

[[Event]]
name = "LVPropulsionReadyEvent"
id = 0xaE
id = 0x3e1
priority = 0

[[Event]]
name = "EnablePropulsionCommand"
id = 0x3e2
priority = 0

[[Event]]
name = "DisablePropulsionCommand"
id = 0x3e3
priority = 0

[[Event]]
Expand Down
4 changes: 2 additions & 2 deletions gs/station/src/connect/tcp_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub async fn transmit_commands_to_tcp(
Ok(command) => {
if matches!(command, Command::Shutdown(_)) {
status_transmitter
.send(Message::Warning("Closing connection...".into()))?;
writer.shutdown().await?;
.send(Message::Warning("Closing connection...".into())).unwrap();
writer.shutdown().await.unwrap();
break;
}
let bytes = command.as_bytes();
Expand Down

0 comments on commit 7695cda

Please sign in to comment.