mm_gps 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d54d7a04b331b5339f0e68b21e903101424a9f9e
4
- data.tar.gz: b07d30015c9e27d411154880d00b23f1afd6cb00
3
+ metadata.gz: bafa75b0c01b3afc71beb0aeec35a2b9b7656a80
4
+ data.tar.gz: 9fc0afa4c8aac65f97f07f056c361a4f74f1e95f
5
5
  SHA512:
6
- metadata.gz: c8f837ef92db27cd2a89db5a03c368f301cdcd5003bc7d43d54279407d0a60c433847ad7283826560e66e11ac3535a22d7ec2397ec62914e8b4eb88d563b4d6b
7
- data.tar.gz: 86cd9f6dadc96679aaa1712b4620569262954635f29014b3672fdac13b5c115e53db40284854433c2d4b12bc62799b9e5e1273e223fac93f0536fccce2d23546
6
+ metadata.gz: dae1b925e9a840821017e70660b50656311976f661a7069af3539769ca5cdf6f9213f1ec2c2f013e5e4b6aecd9f23ac85484186770e163765c4adc9844bf9f65
7
+ data.tar.gz: e1c98dbc0e84f3dedf1fbe1bd965e293df9745e589dd698f8918ce7ead976ccc0a285a8c914716e22e93f9b078fc343ae6d96836e6ce2975bd260b6e5529ab3f
data/README.md CHANGED
@@ -29,12 +29,16 @@ require 'mm_gps'
29
29
  PORT = "/dev/cu.usbmodem1411"
30
30
  BAUD = 115200 # SerialPort class does not support non-standard 500 kbps
31
31
 
32
- beacon = MmGPS::Beacon.new(PORT, BAUD)
32
+ beacon = MmGPS::Beacon.new(PORT, baud: BAUD)
33
33
  beacon.trap # installs signal handler for CTRL-C
34
34
 
35
35
  # Standard each loop. Type CTRL-C for interrupting it
36
- beacon.each do |packet|
37
- p packet
36
+ File.open("dump.bin", 'w') do |f|
37
+ beacon.each do |packet, raw|
38
+ p packet
39
+ puts MmGPS::hexify(raw)
40
+ f.print(raw)
41
+ end
38
42
  end
39
43
 
40
44
  # Use the enumerator:
@@ -1,6 +1,8 @@
1
1
  #include "mm_gps.h"
2
2
 
3
+ #ifndef uchar
3
4
  typedef unsigned char uchar;
5
+ #endif
4
6
 
5
7
  typedef union {
6
8
  ushort w;
@@ -29,10 +31,11 @@ static ushort CRC16(const void *buf, ushort length) {
29
31
  return (ushort)crc.w;
30
32
  }
31
33
 
32
- /* Calculate CRC16 checksum of a string
33
- *
34
- * @param buf [String] the string to be checksummed
35
- * @return [Fixnum] the CRC16 value
34
+ /* @overload crc16(buf)
35
+ * Calculate CRC16 checksum of a string
36
+ *
37
+ * @param buf [String] the string to be checksummed
38
+ * @return [Fixnum] the CRC16 value
36
39
  */
37
40
  static VALUE mm_gps_CRC16(VALUE klass, VALUE str)
38
41
  {
@@ -40,10 +43,11 @@ static VALUE mm_gps_CRC16(VALUE klass, VALUE str)
40
43
  return rb_fix_new(CRC16(RSTRING_PTR(str), RSTRING_LEN(str)));
41
44
  }
42
45
 
43
- /* Appends a CRC16 checksum to a string
44
- *
45
- * @param buf [String] the starting string
46
- * @return [String] the original string plus its CRC16
46
+ /* @overload append_crc16(buf)
47
+ * Appends a CRC16 checksum to a string
48
+ *
49
+ * @param buf [String] the starting string
50
+ * @return [String] the original string plus its CRC16
47
51
  */
48
52
  static VALUE mm_gps_add_CRC16(VALUE klass, VALUE str)
49
53
  {
@@ -4,12 +4,13 @@ module MmGPS
4
4
  # You may want (and can) to have more than one instance.
5
5
  #
6
6
  # @example Typical usage:
7
- # beacon = MmGPS::Beacon.new(PORT, BAUD)
7
+ # beacon = MmGPS::Beacon.new(PORT, baud: BAUD)
8
8
  # beacon.trap # installs signal handler for CTRL-C
9
9
  #
10
10
  # # Standard each loop. Type CTRL-C for interrupting it
11
- # beacon.each do |packet|
11
+ # beacon.each do |packet, raw|
12
12
  # p packet
13
+ # puts MmGPS::hexify(raw)
13
14
  # end
14
15
  # @example Using the enumerator:
15
16
  # # Use the enumerator:
@@ -29,7 +30,7 @@ module MmGPS
29
30
  #
30
31
  # @param port [String] 'COM1' on Windows, '/dev/ttyNNN' on *nix
31
32
  # @param baud [Fixnum] baudrate, value must be supported by the platform
32
- def initialize(port, baud = 115200)
33
+ def initialize(port, baud: 115200)
33
34
  @port, @baud = port, baud
34
35
  self.open
35
36
  end
@@ -98,7 +99,7 @@ module MmGPS
98
99
  return enum_for(:each) unless block_given?
99
100
  loop do
100
101
  begin
101
- yield self.get_packet
102
+ yield self.get_packet, @last_pkt
102
103
  rescue MmGPSError => e
103
104
  warn "Packet Error: #{e.inspect}, reason: #{e.data[:reason]}"
104
105
  warn "Packet: #{MmGPS.hexify(e.data[:packet])}"
@@ -121,8 +122,7 @@ module MmGPS
121
122
  if pkt.empty? then
122
123
  raise MmGPSError.new("Data unavailable", {reason: :noavail})
123
124
  end
124
- @last_pkt = pkt
125
- return @last_pkt
125
+ return @last_pkt = pkt
126
126
  end
127
127
 
128
128
  # Reads a raw packet, checks its CRC, and returns its contents as a Hash.
@@ -1,3 +1,3 @@
1
1
  module MmGPS
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/test.rb CHANGED
@@ -4,15 +4,18 @@ require 'mm_gps'
4
4
  PORT = "/dev/cu.usbmodem1411"
5
5
  BAUD = 115200 # SerialPort class does not support non-standard 500 kbps
6
6
 
7
- beacon = MmGPS::Beacon.new(PORT, BAUD)
7
+ beacon = MmGPS::Beacon.new(PORT, baud: BAUD)
8
8
  beacon.trap # installs signal handler for CTRL-C
9
9
 
10
10
  # Standard each loop. Type CTRL-C for interrupting it
11
- beacon.each do |packet|
12
- p packet
11
+ File.open("dump.bin", 'w') do |f|
12
+ beacon.each do |packet, raw|
13
+ p packet
14
+ puts MmGPS::hexify(raw)
15
+ f.print(raw)
16
+ end
13
17
  end
14
18
 
15
-
16
19
  # Use the enumerator:
17
20
  beacon.reopen # Needed, since CTRL-C in previous example also closes the Serialport connection
18
21
  enum = beacon.each # gets the Enumerator
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm_gps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Bosetti
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport