From ea9ff0a534b603f39bd66d9099c24b3497206130 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 1 Mar 2021 02:29:53 -0800 Subject: [PATCH] Use static radio_device_t vars --- build.rs | 16 ++++++++++++++++ src/radio.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/build.rs b/build.rs index 01c03d7..2b9f2b6 100644 --- a/build.rs +++ b/build.rs @@ -19,6 +19,22 @@ fn main() { // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .whitelist_type("radio_device_t") + .whitelist_var("radio_md380") + .whitelist_var("radio_md390") + .whitelist_var("radio_md201") + .whitelist_var("radio_uv380") + .whitelist_var("radio_uv390") + .whitelist_var("radio_md960") + .whitelist_var("radio_d900;") + .whitelist_var("radio_dp8") + .whitelist_var("radio_rt27d") + .whitelist_var("radio_rd5") + .whitelist_var("radio_gd77;") + .whitelist_var("radio_dm180") + .whitelist_var("radio_d868u") + .whitelist_var("radio_d878u") + .whitelist_var("radio_dmr6x") + .whitelist_var("radio_rt84") .blacklist_type("FILE") // Finish the builder and generate the bindings. .generate() diff --git a/src/radio.rs b/src/radio.rs index 0f5bc0f..dc3a5f5 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -191,6 +191,33 @@ pub fn verify_config(radio: &Radio) { /// Read firmware image from the binary file. pub fn read_image(filename: &str) -> Radio { + + /* + eprintln!"Read codeplug from file '{}'.", filename); + + let img = std::fs::File::open(filename).unwrap(); + let metadata = std::fs::metadata(filename).unwrap(); + let file_size = metadata.len(); + match file_size { + 851968 | 852533 => { + + } + 262144 | 262709 => { + + } + 1606528 => { + + } + 131072 => { + + } + size => { + eprintln!("{}: Unrecognized file size {} bytes.", filename, size); + exit(-1); + } + }; + */ + let filename = CString::new(filename.to_string()).unwrap(); let ptr = unsafe { radio_read_image(filename.as_ptr())