fix: rppal detect

This commit is contained in:
grabbit 2025-04-05 23:49:31 +08:00
parent 6faba28542
commit ecc90b6fd6

View File

@ -50,8 +50,8 @@ pub struct GpsController {
config: GpsConfig, config: GpsConfig,
/// Serial port for GPS communication /// Serial port for GPS communication
port: Option<Box<dyn SerialPort>>, port: Option<Box<dyn SerialPort>>,
/// GPIO pin for PPS signal (Linux only) /// GPIO pin for PPS signal
#[cfg(target_os = "linux")] #[cfg(feature = "gpio")]
pps_pin: Option<InputPin>, pps_pin: Option<InputPin>,
/// Placeholder for non-Linux platforms /// Placeholder for non-Linux platforms
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
@ -93,6 +93,7 @@ impl GpsController {
Ok(Self { Ok(Self {
config: gps_config, config: gps_config,
port: None, port: None,
#[cfg(feature = "gpio")]
pps_pin: None, pps_pin: None,
position: Arc::new(Mutex::new(initial_position)), position: Arc::new(Mutex::new(initial_position)),
sync_status: Arc::new(Mutex::new(SyncStatus::NoSync)), sync_status: Arc::new(Mutex::new(SyncStatus::NoSync)),
@ -170,8 +171,7 @@ impl GpsController {
} }
// Initialize PPS pin if enabled and GPS initialized successfully // Initialize PPS pin if enabled and GPS initialized successfully
// This is only compiled on Linux #[cfg(feature = "gpio")]
#[cfg(target_os = "linux")]
if self.config.use_pps && !self.gps_state.degraded { if self.config.use_pps && !self.gps_state.degraded {
match Gpio::new() { match Gpio::new() {
Ok(gpio) => { Ok(gpio) => {