File: 120_radio_FT847.diff

package info (click to toggle)
predict 2.2.3-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,716 kB
  • ctags: 1,623
  • sloc: ansic: 19,433; sh: 3,342; makefile: 428; yacc: 318; perl: 82
file content (259 lines) | stat: -rw-r--r-- 6,614 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
Index: predict-2.2.3/clients/gsat-1.1.0/plugins/Makefile
===================================================================
--- predict-2.2.3.orig/clients/gsat-1.1.0/plugins/Makefile	2009-11-14 11:37:00.000000000 -0500
+++ predict-2.2.3/clients/gsat-1.1.0/plugins/Makefile	2009-11-14 11:38:21.000000000 -0500
@@ -4,7 +4,7 @@
 # Edit the TARGETS line to contain only the plugins you need
 #
 
-TARGETS=radio_FT736 radio_ICR10 radio_TMD700 radio_PCR100 radio_print radio_test rotor_print rotor_pictrack
+TARGETS=radio_FT736 radio_FT847 radio_ICR10 radio_TMD700 radio_PCR100 radio_print radio_test rotor_print rotor_pictrack
 
 PLUGINDIR=/usr/local/lib/gsat/plugins
 
@@ -13,14 +13,17 @@
 radio_FT736:
 	gcc -fPIC -shared radio_FT736.c -o radio_FT736
 
+radio_FT847: radio_FT847.c
+	gcc -Wall -fPIC -shared radio_FT847.c -o radio_FT847
+
 radio_ICR10:
 	gcc -fPIC -shared radio_ICR10.c -o radio_ICR10
 
 radio_TMD700:
-	gcc -fPIC -shared radio_TMD700.c -o radio_TMD700 -lm -lD700
+	# gcc -fPIC -shared radio_TMD700.c -o radio_TMD700 -lm -lD700
 
 radio_PCR100:
-	gcc -fPIC -shared radio_PCR100.c -o radio_PCR100 -lpcr100
+	# gcc -fPIC -shared radio_PCR100.c -o radio_PCR100 -lpcr100
 
 radio_print:
 	gcc -fPIC -shared radio_print.c -o radio_print
@@ -35,7 +38,7 @@
 	gcc -fPIC -shared rotor_pictrack.c -o rotor_pictrack
 
 clean:
-	rm *.o *~ $(TARGETS)
+	-rm -f *.o *~ $(TARGETS)
 
 install:
 	cp $(TARGETS) $(PLUGINDIR)
Index: predict-2.2.3/clients/gsat-1.1.0/plugins/radio_FT847.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ predict-2.2.3/clients/gsat-1.1.0/plugins/radio_FT847.c	2009-11-14 11:38:11.000000000 -0500
@@ -0,0 +1,212 @@
+/*
+ * YAESU FT-847 plugin for gsat
+ *
+ * Copyright (C) 2003 by Ralf Baechle DO1GRB (ralf@linux-mips.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Look at the README for more information on the program.
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <fcntl.h>
+
+int plugin_open_rig(char *config);
+void plugin_close_rig(void);
+void plugin_set_downlink_frequency(double frequency);
+void plugin_set_uplink_frequency(double frequency);
+
+static int radiofd;
+
+static void cat_on(int fd)
+{
+	static const char cmd_buf[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+	write(fd, cmd_buf, 5);
+}
+
+static void cat_off(int fd)
+{
+	static const char cmd_buf[5] = { 0x00, 0x00, 0x00, 0x00, 0x80 };
+
+	write(fd, cmd_buf, 5);
+}
+
+static void cat_sat_on(int fd)
+{
+	static const char cmd_buf[5] = { 0x00, 0x00, 0x00, 0x00, 0x4e };
+
+	write(fd, cmd_buf, 5);
+}
+
+static void cat_sat_off(int fd)
+{
+	static const char cmd_buf[5] = { 0x00, 0x00, 0x00, 0x00, 0x8e };
+
+	write(fd, cmd_buf, 5);
+}
+
+static void cat_send_freq(unsigned int freq, int vfo)
+{
+	unsigned int bcd0, bcd1;
+	char cmd_buf[5];
+
+	/*
+	 * CAT only permits setting the frequency with an accuracy of 10Hz,
+	 * so we round to the nearest multiple of of 10Hz.
+	 */
+	freq = (freq + 5) / 10 * 10;
+
+	bcd0 = freq / 100000000; freq -= bcd0 * 100000000;
+	bcd1 = freq / 10000000; freq -= bcd1 * 10000000;
+	cmd_buf[0] = bcd0 << 4 | bcd1;
+
+	bcd0 = freq / 1000000; freq -= bcd0 * 1000000;
+	bcd1 = freq / 100000; freq -= bcd1 * 100000;
+	cmd_buf[1] = bcd0 << 4 | bcd1;
+
+	bcd0 = freq / 10000; freq -= bcd0 * 10000;
+	bcd1 = freq / 1000; freq -= bcd1 * 1000;
+	cmd_buf[2] = bcd0 << 4 | bcd1;
+
+	bcd0 = freq / 100; freq -= bcd0 * 100;
+	bcd1 = freq / 10; freq -= bcd1 * 10;
+	cmd_buf[3] = bcd0 << 4 | bcd1;
+
+	cmd_buf[4] = vfo;
+
+	write(radiofd, cmd_buf, 5);
+}
+
+static void cat_set_freq_sat_rx_vfo(unsigned int freq)
+{
+	cat_send_freq(freq, 0x11);
+}
+
+static void cat_set_freq_sat_tx_vfo(unsigned int freq)
+{
+	cat_send_freq(freq, 0x21);
+}
+
+char *plugin_info(void)
+{
+	return "YAESU FT847 V0.1";
+}
+
+int plugin_open_rig(char *config)
+{
+	struct termios cat_termios;
+	speed_t speed = 0;
+	char dumm[64];
+	char tty[12];
+	char *ptr, *parm;
+
+	tty[0] = '\0';
+
+	if (config) {
+		strncpy(dumm, config, 64);
+
+		ptr = dumm;
+		parm = ptr;
+		while (parm != NULL) {
+			parm = strsep(&ptr, ":");
+			if (parm == NULL)
+				break;
+			if (strlen(parm) != 0) {
+				switch (*parm) {
+				case 'D':	/* tty port */
+					strcpy(tty, parm + 1);
+					break;
+				case 'S':	/* Speed */
+					speed = atoi(parm + 1);
+					break;
+				}
+			}
+		}
+	}
+
+	if (strlen(tty) == 0)
+		strcpy(tty, "/dev/ttyS0");
+
+	/*
+	 * If no serial speed or a bad rate was specified fall back to 4800
+	 * which is the factory default for the FT-847.
+	 */
+	if (speed != 4800 && speed != 9600 && speed != 57600)
+		speed = 4800;
+
+	/*
+	 * Open CAT port
+	 */
+	radiofd = open(tty, O_RDWR | O_NOCTTY);
+	if (radiofd == -1) {
+		fprintf(stderr, "can't open %s\n", tty);
+		return 0;
+	}
+
+	/*
+	 * Set line speed to 4800 8N2
+	 */
+	tcgetattr(radiofd, &cat_termios);
+
+	cat_termios.c_cflag = CLOCAL | CS8 | CSTOPB | CREAD;
+	//cat_termios.c_cflag = CLOCAL | CS8 | CREAD;
+
+	/*
+	 * ICANON  : enable canonical input disable all echo functionality,
+	 * and don't send signals to calling program
+	 */
+	cat_termios.c_lflag |= ICANON;
+	cat_termios.c_lflag &= ~(ECHO | ECHOCTL);
+
+	/* ignore bytes with parity errors */
+	cat_termios.c_iflag |= IGNPAR;
+	cat_termios.c_iflag &= ~IXON;
+
+	/* Raw output.  */
+	cat_termios.c_oflag &= ~OPOST;
+
+	cfsetspeed(&cat_termios, speed);
+	tcsetattr(radiofd, TCSADRAIN, &cat_termios);
+	sleep(1);
+
+	cat_on(radiofd);
+	cat_sat_on(radiofd);
+
+	return 1;
+}
+
+void plugin_close_rig(void)
+{
+	cat_sat_off(radiofd);
+	cat_off(radiofd);
+
+	close(radiofd);
+}
+
+void plugin_set_downlink_frequency(double frequency)
+{
+	cat_set_freq_sat_rx_vfo((unsigned int)(frequency * 1000.0));
+}
+
+void plugin_set_uplink_frequency(double frequency)
+{
+	cat_set_freq_sat_tx_vfo((unsigned int)(frequency * 1000.0));
+}