fldigi 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/fldigi.rb +81 -29
- metadata +1 -1
data/lib/fldigi.rb
CHANGED
@@ -16,17 +16,36 @@
|
|
16
16
|
# More documentation is forthcoming, but for the moment, refer to the
|
17
17
|
# clients published along with this library to see how to use it.
|
18
18
|
|
19
|
+
# Version History:
|
20
|
+
#
|
21
|
+
# 0.0.9 - 05/26/2014 - jfrancis - Added a lot of code comments.
|
22
|
+
#
|
23
|
+
# 0.0.8 - 05/26/2014 - jfrancis - Fixed 10m propnet frequency. Got
|
24
|
+
# carried away with 0.0.7 fix, and had one too many zeros in there.
|
25
|
+
#
|
26
|
+
# 0.0.7 - 05/26/2014 - jfrancis - All propnet frequencies were low by
|
27
|
+
# an order of magnitude (ie, left off a zero).
|
28
|
+
#
|
29
|
+
# 0.0.6 - 05/25/2014 - jfrancis - First public release on
|
30
|
+
# rubygems.org.
|
31
|
+
|
19
32
|
class Fldigi
|
20
33
|
attr_accessor :rigctl, :freq, :carrier, :call, :modem, :afc, :rsid, :sideband, :squelch, :slevel, :spot, :delay, :grid, :phg, :band
|
21
34
|
|
22
35
|
# Do the initial setup. All arguments are optional, default is
|
23
|
-
# rigctl, localhost, standard port.
|
36
|
+
# rigctl, localhost, standard port. If you have no rig control,
|
37
|
+
# call with "Fldigi.new(false)". If you want to remote control an
|
38
|
+
# FLDigi instance that's not on the local machine and/or has a
|
39
|
+
# non-standard port number, you'll have to supply all three options,
|
40
|
+
# like "Fldigi.new(true,10.1.2.3,7362)".
|
24
41
|
def initialize(rigctl=true, host="127.0.0.1", port=7362)
|
42
|
+
# Housekeeping.
|
25
43
|
@host=host
|
26
44
|
@port=port
|
27
45
|
@message=""
|
28
46
|
@rigctl=rigctl
|
29
47
|
|
48
|
+
# Set up the defaults.
|
30
49
|
@freq=14070000.0
|
31
50
|
@freq_old=nil
|
32
51
|
@carrier=1000
|
@@ -48,6 +67,7 @@ class Fldigi
|
|
48
67
|
@spot=nil
|
49
68
|
@spot_old=nil
|
50
69
|
|
70
|
+
# Propnet stuff.
|
51
71
|
@band=nil
|
52
72
|
@fsym=nil
|
53
73
|
@delay=nil
|
@@ -55,22 +75,21 @@ class Fldigi
|
|
55
75
|
@phg=nil
|
56
76
|
@phgtext=""
|
57
77
|
|
78
|
+
# Connect to the FLDigi instance.
|
58
79
|
@srvr=XMLRPC::Client.new(host,"/RPC2",port)
|
59
80
|
end
|
60
81
|
|
61
82
|
# Send a command to FLDigi.
|
62
83
|
def sendcmd(cmd, param=-1)
|
63
84
|
if param==-1
|
64
|
-
#puts "#{cmd}"
|
65
85
|
return @srvr.call(cmd)
|
66
86
|
else
|
67
|
-
#puts "#{cmd} : #{param}"
|
68
87
|
return @srvr.call(cmd,param)
|
69
88
|
end
|
70
89
|
end
|
71
90
|
|
72
91
|
# Push all of the changed settings to FLDigi. Anything that has not
|
73
|
-
#
|
92
|
+
# changed is not pushed (to save time).
|
74
93
|
def config
|
75
94
|
|
76
95
|
# Set the audio carrier.
|
@@ -118,7 +137,8 @@ class Fldigi
|
|
118
137
|
end
|
119
138
|
end
|
120
139
|
|
121
|
-
# Set the sideband ("USB"/"LSB").
|
140
|
+
# Set the sideband ("USB"/"LSB"). ToDo: make sure this is
|
141
|
+
# correct.
|
122
142
|
if @sideband!=@sideband_old
|
123
143
|
@sideband_old=@sideband
|
124
144
|
if @sideband!=self.sendcmd("main.get_sideband")
|
@@ -164,11 +184,16 @@ class Fldigi
|
|
164
184
|
end
|
165
185
|
|
166
186
|
# Set the radio frequency (in hz). If the user has specified no
|
167
|
-
# rig control, it simply returns
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
187
|
+
# rig control, it simply returns true and ignores the provided
|
188
|
+
# value (this is so people who don't have rig control can still
|
189
|
+
# use the other features of the library, they just can't set the
|
190
|
+
# radio frequency). Otherwise, it returns true if successful in
|
191
|
+
# setting the frequency, false if it fails. The sleep here gives
|
192
|
+
# the radio time to change frequencies before checking. 0.5
|
193
|
+
# seconds work with all of my radios, but it's possible this will
|
194
|
+
# need to be tweaked. Send me an e-mail if this value is not
|
195
|
+
# adequate for your radio, and I'll figure out a plan. So far, it
|
196
|
+
# works on my IC-706MkII, my IC-756Pro, and my FT-817.
|
172
197
|
@freq=@freq.to_f
|
173
198
|
if @freq!=@freq_old and @rigctl
|
174
199
|
@freq_old=@freq
|
@@ -198,7 +223,10 @@ class Fldigi
|
|
198
223
|
end
|
199
224
|
end
|
200
225
|
|
201
|
-
# Set FLDigi to transmit (immediate).
|
226
|
+
# Set FLDigi to transmit (immediate). When switched to transmit,
|
227
|
+
# FLDigi will send whatever text exists in FLDigi's transmit buffer
|
228
|
+
# (which is *not* the same thing as the object's internal message
|
229
|
+
# queue called @message).
|
202
230
|
def transmit
|
203
231
|
if self.sendcmd("main.get_trx_status")=="tx"
|
204
232
|
return true
|
@@ -213,7 +241,16 @@ class Fldigi
|
|
213
241
|
end
|
214
242
|
|
215
243
|
# Send the currently buffered data using the carrier, mode,
|
216
|
-
# frequency, etc. currently configured.
|
244
|
+
# frequency, etc. currently configured. The current code will wait
|
245
|
+
# up to ten seconds for the first character to be transmitted (this
|
246
|
+
# gives time for really slow modems to get rolling). Once the first
|
247
|
+
# sent character is detected, it makes sure it sees as least one
|
248
|
+
# character every two seconds (which again, is just enough for the
|
249
|
+
# very slowest modem). You can set the two second value lower if
|
250
|
+
# you're only going to use fast modems, but if you forget and use a
|
251
|
+
# slow modem with this set lower, you'll chop off your own
|
252
|
+
# transmissions. This value also affects how long of an idle is
|
253
|
+
# left after the last character. Everything's a trade-off...
|
217
254
|
def send_buffer
|
218
255
|
if @message.length > 0
|
219
256
|
self.sendcmd("text.add_tx",@message)
|
@@ -241,39 +278,44 @@ class Fldigi
|
|
241
278
|
end
|
242
279
|
|
243
280
|
# Add a string of text to the outgoing buffer. If you want carriage
|
244
|
-
# returns, you must supply them.
|
281
|
+
# returns, you must supply them as part of the text (ie, "foo\n").
|
245
282
|
def add_tx_string(text)
|
246
283
|
@message=@message+text
|
247
284
|
return @message
|
248
285
|
end
|
249
286
|
|
250
|
-
#
|
287
|
+
# Return the received data accumulated since the last time you asked.
|
251
288
|
def get_rx_data
|
252
289
|
return self.sendcmd("rx.get_data")
|
253
290
|
end
|
254
291
|
|
255
|
-
#
|
292
|
+
# Return the tranmitted data accumulated since the last time you asked.
|
256
293
|
def get_tx_data
|
257
294
|
return self.sendcmd("tx.get_data")
|
258
295
|
end
|
259
296
|
|
260
|
-
# Clear
|
261
|
-
# this).
|
297
|
+
# Clear FLDigi's incoming data buffer (you probably don't want to do
|
298
|
+
# this, except *possibly* the first time you connect).
|
262
299
|
def clear_rx_data
|
263
300
|
return self.sendcmd("text.clear_rx")
|
264
301
|
end
|
265
302
|
|
266
|
-
# Clear any buffered untransmitted data
|
303
|
+
# Clear any buffered untransmitted data (as with clear_rx_data(),
|
304
|
+
# this is something you'll use sparingly, if at all).
|
267
305
|
def clear_tx_data
|
268
306
|
return self.sendcmd("text.clear_tx")
|
269
307
|
end
|
270
308
|
|
271
|
-
# Clear out the internal buffered message.
|
309
|
+
# Clear out the internal buffered message. This clears the internal
|
310
|
+
# object's message queue, but does not change what may or may not be
|
311
|
+
# queued in FLDigi for transmission (clear_tx_data() does that).
|
272
312
|
def clear_message
|
273
313
|
@message=""
|
274
314
|
end
|
275
315
|
|
276
|
-
# Return a list of valid modems.
|
316
|
+
# Return a list of valid modems supported by FLDigi. Note that not
|
317
|
+
# all modems make sense and/or will work. Like Feld Hell, for
|
318
|
+
# example. Or the Wefax modes.
|
277
319
|
def list_modems
|
278
320
|
return self.sendcmd("modem.get_names")
|
279
321
|
end
|
@@ -284,16 +326,23 @@ class Fldigi
|
|
284
326
|
return self.sendcmd("fldigi.list")
|
285
327
|
end
|
286
328
|
|
287
|
-
# Setup for propnet.
|
288
|
-
# propnet() can be called as many times as desired. If
|
289
|
-
# @grid, @phg, or @call changes between calls to propnet(),
|
290
|
-
# method must be called again.
|
329
|
+
# Setup for propnet. You must call config() one time after this
|
330
|
+
# before propnet() can be called as many times as desired. If
|
331
|
+
# @band, @grid, @phg, or @call changes between calls to propnet(),
|
332
|
+
# this method (and config()) must be called again.
|
291
333
|
def propnet_config
|
292
334
|
if @call and @grid and @band and @phg
|
293
335
|
|
336
|
+
# We don't want the carrier wandering around while doing
|
337
|
+
# propnet.
|
294
338
|
@afc=false
|
339
|
+
|
340
|
+
# The carrier for North America is 1500hz. Might (probably is)
|
341
|
+
# different for other places. ToDo: fix this so it's
|
342
|
+
# user-settable.
|
295
343
|
@carrier=1500
|
296
344
|
|
345
|
+
# Transmit frequencies are pre-defined by the propnet folks.
|
297
346
|
case @band.to_i
|
298
347
|
when 80
|
299
348
|
@freq=3598200
|
@@ -325,27 +374,30 @@ class Fldigi
|
|
325
374
|
else
|
326
375
|
return false
|
327
376
|
end
|
328
|
-
|
377
|
+
|
378
|
+
# Figure out how long to sleep based on the supplied PHG value.
|
329
379
|
if @phg[7,1].to_i==0
|
330
380
|
@delay=nil
|
331
381
|
else
|
332
382
|
@delay=3600/(@phg[7,1].to_i)
|
333
383
|
end
|
334
384
|
|
385
|
+
# Construct the actual string to be sent.
|
335
386
|
tmp="#{@call.downcase}>#{@fsym}:[#{@grid}]#{@phg}/^"
|
336
387
|
tmp=tmp+((self.crc16(tmp)).to_s(16)).upcase
|
337
388
|
@phgtext="FOR INFO: http://www.PropNET.org\n"+tmp
|
338
389
|
end
|
339
390
|
end
|
340
391
|
|
341
|
-
#
|
342
|
-
# @band, and @phg to be
|
392
|
+
# Queue the pre-built PropNET packet (must call propnet_config() and
|
393
|
+
# config() first). Requires @grid, @call, @band, and @phg to be
|
394
|
+
# set. Call send_buffer() after to start the actual transmission.
|
343
395
|
def propnet
|
344
396
|
self.add_tx_string(@phgtext)
|
345
397
|
end
|
346
398
|
|
347
|
-
#
|
348
|
-
# false. Call send_buffer() after.
|
399
|
+
# Queues up a CQ call. Requires that @call be previously set, else
|
400
|
+
# returns false. Call send_buffer() after to begin transmission.
|
349
401
|
def cq
|
350
402
|
if @call
|
351
403
|
self.add_tx_string("CQ CQ CQ de #{@call} #{@call} #{@call} pse k")
|