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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-10-25 11:17:10 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20141025111710-n32skgya3l9u1brw
Tags: 1.3.17-1
* New upstream release (Closes: #761839)
* Debian Standards-Version: 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Yaesu FT-990 drivers
3
 
 *
4
 
 * a part of flrig
5
 
 *
6
 
 * Copyright 2011, Dave Freese, W1HKJ
7
 
 *
8
 
 */
9
 
 
10
 
#include "FT990.h"
11
 
#include "rig.h"
12
 
 
13
 
static const char FT990name_[] = "FT-990";
14
 
static const char *FT990modes_[] =
15
 
{ "LSB", "USB", "CW2.4", "CW500",
16
 
  "AM6.0", "AM2.4", "FM",
17
 
  "RTTY(L)", "RTTY(U)", "PKT(L)", "PKT(FM)", NULL};
18
 
 
19
 
static const int FT990_def_bw[] = {
20
 
0, 0, 0, 2,
21
 
4, 0, 0,
22
 
0, 0, 0, 0 };
23
 
 
24
 
static const int FT990_mode_val[] = {
25
 
0, 1, 2, 3,
26
 
4, 5, 6,
27
 
8, 9, 10, 11 };
28
 
 
29
 
static const char FT990_mode_type[] = {
30
 
'L', 'U', 'L', 'L',
31
 
'U', 'U', 'U',
32
 
'L', 'U', 'L', 'U' };
33
 
 
34
 
static const char *FT990widths_[] =
35
 
{ "2400", "2000", "500", "250", "6000", NULL};
36
 
 
37
 
static const int FT990_bw_val[] =
38
 
{ 0, 1, 2, 3, 4 };
39
 
 
40
 
RIG_FT990::RIG_FT990() {
41
 
        name_ = FT990name_;
42
 
        modes_ = FT990modes_;
43
 
        bandwidths_ = FT990widths_;
44
 
        comm_baudrate = BR4800;
45
 
        stopbits = 2;
46
 
        comm_retries = 2;
47
 
        comm_wait = 5;
48
 
        comm_timeout = 100;
49
 
        comm_rtscts = false;
50
 
        comm_rtsplus = false;
51
 
        comm_dtrplus = true;
52
 
        comm_catptt = true;
53
 
        comm_rtsptt = false;
54
 
        comm_dtrptt = false;
55
 
        afreq = bfreq = A.freq = B.freq = 14070000;
56
 
        amode = bmode = A.imode = B.imode = 1;
57
 
        aBW = bBW = A.iBW = B.iBW = 2;
58
 
 
59
 
        precision = 10;
60
 
        ndigits = 9;
61
 
 
62
 
 
63
 
        has_split = has_split_AB =
64
 
        has_get_info =
65
 
        has_smeter =
66
 
        has_power_out =
67
 
        has_swr_control =
68
 
        has_mode_control =
69
 
        has_bandwidth_control =
70
 
        has_ptt_control = true;
71
 
 
72
 
}
73
 
 
74
 
int  RIG_FT990::adjust_bandwidth(int m)
75
 
{
76
 
        if (m == 0 || m == 1 || m == 5) return 2;
77
 
        if (m == 2 || m == 3 ) return 1;
78
 
        if (m == 4 || m == 6 || m == 7) return 3;
79
 
        return 2;
80
 
}
81
 
 
82
 
void RIG_FT990::init_cmd()
83
 
{
84
 
        cmd = "00000";
85
 
        for (size_t i = 0; i < 5; i++) cmd[i] = 0;
86
 
        replystr.clear();
87
 
}
88
 
 
89
 
void RIG_FT990::initialize()
90
 
{
91
 
}
92
 
 
93
 
void RIG_FT990::selectA()
94
 
{
95
 
        init_cmd();
96
 
        cmd[4] = 0x05;
97
 
        sendCommand(cmd);
98
 
        showresp(WARN, HEX, "select A", cmd, replystr);
99
 
}
100
 
 
101
 
void RIG_FT990::selectB()
102
 
{
103
 
        init_cmd();
104
 
        cmd[3] = 0x01;
105
 
        cmd[4] = 0x05;
106
 
        sendCommand(cmd);
107
 
        showresp(WARN, HEX, "select B", cmd, replystr);
108
 
}
109
 
 
110
 
void RIG_FT990::set_split(bool val)
111
 
{
112
 
        split = val;
113
 
        init_cmd();
114
 
        cmd[3] = val ? 0x01 : 0x00;
115
 
        cmd[4] = 0x01;
116
 
        sendCommand(cmd);
117
 
        if (val)
118
 
                showresp(WARN, HEX, "set split ON", cmd, replystr);
119
 
        else
120
 
                showresp(WARN, HEX, "set split OFF", cmd, replystr);
121
 
}
122
 
 
123
 
bool RIG_FT990::get_info()
124
 
{
125
 
        bool memmode = false, vfobmode = false;
126
 
        int pfreq, pmode, pbw;
127
 
        init_cmd();
128
 
        cmd[3] = 0x00;
129
 
        cmd[4] = 0xFA;
130
 
        int ret = waitN(5, 100, "Read flags");
131
 
 
132
 
        if (ret >= 5) {
133
 
                size_t p = ret - 5;
134
 
                memmode = ((replystr[p+1] & 0x10) == 0x10);
135
 
                vfobmode = ((replystr[p] & 0x02) == 0x02);
136
 
                if (memmode) return false;
137
 
                if (vfobmode && !useB) {
138
 
                        useB = true;
139
 
                        Fl::awake(highlight_vfo, (void *)0);
140
 
                } else if (!vfobmode && useB) {
141
 
                        useB = false;
142
 
                        Fl::awake(highlight_vfo, (void *)0);
143
 
                }
144
 
        }
145
 
 
146
 
        init_cmd();
147
 
        cmd[4] = 0x10; // update info
148
 
        cmd[0] = 0x02; // 1 16 byte sequences for current VFO / MEM
149
 
        ret = waitN(16, 100, "Read info");
150
 
 
151
 
        if (ret >= 16) {
152
 
                size_t p = ret - 16;
153
 
                // current VFO / MEM
154
 
                pfreq = 0;
155
 
                for (size_t n = 1; n < 5; n++)
156
 
                        pfreq = pfreq * 256 + (unsigned char)replystr[p + n];
157
 
                pfreq = pfreq * 1.25; // 100D resolution is 1.25 Hz / bit for read
158
 
 
159
 
                int rmode = replystr[p + 7] & 0x07;
160
 
                switch (rmode) {
161
 
                        case 0 : pmode = 0; break; // LSB
162
 
                        case 1 : pmode = 1; break; // USB
163
 
                        case 2 : pmode = 2; break; // CW
164
 
                        case 3 : pmode = 5; break; // AM
165
 
                        case 4 : pmode = 6; break; // FM
166
 
                        case 5 : pmode = 8; break; // RTTY
167
 
                        case 6 : pmode = 9; break; // PKT
168
 
                        default : pmode = 1; break;
169
 
                }
170
 
 
171
 
                int rpbw = replystr[p + 8];
172
 
                pbw = rpbw & 0x05;
173
 
                if (pbw > 4) pbw = 4;
174
 
                if ((rpbw & 0x80) == 0x80) {
175
 
                        if (pmode == 10) pmode = 11;
176
 
                        if (pmode == 8) pmode = 9;
177
 
                }
178
 
                if (pmode == 6) pbw = 0;
179
 
                if (useB) {
180
 
                        B.freq = pfreq; B.imode = pmode; B.iBW = pbw;
181
 
                } else {
182
 
                        A.freq = pfreq; A.imode = pmode; A.iBW = pbw;
183
 
                }
184
 
LOG_WARN("Vfo %c = %d, BW %s", vfobmode ? 'B' : 'A', pfreq, FT990widths_[pbw]);
185
 
                return true;
186
 
        }
187
 
        return false;
188
 
}
189
 
 
190
 
long RIG_FT990::get_vfoA ()
191
 
{
192
 
        return A.freq;
193
 
}
194
 
 
195
 
void RIG_FT990::set_vfoA (long freq)
196
 
{
197
 
        A.freq = freq;
198
 
        freq /=10; // 100D does not support 1 Hz resolution
199
 
        cmd = to_bcd_be(freq, 8);
200
 
        cmd += 0x0A;
201
 
        sendCommand(cmd);
202
 
        showresp(WARN, HEX, "set freq A", cmd, replystr);
203
 
}
204
 
 
205
 
int RIG_FT990::get_modeA()
206
 
{
207
 
        return A.imode;
208
 
}
209
 
 
210
 
void RIG_FT990::set_modeA(int val)
211
 
{
212
 
        A.imode = val;
213
 
        init_cmd();
214
 
        cmd[3] = FT990_mode_val[val];
215
 
        cmd[4] = 0x0C;
216
 
        sendCommand(cmd);
217
 
        showresp(WARN, HEX, "set mode A", cmd, replystr);
218
 
}
219
 
 
220
 
void RIG_FT990::set_bwA (int val)
221
 
{
222
 
        A.iBW = val;
223
 
        init_cmd();
224
 
        cmd[3] = FT990_bw_val[val];
225
 
        cmd[4] = 0x8C;
226
 
        sendCommand(cmd);
227
 
        showresp(WARN, HEX, "set BW A", cmd, replystr);
228
 
}
229
 
 
230
 
 
231
 
int RIG_FT990::get_bwA()
232
 
{
233
 
        return A.iBW;
234
 
}
235
 
 
236
 
long RIG_FT990::get_vfoB()
237
 
{
238
 
        return B.freq;
239
 
}
240
 
 
241
 
void RIG_FT990::set_vfoB(long freq)
242
 
{
243
 
        B.freq = freq;
244
 
        freq /=10;
245
 
        cmd = to_bcd_be(freq, 8);
246
 
        cmd += 0x0A;
247
 
        sendCommand(cmd);
248
 
        showresp(WARN, HEX, "set freq B", cmd, replystr);
249
 
}
250
 
 
251
 
void RIG_FT990::set_modeB(int val)
252
 
{
253
 
        B.imode = val;
254
 
        init_cmd();
255
 
        cmd[3] = FT990_mode_val[val];
256
 
        cmd[4] = 0x0C;
257
 
        sendCommand(cmd);
258
 
        showresp(WARN, HEX, "set mode B", cmd, replystr);
259
 
}
260
 
 
261
 
int  RIG_FT990::get_modeB()
262
 
{
263
 
        return B.imode;
264
 
}
265
 
 
266
 
void RIG_FT990::set_bwB(int val)
267
 
{
268
 
        B.iBW = val;
269
 
        init_cmd();
270
 
        cmd[3] = FT990_bw_val[val];
271
 
        cmd[4] = 0x8C;
272
 
        sendCommand(cmd);
273
 
        showresp(WARN, HEX, "set bw B", cmd, replystr);
274
 
}
275
 
 
276
 
int  RIG_FT990::get_bwB()
277
 
{
278
 
        return B.iBW;
279
 
}
280
 
 
281
 
int  RIG_FT990::def_bandwidth(int m)
282
 
{
283
 
        return FT990_def_bw[m];
284
 
}
285
 
 
286
 
// Tranceiver PTT on/off
287
 
void RIG_FT990::set_PTT_control(int val)
288
 
{
289
 
        init_cmd();
290
 
        if (val) cmd[3] = 1;
291
 
        cmd[4] = 0x0F;
292
 
        sendCommand(cmd);
293
 
        if (val)
294
 
                showresp(WARN, HEX, "set PTT ON", cmd, replystr);
295
 
        else
296
 
                showresp(WARN, HEX, "set PTT OFF", cmd, replystr);
297
 
}
298
 
 
299
 
int RIG_FT990::get_smeter()
300
 
{
301
 
        init_cmd();
302
 
        cmd[4] = 0xF7;
303
 
        int ret = waitN(5, 100, "S-meter");
304
 
        if (ret < 5) return 0;
305
 
        int sval = (unsigned char)replybuff[0];
306
 
        if (sval < 90) sval = 90;
307
 
        if (sval > 200) sval = 200;
308
 
        if (sval < 120) sval = 250 - 5 * sval / 3;
309
 
        else sval = 125 - 5 * sval / 8;
310
 
        return sval;
311
 
}
312
 
 
313
 
int RIG_FT990::get_swr()
314
 
{
315
 
        return 0;
316
 
}
317
 
 
318
 
int RIG_FT990::get_power_out()
319
 
{
320
 
        init_cmd();
321
 
        cmd[4] = 0xF7;
322
 
        int ret = waitN(5, 100, "Power out");
323
 
        if (ret < 5) return 0;
324
 
        int sval = (unsigned char)replybuff[0];
325
 
        if (sval < 90) sval = 90;
326
 
        if (sval > 200) sval = 200;
327
 
        if (sval < 120) sval = 250 - 5 * sval / 3;
328
 
        else sval = 125 - 5 * sval / 8;
329
 
        return sval;
330
 
}
331