diff --git a/radio.c b/radio.c index a818318..d0723b0 100644 --- a/radio.c +++ b/radio.c @@ -63,20 +63,6 @@ static radio_device_t *device; // Device-dependent interface unsigned char radio_mem [1024*1024*2]; // Radio memory contents, up to 2 Mbytes int radio_progress; // Read/write progress counter -// -// Close the serial port. -// -void radio_disconnect() -{ - fprintf(stderr, "Close device.\n"); - - // Restore the normal radio mode. - dfu_reboot(); - dfu_close(); - hid_close(); - serial_close(); -} - // // Print a generic information about the device. // diff --git a/src/radio.rs b/src/radio.rs index d832b98..d49bdc0 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -7,7 +7,7 @@ pub struct RadioDeviceT { _private: [u8; 0] } extern { fn radio_connect() -> *const RadioDeviceT; - fn radio_disconnect(); + fn radio_download(device: *const RadioDeviceT); fn radio_upload(device: *const RadioDeviceT, cont_flag: c_int); fn radio_list_c(); @@ -18,6 +18,11 @@ extern { fn radio_save_image(device: *const RadioDeviceT, filename: *const c_char); fn radio_parse_config(device: *const RadioDeviceT, filename: *const c_char); fn radio_write_csv(device: *const RadioDeviceT, filename: *const c_char); + + fn dfu_reboot(); + fn dfu_close(); + fn hid_close(); + fn serial_close(); } /// Connect to the radio via the serial port. @@ -30,8 +35,14 @@ pub fn connect() -> *const RadioDeviceT { /// Close the serial port. pub fn disconnect() { + + eprintln!("Close device."); unsafe { - radio_disconnect() + // Restore the normal radio mode. + dfu_reboot(); + dfu_close(); + hid_close(); + serial_close(); } }