-
Notifications
You must be signed in to change notification settings - Fork 12
/
radio.h
144 lines (124 loc) · 4.15 KB
/
radio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Clone Utility for Baofeng radios.
*
* Copyright (C) 2013 Serge Vakulenko, KK6ABQ
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
//
// Program version.
//
extern const char program_version[];
extern const char program_copyright[];
//
// Connect to the radio via the serial port.
// Identify the type of device.
//
void radio_connect(const char *port_name);
//
// 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 generic information about the device.
//
void radio_print_version(FILE *out, int show_version);
//
// 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);
//
// Set VFO mode with given frequency.
//
void radio_set_vfo(int vfo_index, double freq_mhz);
//
// Device-dependent interface to the radio.
//
typedef struct {
const char *name;
void (*download)(void);
void (*upload)(int cont_flag);
void (*read_image)(FILE *img, unsigned char *ident);
void (*save_image)(FILE *img);
void (*print_version)(FILE *out, int show_version);
void (*print_config)(FILE *out, int verbose);
void (*parse_parameter)(char *param, char *value);
int (*parse_header)(char *line);
int (*parse_row)(int table_id, int first_row, char *line);
void (*set_vfo)(int vfo_index, double freq_mhz);
} radio_device_t;
extern radio_device_t radio_uv5r; // Baofeng UV-5R, UV-5RA
extern radio_device_t radio_uv5r_aged; // Baofeng UV-5R with old firmware
extern radio_device_t radio_uvb5; // Baofeng UV-B5, UV-B6
extern radio_device_t radio_bf888s; // Baofeng BF-888S
extern radio_device_t radio_bft1; // Baofeng BF-T1
//
// Radio: memory contents.
//
extern unsigned char radio_mem[];
//
// Radio: identifier
//
extern unsigned char radio_ident[8];
//
// File descriptor of serial port with programming cable attached.
//
extern int radio_port;
//
// Read/write progress counter.
//
extern int radio_progress;
//
// For testing.
//
void uv5r_decode_vfo(int index, int *band, int *hz, int *offset, int *rx_ctcs, int *tx_ctcs,
int *rx_dcs, int *tx_dcs, int *lowpower, int *wide, int *step, int *scode);
void uv5r_setup_vfo(int index, int band, double rx_mhz, double tx_offset_mhz, int rxtone, int txtone, int step,
int lowpower, int wide, int scode);
#ifdef __cplusplus
}
#endif