Remove radio disconnect
This commit is contained in:
parent
2315ee4a74
commit
cece963e91
14
radio.c
14
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
|
unsigned char radio_mem [1024*1024*2]; // Radio memory contents, up to 2 Mbytes
|
||||||
int radio_progress; // Read/write progress counter
|
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.
|
// Print a generic information about the device.
|
||||||
//
|
//
|
||||||
|
15
src/radio.rs
15
src/radio.rs
@ -7,7 +7,7 @@ pub struct RadioDeviceT { _private: [u8; 0] }
|
|||||||
|
|
||||||
extern {
|
extern {
|
||||||
fn radio_connect() -> *const RadioDeviceT;
|
fn radio_connect() -> *const RadioDeviceT;
|
||||||
fn radio_disconnect();
|
|
||||||
fn radio_download(device: *const RadioDeviceT);
|
fn radio_download(device: *const RadioDeviceT);
|
||||||
fn radio_upload(device: *const RadioDeviceT, cont_flag: c_int);
|
fn radio_upload(device: *const RadioDeviceT, cont_flag: c_int);
|
||||||
fn radio_list_c();
|
fn radio_list_c();
|
||||||
@ -18,6 +18,11 @@ extern {
|
|||||||
fn radio_save_image(device: *const RadioDeviceT, filename: *const c_char);
|
fn radio_save_image(device: *const RadioDeviceT, filename: *const c_char);
|
||||||
fn radio_parse_config(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 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.
|
/// Connect to the radio via the serial port.
|
||||||
@ -30,8 +35,14 @@ pub fn connect() -> *const RadioDeviceT {
|
|||||||
|
|
||||||
/// Close the serial port.
|
/// Close the serial port.
|
||||||
pub fn disconnect() {
|
pub fn disconnect() {
|
||||||
|
|
||||||
|
eprintln!("Close device.");
|
||||||
unsafe {
|
unsafe {
|
||||||
radio_disconnect()
|
// Restore the normal radio mode.
|
||||||
|
dfu_reboot();
|
||||||
|
dfu_close();
|
||||||
|
hid_close();
|
||||||
|
serial_close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user