2
* Global Marine, Raytheon 152 transceiver driver
6
* Copyright 2011, Dave Freese, W1HKJ
17
//=============================================================================
19
const char RIG_RAY152name_[] = "RAY 152";
21
const char *RIG_RAY152modes_[] = { "USB", "LSB", "H3E", "A1A", "F1B", NULL};
22
static const char RIG_RAY152_mode_type[] = {'U', 'L', 'U', 'L', 'U'};
24
static GUI rig_widgets[]= {
25
{ (Fl_Widget *)btnVol, 2, 145, 50 },
26
{ (Fl_Widget *)sldrVOLUME, 54, 145, 368 },
27
{ (Fl_Widget *)sldrRFGAIN, 54, 125, 156 },
28
{ (Fl_Widget *)sldrSQUELCH, 266, 125, 156 },
29
{ (Fl_Widget *)NULL, 0, 0, 0 }
32
RIG_RAY152::RIG_RAY152() {
33
name_ = RIG_RAY152name_;
34
modes_ = RIG_RAY152modes_;
36
widgets = rig_widgets;
38
comm_baudrate = BR1200;
62
has_mode_control = true;
63
has_ptt_control = true;
64
has_rf_control = true;
65
has_volume_control = true;
67
has_sql_control = true;
68
has_noise_control = true;
69
has_auto_notch = true;
73
static void nocr( string & s)
75
for (size_t i = 0; i < s.length(); i++)
76
if (s[i] == '\r') s[i] = ' ';
80
Data string returned by the 'O' command
82
5 C***\r Memory channel #
83
5 D+/-**\r Clarifier frequency
84
9 FT******\r Transmit frequemcy
85
9 FR******\r Receive frequency
86
6 I****\r ITU channel #
88
3 N*\r Noise blanker status
89
3 P*\r Power reduction status
90
5 Q***\r Squelch setting
91
5 R***\r RF gain setting
92
5 V***\r Volume setting
96
void RIG_RAY152::get_data()
98
int ret = sendCommand("O\r");
101
//replystr = "A1\rC000\rD-05\rFT1407000\rFR1407000\rI0000\rM1\rN1\rP0\rQ000\rR100\rV128\rZ1\r";
104
LOG_WARN("\n%s", replystr.c_str());
109
pos = replystr.find("FR"); // receive frequency
110
if (pos != string::npos) {
112
sscanf(&replystr[pos + 2], "%d", &freq);
116
pos = replystr.find("M"); // mode
117
if (pos != string::npos)
118
A.imode = replystr[pos + 1] - '1';
120
pos = replystr.find("D");
121
if (pos != string::npos) {
122
sscanf(&replystr[pos + 1], "%d", &RitFreq);
126
pos = replystr.find("\rR");
127
if (pos != string::npos)
128
sscanf(&replystr[pos + 2], "%d", &rfg);
130
pos = replystr.find("V");
131
if (pos != string::npos) {
132
sscanf(&replystr[pos + 1], "%d", &vol);
137
pos = replystr.find("Q");
138
if (pos != string::npos) {
139
sscanf(&replystr[pos + 1], "%d", &squelch);
142
pos = replystr.find("N");
143
if (pos != string::npos) {
144
if (replystr[pos + 1] > '0') {
145
nb_set = replystr[pos+1];
154
// RAY152 usurps the autonotch button for AGC control
155
pos = replystr.find("A");
156
if (pos != string::npos)
157
agc = replystr[1] == '1' ? 1 : 0;
161
void RIG_RAY152::initialize()
163
rig_widgets[0].W = btnVol;
164
rig_widgets[1].W = sldrVOLUME;
165
rig_widgets[2].W = sldrRFGAIN;
166
rig_widgets[3].W = sldrSQUELCH;
168
sendCommand("E1\r", 0);
169
sendCommand("Z1\r", 0);
175
void RIG_RAY152::shutdown()
177
sendCommand("E0\r", 0);
178
LOG_INFO("%s", cmd.c_str());
181
long RIG_RAY152::get_vfoA ()
186
void RIG_RAY152::set_vfoA (long freq)
191
cmd[7] += freq % 10; freq /= 10;
192
cmd[6] += freq % 10; freq /= 10;
193
cmd[5] += freq % 10; freq /= 10;
194
cmd[4] += freq % 10; freq /= 10;
195
cmd[3] += freq % 10; freq /=10;
198
LOG_INFO("%s", cmd.c_str());
201
LOG_INFO("%s", cmd.c_str());
204
long RIG_RAY152::get_vfoB ()
209
void RIG_RAY152::set_vfoB (long freq)
214
cmd[7] += freq % 10; freq /= 10;
215
cmd[6] += freq % 10; freq /= 10;
216
cmd[5] += freq % 10; freq /= 10;
217
cmd[4] += freq % 10; freq /= 10;
218
cmd[3] += freq % 10; freq /=10;
221
LOG_INFO("%s", cmd.c_str());
224
LOG_INFO("%s", cmd.c_str());
227
void RIG_RAY152::set_PTT_control(int val)
229
cmd = val ? "X1\r" : "X0\r";
231
LOG_INFO("%s", cmd.c_str());
234
void RIG_RAY152::set_modeA(int md)
241
LOG_INFO("%s", cmd.c_str());
244
int RIG_RAY152::get_modeA()
249
void RIG_RAY152::set_modeB(int md)
256
LOG_INFO("%s", cmd.c_str());
259
int RIG_RAY152::get_modeB()
264
int RIG_RAY152::get_modetype(int n)
266
return RIG_RAY152_mode_type[n];
269
void RIG_RAY152::set_volume_control(int val)
272
string cmd = "V000\r";
275
cmd[3] += val % 10; val /= 10;
276
cmd[2] += val % 10; val /= 10;
279
LOG_INFO("%s", cmd.c_str());
282
void RIG_RAY152::set_rf_gain(int val)
286
cmd[3] += val % 10; val /= 10;
287
cmd[2] += val % 10; val /= 10;
290
LOG_INFO("%s", cmd.c_str());
293
int RIG_RAY152::get_smeter(void)
296
int ret = sendCommand(cmd);
299
LOG_WARN("%s", s.c_str());
300
if (ret < 5) return 0;
301
if (replystr[ret - 5] == 'U') {
303
sscanf(&replystr[ret - 5 + 1], "%d", &val);
304
val = (int)(60.0 * (256.0 / (val + 16.0) - 1.0));
305
if (val > 100) val = 100;
306
if (val < 0) val = 0;
312
int RIG_RAY152::get_power_out(void)
314
int ret = sendCommand("U\r");
315
if (ret < 5) return 0;
316
if (replystr[ret - 5] == 'U') {
318
sscanf(&replystr[ret - 5 + 1], "%d", &val);
327
void RIG_RAY152::setRit(int v)
331
if (v < 0) cmd[1] = '-';
334
cmd[3] += v % 10; v /= 10;
337
LOG_INFO("%s", cmd.c_str());
340
int RIG_RAY152::getRit()
345
void RIG_RAY152::set_squelch(int val)
349
cmd[3] += val % 10; val /= 10;
350
cmd[2] += val % 10; val /= 10;
353
LOG_INFO("%s", cmd.c_str());
356
int RIG_RAY152::get_squelch()
361
void RIG_RAY152::set_noise(bool on)
364
cmd[1] = on ? nb_set : '0';
366
LOG_INFO("%s", cmd.c_str());
369
int RIG_RAY152::get_noise()
374
void RIG_RAY152::set_auto_notch(int v)
377
cmd[1] = v ? '1' : '0';
379
LOG_INFO("%s", cmd.c_str());
382
int RIG_RAY152::get_auto_notch()