|
1 | 1 | use defmt::*; |
2 | 2 | use embassy_executor::Spawner; |
3 | | -use embassy_stm32::can::bxcan::{filter, Fifo, Frame, Id, StandardId}; |
| 3 | +use embassy_stm32::can::bxcan::{Fifo, Frame, Id, StandardId, filter}; |
4 | 4 | use embassy_stm32::can::{Can, CanRx, CanTx}; |
5 | 5 | use embassy_stm32::peripherals::CAN; |
6 | 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
7 | 7 |
|
8 | 8 | use embassy_sync::pubsub::{PubSubChannel, Publisher, Subscriber}; |
9 | | -use shared_types::{CanBusMessage, CanBusMessageId, FlightMode, TelemetryToPayloadMessage}; |
| 9 | +use shared_types::FlightMode; |
| 10 | +//use shared_types::{CanBusMessage, CanBusMessageId, FlightMode, TelemetryToPayloadMessage}; |
10 | 11 | use static_cell::StaticCell; |
11 | 12 |
|
12 | 13 | pub const CAN_QUEUE_SIZE: usize = 3; // TODO |
@@ -46,8 +47,9 @@ pub async fn spawn( |
46 | 47 | .leave_disabled(); |
47 | 48 |
|
48 | 49 | let telemetry_filter = filter::Mask32::frames_with_std_id( |
49 | | - StandardId::new(CanBusMessageId::TelemetryBroadcast(0).into()).unwrap(), |
50 | | - StandardId::new(0x700).unwrap(), |
| 50 | + //StandardId::new(CanBusMessageId::TelemetryBroadcast(0).into()).unwrap(), |
| 51 | + StandardId::new(0x1af).unwrap(), |
| 52 | + StandardId::new(0x7ff).unwrap(), |
51 | 53 | ); |
52 | 54 |
|
53 | 55 | can.modify_filters().enable_bank(0, Fifo::Fifo0, telemetry_filter); |
@@ -86,9 +88,11 @@ async fn run_rx( |
86 | 88 | can_rx: &'static mut CanRx<'static, 'static, CAN>, |
87 | 89 | publisher: Publisher<'static, CriticalSectionRawMutex, CanFrame, CAN_QUEUE_SIZE, NUM_CAN_SUBSCRIBERS, 1>, |
88 | 90 | ) -> ! { |
| 91 | + info!("Running RX..."); |
89 | 92 | loop { |
90 | 93 | match can_rx.read().await { |
91 | 94 | Ok(envelope) => { |
| 95 | + info!("got envelope"); |
92 | 96 | let frame = envelope.frame; |
93 | 97 | let Some(data) = frame.data() else { |
94 | 98 | continue; |
@@ -121,10 +125,11 @@ pub async fn run_flight_mode_listener( |
121 | 125 | ) -> ! { |
122 | 126 | loop { |
123 | 127 | let (sid, data) = can_subscriber.next_message_pure().await; |
124 | | - if sid == CanBusMessageId::TelemetryBroadcast(0).into() { |
125 | | - if let Ok(Some(msg)) = TelemetryToPayloadMessage::parse(data) { |
126 | | - flight_mode_publisher.publish_immediate(msg.mode); |
127 | | - } |
128 | | - } |
| 128 | + info!("blub"); |
| 129 | + //if sid == CanBusMessageId::TelemetryBroadcast(0).into() { |
| 130 | + // if let Ok(Some(msg)) = TelemetryToPayloadMessage::parse(data) { |
| 131 | + // flight_mode_publisher.publish_immediate(msg.mode); |
| 132 | + // } |
| 133 | + //} |
129 | 134 | } |
130 | 135 | } |
0 commit comments