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

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/rigs/FT847.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-847 drivers
3
 
 * 
4
 
 * a part of flrig
5
 
 * 
6
 
 * Copyright 2009, Dave Freese, W1HKJ
7
 
 * 
8
 
 */
9
 
 
10
 
#include "FT847.h"
11
 
#include "rig.h"
12
 
 
13
 
static const char FT847name_[] = "FT-847";
14
 
static const char *FT847modes_[] = 
15
 
{ "LSB", "USB", "CW", "CW-R", "AM", "FM", "CW-N", "CW-NR", "AM-N", "FM-N", NULL};
16
 
 
17
 
static const int FT847_mode_val[] =
18
 
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x08, 0x82, 0x83, 0x84, 0x88 };
19
 
 
20
 
static const char FT847_mode_type[] =
21
 
{ 'L', 'U', 'L', 'U', 'U', 'U', 'L', 'U', 'U', 'U' };
22
 
 
23
 
//static const int FT847_def_bw[] = { 2, 2, 1, 1, 3, 2, 2, 3 };
24
 
//static const char *FT847widths_[] = { "300", "500", "2400", "6000", NULL};
25
 
//static const int FT847_bw_val[] = { 0, 1, 2, 3 };
26
 
 
27
 
RIG_FT847::RIG_FT847() {
28
 
        name_ = FT847name_;
29
 
        modes_ = FT847modes_;
30
 
//      bandwidths_ = FT847widths_;
31
 
        comm_baudrate = BR9600;
32
 
        stopbits = 2;
33
 
        comm_retries = 2;
34
 
        comm_wait = 5;
35
 
        comm_timeout = 50;
36
 
        comm_rtscts = false;
37
 
        comm_rtsplus = false;
38
 
        comm_dtrplus = true;
39
 
        comm_catptt = true;
40
 
        comm_rtsptt = false;
41
 
        comm_dtrptt = false;
42
 
        afreq = A.freq = B.freq = 14070000;
43
 
        amode = A.imode = B.imode = 1;
44
 
 
45
 
        precision = 10;
46
 
        ndigits = 8;
47
 
 
48
 
 
49
 
//      has_get_info =
50
 
//      has_bandwidth_control =
51
 
        has_mode_control =
52
 
        has_ptt_control = true;
53
 
 
54
 
}
55
 
 
56
 
void RIG_FT847::init_cmd()
57
 
{
58
 
        cmd = "00000";
59
 
        for (size_t i = 0; i < 5; i++) cmd[i] = 0;
60
 
}
61
 
 
62
 
void RIG_FT847::initialize()
63
 
{
64
 
        init_cmd();
65
 
        sendCommand(cmd, 0); // CAT on
66
 
        cmd[4] = 0x8E; // satellite mode off
67
 
        replystr.clear();
68
 
        sendCommand(cmd);
69
 
        showresp(WARN, HEX, "init", cmd, replystr);
70
 
}
71
 
 
72
 
bool RIG_FT847::get_info()
73
 
{
74
 
        int ret = 0, i = 0;
75
 
 
76
 
        init_cmd();
77
 
        cmd[4] = 0x03;
78
 
        ret = waitN(5, 100, "get info", HEX);
79
 
        if (ret >= 5) {
80
 
                afreq = fm_bcd(&replystr[ret - 5], 8)*10;
81
 
                amode = replystr[ret - 1];
82
 
                for (i = 0; i < 10; i++) if (FT847_mode_val[i] == amode) break;
83
 
                if (i == 10) i = 1;
84
 
                amode = i;
85
 
                return true;
86
 
        }
87
 
        return false;
88
 
}
89
 
 
90
 
long RIG_FT847::get_vfoA ()
91
 
{
92
 
        if (get_info()) {
93
 
                A.freq = afreq;
94
 
                A.imode = amode;
95
 
                A.iBW = aBW;
96
 
        }
97
 
        return A.freq;
98
 
}
99
 
 
100
 
void RIG_FT847::set_vfoA (long freq)
101
 
{
102
 
        A.freq = freq;
103
 
        freq /=10; // 847 does not support 1 Hz resolution
104
 
        cmd = to_bcd(freq, 8);
105
 
        cmd += 0x01;
106
 
        replystr.clear();
107
 
        sendCommand(cmd);
108
 
        showresp(WARN, HEX, "set vfo A", cmd, replystr);
109
 
}
110
 
 
111
 
int RIG_FT847::get_modeA()
112
 
{
113
 
        return A.imode;
114
 
}
115
 
 
116
 
void RIG_FT847::set_modeA(int val)
117
 
{
118
 
        A.imode = val;
119
 
        init_cmd();
120
 
        cmd[0] = FT847_mode_val[val];
121
 
        cmd[4] = 0x07;
122
 
        replystr.clear();
123
 
        sendCommand(cmd);
124
 
        showresp(WARN, HEX, "set mode A", cmd, replystr);
125
 
}
126
 
 
127
 
long RIG_FT847::get_vfoB()
128
 
{
129
 
        if (get_info()) {
130
 
                B.freq = afreq;
131
 
                B.imode = amode;
132
 
                B.iBW = aBW;
133
 
        }
134
 
        return B.freq;
135
 
}
136
 
 
137
 
void RIG_FT847::set_vfoB(long freq)
138
 
{
139
 
        B.freq = freq;
140
 
        freq /=10; // 847 does not support 1 Hz resolution
141
 
        cmd = to_bcd(freq, 8);
142
 
        cmd += 0x01;
143
 
        replystr.clear();
144
 
        sendCommand(cmd);
145
 
        showresp(WARN, HEX, "set vfo B", cmd, replystr);
146
 
}
147
 
 
148
 
void RIG_FT847::set_modeB(int val)
149
 
{
150
 
        B.imode = val;
151
 
        init_cmd();
152
 
        cmd[0] = FT847_mode_val[val];
153
 
        cmd[4] = 0x07;
154
 
        replystr.clear();
155
 
        sendCommand(cmd);
156
 
        showresp(WARN, HEX, "set mode B", cmd, replystr);
157
 
}
158
 
 
159
 
int  RIG_FT847::get_modeB()
160
 
{
161
 
        return B.imode;
162
 
}
163
 
 
164
 
// Tranceiver PTT on/off
165
 
void RIG_FT847::set_PTT_control(int val)
166
 
{
167
 
        init_cmd();
168
 
        if (val) cmd[4] = 0x08;
169
 
        else cmd[4] = 0x88;
170
 
        replystr.clear();
171
 
        sendCommand(cmd);
172
 
        showresp(WARN, HEX, "set PTT", cmd, replystr);
173
 
}
174
 
 
175
 
int RIG_FT847::get_smeter()
176
 
{
177
 
        init_cmd();
178
 
        cmd[4] = 0xE7;
179
 
        int sval = 0;
180
 
        int ret = waitN(1, 100, "get smeter", HEX);
181
 
        if (ret >= 1)
182
 
                sval = (replystr[ret - 1] & 0x1F) / 32.0;
183
 
        return sval;
184
 
}
185
 
 
186
 
int RIG_FT847::get_power_out()
187
 
{
188
 
        init_cmd();
189
 
        cmd[4] = 0xF7;
190
 
        fwdpwr = 0;
191
 
        int ret = waitN(1, 100, "get power", HEX);
192
 
        if (ret >= 1)
193
 
                fwdpwr = (replystr[ret - 1] & 0x1F) / 32.0;
194
 
        return fwdpwr;
195
 
}
196