2
* TenTec ArgoV (TT516) drivers
6
* Copyright 2009, Dave Freese, W1HKJ
11
* Note for anyone wishing to expand on the command set.
13
* The Argo V always sends a response and ends the response with a "G\r" to
14
* indicate that the command was accepted. A rejected command is responded to by a
15
* two character sequence "Z\r". You should always expect a maximum response equal
16
* to the number of data bytes plus two.
19
* A request for the present receiver filter bandwidth is the the string:
20
* "?W\r" which is 3 bytes in length
21
* The response from the Argonaut V will be:
22
* "Wn\rG\r" which is 5 bytes in length, where n is an unsigned char (byte)
23
* If the transceiver failed to receive the command correctly it will respond:
24
* "Z\r" ----> you need to check for that condition
31
static const char TT516name_[] = "TT-516";
33
static const char *TT516modes_[] = {
34
"AM", "USB", "LSB", "CW", "FM", NULL};
36
static int TT516_def_bw[] = { 26, 36, 36, 12, 36 };
37
static const char TT516mode_chr[] = { '0', '1', '2', '3', '4' };
38
static const char TT516mode_type[] = { 'U', 'U', 'L', 'U', 'U' };
40
static const char *TT516_widths[] = {
41
"200", "250", "300", "350", "400", "450", "500", "550", "600", "650",
42
"700", "750", "800", "850", "900", "950", "1000", "1100", "1200", "1300",
43
"1400", "1500", "1600", "1700", "1800", "1900", "2000", "2100", "2200", "2300",
44
"2400", "2500", "2600", "2700", "2800", "2900", "3000", NULL};
46
static const char *TT516_AM_widths[] = {
47
"400", "500", "600", "700", "800", "900", "1000", "1100", "1200", "1350",
48
"1400", "1500", "1600", "1700", "1800", "1900", "2000", "2200", "2400", "2600",
49
"2800", "3000", "3200", "3400", "3600", "3800", "4000", "4200", "4400", "4600",
50
"4800", "5000", "5200", "5400", "5600", "5800", "6000", NULL};
52
static char TT516setBW[] = "*Wx\r";
53
static char TT516setPBT[] = "*Pxx\r";
54
static char TT516setMODE[] = "*Mnn\r";
55
static char TT516setFREQA[] = "*Annnn\r";
56
static char TT516setFREQB[] = "*Bnnnn\r";
57
static char TT516setNB[] = "*Kn\r";
58
static char TT516setXMT[] = "#1\r";
59
static char TT516setRCV[] = "#0\r";
60
static char TT516setSPLIT[] = "*On\r";
61
static char TT516setATT[] = "*Jn\r";
62
static char TT516getFREQA[] = "?A\r";
63
static char TT516getFREQB[] = "?B\r";
64
static char TT516getFWDPWR[] = "?F\r";
65
static char TT516getATT[] = "?J\r";
66
static char TT516getMODE[] = "?M\r";
67
//static char TT516getPBT[] = "?P\r";
68
static char TT516getREFPWR[] = "?R\r";
69
static char TT516getSMETER[] = "?S\r";
70
static char TT516getBW[] = "?W\r";
71
static char TT516setVfo[] = "*EVx\r";
73
static GUI rig_widgets[]= {
74
{ (Fl_Widget *)btnIFsh, 214, 105, 50 },
75
{ (Fl_Widget *)sldrIFSHIFT, 266, 105, 156 },
76
{ (Fl_Widget *)NULL, 0, 0, 0 }
79
RIG_TT516::RIG_TT516() {
83
bandwidths_ = TT516_widths;
85
widgets = rig_widgets;
87
comm_baudrate = BR1200;
100
def_mode = modeB = modeA = B.imode = A.imode = 1;
101
def_bw = bwB = bwA = B.iBW = A.iBW = 34;
102
def_freq = freqB = freqA = B.freq = A.freq = 14070000;
105
can_change_alt_vfo = true;
109
has_micgain_control =
113
has_swr_control = false;
120
has_attenuator_control =
121
has_ifshift_control =
123
has_bandwidth_control =
124
has_mode_control = true;
131
void RIG_TT516::initialize()
133
rig_widgets[0].W = btnIFsh;
134
rig_widgets[1].W = sldrIFSHIFT;
137
long RIG_TT516::get_vfoA ()
140
int ret = waitN(8, 150, "get vfo A", HEX);
141
if (ret != 8) return A.freq;
142
if (replystr[0] != 'A') return A.freq;
143
if (replystr[6] != 'G') return A.freq;
145
for (size_t n = 1; n < 5; n++) {
146
f = f*256 + ((unsigned char)replystr[n] & 0xFF) ;
152
void RIG_TT516::set_vfoA (long freq)
156
cmd[5] = freq & 0xff; freq = freq >> 8;
157
cmd[4] = freq & 0xff; freq = freq >> 8;
158
cmd[3] = freq & 0xff; freq = freq >> 8;
159
cmd[2] = freq & 0xff;
160
LOG_INFO(" %c%c %02X %02X %02X %02X %02X", cmd[0], cmd[1],
161
cmd[2] & 0xFF, cmd[3] & 0xFF, cmd[4] & 0xFF, cmd[5] & 0xFF, cmd[6]);
166
long RIG_TT516::get_vfoB ()
169
int ret = waitN(8, 150, "get vfo B", HEX);
170
if (ret != 8) return B.freq;
171
if (replystr[0] != 'B') return B.freq;
172
if (replystr[6] != 'G') return B.freq;
175
for (size_t n = 1; n < 5; n++) {
176
f = f*256 + ((unsigned char)replystr[n] & 0xFF) ;
183
void RIG_TT516::set_vfoB (long freq)
187
cmd[5] = freq & 0xff; freq = freq >> 8;
188
cmd[4] = freq & 0xff; freq = freq >> 8;
189
cmd[3] = freq & 0xff; freq = freq >> 8;
190
cmd[2] = freq & 0xff;
191
LOG_INFO(" %c%c %02X %02X %02X %02X %02X", cmd[0], cmd[1],
192
cmd[2] & 0xFF, cmd[3] & 0xFF, cmd[4] & 0xFF, cmd[5] & 0xFF, cmd[6]);
197
void RIG_TT516::selectA()
207
void RIG_TT516::selectB()
217
void RIG_TT516::set_split(bool val)
220
cmd[2] = val ? '\x01' : '\x00';
225
// Tranceiver PTT on/off
226
void RIG_TT516::set_PTT_control(int val)
228
if (val) sendCommand(TT516setXMT);
229
else sendCommand(TT516setRCV);
232
int RIG_TT516::get_modetype(int n)
234
return TT516mode_type[n];
237
const char **RIG_TT516::bwtable(int m)
239
if (m == 0) return TT516_AM_widths;
243
int RIG_TT516::def_bandwidth(int m)
245
return TT516_def_bw[m];
248
int RIG_TT516::adjust_bandwidth(int m)
251
return def_bandwidth(m);
254
void RIG_TT516::set_modeA(int val)
258
cmd[2] = TT516mode_chr[A.imode];
259
cmd[3] = TT516mode_chr[B.imode];
263
int RIG_TT516::get_modeA()
266
int ret = waitN(6, 150, "get mode A", HEX);
267
if (ret < 6) return A.imode;
268
if (replystr[ret - 2] != 'G') return A.imode;
269
size_t p = replystr.rfind("M");
270
if (p == string::npos) return A.imode;
272
A.imode = replystr[p+1] - '0';
277
void RIG_TT516::set_modeB(int val)
281
cmd[2] = TT516mode_chr[A.imode];
282
cmd[3] = TT516mode_chr[B.imode];
286
int RIG_TT516::get_modeB()
289
int ret = waitN(6, 150, "get mode B", HEX);
290
if (ret < 6) return B.imode;
291
if (replystr[ret - 2] != 'G') return B.imode;
292
size_t p = replystr.rfind("M");
293
if (p == string::npos) return B.imode;
295
B.imode = replystr[p+2] - '0';
300
int RIG_TT516::get_bwA()
304
int ret = waitN(5, 150, "get bw A", HEX);
305
if (ret < 5) return A.iBW;
306
if (replystr[ret - 2] != 'G') return A.iBW;
307
size_t p = replystr.rfind("W");
308
if (p == string::npos) return A.iBW;
309
A.iBW = (unsigned char)replystr[p+1];
314
void RIG_TT516::set_bwA(int val)
324
int RIG_TT516::get_bwB()
328
int ret = waitN(5, 150, "get bw B", HEX);
329
if (ret < 5) return B.iBW;
330
if (replystr[ret - 2] != 'G') return B.iBW;
331
size_t p = replystr.rfind("W");
332
if (p == string::npos) return B.iBW;
333
B.iBW = (unsigned char)replystr[p+1];
338
void RIG_TT516::set_bwB(int val)
348
void RIG_TT516::set_if_shift(int val)
352
cmd[2] = (si & 0xff00) >> 8;
353
cmd[3] = (si & 0xff);
357
bool RIG_TT516::get_if_shift(int &val)
363
void RIG_TT516::get_if_min_max_step(int &min, int &max, int &step)
370
void RIG_TT516::set_attenuator(int val)
373
if (val) cmd[2] = '1';
379
int RIG_TT516::get_attenuator()
382
int ret = sendCommand(cmd);
383
if (ret < 5) return 0;
384
size_t p = replystr.rfind("J");
385
if (p == string::npos) return 0;
386
if (replystr[p+1] == '1')
391
void RIG_TT516::set_noise(bool b)
401
int RIG_TT516::get_smeter()
404
cmd = TT516getSMETER;
405
int ret = sendCommand(cmd);
406
if (ret < 6) return 0;
407
size_t p = replystr.rfind("S");
408
if (p == string::npos) return 0;
410
sig = (50.0 / 9.0) * ((unsigned char)replystr[p+1] + (unsigned char)replystr[p+2] / 256.0);
415
int RIG_TT516::get_swr()
417
double swr = (fwdv + refv) / (fwdv - refv + .0001);
420
if (swr < 0) swr = 0;
421
if (swr > 100) swr = 100;
425
int RIG_TT516::get_power_out()
427
fwdpwr = refpwr = fwdv = refv = 0;
428
cmd = TT516getFWDPWR;
429
int ret = sendCommand(cmd);
430
if (ret < 5) return fwdpwr;
431
size_t p = replystr.rfind("F");
432
if (p == string::npos) return fwdpwr;
434
fwdv = 1.0 * (unsigned char)replystr[p+1];
435
cmd = TT516getREFPWR;
436
ret = sendCommand(cmd);
437
if (ret < 5) return fwdpwr;
438
p = replystr.rfind("R");
439
if (p == string::npos) return fwdpwr;
441
refv = 1.0 * (unsigned char)replystr[p+1];
443
fwdpwr = 30.0 * (fwdv * fwdv) / (256 * 256);
444
refpwr = 30.0 * (refv * refv) / (256 * 256);