Move C header comments to Rust doc comments

This commit is contained in:
Greg Shuflin 2021-02-28 02:53:19 -08:00
parent 05b7842053
commit c2471516fd
2 changed files with 13 additions and 62 deletions

61
radio.h
View File

@ -26,67 +26,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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. // Check for compatible radio model.
// //

View File

@ -20,44 +20,51 @@ extern {
fn radio_write_csv(filename: *const c_char); 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 { pub fn connect() -> *const RadioDeviceT {
unsafe { unsafe {
radio_connect() radio_connect()
} }
} }
/// Close the serial port.
pub fn disconnect() { pub fn disconnect() {
unsafe { unsafe {
radio_disconnect() radio_disconnect()
} }
} }
/// Read firmware image from the device
pub fn download(device: *const RadioDeviceT) { pub fn download(device: *const RadioDeviceT) {
unsafe { unsafe {
radio_download(device) radio_download(device)
} }
} }
/// Write firmware image to the device.
pub fn upload(device: *const RadioDeviceT, cont_flag: c_int) { pub fn upload(device: *const RadioDeviceT, cont_flag: c_int) {
unsafe { unsafe {
radio_upload(device, cont_flag) radio_upload(device, cont_flag)
} }
} }
/// List all supported radios.
pub fn list() { pub fn list() {
unsafe { unsafe {
radio_list_c(); radio_list_c();
} }
} }
/// Check the configuration.
pub fn verify_config() { pub fn verify_config() {
unsafe { unsafe {
radio_verify_config(); radio_verify_config();
} }
} }
/// Read firmware image from the binary file.
pub fn read_image(filename: &str) { pub fn read_image(filename: &str) {
let filename = CString::new(filename.to_string()).unwrap(); let filename = CString::new(filename.to_string()).unwrap();
unsafe { unsafe {
@ -65,6 +72,7 @@ pub fn read_image(filename: &str) {
} }
} }
/// Save firmware image to the binary file.
pub fn save_image(filename: &str) { pub fn save_image(filename: &str) {
let filename = CString::new(filename.to_string()).unwrap(); let filename = CString::new(filename.to_string()).unwrap();
unsafe { 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) { pub fn parse_config(filename: &str) {
let filename = CString::new(filename.to_string()).unwrap(); let filename = CString::new(filename.to_string()).unwrap();
unsafe { unsafe {
@ -79,6 +88,7 @@ pub fn parse_config(filename: &str) {
} }
} }
/// Print full information about the device configuration.
pub fn print_config(filename: &str) { pub fn print_config(filename: &str) {
let file = std::fs::File::create(filename).unwrap(); let file = std::fs::File::create(filename).unwrap();
let fd = file.as_raw_fd(); 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) { pub fn print_version(device: *const RadioDeviceT) {
let mode = CString::new("w").unwrap(); let mode = CString::new("w").unwrap();
unsafe { unsafe {
@ -110,6 +121,7 @@ pub fn print_version(device: *const RadioDeviceT) {
} }
} }
/// Update CSV contacts database.
pub fn write_csv(filename: &str) { pub fn write_csv(filename: &str) {
let filename = CString::new(filename.to_string()).unwrap(); let filename = CString::new(filename.to_string()).unwrap();
unsafe { unsafe {