]> code.octet-stream.net Git - m17rt/blobdiff - tools/m17rt-mod/src/main.rs
Fix timing bugs and add documentation
[m17rt] / tools / m17rt-mod / src / main.rs
index 968c22a44d0d0a441dc543c7e0b4d0e3fa087ab9..b5708e95858a7e974b36ef8d9547f8e2065b2e31 100644 (file)
@@ -1,27 +1,35 @@
 use m17app::app::M17App;
 use m17app::app::M17App;
-use m17app::soundmodem::{
-    InputRrcFile, InputSoundcard, NullInputSource, NullOutputSink, OutputRrcFile, OutputSoundcard,
-    Soundmodem,
-};
-use m17codec2::{Codec2Adapter, WavePlayer};
+use m17app::link_setup::M17Address;
+use m17app::serial::{PttPin, SerialPtt};
+use m17app::soundcard::Soundcard;
+use m17app::soundmodem::Soundmodem;
+use m17codec2::WavePlayer;
 use std::path::PathBuf;
 
 pub fn mod_test() {
 use std::path::PathBuf;
 
 pub fn mod_test() {
-    let in_path = PathBuf::from("../../../Data/test_vk7xt_8k.wav");
-    //let out_path = PathBuf::from("../../../Data/mymod.rrc");
-    //let output = OutputRrcFile::new(out_path);
-    let output = OutputSoundcard::new();
-    let soundmodem = Soundmodem::new_with_input_and_output(NullInputSource::new(), output);
+    let soundcard = Soundcard::new("plughw:CARD=Device,DEV=0").unwrap();
+    soundcard.set_tx_inverted(true);
+    let ptt = SerialPtt::new("/dev/ttyUSB0", PttPin::Rts);
+    let soundmodem = Soundmodem::new(soundcard.input(), soundcard.output(), ptt);
     let app = M17App::new(soundmodem);
     app.start();
     std::thread::sleep(std::time::Duration::from_secs(1));
     println!("Beginning playback...");
     let app = M17App::new(soundmodem);
     app.start();
     std::thread::sleep(std::time::Duration::from_secs(1));
     println!("Beginning playback...");
-    WavePlayer::play(in_path, app.tx());
-    println!("Playback complete, terminating in 5 secs");
-    std::thread::sleep(std::time::Duration::from_secs(5));
+    WavePlayer::play(
+        PathBuf::from("../../../Data/test_vk7xt_8k.wav"),
+        app.tx(),
+        &M17Address::from_callsign("VK7XT-1").unwrap(),
+        &M17Address::new_broadcast(),
+        0,
+    );
+    println!("Playback complete.");
+    std::thread::sleep(std::time::Duration::from_secs(1));
+    app.close();
 }
 
 fn main() {
 }
 
 fn main() {
-    env_logger::init();
+    env_logger::builder()
+        .format_timestamp(Some(env_logger::TimestampPrecision::Millis))
+        .init();
     mod_test();
 }
     mod_test();
 }