fldigi 0.0.11 → 0.0.12

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/fldigi.rb +69 -39
  3. metadata +6 -8
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01ed9311a2dcab94b12c12beec7d3aacdb07621c
4
+ data.tar.gz: a099959442ab9775b6631cf26f39d1bc16ef9042
5
+ SHA512:
6
+ metadata.gz: e00f032b5347b1425347ff6ef02668efc4f1cd8f8300390a7ad014e7c70dbc53a26b37ba99dbc6fb7b6f478c39c2c60039d7852dfc4bbb62ef32a15cd0581dba
7
+ data.tar.gz: 4fcc64a79d71b3739a0d6ba26e8ccc8be56315762b15a6643c72d1d327f29a78f496ec8b0da0153a4c6a02b92edbf2fc8d77522d4a72ae74998360e6054deb09
@@ -13,11 +13,16 @@
13
13
  #
14
14
  # http://www.w1hkj.com/FldigiHelp-3.22/xmlrpc-control.html
15
15
  #
16
- # More documentation is forthcoming, but for the moment, refer to the
17
- # clients published along with this library to see how to use it.
18
-
16
+ # More documentation for this code is forthcoming, but for the moment,
17
+ # refer to the clients published on my web page to see how to use it.
18
+ #
19
19
  # Version History:
20
20
  #
21
+ # 0.0.12 - 06/05/2014 - jfrancis - Allows for additional data to be
22
+ # appended to the output queue during transmit. Also now defaults to
23
+ # not displaying a running output of transmitted data (though it can
24
+ # be switched back on with a 'true' flag to send_buffer()).
25
+ #
21
26
  # 0.0.11 - 05/29/2014 - jfrancis - Added optional offset.
22
27
  #
23
28
  # 0.0.10 - 05/26/2014 - jfrancis - Forgot the 'require'.
@@ -33,17 +38,19 @@
33
38
  # 0.0.6 - 05/25/2014 - jfrancis - First public release on
34
39
  # rubygems.org.
35
40
 
36
- require "xmlrpc/client"
41
+ require 'xmlrpc/client'
42
+ require 'thread'
37
43
 
38
44
  class Fldigi
39
- attr_accessor :rigctl, :freq, :carrier, :call, :modem, :afc, :rsid, :sideband, :squelch, :slevel, :spot, :delay, :grid, :phg, :band, :offset
45
+ attr_accessor :rigctl, :freq, :carrier, :call, :modem, :afc, :rsid, :sideband, :squelch, :slevel, :spot, :delay, :grid, :phg, :band, :offset, :start_wait, :char_wait
40
46
 
41
47
  # Do the initial setup. All arguments are optional, default is
42
48
  # rigctl, localhost, standard port. If you have no rig control,
43
- # call with "Fldigi.new(false)". If you want to remote control an
44
- # FLDigi instance that's not on the local machine and/or has a
45
- # non-standard port number, you'll have to supply all three options,
46
- # like "Fldigi.new(true,10.1.2.3,7362)".
49
+ # call with Fldigi.new(false) (ie, it assumes you do have rig
50
+ # control). If you want to remote control an FLDigi instance that's
51
+ # not on the local machine and/or has a non-standard port number,
52
+ # you'll have to supply all three options, like
53
+ # Fldigi.new(true,10.1.2.3,7362).
47
54
  def initialize(rigctl=true, host="127.0.0.1", port=7362)
48
55
  # Housekeeping.
49
56
  @host=host
@@ -74,6 +81,8 @@ class Fldigi
74
81
  @spot_old=nil
75
82
  @offset=0
76
83
  @offset_old=0
84
+ @start_wait=10
85
+ @char_wait=2
77
86
 
78
87
  # Propnet stuff.
79
88
  @band=nil
@@ -85,6 +94,7 @@ class Fldigi
85
94
 
86
95
  # Connect to the FLDigi instance.
87
96
  @srvr=XMLRPC::Client.new(host,"/RPC2",port)
97
+ @m=Mutex.new
88
98
  end
89
99
 
90
100
  # Send a command to FLDigi.
@@ -250,7 +260,7 @@ class Fldigi
250
260
 
251
261
  # Set FLDigi to transmit (immediate). When switched to transmit,
252
262
  # FLDigi will send whatever text exists in FLDigi's transmit buffer
253
- # (which is *not* the same thing as the object's internal message
263
+ # (which is *not* the same thing as this object's internal message
254
264
  # queue called @message).
255
265
  def transmit
256
266
  if self.sendcmd("main.get_trx_status")=="tx"
@@ -267,48 +277,66 @@ class Fldigi
267
277
 
268
278
  # Send the currently buffered data using the carrier, mode,
269
279
  # frequency, etc. currently configured. The current code will wait
270
- # up to ten seconds for the first character to be transmitted (this
271
- # gives time for really slow modems to get rolling). Once the first
272
- # sent character is detected, it makes sure it sees as least one
273
- # character every two seconds (which again, is just enough for the
274
- # very slowest modem). You can set the two second value lower if
275
- # you're only going to use fast modems, but if you forget and use a
276
- # slow modem with this set lower, you'll chop off your own
277
- # transmissions. This value also affects how long of an idle is
278
- # left after the last character. Everything's a trade-off...
279
- def send_buffer
280
+ # up to @start_wait (10) seconds for the first character to be
281
+ # transmitted (this gives time for really slow modems to get
282
+ # rolling). Once the first sent character is detected, it makes
283
+ # sure it sees as least one character every @char_wait (2) seconds
284
+ # (which again, is just enough for the very slowest modem). You can
285
+ # set the @char_wait value lower if you're only going to use fast
286
+ # modems, but if you forget and use a slow modem with this set
287
+ # lower, you'll chop off your own transmissions before completion.
288
+ # This value also affects how long of an idle is left after the last
289
+ # character before switching back to receive. Everything's a
290
+ # trade-off... If you keep adding data to the buffer (ie, calling
291
+ # add_tx_string()) while transmitting, it'll keep sending data until
292
+ # the buffer is empty. If you set verbose to true, send_buffer()
293
+ # will display a running stream of transmitted data to STDOUT.
294
+ def send_buffer(verbose=false)
280
295
  if @message.length > 0
281
- self.sendcmd("text.add_tx",@message)
282
296
  self.transmit()
283
- waited=0
284
- max=10
285
-
286
- result="xxx"
287
297
  show=""
288
- while waited<max
289
- waited=waited+1
290
- result=self.get_tx_data()
291
- if result.length > 0
292
- max=2
293
- waited=0
294
- show=show+result
295
- puts show
298
+ while @message.length > 0
299
+ @m.synchronize do
300
+ self.sendcmd("text.add_tx",@message)
301
+ @message=""
302
+ end
303
+ waited=0
304
+ max=@start_wait
305
+
306
+ result=""
307
+ while waited<max
308
+ waited=waited+1
309
+ result=self.get_tx_data()
310
+ if result.length > 0
311
+ max=@char_wait
312
+ waited=0
313
+ show=show+result
314
+ if verbose
315
+ puts show
316
+ end
317
+ end
318
+ sleep 1
296
319
  end
297
- sleep 1
298
320
  end
299
-
300
- self.receive()
301
- return show
302
321
  end
322
+ self.receive()
323
+ return show
303
324
  end
304
325
 
305
326
  # Add a string of text to the outgoing buffer. If you want carriage
306
327
  # returns, you must supply them as part of the text (ie, "foo\n").
307
328
  def add_tx_string(text)
308
- @message=@message+text
329
+ @m.synchronize do
330
+ @message=@message+text
331
+ end
309
332
  return @message
310
333
  end
311
334
 
335
+ # Return the modem signal quality in the range [0:100]
336
+ def quality
337
+ return self.sendcmd("modem.get_quality")
338
+ end
339
+
312
340
  # Return the received data accumulated since the last time you asked.
313
341
  def get_rx_data
314
342
  return self.sendcmd("rx.get_data")
@@ -335,7 +363,9 @@ class Fldigi
335
363
  # object's message queue, but does not change what may or may not be
336
364
  # queued in FLDigi for transmission (clear_tx_data() does that).
337
365
  def clear_message
338
- @message=""
366
+ @m.synchronize do
367
+ @message=""
368
+ end
339
369
  end
340
370
 
341
371
  # Return a list of valid modems supported by FLDigi. Note that not
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fldigi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
5
- prerelease:
4
+ version: 0.0.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeff Francis, N0GQ
@@ -21,26 +20,25 @@ files:
21
20
  homepage: http://fldigi.gritch.org/
22
21
  licenses:
23
22
  - MIT
23
+ metadata: {}
24
24
  post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
- none: false
30
29
  requirements:
31
- - - ! '>='
30
+ - - '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  required_rubygems_version: !ruby/object:Gem::Requirement
35
- none: false
36
34
  requirements:
37
- - - ! '>='
35
+ - - '>='
38
36
  - !ruby/object:Gem::Version
39
37
  version: '0'
40
38
  requirements: []
41
39
  rubyforge_project:
42
- rubygems_version: 1.8.23
40
+ rubygems_version: 2.0.14
43
41
  signing_key:
44
- specification_version: 3
42
+ specification_version: 4
45
43
  summary: A library for talking to FLDigi.
46
44
  test_files: []