wire fmt def work

This commit is contained in:
TerraMaster85 2024-12-15 00:05:01 -05:00
parent e6455ce36f
commit 2094fa73bf
12 changed files with 193 additions and 225 deletions

297
Cargo.lock generated
View file

@ -160,16 +160,6 @@ dependencies = [
"libloading",
]
[[package]]
name = "colored"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
]
[[package]]
name = "combine"
version = "4.6.7"
@ -241,15 +231,6 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "deranged"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
dependencies = [
"powerfmt",
]
[[package]]
name = "either"
version = "1.13.0"
@ -290,19 +271,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "sang"
version = "0.1.0"
dependencies = [
"anyhow",
"cpal",
"log",
"ringbuf",
"simple_logger",
"thiserror 2.0.6",
"tokio",
]
[[package]]
name = "itertools"
version = "0.13.0"
@ -312,12 +280,6 @@ dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
[[package]]
name = "jni"
version = "0.21.1"
@ -478,10 +440,14 @@ dependencies = [
]
[[package]]
name = "num-conv"
version = "0.1.0"
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-derive"
@ -524,15 +490,6 @@ dependencies = [
"syn",
]
[[package]]
name = "num_threads"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
dependencies = [
"libc",
]
[[package]]
name = "object"
version = "0.36.5"
@ -571,6 +528,12 @@ version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "parking_lot"
version = "0.12.3"
@ -612,12 +575,6 @@ version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "proc-macro-crate"
version = "3.2.0"
@ -714,6 +671,19 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "sang"
version = "0.1.0"
dependencies = [
"anyhow",
"cpal",
"ringbuf",
"thiserror 2.0.6",
"tokio",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
@ -721,23 +691,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.216"
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.216"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"lazy_static",
]
[[package]]
@ -755,18 +714,6 @@ dependencies = [
"libc",
]
[[package]]
name = "simple_logger"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c5dfa5e08767553704aa0ffd9d9794d527103c736aba9854773851fd7497eb"
dependencies = [
"colored",
"log",
"time",
"windows-sys 0.48.0",
]
[[package]]
name = "smallvec"
version = "1.13.2"
@ -835,36 +782,13 @@ dependencies = [
]
[[package]]
name = "time"
version = "0.3.37"
name = "thread_local"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [
"deranged",
"itoa",
"libc",
"num-conv",
"num_threads",
"powerfmt",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de"
dependencies = [
"num-conv",
"time-core",
"cfg-if",
"once_cell",
]
[[package]]
@ -913,12 +837,75 @@ dependencies = [
"winnow",
]
[[package]]
name = "tracing"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
name = "unicode-ident"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "walkdir"
version = "2.5.0"
@ -1012,6 +999,22 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.9"
@ -1021,6 +1024,12 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.54.0"
@ -1059,15 +1068,6 @@ dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
@ -1092,21 +1092,6 @@ dependencies = [
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
@ -1129,12 +1114,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
@ -1147,12 +1126,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
@ -1165,12 +1138,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
@ -1189,12 +1156,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
@ -1207,12 +1168,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
@ -1225,12 +1180,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
@ -1243,12 +1192,6 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"

View file

@ -6,8 +6,8 @@ edition = "2021"
[dependencies]
anyhow = "1.0.94"
cpal = "0.15.3"
log = "0.4.22"
ringbuf = "0.4.7"
simple_logger = { version = "^5.0.0", features = ["colors", "threads", "timestamps"] }
thiserror = "2.0.6"
tokio = { version = '^1', features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"

View file

@ -3,7 +3,7 @@ use anyhow::{Context, Result};
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{FromSample, Sample, SampleFormat};
use log::{error, info, trace, warn};
use tracing::{error, info, trace, warn};
use tokio::sync::mpsc::Sender;
@ -91,7 +91,7 @@ pub fn audio_receiver_main(
None,
)?,
sample_format => {
Err(anyhow::Error::task_msg(
Err(anyhow::Error::msg(
format!(
"unsupported sample format '{}'", sample_format)
))?

View file

@ -1,6 +1,6 @@
use anyhow::{Context, Result};
use log::{error, info, trace, warn};
use tracing::{error, info, trace, warn};
use tokio::sync::mpsc::{Receiver, UnboundedSender};

View file

@ -8,7 +8,7 @@ use anyhow::{Context, Result};
use cpal::traits::HostTrait;
use log::{trace};
use tracing::{trace};
use tokio::sync::mpsc::{channel, unbounded_channel};
@ -23,13 +23,16 @@ use crate::audio_receiver::audio_receiver_main;
mod dsp_inb;
use crate::dsp_inb::dsp_inb_main;
mod wire_fmt;
//#[derive(argh::FromArgs)]
//struct Cli {}
#[tokio::main]
async fn main() -> Result<()> {
simple_logger::init_with_level(log::Level::Trace)
.expect("logger init failure???");
//simple_logger::init_with_level(tracing::Level::Trace)
// .expect("logger init failure???");
tracing_subscriber::fmt::init();
let cpal_host = cpal::default_host();
let cpal_input = cpal_host.default_input_device().context(
@ -47,7 +50,7 @@ async fn main() -> Result<()> {
trace!("starting listener for audio on wire");
audio_receiver_main(tx_for_demod, cpal_input)
.context("listener for audio on wire has failed to start");
.context("listener for audio on wire has failed to start")?;
let mut tasks = tokio::task::JoinSet::new();

View file

@ -1,12 +0,0 @@
pub enum Service {
pub Telephone = 1,
pub Typewriter = 2,
pub IpDce = 3,
pub EthernetDce = 4,
}
pub struct ChannelCapabilities {
pub sample_rate: u64,
}

View file

@ -1,5 +0,0 @@
mod cap;
pub use cap::*;
mod msg;
pub use msg::*;

View file

@ -1,22 +0,0 @@
pub struct WireDataBytes {
data: Vec<u8>,
}
pub enum WireDataFrame {
pub Hello {
sender:
},
pub Complaint,
pub Data,
pub ModeChange,
}
impl From<WireDataFrame> for WireDataBytes {
fn from(value: WireDataFrame) -> Self {
let mut buf = Vec::new::<u8>();
buf.append(&mut vec![0xAA, 0xAA]); // Alternating high-low prelude
match value {
// TODO
}
}
}

14
src/wire_fmt/cap.rs Normal file
View file

@ -0,0 +1,14 @@
pub struct Capabilities {
}
pub enum Service {
elephone = 1,
Typewriter = 2,
IpDce = 3,
EthernetDce = 4,
}
pub struct ChannelCapabilities {
pub sample_rate: u64,
}

5
src/wire_fmt/mod.rs Normal file
View file

@ -0,0 +1,5 @@
mod cap;
pub use cap::*;
mod wire_msg;
pub use wire_msg::*;

42
src/wire_fmt/wire_msg.rs Normal file
View file

@ -0,0 +1,42 @@
pub struct WireDataBytes {
data: Vec<u8>,
}
pub enum WireDataFrame {
Hello {
src: SangAddr,
dest: SangAddr,
},
Complaint(Complaint),
Data,
ModeChange,
}
pub type SangAddr = [i64; 4];
pub enum Complaint {
// you're peaking! please quiet down
VolumeTooHigh,
// i can't / can barely make out what you're saying!
VolumeTooLow,
// this band is lousy - maybe it's noisy or lossy, or
// suffers from pitch/phase shift or instability, or is
// otherwise prone to distortion. let's move to another
CarrierBadBand,
// you're transmitting some Hz above/below what we agreed upon
CarrierPitchWrong(isize),
}
impl From<WireDataFrame> for WireDataBytes {
fn from(value: WireDataFrame) -> Self {
let mut buf: Vec<u8> = Vec::new();
buf.append(&mut vec![0xAA, 0xAA]); // Alternating high-low prelude
match value {
// TODO
_ => todo!(),
}
}
}