commit d5cc9608aa9330df1d7cf8441273f3ff6221daa3
parent 9f1349db9ad1667979f169b85f98f9c537e10215
Author: Bradley Gannon <bradley@bradleygannon.com>
Date: Tue, 8 Sep 2026 15:06:33 -0400
Set log level to info and fix sync checkbox behavior
Diffstat:
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
@@ -50,7 +50,7 @@ static INIT: Once = Once::new();
fn init_logger() {
INIT.call_once(|| {
log::set_logger(&LOGGER).ok();
- log::set_max_level(log::LevelFilter::Trace);
+ log::set_max_level(log::LevelFilter::Info);
});
}
@@ -58,7 +58,7 @@ pub struct CivCtx {
name: String,
port: String,
baud: u32,
- sync_mode: bool,
+ sync_mode: Arc<AtomicBool>,
enabled: bool,
status: Arc<Mutex<String>>,
stop: Arc<AtomicBool>,
@@ -79,7 +79,7 @@ pub unsafe extern "C" fn civ_create(name: *const c_char) -> *mut CivCtx {
name: name.clone(),
port: DEFAULT_PORT.to_string(),
baud: 0,
- sync_mode: true,
+ sync_mode: Arc::new(AtomicBool::new(true)),
enabled: false,
status: Arc::new(Mutex::new("Disconnected".to_string())),
stop: Arc::new(AtomicBool::new(false)),
@@ -122,7 +122,7 @@ pub unsafe extern "C" fn civ_enable(ctx: *mut CivCtx) {
ctx.stop.store(false, Ordering::Relaxed);
let port = ctx.port.clone();
let baud = ctx.baud;
- let sync_mode = ctx.sync_mode;
+ let sync_mode = Arc::clone(&ctx.sync_mode);
let stop = Arc::clone(&ctx.stop);
let status = Arc::clone(&ctx.status);
debug!("starting sync thread (instance: {})", ctx.name);
@@ -214,7 +214,7 @@ pub unsafe extern "C" fn civ_set_sync_mode(ctx: *mut CivCtx, sync_mode: bool) {
return;
}
debug!("mode/filter sync set to {}", sync_mode);
- (*ctx).sync_mode = sync_mode;
+ (*ctx).sync_mode.store(sync_mode, Ordering::Relaxed);
}
/// Fill `out` (up to `out_len` bytes) with NUL-separated serial port names
diff --git a/src/sync.rs b/src/sync.rs
@@ -24,7 +24,7 @@ const BAUD_CANDIDATES: [u32; 6] = [19_200, 9_600, 4_800, 115_200, 38_400, 57_600
pub fn run(
port: String,
baud: u32,
- sync_mode: bool,
+ sync_mode: Arc<AtomicBool>,
stop: Arc<AtomicBool>,
status: Arc<Mutex<String>>,
) {
@@ -73,7 +73,7 @@ pub fn run(
error!("initial frequency sync failed: {}", e);
return;
}
- if sync_mode && mode >= 0 {
+ if sync_mode.load(Ordering::Relaxed) && mode >= 0 {
if let Some(m) = civ::sdrmode_to_icmode(mode) {
if let Err(e) = serial.write_all(&civ::encode_set_mode(m)) {
set_status(&status, &format!("Serial error: {}", e));
@@ -104,6 +104,10 @@ pub fn run(
let mut last_filter_poll = Instant::now();
while !stop.load(Ordering::Relaxed) {
+ // Read the live toggle each iteration so the checkbox takes effect
+ // even while connected.
+ let sync_mode = sync_mode.load(Ordering::Relaxed);
+
// Radio -> SDR: parse incoming CI-V frames.
match serial.read(&mut read_buf) {
Ok(0) => {}