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

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/rigs/FT747.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
 * Yaesu FT-747 drivers
 
3
 *
 
4
 * a part of flrig
 
5
 *
 
6
 * Copyright 2009, Dave Freese, W1HKJ
 
7
 *
 
8
 */
 
9
#include <stdio.h>
 
10
#include <stdlib.h>
 
11
 
 
12
#include "debug.h"
 
13
#include "util.h"
 
14
 
 
15
#include "FT747.h"
 
16
 
 
17
static const char FT747name_[] = "FT-747";
 
18
 
 
19
static const char *FT747modes_[] = {
 
20
                "LSB", "USB", "CW", "CWN", "AMW", "AMN", "FMW", "FMN", NULL};
 
21
static const char FT747_mode_type[] = { 'L', 'U', 'U', 'U', 'U', 'U', 'U', 'U' };
 
22
 
 
23
RIG_FT747::RIG_FT747() {
 
24
// base class values
 
25
        name_ = FT747name_;
 
26
        modes_ = FT747modes_;
 
27
        comm_baudrate = BR4800;
 
28
        stopbits = 2;
 
29
        comm_retries = 2;
 
30
        comm_wait = 5;
 
31
        comm_timeout = 50;
 
32
        comm_rtscts = false;
 
33
        comm_rtsplus = false;
 
34
        comm_dtrplus = true;
 
35
        comm_catptt = false;
 
36
        comm_rtsptt = false;
 
37
        comm_dtrptt = false;
 
38
        modeA = 1;
 
39
        bwA = 0;
 
40
 
 
41
        has_split = true;
 
42
        has_split_AB = true;
 
43
        has_get_info = true;
 
44
        has_ptt_control = true;
 
45
        has_mode_control = true;
 
46
 
 
47
        precision = 10;
 
48
        ndigits = 8;
 
49
 
 
50
};
 
51
 
 
52
void RIG_FT747::init_cmd()
 
53
{
 
54
        cmd = "00000";
 
55
        for (size_t i = 0; i < 5; i++) cmd[i] = 0;
 
56
}
 
57
 
 
58
void RIG_FT747::selectA()
 
59
{
 
60
        init_cmd();
 
61
        cmd[4] = 0x05;
 
62
        sendCommand(cmd);
 
63
        showresp(INFO, HEX, "select A", cmd, replystr);
 
64
}
 
65
 
 
66
void RIG_FT747::selectB()
 
67
{
 
68
        init_cmd();
 
69
        cmd[3] = 0x01;
 
70
        cmd[4] = 0x05;
 
71
        sendCommand(cmd);
 
72
        showresp(INFO, HEX, "select B", cmd, replystr);
 
73
}
 
74
 
 
75
void RIG_FT747::set_split(bool val)
 
76
{
 
77
        split = val;
 
78
        init_cmd();
 
79
        cmd[3] = val ? 0x01 : 0x00;
 
80
        cmd[4] = 0x01;
 
81
        sendCommand(cmd);
 
82
        if (val)
 
83
                showresp(INFO, HEX, "set split ON", cmd, replystr);
 
84
        else
 
85
                showresp(INFO, HEX, "set split OFF", cmd, replystr);
 
86
}
 
87
 
 
88
bool RIG_FT747::get_info()
 
89
{
 
90
        long int afreq = A.freq, bfreq = B.freq;
 
91
        int amode = A.imode;
 
92
        init_cmd();
 
93
        cmd[4] = 0x10;
 
94
        int ret = sendCommand(cmd);
 
95
        showresp(DEBUG, HEX, "get info", cmd, replystr);
 
96
 
 
97
        if (ret >= 28) {
 
98
 
 
99
// GET FREQUENCY bytes ARE NOT the same as SET FREQUENCY bytes
 
100
// returned values are packed BCD 
 
101
// | 00 00 | f2 f3 | f4 f5 | f6 f7 | f8 f9 | where
 
102
//          f2 - 10's of MHz
 
103
//          f3 - MHz
 
104
//      ... f9 - Hz
 
105
// | 00 00 | 01 04 | 02 05 | 00 00 | 00 00 | = 14.250.000 Hz
 
106
 
 
107
                afreq = fm_bcd(&replybuff[9], 8);
 
108
                bfreq = fm_bcd(&replybuff[16], 8);
 
109
 
 
110
                int md = replybuff[22];
 
111
                switch (md) {
 
112
                        case 0x01 : amode = 6; // FMW
 
113
                                                break;
 
114
                        case 0x81 : amode = 7; // FMN
 
115
                                                break;
 
116
                        case 0x02 : amode = 4; // AMW
 
117
                                                break;
 
118
                        case 0x82 : amode = 5; // AMN
 
119
                                                break;
 
120
                        case 0x04 : amode = 2; // CW
 
121
                                                break;
 
122
                        case 0x84 : amode = 3; // CWN
 
123
                                                break;
 
124
                        case 0x08 : amode = 1; // USB
 
125
                                                break;
 
126
                        case 0x10 : amode = 0; // LSB
 
127
                                                break;
 
128
                }
 
129
 
 
130
                A.freq = afreq;
 
131
                A.imode = amode;
 
132
 
 
133
                B.freq = bfreq;
 
134
                B.imode = amode;
 
135
 
 
136
                return true;
 
137
        }
 
138
        A.freq = afreq;
 
139
        A.imode = amode;
 
140
 
 
141
        B.freq = bfreq;
 
142
        B.imode = amode;
 
143
 
 
144
        return false;
 
145
}
 
146
 
 
147
long RIG_FT747::get_vfoA ()
 
148
{
 
149
        return A.freq;
 
150
}
 
151
 
 
152
void RIG_FT747::set_vfoA (long freq)
 
153
{
 
154
        A.freq = freq;
 
155
        freq /=10; // 747 does not support 1 Hz resolution
 
156
        cmd = to_bcd_be(freq, 8);
 
157
        cmd += 0x0A; // SET FREQUENCY
 
158
        SLOG_INFO("cmd: %s", str2hex(cmd.c_str(), cmd.length()));
 
159
        sendCommand(cmd);
 
160
}
 
161
 
 
162
int RIG_FT747::get_modeA()
 
163
{
 
164
        return A.imode;
 
165
}
 
166
 
 
167
void RIG_FT747::set_modeA(int val)
 
168
{
 
169
        A.imode = val;
 
170
        init_cmd();
 
171
        cmd[3] = val;
 
172
        cmd[4] = 0x0C; // MODESEL
 
173
        SLOG_INFO("cmd: %s", str2hex(cmd.c_str(), cmd.length()));
 
174
        sendCommand(cmd);
 
175
}
 
176
 
 
177
long RIG_FT747::get_vfoB ()
 
178
{
 
179
        return B.freq;
 
180
}
 
181
 
 
182
void RIG_FT747::set_vfoB (long freq)
 
183
{
 
184
        B.freq = freq;
 
185
        freq /=10;
 
186
        cmd = to_bcd_be(freq, 8);
 
187
        cmd += 0x0A; // SET FREQUENCY
 
188
        SLOG_INFO("cmd: %s", str2hex(cmd.c_str(), cmd.length()));
 
189
        sendCommand(cmd);
 
190
}
 
191
 
 
192
int RIG_FT747::get_modeB()
 
193
{
 
194
        return B.imode;
 
195
}
 
196
 
 
197
void RIG_FT747::set_modeB(int val)
 
198
{
 
199
        B.imode = val;
 
200
        init_cmd();
 
201
        cmd[3] = val;
 
202
        cmd[4] = 0x0C; // MODESEL
 
203
        SLOG_INFO("cmd: %s", str2hex(cmd.c_str(), cmd.length()));
 
204
        sendCommand(cmd);
 
205
}
 
206
 
 
207
void RIG_FT747::set_PTT_control(int val)
 
208
{
 
209
        init_cmd();
 
210
        cmd[3] = val ? 0x01 : 0x00;
 
211
        cmd[4] = 0x0F;
 
212
        sendCommand(cmd);
 
213
}
 
214