spektrum-log 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80e40d14225d2fc99ad38744cbf85752aca4832b
4
- data.tar.gz: a15dc90df0edd293bd38bfc852e596063e88ddb8
3
+ metadata.gz: cff8b2a019a2b6e62da86cd1420d3b252022b3b6
4
+ data.tar.gz: 6b3631843d9548a9632df6f4afa2684e6d3d5330
5
5
  SHA512:
6
- metadata.gz: 46d5b8afdaefe491852f77fbacc85cf48fb20a93ef33cd437e130ae324dd3c3391819f34a23beacdf129327da13735c27de8caef9a4dab046b1a9ceda24f822c
7
- data.tar.gz: 4f46200e10324cf7024f440b1f8430265923aeb212b54c2539ec8716c477756efb0ca0a217ded1c98b08aea300243cdfe51dc571b396dcf2255a77f67e75b389
6
+ metadata.gz: e1cefbc0896b3c301ab52d91e44bbfa7fe465b54a90e68e54b53daeff4073412d6464e726ea4228e37ac7e5ed779b177351f654fd3c3677484ce4dad6b167f41
7
+ data.tar.gz: 7e9568705a713a1039e65e3da9d6f30972bafffad5378649961b41ab415540e745996b4a061fad2f835733504ef4eabcd0abeace1a5768b19238cda6febb1276
@@ -6,6 +6,9 @@ module Spektrum
6
6
  attr_reader :timestamp
7
7
 
8
8
  def initialize timestamp, raw_data
9
+ if raw_data.length != 15
10
+ raise ArgumentError, "raw_data incorrectly sized (#{raw_data.length})"
11
+ end
9
12
  @timestamp = timestamp
10
13
  @raw_data = raw_data
11
14
  end
@@ -42,15 +45,70 @@ module Spektrum
42
45
 
43
46
  end
44
47
 
48
+ class BasicDataRecord < Record
49
+
50
+ def initialize timestamp, raw_data
51
+ super timestamp, raw_data
52
+ end
53
+
54
+ def rpm pole_count
55
+ raw_rpm * pole_count
56
+ end
57
+
58
+ def rpm?
59
+ raw_rpm != 0xFFFF
60
+ end
61
+
62
+ def voltage
63
+ raw_voltage / 100.0
64
+ end
65
+
66
+ def voltage?
67
+ raw_voltage != 0xFFFF
68
+ end
69
+
70
+ def temperature
71
+ temp = two_byte_field(5..6)
72
+ temp
73
+ end
74
+
75
+ def temperature?
76
+ self.temperature != 0x7FFF
77
+ end
78
+
79
+ private
80
+
81
+ def raw_rpm
82
+ rpm = two_byte_field(1..2)
83
+ rpm
84
+ end
85
+
86
+ def raw_voltage
87
+ volt = two_byte_field(3..4)
88
+ volt
89
+ end
90
+
91
+ end
92
+
45
93
  class FlightLogRecord < Record
46
94
 
47
95
  def initialize timestamp, raw_data
48
96
  super timestamp, raw_data
49
97
  end
50
98
 
51
- def receiver_voltage
99
+ def rx_voltage
100
+ raw_rx_voltage / 100.0
101
+ end
102
+
103
+ def rx_voltage?
104
+ raw_rx_voltage != 0x7FFF
105
+ end
106
+
107
+ private
108
+
109
+ def raw_rx_voltage
52
110
  volt = two_byte_field(13..14)
53
- volt / 100.0
111
+ volt
54
112
  end
55
113
 
56
114
  end
@@ -184,29 +242,6 @@ module Spektrum
184
242
 
185
243
  end
186
244
 
187
- class VoltsTemperatureRPMRecord < Record
188
-
189
- def initialize timestamp, raw_data
190
- super timestamp, raw_data
191
- end
192
-
193
- def rpms pole_count
194
- rpm = two_byte_field(1..2)
195
- rpm * pole_count
196
- end
197
-
198
- def voltage
199
- volt = two_byte_field(3..4)
200
- volt / 100.0
201
- end
202
-
203
- def temperature
204
- temp = two_byte_field(5..6)
205
- temp
206
- end
207
-
208
- end
209
-
210
245
  class Records
211
246
 
212
247
  @@types = {
@@ -215,9 +250,9 @@ module Spektrum
215
250
  0x14 => GForceRecord,
216
251
  0x16 => GPSRecord1,
217
252
  0x17 => GPSRecord2,
218
- 0x7E => VoltsTemperatureRPMRecord,
253
+ 0x7E => BasicDataRecord,
219
254
  0x7F => FlightLogRecord,
220
- 0xFE => VoltsTemperatureRPMRecord,
255
+ 0xFE => BasicDataRecord,
221
256
  0xFF => FlightLogRecord,
222
257
  }
223
258
 
@@ -1,5 +1,5 @@
1
1
  module Spektrum
2
2
  module Log
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spektrum::Log::BasicDataRecord do
4
+
5
+ let(:timestamp) { 0xC67C0100 }
6
+
7
+ let(:raw_data) { ["00FFFF13897FFF0000000000000000"].pack('H*') }
8
+
9
+ subject { Spektrum::Log::BasicDataRecord.new(timestamp, raw_data) }
10
+
11
+ its(:timestamp) { should eql(0xC67C0100) }
12
+
13
+ context 'with only rpm' do
14
+
15
+ let(:raw_data) { ["000123FFFF7FFF0000000000000000"].pack('H*') }
16
+
17
+ its(:rpm?) { should be_true }
18
+
19
+ it 'calculates RPMs appropriately' do
20
+ subject.rpm(6).should eq(1746)
21
+ end
22
+
23
+ its(:temperature?) { should be_false }
24
+
25
+ its(:voltage?) { should be_false }
26
+
27
+ end
28
+
29
+ context 'with only temperature' do
30
+
31
+ let(:raw_data) { ["00FFFFFFFF00A10000000000000000"].pack('H*') }
32
+
33
+ its(:rpm?) { should be_false }
34
+
35
+ its(:temperature?) { should be_true }
36
+
37
+ its(:temperature) { should eq(161) }
38
+
39
+ its(:voltage?) { should be_false }
40
+
41
+ end
42
+
43
+ context 'with only voltage' do
44
+
45
+ let(:raw_data) { ["00FFFF13897FFF0000000000000000"].pack('H*') }
46
+
47
+ its(:rpm?) { should be_false }
48
+
49
+ its(:temperature?) { should be_false }
50
+
51
+ its(:voltage?) { should be_true }
52
+
53
+ its(:voltage) { should eq(50.01) }
54
+
55
+ end
56
+
57
+ context 'with everything' do
58
+
59
+ let(:raw_data) { ["0000A6138900A60000000000000000"].pack('H*') }
60
+
61
+ its(:rpm?) { should be_true }
62
+
63
+ it 'calculates RPMs appropriately' do
64
+ subject.rpm(12).should eq(1992)
65
+ end
66
+
67
+ its(:temperature?) { should be_true }
68
+
69
+ its(:temperature) { should eq(166) }
70
+
71
+ its(:voltage?) { should be_true }
72
+
73
+ its(:voltage) { should eq(50.01) }
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spektrum::Log::FlightLogRecord do
4
+
5
+ let(:timestamp) { 0xC67C0101 }
6
+
7
+ let(:raw_data) { ["00FFFF13897FFF0000000000000347"].pack('H*') }
8
+
9
+ subject { Spektrum::Log::FlightLogRecord.new(timestamp, raw_data) }
10
+
11
+ its(:timestamp) { should eql(0xC67C0101) }
12
+
13
+ context 'with voltage' do
14
+
15
+ let(:raw_data) { ["00FFFF13897FFF0000000000000347"].pack('H*') }
16
+
17
+ its(:rx_voltage?) { should be_true }
18
+
19
+ its(:rx_voltage) { should eq(8.39) }
20
+
21
+ end
22
+
23
+ context 'without voltage' do
24
+
25
+ let(:raw_data) { ["00FFFF13897FFF0000000000007FFF"].pack('H*') }
26
+
27
+ its(:rx_voltage?) { should be_false }
28
+
29
+ end
30
+
31
+ end
data/spektrum-log.gemspec CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/spektrum-log/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Nick Veys"]
6
- gem.email = ["nveys@aramisgroup.com"]
6
+ gem.email = ["nick@codelever.com"]
7
7
  gem.description = %q{Read and interpret Spektrum TLM log files.}
8
8
  gem.summary = %q{Spektrum TLM log file reader}
9
9
  gem.homepage = ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektrum-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '10.0'
41
41
  description: Read and interpret Spektrum TLM log files.
42
42
  email:
43
- - nveys@aramisgroup.com
43
+ - nick@codelever.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
@@ -62,6 +62,8 @@ files:
62
62
  - lib/spektrum-log/reader.rb
63
63
  - lib/spektrum-log/records.rb
64
64
  - lib/spektrum-log/version.rb
65
+ - spec/basic_data_record_spec.rb
66
+ - spec/flight_log_record_spec.rb
65
67
  - spec/flight_spec.rb
66
68
  - spec/reader_spec.rb
67
69
  - spec/spec_helper.rb
@@ -90,6 +92,8 @@ signing_key:
90
92
  specification_version: 4
91
93
  summary: Spektrum TLM log file reader
92
94
  test_files:
95
+ - spec/basic_data_record_spec.rb
96
+ - spec/flight_log_record_spec.rb
93
97
  - spec/flight_spec.rb
94
98
  - spec/reader_spec.rb
95
99
  - spec/spec_helper.rb