From 863f14b0c2298f2ee97fd84f7cf1e4539a9e8723 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 28 Feb 2021 02:38:07 -0800 Subject: [PATCH] radio::upload --- src/lib.rs | 11 ++--------- src/radio.rs | 7 +++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f58deb3..e70d089 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,9 +7,6 @@ mod radio; const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ"; const VERSION: Option<&'static str> = option_env!("VERSION"); -extern { - fn radio_upload(cont_flag: c_int); -} fn print_usage() { let version = VERSION.unwrap_or("-----"); @@ -91,13 +88,11 @@ pub extern "C" fn rust_main(_argc: c_int, _argv: *const *const c_char) -> c_int if matches.free.len() != 1 { print_usage(); } - unsafe { let device = radio::connect(); radio::read_image(&matches.free[0]); radio::print_version(device); - radio_upload(0); + radio::upload(device, 0); radio::disconnect(); - } } else if config_flag { let conf_args = matches.free.len(); if !(conf_args == 1 || conf_args == 2) { @@ -119,16 +114,14 @@ pub extern "C" fn rust_main(_argc: c_int, _argv: *const *const c_char) -> c_int radio::save_image("device.img"); } else { // Update device from text config file. - unsafe { let device = radio::connect(); radio::download(device); radio::print_version(device); radio::save_image("device.img"); radio::parse_config(&config_filename); radio::verify_config(); - radio_upload(1); + radio::upload(device, 1); radio::disconnect(); - } } } else if verify_flag { if matches.free.len() != 1 { diff --git a/src/radio.rs b/src/radio.rs index 3f74eb6..66b17cf 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -9,6 +9,7 @@ extern { fn radio_connect() -> *const RadioDeviceT; fn radio_disconnect(); fn radio_download(device: *const RadioDeviceT); + fn radio_upload(cont_flag: c_int); fn radio_list_c(); fn radio_verify_config(); fn radio_print_version(device: *const RadioDeviceT, stdout: *const libc::FILE); @@ -37,6 +38,12 @@ pub fn download(device: *const RadioDeviceT) { } } +pub fn upload(_device: *const RadioDeviceT, cont_flag: c_int) { + unsafe { + radio_upload(cont_flag) + } +} + pub fn list() {