Skip to content

Commit

Permalink
clippy and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
bastibl committed Oct 27, 2024
1 parent 3c5c70a commit 9ac2ea4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ rtl_sdr_blog = []
[dependencies]
byteorder = "1"
log = "0.4"
mockall = "0.11"
parking_lot = "0.12.1"
mockall = "0.13"
parking_lot = "0.12"
rusb = "0.9"
thiserror = "1.0"

[dev-dependencies]
rusb = "0.9"
byteorder = "1"
ctrlc = "3.2.3"
ctrlc = "3.4"
num-complex = "0.4"
stderrlog = "0.5"
stderrlog = "0.6"
12 changes: 6 additions & 6 deletions examples/rtl_test.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use rtlsdr_rs::{error::Result, RtlSdr};
use seify_rtlsdr::{error::Result, RtlSdr};
use std::sync::atomic::{AtomicBool, Ordering};

const DEFAULT_BUF_LENGTH: usize = 16 * 16384;

const SAMPLE_RATE: u32 = 2_048_000;

fn main() -> Result<()> {
let devices = rtlsdr_rs::enumerate()?;
let devices = seify_rtlsdr::enumerate()?;
println!("devices: {devices:?}");

// Create shutdown flag and set it when ctrl-c signal caught
static shutdown: AtomicBool = AtomicBool::new(false);
ctrlc::set_handler(|| {
shutdown.swap(true, Ordering::Relaxed);
static SHUTDOWN: AtomicBool = AtomicBool::new(false);
let _ = ctrlc::set_handler(|| {
SHUTDOWN.swap(true, Ordering::Relaxed);
});

// Open device
Expand Down Expand Up @@ -44,7 +44,7 @@ fn main() -> Result<()> {
println!("Reading samples in sync mode...");
let mut buf: [u8; DEFAULT_BUF_LENGTH] = [0; DEFAULT_BUF_LENGTH];
loop {
if shutdown.load(Ordering::Relaxed) {
if SHUTDOWN.load(Ordering::Relaxed) {
break;
}
let n = sdr.read_sync(&mut buf);
Expand Down
13 changes: 6 additions & 7 deletions examples/simple_fm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ impl Demod {
/// Applies a low-pass filter on a vector of complex values
fn low_pass_complex(&mut self, buf: Vec<Complex<i32>>) -> Vec<Complex<i32>> {
let mut res = vec![];
for orig in 0..buf.len() {
self.lp_now += buf[orig];
for orig in buf {
self.lp_now += orig;

self.prev_index += 1;
if self.prev_index < self.config.downsample as usize {
Expand Down Expand Up @@ -329,12 +329,11 @@ impl Demod {
if yabs < 0 {
yabs = -yabs;
}
let angle;
if x >= 0 {
angle = pi4 - (pi4 as i64 * (x - yabs) as i64) as i32 / (x + yabs);
let angle = if x >= 0 {
pi4 - (pi4 as i64 * (x - yabs) as i64) as i32 / (x + yabs)
} else {
angle = pi34 - (pi4 as i64 * (x + yabs) as i64) as i32 / (yabs - x);
}
pi34 - (pi4 as i64 * (x + yabs) as i64) as i32 / (yabs - x)
};
if y < 0 {
return -angle;
}
Expand Down
16 changes: 5 additions & 11 deletions src/rtlsdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,10 @@ impl RtlSdr {
// Hack to force the Bias T to always be on if we set the IR-Endpoint bit in the EEPROM to 0. Default on EEPROM is 1.
let buf: [u8; EEPROM_SIZE] = [0; EEPROM_SIZE];
self.handle.read_eeprom(&buf, 0, EEPROM_SIZE)?;
if buf[7] & 0x02 != 0 {
inner.deref().borrow_mut().force_bt = false;
} else {
inner.deref().borrow_mut().force_bt = true;
}

inner.deref().borrow_mut().force_bt = buf[7] & 0x02 == 0;
// Hack to force direct sampling mode to always be on if we set the remote-enabled bit in the EEPROM to 1. Default on EEPROM is 0.
if buf[7] & 0x01 != 0 {
inner.deref().borrow_mut().force_ds = true;
} else {
inner.deref().borrow_mut().force_ds = false;
}
inner.deref().borrow_mut().force_ds = buf[7] & 0x01 != 0;
// TODO: if(force_ds){tuner_type = TUNER_UNKNOWN}
info!("Init tuner");
inner.deref().borrow_mut().tuner.init(&self.handle)?;
Expand Down Expand Up @@ -400,7 +393,8 @@ impl RtlSdr {
Ok(())
}

pub fn set_offset_tuning(&self, _enable: bool) -> Result<()> {
#[allow(unused_variables)]
pub fn set_offset_tuning(&self, enable: bool) -> Result<()> {
// RTL-SDR-BLOG Hack, enables us to turn on the bias tee by clicking on "offset tuning"
// in software that doesn't have specified bias tee support.
// Offset tuning is not used for R820T devices so it is no problem.
Expand Down
4 changes: 3 additions & 1 deletion src/tuners/r820t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ impl R820T {
Ok(())
}

#[allow(unused_variables, unused_assignments)]
fn sysfreq_sel(
&mut self,
handle: &Device,
Expand All @@ -692,7 +693,8 @@ impl R820T {
let mixer_top;
let lna_top;
let cp_cur;
let div_buf_cur;
#[allow(unused_mut)]
let mut div_buf_cur;
let lna_vth_l;
let mixer_vth_l;
let air_cable1_in;
Expand Down

0 comments on commit 9ac2ea4

Please sign in to comment.