px4_log_reader 0.0.5 → 0.0.6

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.
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  module Px4LogReader
2
34
 
3
35
  def self.open_common( file, options, &block )
@@ -33,27 +65,27 @@ module Px4LogReader
33
65
  return reader
34
66
  end
35
67
 
36
- class Context
37
- attr_reader :messages
38
- def initialize
39
- messages = {}
40
- end
41
- def find_by_name( name )
42
- named_message = nil
43
- @messages.values.each do |message|
44
- if message.descriptor.name == name
45
- named_message = message
46
- end
47
- end
48
- return named_message
49
- end
50
- def find_by_type( type )
51
- return @messages[ type ]
52
- end
53
- def set( message )
54
- @messages[ message.descriptor.type ] = message.dup
55
- end
56
- end
68
+ class Context
69
+ attr_reader :messages
70
+ def initialize
71
+ messages = {}
72
+ end
73
+ def find_by_name( name )
74
+ named_message = nil
75
+ @messages.values.each do |message|
76
+ if message.descriptor.name == name
77
+ named_message = message
78
+ end
79
+ end
80
+ return named_message
81
+ end
82
+ def find_by_type( type )
83
+ return @messages[ type ]
84
+ end
85
+ def set( message )
86
+ @messages[ message.descriptor.type ] = message.dup
87
+ end
88
+ end
57
89
 
58
90
  class Reader
59
91
 
@@ -1,3 +1,3 @@
1
1
  module Px4LogReader
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -1,4 +1,38 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'px4_log_reader/version'
34
+ require 'px4_log_reader/error'
35
+ require 'px4_log_reader/file_not_found_error'
2
36
  require 'px4_log_reader/invalid_descriptor_error'
3
37
  require 'px4_log_reader/log_message'
4
38
  require 'px4_log_reader/message_descriptor'
@@ -1,17 +1,50 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
3
+ #
4
+ # Copyright (c) 2016, Robert Glissmann
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are met:
9
+ #
10
+ # * Redistributions of source code must retain the above copyright notice, this
11
+ # list of conditions and the following disclaimer.
12
+ #
13
+ # * Redistributions in binary form must reproduce the above copyright notice,
14
+ # this list of conditions and the following disclaimer in the documentation
15
+ # and/or other materials provided with the distribution.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ #
28
+
29
+ # %% license-end-token %%
30
+ #
31
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
32
+ #
33
+ #
34
+
2
35
  require_relative 'lib/px4_log_reader/version'
3
36
 
4
37
  Gem::Specification.new do |s|
5
- s.name = 'px4_log_reader'
6
- s.version = Px4LogReader::VERSION
7
- s.date = Time.now.to_date.strftime('%Y-%m-%d')
8
- s.summary = "PX4 flight log reader"
9
- s.description = "Px4LogReader is a gem for parsing PX4-format flight logs generated by the Pixhawk."
10
- s.authors = [ "Robert Glissmann" ]
11
- s.email = 'Robert.Glissmann@gmail.com'
12
- s.files = `git ls-files`.split("\n")
13
- s.licenses = ['BSD']
14
- s.homepage = 'https://github.com/rgmann/px4_log_reader'
38
+ s.name = 'px4_log_reader'
39
+ s.version = Px4LogReader::VERSION
40
+ s.date = Time.now.to_date.strftime('%Y-%m-%d')
41
+ s.summary = "PX4 flight log reader"
42
+ s.description = "Px4LogReader is a gem for parsing PX4-format flight logs generated by the Pixhawk."
43
+ s.authors = [ "Robert Glissmann" ]
44
+ s.email = 'Robert.Glissmann@gmail.com'
45
+ s.files = `git ls-files`.split("\n")
46
+ s.licenses = ['BSD']
47
+ s.homepage = 'https://github.com/rgmann/px4_log_reader'
15
48
 
16
- s.add_development_dependency 'rspec', '~> 3.1'
49
+ s.add_development_dependency 'rspec', '~> 3.1'
17
50
  end
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'minitest/autorun'
2
34
  require 'px4_log_reader'
3
35
 
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'minitest/autorun'
2
34
  require 'px4_log_reader'
3
35
 
@@ -21,6 +53,8 @@ class TestLogFile < MiniTest::Test
21
53
 
22
54
  # log_file.close
23
55
 
56
+ # TODO
57
+
24
58
  end
25
59
 
26
60
  def test_read_message
@@ -33,11 +67,13 @@ class TestLogFile < MiniTest::Test
33
67
 
34
68
  # puts message.descriptor
35
69
 
70
+ # TODO
71
+
36
72
  end
37
73
 
38
74
 
39
75
  def open_log_file
40
- log_file = File.open( File.join( '/Volumes/rvaughan_share/Development/px4_log_reader_test_data', '2016-07-24', '17_18_36.px4log' ), 'r' )
76
+ log_file = File.open( File.join( 'test', 'test_files', 'test_log.px4log' ), 'r' )
41
77
  log_file
42
78
  end
43
79
 
@@ -0,0 +1,74 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
33
+ require 'minitest/autorun'
34
+ require 'px4_log_reader'
35
+
36
+ class TestLogMessage < MiniTest::Test
37
+
38
+ def setup
39
+ end
40
+
41
+ def teardown
42
+ end
43
+
44
+ def test_get_field
45
+ fields = [ 0x24, 32, 'test', 'IIbMh', 'id,counts,flag,length,ord' ]
46
+
47
+ message = Px4LogReader::LogMessage.new(
48
+ Px4LogReader::FORMAT_MESSAGE,
49
+ fields )
50
+
51
+ assert_equal fields[0], message.get('Type')
52
+ assert_equal fields[1], message.get('Length')
53
+ assert_equal fields[2], message.get('Name')
54
+ assert_equal fields[3], message.get('Format')
55
+ assert_equal fields[4], message.get('Labels')
56
+
57
+ assert_nil message.get('name')
58
+ assert_nil message.get('ThisFieldDoesNotExist')
59
+ end
60
+
61
+ def test_pack_message
62
+ fields = [ 0x24, 32, 'test', 'IIbMh', 'id,counts,flag,length,ord' ]
63
+
64
+ message = Px4LogReader::LogMessage.new(
65
+ Px4LogReader::FORMAT_MESSAGE,
66
+ fields )
67
+
68
+ # This is a format message, so the format specifier is 'BBnNZ'
69
+ expected_length = 1 + 1 + 4 + 16 + 64
70
+
71
+ assert_equal expected_length, message.pack.length
72
+ end
73
+
74
+ end
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'minitest/autorun'
2
34
  require 'px4_log_reader'
3
35
 
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'minitest/autorun'
2
34
  require 'px4_log_reader'
3
35
 
data/test/test_reader.rb CHANGED
@@ -1,3 +1,35 @@
1
+ #
2
+ # Copyright (c) 2016, Robert Glissmann
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+
27
+ # %% license-end-token %%
28
+ #
29
+ # Author: Robert.Glissmann@gmail.com (Robert Glissmann)
30
+ #
31
+ #
32
+
1
33
  require 'minitest/autorun'
2
34
  require 'px4_log_reader'
3
35
 
@@ -85,6 +117,33 @@ class TestReader < MiniTest::Test
85
117
 
86
118
  end
87
119
 
120
+ end
121
+
122
+ assert_equal true, log_file_opened
123
+
124
+ end
125
+
126
+
127
+ def test_reader_blacklist
128
+
129
+ log_file_opened = false
130
+ log_filename = File.join( 'test', 'test_files', 'test_log.px4log' )
131
+
132
+ Px4LogReader.open( log_filename ) do |reader|
133
+
134
+ log_file_opened = true
135
+
136
+ # The log file associated with this test case contains the following
137
+ # messages in the specified order. Validate the order and context.
138
+ #
139
+ # 1) TIME
140
+ # 2) STAT
141
+ # 3) IMU
142
+ # 4) SENS
143
+ # 5) IMU1
144
+ # 6) VTOL
145
+ # 7) GPS
146
+ #
88
147
 
89
148
  index = 0
90
149
  expected_message_names = ['TIME','IMU','SENS','VTOL','GPS']
@@ -114,9 +173,58 @@ class TestReader < MiniTest::Test
114
173
  end
115
174
 
116
175
  assert_equal true, log_file_opened
117
-
118
176
  end
119
177
 
178
+ def test_reader_whitelist
179
+
180
+ log_file_opened = false
181
+ log_filename = File.join( 'test', 'test_files', 'test_log.px4log' )
182
+
183
+ Px4LogReader.open( log_filename ) do |reader|
184
+
185
+ log_file_opened = true
186
+
187
+ # The log file associated with this test case contains the following
188
+ # messages in the specified order. Validate the order and context.
189
+ #
190
+ # 1) TIME
191
+ # 2) STAT
192
+ # 3) IMU
193
+ # 4) SENS
194
+ # 5) IMU1
195
+ # 6) VTOL
196
+ # 7) GPS
197
+ #
198
+
199
+ index = 0
200
+ expected_message_names = ['TIME','SENS']
201
+ expected_message_types = [0x81,0x05]
202
+
203
+ reader.each_message( { with: ['TIME','SENS'] } ) do |message,context|
204
+
205
+ expected_name = expected_message_names[ index ]
206
+ expected_type = expected_message_types[ index ]
207
+
208
+ assert_equal expected_name, message.descriptor.name
209
+ assert_equal expected_type, message.descriptor.type
210
+
211
+ context_message = context.find_by_name( expected_name )
212
+ refute_nil context_message
213
+ assert_equal expected_name, context_message.descriptor.name
214
+
215
+ context_message = context.find_by_type( expected_type )
216
+ refute_nil context_message
217
+ assert_equal expected_type, context_message.descriptor.type
218
+
219
+ index += 1
220
+ assert_equal index, context.messages.size
221
+
222
+ end
223
+
224
+ end
225
+
226
+ assert_equal true, log_file_opened
227
+ end
120
228
 
121
229
 
122
230
  def all_descriptors_found( descriptors )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: px4_log_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Glissmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -32,9 +32,12 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - LICENSE.txt
35
36
  - README.md
36
37
  - Rakefile
37
38
  - lib/px4_log_reader.rb
39
+ - lib/px4_log_reader/error.rb
40
+ - lib/px4_log_reader/file_not_found_error.rb
38
41
  - lib/px4_log_reader/invalid_descriptor_error.rb
39
42
  - lib/px4_log_reader/log_buffer.rb
40
43
  - lib/px4_log_reader/log_file.rb
@@ -43,13 +46,12 @@ files:
43
46
  - lib/px4_log_reader/message_descriptor_cache.rb
44
47
  - lib/px4_log_reader/reader.rb
45
48
  - lib/px4_log_reader/version.rb
46
- - lib/px4log_parser.rb
47
49
  - px4_log_reader.gemspec
48
- - test/test.rb
49
50
  - test/test_files/pixhawk_descriptor_cache.px4mc
50
51
  - test/test_files/test_log.px4log
51
52
  - test/test_log_buffer.rb
52
53
  - test/test_log_file.rb
54
+ - test/test_log_message.rb
53
55
  - test/test_message_descriptor.rb
54
56
  - test/test_message_descriptor_cache.rb
55
57
  - test/test_reader.rb