Skip to content

Commit

Permalink
Address All Rust Build Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
njfdev committed Aug 12, 2024
1 parent 671d63e commit dd54c85
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src-tauri/src/modes/adsb/airborne_pos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::f64::consts::PI;

use fundsp::typenum::Pow;
use nalgebra::ComplexField;
use rustfft::num_complex::ComplexFloat;
use unit_conversions::length;

use crate::modes::types::*;
Expand All @@ -17,8 +14,9 @@ pub fn decode_aircraft_pos(me: &[u8], adsb_state: &mut AdsbState) {
} else {
AltitudeSource::GNSS
};
let ss_bits = (me[0] >> 1) & 0b11;
let single_antenna_flag = if (me[0] & 1) == 1 { true } else { false };
// TODO: use these bits
let _ss_bits = (me[0] >> 1) & 0b11;
let _single_antenna_flag = if (me[0] & 1) == 1 { true } else { false };
let encoded_alt = ((me[1] as u16) << 4) | (me[2] as u16 >> 4);
// 0 -> even frame, 1 -> odd frame
let cpr_format = (me[2] >> 2) & 1;
Expand Down Expand Up @@ -224,6 +222,8 @@ fn calc_globally_unambiguous_lat_long(
Ok((final_lat, final_lon))
}

// TODO: actually use this function and remove the allow dead_code statement
#[allow(dead_code)]
fn calc_locally_unambiguous_lat_long(
cpr_format: u8,
cpr_lat: f64,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/modes/adsb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use airborne_pos::*;
use airborne_vel::*;
use aircraft_ident::*;

use super::{AdsbState, ModeSState};
use super::AdsbState;

pub fn decode_adsb_msg(me: &[u8], adsb_state: &mut AdsbState) {
let type_code = me[0] >> 3;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/modes/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const MODES_CHECKSUM_TABLE: [u32; 112] = [

fn compute_modes_crc(msg: Vec<u8>, msg_bits: usize) -> u32 {
let mut crc: u32 = 0;
let offset = if (msg_bits == MODES_LONG_MSG_BITS) {
let offset = if msg_bits == MODES_LONG_MSG_BITS {
0
} else {
MODES_LONG_MSG_BITS - MODES_SHORT_MSG_BITS
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/modes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ pub mod types;

use adsb::decode_adsb_msg;
use crc::perform_modes_crc;
use tauri::{AppHandle, Emitter};
use types::*;

pub fn detect_modes_signal(m: Vec<u16>, modes_state: &mut ModeSState, app: AppHandle) {
pub fn detect_modes_signal(m: Vec<u16>, modes_state: &mut ModeSState) {
/* Go through each sample, and see if it and the following 9 samples match the start of the Mode S preamble.
*
* The Mode S preamble is made of impulses with a width of 0.5 microseconds, and each sample is 0.5 microseconds
Expand Down Expand Up @@ -139,7 +138,8 @@ pub fn detect_modes_signal(m: Vec<u16>, modes_state: &mut ModeSState, app: AppHa

pub fn decode_modes_msg(msg: Vec<u8>, modes_state: &mut ModeSState) {
let msg_type = msg[0] >> 3;
let ca = msg[0] & 0b111; // responder capabilities
// TODO: process this and send to frontend
let _ca = msg[0] & 0b111; // responder capabilities

println!(
"Existing Known ICAO Addresses: {:?}",
Expand Down
11 changes: 4 additions & 7 deletions src-tauri/src/radio_services/soapysdr_adsb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use soapysdr::Direction;
use tauri::{async_runtime, AppHandle, Emitter};
use tokio::{self, time};

use crate::radiorust_blocks::{
adsb_decode::AdsbDecode, am_demod::AmDemod, rbds_decode::DownMixer, wav_writer::WavWriterBlock,
};
use crate::radiorust_blocks::adsb_decode::AdsbDecode;

pub struct AdsbDecoderState(Arc<Mutex<AdsbDecoderData>>);
pub struct AdsbDecoderData {
Expand All @@ -22,9 +20,7 @@ pub struct AdsbDecoderData {
}

#[derive(serde::Deserialize)]
pub struct StreamSettings {
gain: f64,
}
pub struct StreamSettings {}

impl AdsbDecoderState {
pub fn new() -> Self {
Expand All @@ -34,7 +30,8 @@ impl AdsbDecoderState {
})))
}

pub fn start_decoding(&self, app: AppHandle, stream_settings: StreamSettings) {
// TODO: use these stream settings and allow users to modify ADS-B decode settings
pub fn start_decoding(&self, app: AppHandle, _stream_settings: StreamSettings) {
let adbs_decoder_state = self.0.clone();
let adbs_decoder_state_clone = adbs_decoder_state.clone();

Expand Down
8 changes: 1 addition & 7 deletions src-tauri/src/radiorust_blocks/adsb_decode.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::f32::consts::PI;

use crate::modes::*;
use radiorust::{
flow::{new_receiver, new_sender, ReceiverConnector, SenderConnector},
Expand Down Expand Up @@ -117,11 +115,7 @@ where
processing_chunk.push(u8_value);
}

detect_modes_signal(
processing_chunk.to_vec(),
&mut modes_state,
app.clone(),
);
detect_modes_signal(processing_chunk.to_vec(), &mut modes_state);

// send update of data (whether new or not)
app.emit("modes_state", modes_state.clone()).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/radiorust_blocks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod adsb_decode;
pub mod am_demod;
pub mod rbds_decode;
pub mod wav_writer;
// Exclude wav_writer for now to prevent dead_code warnings
//pub mod wav_writer;
4 changes: 1 addition & 3 deletions src-tauri/src/radiorust_blocks/wav_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ use std::{
sync::{Arc, Mutex},
};

use biquad::{self, Biquad, Coefficients, DirectForm1, ToHertz, Type, Q_BUTTERWORTH_F64};

use hound::{WavSpec, WavWriter};
use radiorust::{
flow::{new_receiver, new_sender, ReceiverConnector, SenderConnector},
impl_block_trait,
numbers::Float,
prelude::{ChunkBufPool, Complex},
prelude::Complex,
signal::Signal,
};
use tokio::spawn;
Expand Down

0 comments on commit dd54c85

Please sign in to comment.