fldigi 0.1.6 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/fldigi.rb +39 -59
  3. metadata +5 -7
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmZlZTZmNTkyOWU3N2EwMDQ5ZDVjNTFhY2NjZTJhZTMyZTFkYWY2Mg==
5
+ data.tar.gz: !binary |-
6
+ MzRhZGUzOWVmODYzNTdjMDg0ZDRhZGU2YTFmOGQ4NTRkYmIxOTdhOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzlhOWZjZWE3NzliYzNhMjQ2NWQyMDg5YmJiZWRjOWFhNTkxZDgxMTU5MTcz
10
+ YzQ4Yzg2MDAxYzQyMTIyYzQ2ZjBjOTZlNTVmYWEyYzYwOTI1NzVjOWY5NDEw
11
+ MGExYTQxZmY2M2IzMzllOTVkOTFhNGY3ZjRkZGIzZmM0YThjZTg=
12
+ data.tar.gz: !binary |-
13
+ NjRiYzhjNTQ2YjUxYTU3M2JiNjkxZjg0ZmVlMjdhYzlmNGJhN2NhYzZlMzdj
14
+ M2I4MWYwNDgwOWNlZDliODAxN2NiZGJjZWQ0ZTI0MGY2YjQ0MWJmODU4MTQ1
15
+ NTY3ODdlM2FiMTY4ODhhNDdmYWQzOTJkMGI1MGM3M2UyYTE5MTY=
data/lib/fldigi.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  require 'time'
24
24
  require 'xmlrpc/client'
25
25
  require 'thread'
26
+ require 'digest/crc16_ccitt'
26
27
 
27
28
  # Turn 1/0 into false/true (some XMLRPC libraries seem to return 1/0,
28
29
  # others true/false). This cleans up the code a bit.
@@ -49,7 +50,7 @@ class Error
49
50
  end
50
51
 
51
52
  class Fldigi
52
- attr_accessor :rigctl, :dial_freq, :carrier, :call, :modem, :afc, :rsid, :sideband, :squelch, :slevel, :spot, :delay, :grid, :phg, :band, :offset, :start_wait, :char_wait, :debug, :errors
53
+ attr_accessor :rigctl, :dial_freq, :carrier, :call, :modem, :afc, :rsid, :sideband, :squelch, :slevel, :spot, :delay, :grid, :phg, :band, :offset, :start_wait, :char_wait, :debug, :errors, :fexpire
53
54
 
54
55
  # Do the initial setup. All arguments are optional, default is
55
56
  # rigctl, localhost, standard port. If you have no rig control,
@@ -91,6 +92,8 @@ class Fldigi
91
92
  @start_wait=10
92
93
  @char_wait=2
93
94
  @debug=false
95
+ @fexpire=3
96
+ @ftime=0
94
97
 
95
98
  # Propnet stuff.
96
99
  @band=nil
@@ -369,24 +372,33 @@ class Fldigi
369
372
  # frequency you most recently specified. IMPORTANT: The returned
370
373
  # value may not be where the radio is currently tuned. This
371
374
  # function returns what you *told* the radio to be, which could be
372
- # different than what it's currently set to. It's entirely possible
373
- # that the user turned the knob after you set the frequency. If you
374
- # want to see what the radio is *actually* tuned to, use the
375
- # radio_freq() method (below). This method does, however, go out
376
- # and read the actual current carrier, as that tends to float around
377
- # due to both the user clicking on the waterfall, and naturally due
378
- # to AFC. If you do supply a parameter, it sets the transmit
379
- # frequency by subtracting the currently requested carrier (ie, not
380
- # the actual current carrier, but what you set @carrier to) from the
381
- # supplied frequency, then setting @dial_freq to that value. For
382
- # example, if @carrier was set to 1000 and you called
383
- # self.freq(14071000), @dial_freq would be set to 14070000. Note
384
- # that this only sets up all the values in the object, you still
385
- # have to "push" them to the radio with the self.config() method.
375
+ # different than what it's currently set to. It updates itself
376
+ # every @fexpire seconds (3 by default), but it's entirely possible
377
+ # that the user turned the knob in the three seconds since the last
378
+ # time you set/checked the frequency. If you want to see what the
379
+ # radio is *actually* tuned to in real time, use the radio_freq()
380
+ # method (below). This method does, however, go out and read the
381
+ # actual current carrier, as that tends to float around due to both
382
+ # the user clicking on the waterfall, and naturally due to AFC. If
383
+ # you do supply a parameter, it sets the transmit frequency by
384
+ # subtracting the currently requested carrier (ie, not the actual
385
+ # current carrier, but what you set @carrier to) from the supplied
386
+ # frequency, then setting @dial_freq to that value. For example, if
387
+ # @carrier was set to 1000 and you called self.freq(14071000),
388
+ # @dial_freq would be set to 14070000. Note that this only sets up
389
+ # all the values in the object, you still have to "push" them to the
390
+ # radio with the self.config() method.
386
391
  def freq(f=false)
387
392
  if f
388
393
  @dial_freq=f-@carrier
389
394
  else
395
+ # If the last time we checked the dial frequency is more than
396
+ # @fexpire seconds ago, re-read the frequency and update the
397
+ # timestamp.
398
+ if Time.now().to_i-@ftime>@fexpire
399
+ @dial_freq=(self.radio_freq()+self.get_carrier()).to_i
400
+ @ftime=Time.now().to_i
401
+ end
390
402
  return (@dial_freq+self.get_carrier()).to_i
391
403
  end
392
404
  end
@@ -586,10 +598,18 @@ class Fldigi
586
598
  @delay=3600/(@phg[7,1].to_i)
587
599
  end
588
600
 
589
- # Construct the actual string to be sent.
590
- tmp="#{@call.downcase}>#{@fsym}:[#{@grid}]#{@phg}/^"
591
- tmp=tmp+((self.crc16(tmp)).to_s(16)).upcase
592
- @phgtext="FOR INFO: http://www.PropNET.org\n"+tmp
601
+ # Construct the actual string to be sent. Do some farting around
602
+ # with case to be consistent with what I actually see on the
603
+ # air.
604
+ tmpmsg="#{@call.upcase}>#{@fsym}:[#{@grid.downcase}]#{@phg.upcase}/"
605
+ tmpcrc=(Digest::CRC16CCITT.hexdigest(tmpmsg)).upcase
606
+ # Make sure the CRC is actually four characters long. Doesn't
607
+ # happen often, but it does happen (and I'm guessing won't be
608
+ # accepted by PropNet).
609
+ while tmpcrc.length<4
610
+ tmpcrc="0"+tmpcrc
611
+ end
612
+ @phgtext="FOR INFO: http://www.PropNET.org\n"+tmpmsg+"^"+tmpcrc+"\n"
593
613
  end
594
614
  end
595
615
 
@@ -612,44 +632,4 @@ class Fldigi
612
632
  end
613
633
  end
614
634
 
615
- # CRC16 function for use with propnet. "Borrowed" from:
616
- # http://www.hadermann.be/blog/32/ruby-crc16-implementation/
617
- def crc16(buf, crc=0)
618
- ccitt_16 = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
619
- 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
620
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
621
- 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
622
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
623
- 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
624
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
625
- 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
626
- 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
627
- 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
628
- 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
629
- 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
630
- 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
631
- 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
632
- 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
633
- 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
634
- 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
635
- 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
636
- 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
637
- 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
638
- 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
639
- 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
640
- 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
641
- 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
642
- 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
643
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
644
- 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
645
- 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
646
- 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
647
- 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
648
- 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
649
- 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0]
650
-
651
- buf.each_byte{|x| crc = ((crc<<8) ^ ccitt_16[(crc>>8) ^ x])&0xffff} #>>
652
- return crc
653
- end
654
-
655
635
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fldigi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.1.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeff Francis, N0GQ
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A library for talking to FLDigi.
15
14
  email: jeff@gritch.org
@@ -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.4.1
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: []