1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 // David Freese, W1HKJ
4 //
5 // This file is part of flrig.
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // aunsigned long int with this program. If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20
21 #include "IC735.h"
22
23 //=============================================================================
24 // IC-735
25 //
26 const char IC735name_[] = "IC-735";
27 const char *IC735modes_[] = { "LSB", "USB", "AM", "CW", "RTTY", "FM", NULL};
28
RIG_IC735()29 RIG_IC735::RIG_IC735() {
30 name_ = IC735name_;
31 modes_ = IC735modes_;
32 comm_baudrate = BR1200;
33 stopbits = 2;
34 comm_retries = 2;
35 comm_wait = 10;
36 comm_timeout = 50;
37 comm_echo = true;
38 comm_rtscts = false;
39 comm_rtsplus = true;
40 comm_dtrplus = true;
41 comm_catptt = false;
42 comm_rtsptt = false;
43 comm_dtrptt = false;
44 modeA = 1;
45 bwA = 0;
46
47 has_mode_control = true;
48 has_bandwidth_control = true;
49
50 defaultCIV = 0x04;
51 adjustCIV(defaultCIV);
52
53 precision = 10;
54 ndigits = 7;
55
56 };
57
58 //=============================================================================
selectA()59 void RIG_IC735::selectA()
60 {
61 cmd = pre_to;
62 cmd += '\x07';
63 cmd += '\x00';
64 cmd.append(post);
65 waitFB("select A");
66 }
67
selectB()68 void RIG_IC735::selectB()
69 {
70 cmd = pre_to;
71 cmd += '\x07';
72 cmd += '\x01';
73 cmd.append(post);
74 waitFB("select B");
75 }
76
check()77 bool RIG_IC735::check ()
78 {
79 string resp = pre_fm;
80 resp += '\x03';
81 cmd = pre_to;
82 cmd += '\x03';
83 cmd.append( post );
84 bool ok = waitFOR(10, "check vfo");
85 rig_trace(2, "check()", str2hex(replystr.c_str(), replystr.length()));
86 return ok;
87 }
88
get_vfoA()89 unsigned long int RIG_IC735::get_vfoA ()
90 {
91 if (useB) return A.freq;
92 string cstr = "\x03";
93 string resp = pre_fm;
94 resp.append(cstr);
95 cmd = pre_to;
96 cmd.append(cstr);
97 cmd.append( post );
98 if (waitFOR(10, "get vfo A")) {
99 size_t p = replystr.rfind(resp);
100 if (p != string::npos) {
101 if (replystr[p+5] == -1)
102 A.freq = 0;
103 else
104 freqA = fm_bcd_be(replystr.substr(p+5), 8);
105 }
106 }
107 return freqA;
108 }
109
set_vfoA(unsigned long int freq)110 void RIG_IC735::set_vfoA (unsigned long int freq)
111 {
112 freqA = freq;
113 cmd = pre_to;
114 cmd += '\x05';
115 cmd.append( to_bcd_be( freq, 8 ) );
116 cmd.append( post );
117 waitFB("set vfo A");
118 }
119
get_vfoB()120 unsigned long int RIG_IC735::get_vfoB ()
121 {
122 if (!useB) return B.freq;
123 string cstr = "\x03";
124 string resp = pre_fm;
125 resp.append(cstr);
126 cmd = pre_to;
127 cmd.append(cstr);
128 cmd.append( post );
129 if (waitFOR(10, "get vfo B")) {
130 size_t p = replystr.rfind(resp);
131 if (p != string::npos) {
132 if (replystr[p+5] == -1)
133 A.freq = 0;
134 else
135 freqB = fm_bcd_be(replystr.substr(p+5), 8);
136 }
137 }
138 return freqB;
139 }
140
set_vfoB(unsigned long int freq)141 void RIG_IC735::set_vfoB (unsigned long int freq)
142 {
143 freqA = freq;
144 cmd = pre_to;
145 cmd += '\x05';
146 cmd.append( to_bcd_be( freq, 8 ) );
147 cmd.append( post );
148 waitFB("set vfo B");
149 }
150
set_modeA(int val)151 void RIG_IC735::set_modeA(int val)
152 {
153 modeA = val;
154 cmd = pre_to;
155 cmd += "\x06";
156 cmd += modeA; // set the mode byte
157 cmd.append( post );
158 waitFB("set mode");
159 }
160
get_modeA()161 int RIG_IC735::get_modeA()
162 {
163 cmd = pre_to;
164 cmd += '\x04';
165 cmd.append(post);
166 string resp = pre_fm;
167 resp += '\x04';
168 if (waitFOR(7, "get mode")) {
169 size_t p = replystr.rfind(resp);
170 if (p != string::npos) {
171 if (replystr[p+5] == -1) { modeA = 0; }
172 else {
173 modeA = replystr[p+5];
174 }
175 }
176 }
177 return modeA;
178 }
179