~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/rigs/IC9100.cxx

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-06-07 11:28:52 UTC
  • Revision ID: package-import@ubuntu.com-20140607112852-pj9xhtlvwpgqjy5x
Tags: 1.3.15-1
* Initial release (Closes: #750861)
  flrig version 1.3.15 plus the following upstream commits:
  - 0001-License-Declaration.patch
  - 0002-FL_APPS-folder.patch
  - 0003-rig-home-dir.patch
  - 0004-RTS-DTR-restore.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * 9100 ... drivers
 
3
 *
 
4
 * a part of flrig
 
5
 *
 
6
 * Copyright 2012, Dave Freese, W1HKJ
 
7
 *
 
8
 */
 
9
 
 
10
#include "IC9100.h"
 
11
 
 
12
bool IC9100_DEBUG = true;
 
13
 
 
14
//=============================================================================
 
15
// IC-9100
 
16
 
 
17
const char IC9100name_[] = "IC-9100";
 
18
 
 
19
const char *IC9100modes_[] = {
 
20
        "LSB", "USB", "AM", "CW", "RTTY", "FM", "CW-R", "RTTY-R", "PSK", "PSK-R", 
 
21
        "LSB-D1", "LSB-D2", "LSB-D3",
 
22
        "USB-D1", "USB-D2", "USB-D3", NULL};
 
23
 
 
24
const char IC9100_mode_type[] = {
 
25
        'L', 'U', 'U', 'U', 'L', 'U', 'L', 'U', 'U', 'L', 
 
26
        'L', 'L', 'L',
 
27
        'U', 'U', 'U' };
 
28
 
 
29
const char IC9100_mode_nbr[] = {
 
30
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x12, 0x13, 
 
31
        0x00, 0x00, 0x00,
 
32
        0x01, 0x01, 0x01 };
 
33
 
 
34
const char *IC9100_ssb_bws[] = {
 
35
"50",    "100",  "150",  "200",  "250",  "300",  "350",  "400",  "450",  "500",
 
36
"600",   "700",  "800",  "900",
 
37
"1000", "1100", "1200", "1300", "1400", "1500", "1600", "1700", "1800", "1900",
 
38
"2000", "2100", "2200", "2300", "2400", "2500", "2600", "2700", "2800", "2900",
 
39
"3000", "3100", "3200", "3300", "3400", "3500", "3600", NULL };
 
40
 
 
41
const char *IC9100_rtty_bws[] = {
 
42
"50",    "100",  "150",  "200",  "250",  "300",  "350",  "400",  "450",  "500",
 
43
"600",   "700",  "800",  "900",
 
44
"1000", "1100", "1200", "1300", "1400", "1500", "1600", "1700", "1800", "1900",
 
45
"2000", "2100", "2200", "2300", "2400", "2500", "2600", "2700", NULL };
 
46
 
 
47
const char *IC9100_am_bws[] = {
 
48
"200",   "400",  "600",  "800", "1000", "1200", "1400", "1600", "1800", "2000",
 
49
"2200", "2400", "2600", "2800", "3000", "3200", "3400", "3600", "3800", "4000",
 
50
"4200", "4400", "4600", "4800", "5000", "5200", "5400", "5600", "5800", "6000",
 
51
"6200", "6400", "6600", "6800", "7000", "7200", "7400", "9100", "7800", "8000",
 
52
"8200", "8400", "8600", "8800", "9000", "9200", "9400", "9600", "9800", "10000", NULL };
 
53
 
 
54
const char *IC9100_fm_bws[] = {
 
55
"FIXED", NULL };
 
56
 
 
57
static GUI IC9100_widgets[]= {
 
58
        { (Fl_Widget *)btnVol, 2, 125,  50 },
 
59
        { (Fl_Widget *)sldrVOLUME, 54, 125, 156 },
 
60
        { (Fl_Widget *)sldrRFGAIN, 54, 145, 156 },
 
61
        { (Fl_Widget *)sldrSQUELCH, 54, 165, 156 },
 
62
        { (Fl_Widget *)btnNR, 2, 185,  50 },
 
63
        { (Fl_Widget *)sldrNR, 54, 185, 156 },
 
64
        { (Fl_Widget *)btnIFsh, 214, 125,  50 },
 
65
        { (Fl_Widget *)sldrIFSHIFT, 266, 125, 156 },
 
66
        { (Fl_Widget *)btnNotch, 214, 145,  50 },
 
67
        { (Fl_Widget *)sldrNOTCH, 266, 145, 156 },
 
68
        { (Fl_Widget *)sldrMICGAIN, 266, 165, 156 },
 
69
        { (Fl_Widget *)sldrPOWER, 266, 185, 156 },
 
70
        { (Fl_Widget *)NULL, 0, 0, 0 }
 
71
};
 
72
 
 
73
RIG_IC9100::RIG_IC9100() {
 
74
        defaultCIV = 0x7C;
 
75
        name_ = IC9100name_;
 
76
        modes_ = IC9100modes_;
 
77
        bandwidths_ = IC9100_ssb_bws;
 
78
        _mode_type = IC9100_mode_type;
 
79
        adjustCIV(defaultCIV);
 
80
 
 
81
        widgets = IC9100_widgets;
 
82
 
 
83
        has_extras =
 
84
 
 
85
        has_cw_wpm =
 
86
        has_cw_spot_tone =
 
87
        has_cw_qsk =
 
88
 
 
89
        has_vox_onoff =
 
90
        has_vox_gain =
 
91
        has_vox_anti =
 
92
        has_vox_hang =
 
93
 
 
94
        has_smeter =
 
95
        has_power_out =
 
96
        has_alc_control =
 
97
        has_swr_control =
 
98
 
 
99
        has_compON =
 
100
        has_compression =
 
101
 
 
102
        has_auto_notch = 
 
103
        has_notch_control = 
 
104
 
 
105
        has_split =
 
106
 
 
107
        has_micgain_control =
 
108
        has_bandwidth_control = true;
 
109
 
 
110
        precision = 1;
 
111
        ndigits = 9;
 
112
 
 
113
};
 
114
 
 
115
//======================================================================
 
116
// IC9100 unique commands
 
117
//======================================================================
 
118
 
 
119
void RIG_IC9100::initialize()
 
120
{
 
121
        IC9100_widgets[0].W = btnVol;
 
122
        IC9100_widgets[1].W = sldrVOLUME;
 
123
        IC9100_widgets[2].W = sldrRFGAIN;
 
124
        IC9100_widgets[3].W = sldrSQUELCH;
 
125
        IC9100_widgets[4].W = btnNR;
 
126
        IC9100_widgets[5].W = sldrNR;
 
127
        IC9100_widgets[6].W = btnIFsh;
 
128
        IC9100_widgets[7].W = sldrIFSHIFT;
 
129
        IC9100_widgets[8].W = btnNotch;
 
130
        IC9100_widgets[9].W = sldrNOTCH;
 
131
        IC9100_widgets[10].W = sldrMICGAIN;
 
132
        IC9100_widgets[11].W = sldrPOWER;
 
133
}
 
134
 
 
135
void RIG_IC9100::selectA()
 
136
{
 
137
        cmd = pre_to;
 
138
        cmd += '\x07';
 
139
        cmd += '\xD0';
 
140
        cmd.append(post);
 
141
        sendICcommand(cmd, 6);
 
142
        checkresponse();
 
143
}
 
144
 
 
145
void RIG_IC9100::selectB()
 
146
{
 
147
        cmd = pre_to;
 
148
        cmd += '\x07';
 
149
        cmd += '\xD1';
 
150
        cmd.append(post);
 
151
        sendICcommand(cmd, 6);
 
152
        checkresponse();
 
153
}
 
154
 
 
155
void RIG_IC9100::set_modeA(int val)
 
156
{
 
157
        A.imode = val;
 
158
        cmd = pre_to;
 
159
        cmd += '\x06';
 
160
        cmd += IC9100_mode_nbr[val];
 
161
        cmd.append( post );
 
162
        if (IC9100_DEBUG)
 
163
                LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
164
        sendICcommand (cmd, 6);
 
165
        checkresponse();
 
166
// digital set / clear
 
167
        if (A.imode >= 10) {
 
168
                cmd = pre_to;
 
169
                cmd += '\x1A'; cmd += '\x06';
 
170
                switch (A.imode) {
 
171
                        case 10 : case 13 : cmd += '\x01'; cmd += '\x01';break;
 
172
                        case 11 : case 14 : cmd += '\x02'; cmd += '\x01';break;
 
173
                        case 12 : case 15 : cmd += '\x03'; cmd += '\x01';break;
 
174
                        default :
 
175
                                cmd += '\x00'; cmd += '\x00';
 
176
                }
 
177
                cmd.append( post);
 
178
                if (IC9100_DEBUG)
 
179
                        LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
180
                sendICcommand (cmd, 6);
 
181
                checkresponse();
 
182
        }
 
183
}
 
184
 
 
185
int RIG_IC9100::get_modeA()
 
186
{
 
187
        int md = 0;
 
188
        cmd = pre_to;
 
189
        cmd += '\x04';
 
190
        cmd.append(post);
 
191
        if (sendICcommand (cmd, 8 )) {
 
192
                for (md = 0; md < 10; md++) if (replystr[5] == IC9100_mode_nbr[md]) break;
 
193
                if (md == 10) md = 0;
 
194
                A.imode = md;
 
195
        } else
 
196
                checkresponse();
 
197
        if (md == 0 || md == 1) {
 
198
                cmd = pre_to;
 
199
                cmd += '\x1A'; cmd += '\x06';
 
200
                cmd.append(post);
 
201
                if (sendICcommand(cmd, 9)) {
 
202
                        if (replystr[6] > 0 && A.imode < 2) {
 
203
                                if (replystr[6] < 4)
 
204
                                        A.imode = 9 + A.imode * 3 + replystr[6];
 
205
                        }
 
206
                }
 
207
        }
 
208
        return A.imode;
 
209
}
 
210
 
 
211
void RIG_IC9100::set_modeB(int val)
 
212
{
 
213
        B.imode = val;
 
214
        cmd = pre_to;
 
215
        cmd += '\x06';
 
216
        cmd += IC9100_mode_nbr[val];
 
217
        cmd.append( post );
 
218
        if (IC9100_DEBUG)
 
219
                LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
220
        sendICcommand (cmd, 6);
 
221
        checkresponse();
 
222
// digital set / clear
 
223
        if (B.imode >= 10) {
 
224
                cmd = pre_to;
 
225
                cmd += '\x1A'; cmd += '\x06';
 
226
                switch (B.imode) {
 
227
                        case 10 : case 13 : cmd += '\x01'; cmd += '\x01';break;
 
228
                        case 11 : case 14 : cmd += '\x02'; cmd += '\x01';break;
 
229
                        case 12 : case 15 : cmd += '\x03'; cmd += '\x01';break;
 
230
                        default :
 
231
                                cmd += '\x00'; cmd += '\x00';
 
232
                }
 
233
                cmd.append( post);
 
234
                if (IC9100_DEBUG)
 
235
                        LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
236
                sendICcommand (cmd, 6);
 
237
                checkresponse();
 
238
        }
 
239
}
 
240
 
 
241
int RIG_IC9100::get_modeB()
 
242
{
 
243
        int md = 0;
 
244
        cmd = pre_to;
 
245
        cmd += '\x04';
 
246
        cmd.append(post);
 
247
        if (sendICcommand (cmd, 8 )) {
 
248
                for (md = 0; md < 10; md++) if (replystr[5] == IC9100_mode_nbr[md]) break;
 
249
                if (md == 10) md = 0;
 
250
                B.imode = md;
 
251
        } else
 
252
                checkresponse();
 
253
        if (md == 0 || md == 1) {
 
254
                cmd = pre_to;
 
255
                cmd += '\x1A'; cmd += '\x06';
 
256
                cmd.append(post);
 
257
                if (sendICcommand(cmd, 9)) {
 
258
                        if (replystr[6] > 0 && B.imode < 2) {
 
259
                                if (replystr[6] < 4)
 
260
                                        B.imode = 9 + B.imode * 3 + replystr[6];
 
261
                        }
 
262
                }
 
263
        }
 
264
        return B.imode;
 
265
}
 
266
 
 
267
int RIG_IC9100::get_bwA()
 
268
{
 
269
        if (A.imode == 5) return 0;
 
270
        cmd = pre_to;
 
271
        cmd.append("\x1a\x03");
 
272
        cmd.append(post);
 
273
        if (sendICcommand (cmd, 8)) {
 
274
                A.iBW = fm_bcd(&replystr[6], 2);
 
275
        }
 
276
        return A.iBW;
 
277
}
 
278
 
 
279
void RIG_IC9100::set_bwA(int val)
 
280
{
 
281
        A.iBW = val;
 
282
        if (A.imode == 5) return;
 
283
        cmd = pre_to;
 
284
        cmd.append("\x1a\x03");
 
285
        cmd.append(to_bcd(A.iBW, 2));
 
286
        cmd.append(post);
 
287
        if (IC9100_DEBUG)
 
288
                LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
289
        sendICcommand (cmd, 6);
 
290
        checkresponse();
 
291
}
 
292
 
 
293
int RIG_IC9100::get_bwB()
 
294
{
 
295
        if (B.imode == 5) return 0;
 
296
        cmd = pre_to;
 
297
        cmd.append("\x1a\x03");
 
298
        cmd.append(post);
 
299
        if (sendICcommand (cmd, 8)) {
 
300
                B.iBW = fm_bcd(&replystr[6], 2);
 
301
        }
 
302
        return B.iBW;
 
303
}
 
304
 
 
305
void RIG_IC9100::set_bwB(int val)
 
306
{
 
307
        B.iBW = val;
 
308
        if (B.imode == 5) return;
 
309
        cmd = pre_to;
 
310
        cmd.append("\x1a\x03");
 
311
        cmd.append(to_bcd(A.iBW, 2));
 
312
        cmd.append(post);
 
313
        if (IC9100_DEBUG)
 
314
                LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
315
        sendICcommand (cmd, 6);
 
316
        checkresponse();
 
317
}
 
318
 
 
319
int RIG_IC9100::adjust_bandwidth(int m)
 
320
{
 
321
        int bw = 0;
 
322
        switch (m) {
 
323
                case 2: // AM
 
324
                        bandwidths_ = IC9100_am_bws;
 
325
                        bw = 19;
 
326
                        break;
 
327
                case 5: // FM
 
328
                        bandwidths_ = IC9100_fm_bws;
 
329
                        bw = 0;
 
330
                        break;
 
331
                case 4: case 7: // RTTY
 
332
                        bandwidths_ = IC9100_rtty_bws;
 
333
                        bw = 12;
 
334
                        break;
 
335
                case 3: case 6: // CW
 
336
                        bandwidths_ = IC9100_ssb_bws;
 
337
                        bw = 12;
 
338
                        break;
 
339
                case 8: case 9: // PKT
 
340
                        bandwidths_ = IC9100_ssb_bws;
 
341
                        bw = 34;
 
342
                        break;
 
343
                case 0: case 1: // SSB
 
344
                default:
 
345
                case 10: case 11 : case 12 :
 
346
                case 13: case 14 : case 15 :
 
347
                        bandwidths_ = IC9100_ssb_bws;
 
348
                        bw = 34;
 
349
        }
 
350
        return bw;
 
351
}
 
352
 
 
353
int RIG_IC9100::def_bandwidth(int m)
 
354
{
 
355
        int bw = 0;
 
356
        switch (m) {
 
357
                case 2: // AM
 
358
                        bw = 19;
 
359
                        break;
 
360
                case 5: // FM
 
361
                        bw = 0;
 
362
                        break;
 
363
                case 4: case 7: // RTTY
 
364
                        bw = 12;
 
365
                        break;
 
366
                case 3: case 6: // CW
 
367
                        bw = 12;
 
368
                        break;
 
369
                case 8: case 9: // PKT
 
370
                        bw = 34;
 
371
                        break;
 
372
                case 0: case 1: // SSB
 
373
                case 10: case 11 : case 12 :
 
374
                case 13: case 14 : case 15 :
 
375
                default:
 
376
                        bw = 34;
 
377
        }
 
378
        return bw;
 
379
}
 
380
 
 
381
void RIG_IC9100::set_mic_gain(int v)
 
382
{
 
383
        ICvol = (int)(v * 255 / 100);
 
384
        if (!progStatus.USBaudio) {
 
385
                cmd = pre_to;
 
386
                cmd.append("\x14\x0B");
 
387
                cmd.append(to_bcd(ICvol, 3));
 
388
                cmd.append( post );
 
389
        } else {
 
390
                cmd = pre_to;
 
391
                cmd += '\x1A'; cmd += '\x05';
 
392
                cmd += '\x00'; cmd += '\x29';
 
393
                cmd.append(to_bcd(ICvol, 3));
 
394
                cmd.append( post );
 
395
        }
 
396
        sendICcommand (cmd, 6);
 
397
        checkresponse();
 
398
        if (IC9100_DEBUG)
 
399
                LOG_WARN("%s", str2hex(cmd.data(), cmd.length()));
 
400
}
 
401
 
 
402
void RIG_IC9100::set_attenuator(int val)
 
403
{
 
404
        int cmdval = 0;
 
405
        if (atten_level == 0) {
 
406
                atten_level = 1;
 
407
                atten_label("20 dB", true);
 
408
                cmdval = 0x20;
 
409
        } else {
 
410
                atten_level = 0;
 
411
                atten_label("Att", false);
 
412
                cmdval = 0x00;
 
413
        }
 
414
        cmd = pre_to;
 
415
        cmd += '\x11';
 
416
        cmd += cmdval;
 
417
        cmd.append( post );
 
418
        sendICcommand(cmd,6);
 
419
        checkresponse();
 
420
        if (IC9100_DEBUG)
 
421
                LOG_INFO("%s", str2hex(cmd.data(), cmd.length()));
 
422
}
 
423
 
 
424
int RIG_IC9100::get_attenuator()
 
425
{
 
426
        cmd = pre_to;
 
427
        cmd += '\x11';
 
428
        cmd.append( post );
 
429
        if (sendICcommand(cmd,6)) {
 
430
                if (replystr[5] == 0x20) {
 
431
                        atten_level = 1;
 
432
                        atten_label("20 dB", true);
 
433
                } else {
 
434
                        atten_level = 0;
 
435
                        atten_label("Att", false);
 
436
                }
 
437
        }
 
438
        return atten_level;
 
439
}
 
440
 
 
441
void RIG_IC9100::set_compression()
 
442
{
 
443
        if (progStatus.compON) {
 
444
                cmd.assign(pre_to).append("\x14\x0E");
 
445
                cmd.append(to_bcd(progStatus.compression * 255 / 100, 3));
 
446
                cmd.append( post );
 
447
                waitFB("set comp");
 
448
 
 
449
                cmd = pre_to;
 
450
                cmd.append("\x16\x44");
 
451
                cmd += '\x01';
 
452
                cmd.append(post);
 
453
                waitFB("set Comp ON");
 
454
 
 
455
        } else{
 
456
                cmd.assign(pre_to).append("\x16\x44");
 
457
                cmd += '\x00';
 
458
                cmd.append(post);
 
459
                waitFB("set Comp OFF");
 
460
        }
 
461
}
 
462
 
 
463
void RIG_IC9100::set_vox_onoff()
 
464
{
 
465
        cmd.assign(pre_to).append("\x16\x46");
 
466
        if (progStatus.vox_onoff) {
 
467
                cmd += '\x01';
 
468
                cmd.append( post );
 
469
                waitFB("set vox ON");
 
470
        } else {
 
471
                cmd += '\x00';
 
472
                cmd.append( post );
 
473
                waitFB("set vox OFF");
 
474
        }
 
475
}
 
476
 
 
477
void RIG_IC9100::set_vox_gain()
 
478
{
 
479
        cmd.assign(pre_to).append("\x1A\x05");
 
480
        cmd +='\x01';
 
481
        cmd +='\x25';
 
482
        cmd.append(to_bcd((int)(progStatus.vox_gain * 2.55), 3));
 
483
        cmd.append( post );
 
484
        waitFB("SET vox gain");
 
485
}
 
486
 
 
487
void RIG_IC9100::set_vox_anti()
 
488
{
 
489
        cmd.assign(pre_to).append("\x1A\x05");
 
490
        cmd +='\x01';
 
491
        cmd +='\x26';
 
492
        cmd.append(to_bcd((int)(progStatus.vox_anti * 2.55), 3));
 
493
        cmd.append( post );
 
494
        waitFB("SET anti-vox");
 
495
}
 
496
 
 
497
void RIG_IC9100::set_vox_hang()
 
498
{
 
499
        cmd.assign(pre_to).append("\x1A\x05");  //values 00-20 = 0.0 - 2.0 sec
 
500
        cmd +='\x01';
 
501
        cmd +='\x27';
 
502
        cmd.append(to_bcd((int)(progStatus.vox_hang / 10 ), 2));
 
503
        cmd.append( post );
 
504
        waitFB("SET vox hang");
 
505
}
 
506
 
 
507
// these need to be written and tested
 
508
void  RIG_IC9100::get_vox_onoff()
 
509
{
 
510
}
 
511
 
 
512
void  RIG_IC9100::get_vox_gain()
 
513
{
 
514
}
 
515
 
 
516
void  RIG_IC9100::get_vox_anti()
 
517
{
 
518
}
 
519
 
 
520
void  RIG_IC9100::get_vox_hang()
 
521
{
 
522
}
 
523
 
 
524
// CW controls
 
525
 
 
526
void RIG_IC9100::set_cw_wpm()
 
527
{
 
528
        cmd.assign(pre_to).append("\x14\x0C"); // values 0-255
 
529
        cmd.append(to_bcd(round((progStatus.cw_wpm - 6) * 255 / (60 - 6)), 3));
 
530
        cmd.append( post );
 
531
        waitFB("SET cw wpm");
 
532
}
 
533
 
 
534
void RIG_IC9100::set_cw_qsk()
 
535
{
 
536
        int n = round(progStatus.cw_qsk * 10); // values 0-255
 
537
        cmd.assign(pre_to).append("\x14\x0F");
 
538
        cmd.append(to_bcd(n, 3));
 
539
        cmd.append(post);
 
540
        waitFB("Set cw qsk delay");
 
541
}
 
542
 
 
543
void RIG_IC9100::set_cw_spot_tone()
 
544
{
 
545
        cmd.assign(pre_to).append("\x14\x09"); // values 0=300Hz 255=900Hz
 
546
        int n = round((progStatus.cw_spot_tone - 300) * 255.0 / 600.0);
 
547
        if (n > 255) n = 255;
 
548
        if (n < 0) n = 0;
 
549
        cmd.append(to_bcd(n, 3));
 
550
        cmd.append( post );
 
551
        waitFB("SET cw spot tone");
 
552
}
 
553
 
 
554
void RIG_IC9100::set_cw_vol()
 
555
{
 
556
        cmd.assign(pre_to);
 
557
        cmd.append("\x1A\x05");
 
558
        cmd += '\x00';
 
559
        cmd += '\x24';
 
560
        cmd.append(to_bcd((int)(progStatus.cw_vol * 2.55), 3));
 
561
        cmd.append( post );
 
562
        waitFB("SET cw sidetone volume");
 
563
}
 
564
 
 
565
int RIG_IC9100::get_smeter()
 
566
{
 
567
        string cstr = "\x15\x02";
 
568
        string resp = pre_fm;
 
569
        resp.append(cstr);
 
570
        cmd = pre_to;
 
571
        cmd.append(cstr);
 
572
        cmd.append( post );
 
573
        int mtr= -1;
 
574
        if (waitFOR(9, "get smeter")) {
 
575
                size_t p = replystr.rfind(resp);
 
576
                if (p != string::npos) {
 
577
                        mtr = fm_bcd(&replystr[p+6], 3);
 
578
                        mtr = (int)ceil(mtr /2.40);
 
579
                        if (mtr > 100) mtr = 100;
 
580
                }
 
581
        }
 
582
        return mtr;
 
583
}
 
584
 
 
585
int RIG_IC9100::get_power_out()
 
586
{
 
587
        string cstr = "\x15\x11";
 
588
        string resp = pre_fm;
 
589
        resp.append(cstr);
 
590
        cmd = pre_to;
 
591
        cmd.append(cstr);
 
592
        cmd.append( post );
 
593
        int mtr= -1;
 
594
        if (waitFOR(9, "get pout")) {
 
595
                size_t p = replystr.rfind(resp);
 
596
                if (p != string::npos) {
 
597
                        mtr = fm_bcd(&replystr[p+6], 3);
 
598
                        mtr = (int)ceil(mtr /2.15);
 
599
                        if (mtr > 100) mtr = 100;
 
600
                }
 
601
        }
 
602
        return mtr;
 
603
}
 
604
 
 
605
int RIG_IC9100::get_swr()
 
606
{
 
607
        string cstr = "\x15\x12";
 
608
        string resp = pre_fm;
 
609
        resp.append(cstr);
 
610
        cmd = pre_to;
 
611
        cmd.append(cstr);
 
612
        cmd.append( post );
 
613
        int mtr= -1;
 
614
        if (waitFOR(9, "get SWR")) {
 
615
                size_t p = replystr.rfind(resp);
 
616
                if (p != string::npos) {
 
617
                        mtr = fm_bcd(&replystr[p+6], 3);
 
618
                        mtr = (int)ceil(mtr /2.40);
 
619
                        if (mtr > 100) mtr = 100;
 
620
                }
 
621
        }
 
622
        return mtr;
 
623
}
 
624
 
 
625
int RIG_IC9100::get_alc()
 
626
{
 
627
        string cstr = "\x15\x13";
 
628
        string resp = pre_fm;
 
629
        resp.append(cstr);
 
630
        cmd = pre_to;
 
631
        cmd.append(cstr);
 
632
        cmd.append( post );
 
633
        int mtr= -1;
 
634
        if (waitFOR(9, "get alc")) {
 
635
                size_t p = replystr.rfind(resp);
 
636
                if (p != string::npos) {
 
637
                        mtr = fm_bcd(&replystr[p+6], 3);
 
638
                        mtr = (int)ceil(mtr /2.55);
 
639
                        if (mtr > 100) mtr = 100;
 
640
                }
 
641
        }
 
642
        return mtr;
 
643
}
 
644
 
 
645
void RIG_IC9100::set_notch(bool on, int val)
 
646
{
 
647
        int notch = (int)(val * 256.0 / 3000.0);
 
648
 
 
649
        cmd = pre_to;
 
650
        cmd.append("\x16\x48");
 
651
        cmd += on ? '\x01' : '\x00';
 
652
        cmd.append(post);
 
653
        waitFB("set notch");
 
654
 
 
655
        cmd = pre_to;
 
656
        cmd.append("\x14\x0D");
 
657
        cmd.append(to_bcd(notch,3));
 
658
        cmd.append(post);
 
659
        waitFB("set notch val");
 
660
 
 
661
}
 
662
 
 
663
bool RIG_IC9100::get_notch(int &val)
 
664
{
 
665
        bool on = false;
 
666
        val = 0;
 
667
 
 
668
        string cstr = "\x16\x48";
 
669
        string resp = pre_fm;
 
670
        resp.append(cstr);
 
671
        cmd = pre_to;
 
672
        cmd.append(cstr);
 
673
        cmd.append( post );
 
674
        if (waitFOR(8, "get notch")) {
 
675
                size_t p = replystr.rfind(resp);
 
676
                if (p != string::npos)
 
677
                        on = replystr[p + 6];
 
678
                cmd = pre_to;
 
679
                resp = pre_fm;
 
680
                cstr = "\x14\x0D";
 
681
                cmd.append(cstr);
 
682
                resp.append(cstr);
 
683
                cmd.append(post);
 
684
                if (waitFOR(9, "notch val")) {
 
685
                        size_t p = replystr.rfind(resp);
 
686
                        if (p != string::npos)
 
687
                                val = (int)ceil(fm_bcd(&replystr[p+6],3) * 3000.0 / 255.0);
 
688
                }
 
689
        }
 
690
        return on;
 
691
}
 
692
 
 
693
void RIG_IC9100::get_notch_min_max_step(int &min, int &max, int &step)
 
694
{
 
695
        min = 0;
 
696
        max = 3000;
 
697
        step = 20;
 
698
}
 
699
 
 
700
void RIG_IC9100::set_auto_notch(int val)
 
701
{
 
702
        cmd = pre_to;
 
703
        cmd += '\x16';
 
704
        cmd += '\x41';
 
705
        cmd += val ? 0x01 : 0x00;
 
706
        cmd.append( post );
 
707
        waitFB("set AN");
 
708
}
 
709
 
 
710
int RIG_IC9100::get_auto_notch()
 
711
{
 
712
        string cstr = "\x16\x41";
 
713
        string resp = pre_fm;
 
714
        resp.append(cstr);
 
715
        cmd = pre_to;
 
716
        cmd.append(cstr);
 
717
        cmd.append( post );
 
718
        if (waitFOR(8, "get AN")) {
 
719
                size_t p = replystr.rfind(resp);
 
720
                if (p != string::npos) {
 
721
                        if (replystr[p+6] == 0x01) {
 
722
                                auto_notch_label("AN", true);
 
723
                                return true;
 
724
                        } else {
 
725
                                auto_notch_label("AN", false);
 
726
                                return false;
 
727
                        }
 
728
                }
 
729
        }
 
730
        return progStatus.auto_notch;
 
731
}
 
732
 
 
733
void RIG_IC9100::set_split(bool val)
 
734
{
 
735
        cmd = pre_to;
 
736
        cmd += 0x0F;
 
737
        cmd += val ? 0x01 : 0x00;
 
738
        cmd.append(post);
 
739
        waitFB("set split");
 
740
}
 
741
 
 
742
int  RIG_IC9100::get_split()
 
743
{
 
744
        LOG_WARN("%s", "get split - not implemented");
 
745
        return progStatus.split;
 
746
/*
 
747
        cmd = pre_to;
 
748
        cmd += 0x0F;
 
749
        cmd.append(post);
 
750
        string resp = pre_fm;
 
751
        resp += 0x0F;
 
752
        if (waitFOR(8, "get split")) {
 
753
                size_t p = replystr.rfind(resp);
 
754
                if (p != string::npos)
 
755
                        return (replystr[p+6] ? 1 : 0);
 
756
        }
 
757
        return 0;
 
758
*/
 
759
}
 
760