diff --git a/radio.h b/radio.h index 71eeb33..f170a60 100644 --- a/radio.h +++ b/radio.h @@ -26,67 +26,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// -// Connect to the radio via the serial port. -// Identify the type of device. -// -//void radio_connect(void); - -// -// Close the serial port. -// -void radio_disconnect(void); - -// -// Read firmware image from the device. -// -//void radio_download(void); - -// -// Write firmware image to the device. -// -//void radio_upload(int cont_flag); - -// -// Print a generic information about the device. -// -//void radio_print_version(FILE *out); - -// -// Print full information about the device configuration. -// -void radio_print_config(FILE *out, int verbose); - -// -// Read firmware image from the binary file. -// -void radio_read_image(const char *filename); - -// -// Save firmware image to the binary file. -// -void radio_save_image(const char *filename); - -// -// Read the configuration from text file, and modify the firmware. -// -void radio_parse_config(const char *filename); - -// -// Check the configuration. -// -void radio_verify_config(void); - -// -// Update CSV contacts database. -// -void radio_write_csv(const char *filename); - -// -// List all supported radios. -// -//void radio_list_c(void); - // // Check for compatible radio model. // diff --git a/src/radio.rs b/src/radio.rs index 0377d76..fd5a240 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -20,44 +20,51 @@ extern { fn radio_write_csv(filename: *const c_char); } +/// Connect to the radio via the serial port. +/// Identify the type of device. pub fn connect() -> *const RadioDeviceT { unsafe { radio_connect() } } +/// Close the serial port. pub fn disconnect() { unsafe { radio_disconnect() } } +/// Read firmware image from the device pub fn download(device: *const RadioDeviceT) { unsafe { radio_download(device) } } +/// Write firmware image to the device. pub fn upload(device: *const RadioDeviceT, cont_flag: c_int) { unsafe { radio_upload(device, cont_flag) } } +/// List all supported radios. pub fn list() { - unsafe { radio_list_c(); } } +/// Check the configuration. pub fn verify_config() { unsafe { radio_verify_config(); } } +/// Read firmware image from the binary file. pub fn read_image(filename: &str) { let filename = CString::new(filename.to_string()).unwrap(); unsafe { @@ -65,6 +72,7 @@ pub fn read_image(filename: &str) { } } +/// Save firmware image to the binary file. pub fn save_image(filename: &str) { let filename = CString::new(filename.to_string()).unwrap(); unsafe { @@ -72,6 +80,7 @@ pub fn save_image(filename: &str) { } } +/// Read the configuration from text file, and modify the firmware. pub fn parse_config(filename: &str) { let filename = CString::new(filename.to_string()).unwrap(); unsafe { @@ -79,6 +88,7 @@ pub fn parse_config(filename: &str) { } } +/// Print full information about the device configuration. pub fn print_config(filename: &str) { let file = std::fs::File::create(filename).unwrap(); let fd = file.as_raw_fd(); @@ -103,6 +113,7 @@ pub fn print_config_to_stdout() { } } +/// Print generic information about the device. pub fn print_version(device: *const RadioDeviceT) { let mode = CString::new("w").unwrap(); unsafe { @@ -110,6 +121,7 @@ pub fn print_version(device: *const RadioDeviceT) { } } +/// Update CSV contacts database. pub fn write_csv(filename: &str) { let filename = CString::new(filename.to_string()).unwrap(); unsafe {