radio::upload
This commit is contained in:
parent
cd74a703c1
commit
863f14b0c2
11
src/lib.rs
11
src/lib.rs
@ -7,9 +7,6 @@ mod radio;
|
|||||||
const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ";
|
const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ";
|
||||||
const VERSION: Option<&'static str> = option_env!("VERSION");
|
const VERSION: Option<&'static str> = option_env!("VERSION");
|
||||||
|
|
||||||
extern {
|
|
||||||
fn radio_upload(cont_flag: c_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn print_usage() {
|
fn print_usage() {
|
||||||
let version = VERSION.unwrap_or("-----");
|
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 {
|
if matches.free.len() != 1 {
|
||||||
print_usage();
|
print_usage();
|
||||||
}
|
}
|
||||||
unsafe {
|
|
||||||
let device = radio::connect();
|
let device = radio::connect();
|
||||||
radio::read_image(&matches.free[0]);
|
radio::read_image(&matches.free[0]);
|
||||||
radio::print_version(device);
|
radio::print_version(device);
|
||||||
radio_upload(0);
|
radio::upload(device, 0);
|
||||||
radio::disconnect();
|
radio::disconnect();
|
||||||
}
|
|
||||||
} else if config_flag {
|
} else if config_flag {
|
||||||
let conf_args = matches.free.len();
|
let conf_args = matches.free.len();
|
||||||
if !(conf_args == 1 || conf_args == 2) {
|
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");
|
radio::save_image("device.img");
|
||||||
} else {
|
} else {
|
||||||
// Update device from text config file.
|
// Update device from text config file.
|
||||||
unsafe {
|
|
||||||
let device = radio::connect();
|
let device = radio::connect();
|
||||||
radio::download(device);
|
radio::download(device);
|
||||||
radio::print_version(device);
|
radio::print_version(device);
|
||||||
radio::save_image("device.img");
|
radio::save_image("device.img");
|
||||||
radio::parse_config(&config_filename);
|
radio::parse_config(&config_filename);
|
||||||
radio::verify_config();
|
radio::verify_config();
|
||||||
radio_upload(1);
|
radio::upload(device, 1);
|
||||||
radio::disconnect();
|
radio::disconnect();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if verify_flag {
|
} else if verify_flag {
|
||||||
if matches.free.len() != 1 {
|
if matches.free.len() != 1 {
|
||||||
|
@ -9,6 +9,7 @@ extern {
|
|||||||
fn radio_connect() -> *const RadioDeviceT;
|
fn radio_connect() -> *const RadioDeviceT;
|
||||||
fn radio_disconnect();
|
fn radio_disconnect();
|
||||||
fn radio_download(device: *const RadioDeviceT);
|
fn radio_download(device: *const RadioDeviceT);
|
||||||
|
fn radio_upload(cont_flag: c_int);
|
||||||
fn radio_list_c();
|
fn radio_list_c();
|
||||||
fn radio_verify_config();
|
fn radio_verify_config();
|
||||||
fn radio_print_version(device: *const RadioDeviceT, stdout: *const libc::FILE);
|
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() {
|
pub fn list() {
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user