cubehub / demod Goto Github PK
View Code? Open in Web Editor NEWCommand line utility based on liquid-dsp for realtime SDR IQ stream demodulation
License: MIT License
Command line utility based on liquid-dsp for realtime SDR IQ stream demodulation
License: MIT License
Hi,
I'm looking for a command line tool to demodulate USB/LSB for Raspberry Pi autonomous WSPR reception. As I see in the code, only FM is supported? No plans to add USB/LSB/SSB?
Thanks
This is all nice, kudos for this tool.
I compiled older, C version of demod & all I get is white noise, even with strong FM station.
I can't get Rust version to compile for specific x86 platform, how to do that? Rust seems to compile liquid-dsp on it's own & I need to provide specific --march options. Any help would be nice. Thanks.
On lines 108 and 109 in main.rs
, why do we divide the f32
s by 32768? What does this action achieve?
When reading these lines, it appeared to me that the bitwise operations successfully converted the u8
values into f32
values, but I don't quite understand why they're divided by a number afterward.
let i: f32 = ((b[1] as i16) << 8 | b[0] as i16) as f32 / 32768.;
let q: f32 = ((b[3] as i16) << 8 | b[2] as i16) as f32 / 32768.;
Compiling demod v0.9.6 (file:///home/kammajaa/demod)
error[E0599]: no function or associated item named new
found for type clap::SubCommand<'_>
in the current scope
--> src/usage.rs:113:29
|
113 | .subcommand(SubCommand::new("fm")
| ^^^^^^^^^^^^^^^ function or associated item not found in clap::SubCommand<'_>
error: aborting due to previous error
error: Could not compile demod
.
It's strange. Is it might be depend to be update library, crates.io? Thanks.
pi@raspberry:~/demod $ cargo build --release
Compiling libc v0.2.39
Compiling num-traits v0.2.1
Compiling rustc-serialize v0.3.24
Compiling unicode-width v0.1.4
Compiling vec_map v0.8.0
Compiling strsim v0.7.0
error: Could not compile `libc`.
Caused by:
process didn't exit successfully: `rustc --crate-name libc /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.39/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=caac43181e7a38c2 -C extra-filename=-caac43181e7a38c2 --out-dir /home/pi/demod/target/release/deps -L dependency=/home/pi/demod/target/release/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
thread '<unnamed>' panicked at 'src/librustc_codegen_ssa/back/write.rs:1545: worker thread panicked', src/librustc/util/bug.rs:37:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: failed to parse bitcode for LTO module: file doesn't start with bitcode header
error: aborting due to previous error
free(): invalid next size (fast)
error: Could not compile `strsim`.
Caused by:
process didn't exit successfully: `rustc --crate-name strsim /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/strsim-0.7.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=e69152eb05c2cfdc -C extra-filename=-e69152eb05c2cfdc --out-dir /home/pi/demod/target/release/deps -L dependency=/home/pi/demod/target/release/deps --cap-lints allow` (signal: 6, SIGABRT: process abort signal)
warning: build failed, waiting for other jobs to finish...
error: Could not compile `num-traits`.
Caused by:
process didn't exit successfully: `rustc --crate-name num_traits /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=ba597cbdaa1cf83d -C extra-filename=-ba597cbdaa1cf83d --out-dir /home/pi/demod/target/release/deps -L dependency=/home/pi/demod/target/release/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: Could not compile `rustc-serialize`.
Caused by:
process didn't exit successfully: `rustc --crate-name rustc_serialize /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=bdf678104c710bcc -C extra-filename=-bdf678104c710bcc --out-dir /home/pi/demod/target/release/deps -L dependency=/home/pi/demod/target/release/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
pi@raspberry:~/demod $ cargo build
Compiling libc v0.2.39
Compiling num-traits v0.2.1
Compiling rustc-serialize v0.3.24
Compiling unicode-width v0.1.4
Compiling vec_map v0.8.0
Compiling bitflags v1.0.1
Compiling ansi_term v0.11.0
Compiling strsim v0.7.0
Compiling textwrap v0.9.0
Compiling rand v0.4.2
Compiling atty v0.2.8
Compiling num-integer v0.1.36
Compiling clap v2.31.1
Compiling num-iter v0.1.35
Compiling num-bigint v0.1.43
Compiling num-complex v0.1.43
Compiling num-rational v0.1.42
Compiling num v0.1.42
Compiling liquid_dsp v0.3.0 (https://github.com/cubehub/rust-liquid-dsp.git#343bf9bd)
Compiling demod v0.9.7 (/home/pi/demod)
Finished dev [unoptimized + debuginfo] target(s) in 1m 42s
I append Cargo.toml, release build option.
[profile.release]
opt-level = 0
It can build unoptimize release build.
pi@raspberry:~/demod $ cargo build --release
Compiling libc v0.2.39
Compiling num-traits v0.2.1
Compiling rustc-serialize v0.3.24
Compiling unicode-width v0.1.4
Compiling vec_map v0.8.0
Compiling strsim v0.7.0
Compiling bitflags v1.0.1
Compiling ansi_term v0.11.0
Compiling textwrap v0.9.0
Compiling rand v0.4.2
Compiling atty v0.2.8
Compiling num-integer v0.1.36
Compiling clap v2.31.1
Compiling num-iter v0.1.35
Compiling num-bigint v0.1.43
Compiling num-complex v0.1.43
Compiling num-rational v0.1.42
Compiling num v0.1.42
Compiling liquid_dsp v0.3.0 (https://github.com/cubehub/rust-liquid-dsp.git#343bf9bd)
Compiling demod v0.9.7 (/home/pi/demod)
Finished release [unoptimized] target(s) in 1m 27s
It is slow because only 2 byes are written with one stdout.write(..)
.
let mut demod_out = vec![0_f32; resampler_output_len as usize];
match args.outputtype.unwrap() {
I16 => {
for i in 0 .. resampler_output_count as usize {
if demod_out[i] > 1.0 {
demod_out[i] = 1.0;
}
if demod_out[i] < -1.0 {
demod_out[i] = -1.0;
}
let sample: [i16; 1] = [(demod_out[i] * 32767_f32) as i16];
let slice = unsafe {slice::from_raw_parts(sample.as_ptr() as *const _, 2)};
stdout.write(&slice).map_err(|e|{println_stderr!("stdout.write error: {:?}", e); exit(1);});
stdout.flush().map_err(|e|{println_stderr!("stdout.write error: {:?}", e); exit(1);});
}
}
F32 => {
let slice = unsafe {slice::from_raw_parts(demod_out.as_ptr() as *const _, (resampler_output_count * 4) as usize)};
stdout.write(&slice).map_err(|e|{println_stderr!("stdout.write error: {:?}", e); exit(1);});
stdout.flush().map_err(|e|{println_stderr!("stdout.write error: {:?}", e); exit(1);});
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.