// SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright 2024 René Ladan use msf60_utils::MSFUtils; fn main() { let mut msf = MSFUtils::default(); const MSGS: [&str; 2] = [ "4 00000000 00000000 0010.0100 0.0100 01.0010 101 10.0000 000.0010 01313330", "4 00000000 00000000 0010.0100 0.0100 01.0010 101 10.0001 000.1000 01313130", ]; for msg in MSGS { for m in msg.chars() { match m { '0' => { msf.set_current_bit_a(Some(false)); msf.set_current_bit_b(Some(false)); } '1' => { msf.set_current_bit_a(Some(true)); msf.set_current_bit_b(Some(false)); } '2' => { msf.set_current_bit_a(Some(false)); msf.set_current_bit_b(Some(true)); } '3' => { msf.set_current_bit_a(Some(true)); msf.set_current_bit_b(Some(true)); } '4' => msf.force_past_new_minute(), '_' => { msf.set_current_bit_a(None); msf.set_current_bit_b(None); } _ => continue, // skip increasing the second counter, as this character is only syntactic sugar } // 0111.1110 train seen? if msf.end_of_minute_marker_present() { let fm = msf.is_first_minute(); // cache because decode_time() clears this on a successful decode msf.decode_time(true, false); let rdt = msf.get_radio_datetime(); println!( "Date/time={:?}-{:?}-{:?} {:?}:{:?} {:?}", rdt.get_year(), rdt.get_month(), rdt.get_day(), rdt.get_hour(), rdt.get_minute(), rdt.get_weekday() ); if !fm { println!( "Jumps={} {} {} {} {} {}", rdt.get_jump_year(), rdt.get_jump_month(), rdt.get_jump_day(), rdt.get_jump_hour(), rdt.get_jump_minute(), rdt.get_jump_weekday() ); } msf.force_new_minute(); } if !msf.increase_second() { println!("Bad increase_second at second {}", msf.get_second()); } } } }