memory_blocs_parser_external_data.test.cc
Go to the documentation of this file.
1 #include <array>
2 #include <gtest/gtest.h>
3 
18 
19 using namespace ixblue_stdbin_decoder;
20 
21 TEST(MemoryBocksParser, ParseUtc)
22 {
23  // Validity Time : 254 (0x000000fe), source : 24 (0x18)
24  // clang-format off
25  const std::vector<uint8_t> memory{
26  0x00, 0x00, 0x00, 0xfe,
27  0x18
28  };
29  // clang-format on
30  auto buffer = boost::asio::buffer(memory.data(), memory.size());
31 
32  Parser::Utc parser;
33  Data::BinaryNav binaryNav;
34  parser.parse(buffer, binaryNav);
35 
36  ASSERT_TRUE(binaryNav.utc.is_initialized());
37  ASSERT_EQ(254, binaryNav.utc.get().validityTime_100us);
38  ASSERT_EQ(24, binaryNav.utc.get().source);
39 
40  // We also check that buffer was completly consumed by parser.
41  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
42 }
43 
44 TEST(MemoryBocksParser, ParseGnss)
45 {
46  // 1 --> Validity Time : 254 (0x000000fe), GNSS Id : 24 (0x18), GNSS Quality : 28
47  // (0x1c), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
48  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), latitudeSD : 1.25f(
49  // 0x3fa00000 ), longitudeSD : 12.55f (0x4148cccd), altSD : -1.5f (0xbfc00000),
50  // latlonCOR : -0.005f (0xbba3d70a), geoidalSep : 8.562 (0x4108fdf4)
51 
52  // 2 --> Validity Time : 254 (0x000000fe), GNSS Id : 24 (0x18), GNSS Quality : 28
53  // (0x1c), latitude : -4.75d (0xc013000000000000), longitude : 25.68d
54  // (0x4039ae147ae147ae), altitude : 154.21f (0x431a35c3), latitudeSD : -1.5f
55  // (0xbfc00000), longitudeSD : 12.55f (0x4148cccd), altSD : 1.25f( 0x3fa00000 ),
56  // latlonCOR : -0.005f (0xbba3d70a), geoidalSep : 8.562 (0x4108fdf4)
57 
58  // 3 --> Validity Time : 58 (0x0000003a), GNSS Id : 4 (0x04), GNSS Quality : 28
59  // (0x1c), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
60  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), latitudeSD : 1.25f(
61  // 0x3fa00000 ), longitudeSD : 12.55f (0x4148cccd), altSD : -1.5f (0xbfc00000),
62  // latlonCOR : -0.005f (0xbba3d70a), geoidalSep : 8.562 (0x4108fdf4)
63 
64  // clang-format off
65  const std::vector<uint8_t> memory1{
66  0x00, 0x00, 0x00, 0xfe,
67  0x18,
68  0x1c,
69  0x40, 0x39, 0xae, 0x14,
70  0x7a, 0xe1, 0x47, 0xae,
71  0xc0, 0x13, 0x00, 0x00,
72  0x00, 0x00, 0x00, 0x00,
73  0x43, 0x1a, 0x35, 0xc3,
74  0x3f, 0xa0, 0x00, 0x00,
75  0x41, 0x48, 0xcc, 0xcd,
76  0xbf, 0xc0, 0x00, 0x00,
77  0xbb, 0xa3, 0xd7, 0x0a,
78  0x41, 0x08, 0xfd, 0xf4
79  };
80 
81  const std::vector<uint8_t> memory2{
82  0x00, 0x00, 0x00, 0xfe,
83  0x18,
84  0x1c,
85  0xc0, 0x13, 0x00, 0x00,
86  0x00, 0x00, 0x00, 0x00,
87  0x40, 0x39, 0xae, 0x14,
88  0x7a, 0xe1, 0x47, 0xae,
89  0x43, 0x1a, 0x35, 0xc3,
90  0xbf, 0xc0, 0x00, 0x00,
91  0x41, 0x48, 0xcc, 0xcd,
92  0x3f, 0xa0, 0x00, 0x00,
93  0xbb, 0xa3, 0xd7, 0x0a,
94  0x41, 0x08, 0xfd, 0xf4
95  };
96 
97  const std::vector<uint8_t> memory3{
98  0x00, 0x00, 0x00, 0x3a,
99  0x04,
100  0x1c,
101  0x40, 0x39, 0xae, 0x14,
102  0x7a, 0xe1, 0x47, 0xae,
103  0xc0, 0x13, 0x00, 0x00,
104  0x00, 0x00, 0x00, 0x00,
105  0x43, 0x1a, 0x35, 0xc3,
106  0x3f, 0xa0, 0x00, 0x00,
107  0x41, 0x48, 0xcc, 0xcd,
108  0xbf, 0xc0, 0x00, 0x00,
109  0xbb, 0xa3, 0xd7, 0x0a,
110  0x41, 0x08, 0xfd, 0xf4
111  };
112  // clang-format on
113 
114  std::vector<uint8_t> gnss_memory(memory1);
115  gnss_memory.insert(gnss_memory.end(), memory2.begin(), memory2.end());
116  gnss_memory.insert(gnss_memory.end(), memory3.begin(), memory3.end());
117 
118  auto buffer = boost::asio::buffer(const_cast<const uint8_t*>(gnss_memory.data()),
119  gnss_memory.size());
120 
121  Parser::Gnss1 parser1;
122  Parser::Gnss2 parser2;
123  Parser::GnssManual parser3;
124 
125  Data::BinaryNav binaryNav;
126 
127  parser1.parse(buffer, binaryNav);
128  parser2.parse(buffer, binaryNav);
129  parser3.parse(buffer, binaryNav);
130 
131  ASSERT_TRUE(binaryNav.gnss1.is_initialized());
132  ASSERT_EQ(254, binaryNav.gnss1.get().validityTime_100us);
133  ASSERT_EQ(24, binaryNav.gnss1.get().gnss_id);
134  ASSERT_EQ(28, binaryNav.gnss1.get().gnss_quality);
135  ASSERT_DOUBLE_EQ(25.68, binaryNav.gnss1.get().latitude_deg);
136  ASSERT_DOUBLE_EQ(-4.75, binaryNav.gnss1.get().longitude_deg);
137  ASSERT_FLOAT_EQ(154.21, binaryNav.gnss1.get().altitude_m);
138  ASSERT_FLOAT_EQ(1.25, binaryNav.gnss1.get().latitude_stddev_m);
139  ASSERT_FLOAT_EQ(12.55, binaryNav.gnss1.get().longitude_stddev_m);
140  ASSERT_FLOAT_EQ(-1.5, binaryNav.gnss1.get().altitude_stddev_m);
141  ASSERT_FLOAT_EQ(-0.005, binaryNav.gnss1.get().lat_lon_stddev_m2);
142  ASSERT_FLOAT_EQ(8.562, binaryNav.gnss1.get().geoidal_separation_m);
143 
144  ASSERT_TRUE(binaryNav.gnss2.is_initialized());
145  ASSERT_EQ(254, binaryNav.gnss2.get().validityTime_100us);
146  ASSERT_EQ(24, binaryNav.gnss2.get().gnss_id);
147  ASSERT_EQ(28, binaryNav.gnss2.get().gnss_quality);
148  ASSERT_DOUBLE_EQ(-4.75, binaryNav.gnss2.get().latitude_deg);
149  ASSERT_DOUBLE_EQ(25.68, binaryNav.gnss2.get().longitude_deg);
150  ASSERT_FLOAT_EQ(154.21, binaryNav.gnss2.get().altitude_m);
151  ASSERT_FLOAT_EQ(-1.5, binaryNav.gnss2.get().latitude_stddev_m);
152  ASSERT_FLOAT_EQ(12.55, binaryNav.gnss2.get().longitude_stddev_m);
153  ASSERT_FLOAT_EQ(1.25, binaryNav.gnss2.get().altitude_stddev_m);
154  ASSERT_FLOAT_EQ(-0.005, binaryNav.gnss2.get().lat_lon_stddev_m2);
155  ASSERT_FLOAT_EQ(8.562, binaryNav.gnss2.get().geoidal_separation_m);
156 
157  ASSERT_TRUE(binaryNav.gnssManual.is_initialized());
158  ASSERT_EQ(58, binaryNav.gnssManual.get().validityTime_100us);
159  ASSERT_EQ(4, binaryNav.gnssManual.get().gnss_id);
160  ASSERT_EQ(28, binaryNav.gnssManual.get().gnss_quality);
161  ASSERT_DOUBLE_EQ(25.68, binaryNav.gnssManual.get().latitude_deg);
162  ASSERT_DOUBLE_EQ(-4.75, binaryNav.gnssManual.get().longitude_deg);
163  ASSERT_FLOAT_EQ(154.21, binaryNav.gnssManual.get().altitude_m);
164  ASSERT_FLOAT_EQ(1.25, binaryNav.gnssManual.get().latitude_stddev_m);
165  ASSERT_FLOAT_EQ(12.55, binaryNav.gnssManual.get().longitude_stddev_m);
166  ASSERT_FLOAT_EQ(-1.5, binaryNav.gnssManual.get().altitude_stddev_m);
167  ASSERT_FLOAT_EQ(-0.005, binaryNav.gnssManual.get().lat_lon_stddev_m2);
168  ASSERT_FLOAT_EQ(8.562, binaryNav.gnssManual.get().geoidal_separation_m);
169 
170  // We also check that buffer was completly consumed by parser.
171  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
172 }
173 
174 TEST(MemoryBocksParser, ParseEmlog)
175 {
176  // 1 -> Validity Time : 254 (0x000000fe), EMLOG Id : 24 (0x18),
177  // Waterspeed : 154.21f (0x431a35c3), WaterspeedSD : 1.25f(0x3fa00000)
178 
179  // 2 -> Validity Time : 58 (0x0000003a), EMLOG Id : 4 (0x04),
180  // Waterspeed : 1.25f(0x3fa00000), WaterspeedSD : 12.55f (0x4148cccd)
181 
182  // clang-format off
183  const std::vector<uint8_t> memory1{
184  0x00, 0x00, 0x00, 0xfe,
185  0x18,
186  0x43, 0x1a, 0x35, 0xc3,
187  0x3f, 0xa0, 0x00, 0x00
188  };
189 
190  const std::vector<uint8_t> memory2{
191  0x00, 0x00, 0x00, 0x3a,
192  0x04,
193  0x3f, 0xa0, 0x00, 0x00,
194  0x41, 0x48, 0xcc, 0xcd
195  };
196  // clang-format on
197 
198  std::vector<uint8_t> emlog_memory(memory1);
199  emlog_memory.insert(emlog_memory.end(), memory2.begin(), memory2.end());
200 
201  auto buffer = boost::asio::buffer(const_cast<const uint8_t*>(emlog_memory.data()),
202  emlog_memory.size());
203 
204  Parser::Emlog1 parser1;
205  Parser::Emlog2 parser2;
206 
207  Data::BinaryNav binaryNav;
208 
209  parser1.parse(buffer, binaryNav);
210  parser2.parse(buffer, binaryNav);
211 
212  ASSERT_TRUE(binaryNav.emlog1.is_initialized());
213  ASSERT_EQ(254, binaryNav.emlog1.get().validityTime_100us);
214  ASSERT_EQ(24, binaryNav.emlog1.get().emlog_id);
215  ASSERT_FLOAT_EQ(154.21, binaryNav.emlog1.get().xv1_waterSpeed_ms);
216  ASSERT_FLOAT_EQ(1.25, binaryNav.emlog1.get().xv1_speed_stddev_ms);
217 
218  ASSERT_TRUE(binaryNav.emlog2.is_initialized());
219  ASSERT_EQ(58, binaryNav.emlog2.get().validityTime_100us);
220  ASSERT_EQ(4, binaryNav.emlog2.get().emlog_id);
221  ASSERT_FLOAT_EQ(1.25, binaryNav.emlog2.get().xv1_waterSpeed_ms);
222  ASSERT_FLOAT_EQ(12.55, binaryNav.emlog2.get().xv1_speed_stddev_ms);
223 
224  // We also check that buffer was completly consumed by parser.
225  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
226 }
227 
228 TEST(MemoryBocksParser, ParseUsbl)
229 {
230  // 1 --> Validity Time : 254 (0x000000fe), USBL Id : 24 (0x18), Beacon id : abcdefgh
231  // (0x6162636465666768), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
232  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), latitudeSD : 1.25f(
233  // 0x3fa00000 ), longitudeSD : 12.55f (0x4148cccd), latlonCOR : -0.005f (0xbba3d70a),
234  // altSD : -1.5f (0xbfc00000)
235 
236  // 2 --> Validity Time : 58 (0x0000003a), USBL Id : 4 (0x04), Beacon id : abcdefgh
237  // (0x6162636465666768), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
238  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), latitudeSD : 1.25f(
239  // 0x3fa00000 ), longitudeSD : 12.55f (0x4148cccd), latlonCOR : -0.005f (0xbba3d70a),
240  // altSD : -1.5f (0xbfc00000)
241 
242  // 3 --> Validity Time : 254 (0x000000fe), USBL Id : 24 (0x18), Beacon id : abcdefgh
243  // (0x6162636465666768), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
244  // (0xc013000000000000), altitude : 12.55f (0x4148cccd), latitudeSD : 1.25f(
245  // 0x3fa00000 ), longitudeSD : 154.21f (0x431a35c3), latlonCOR : -0.005f (0xbba3d70a),
246  // altSD : -1.5f (0xbfc00000)
247 
248  // clang-format off
249  const std::vector<uint8_t> memory1{
250  0x00, 0x00, 0x00, 0xfe,
251  0x18,
252  0x61, 0x62, 0x63, 0x64,
253  0x65, 0x66, 0x67, 0x68,
254  0x40, 0x39, 0xae, 0x14,
255  0x7a, 0xe1, 0x47, 0xae,
256  0xc0, 0x13, 0x00, 0x00,
257  0x00, 0x00, 0x00, 0x00,
258  0x43, 0x1a, 0x35, 0xc3,
259  0x3f, 0xa0, 0x00, 0x00,
260  0x41, 0x48, 0xcc, 0xcd,
261  0xbb, 0xa3, 0xd7, 0x0a,
262  0xbf, 0xc0, 0x00, 0x00
263  };
264 
265  const std::vector<uint8_t> memory2{
266  0x00, 0x00, 0x00, 0x3a,
267  0x04,
268  0x61, 0x62, 0x63, 0x64,
269  0x65, 0x66, 0x67, 0x68,
270  0x40, 0x39, 0xae, 0x14,
271  0x7a, 0xe1, 0x47, 0xae,
272  0xc0, 0x13, 0x00, 0x00,
273  0x00, 0x00, 0x00, 0x00,
274  0x43, 0x1a, 0x35, 0xc3,
275  0x3f, 0xa0, 0x00, 0x00,
276  0x41, 0x48, 0xcc, 0xcd,
277  0xbb, 0xa3, 0xd7, 0x0a,
278  0xbf, 0xc0, 0x00, 0x00
279  };
280 
281  const std::vector<uint8_t> memory3{
282  0x00, 0x00, 0x00, 0xfe,
283  0x18,
284  0x61, 0x62, 0x63, 0x64,
285  0x65, 0x66, 0x67, 0x68,
286  0x40, 0x39, 0xae, 0x14,
287  0x7a, 0xe1, 0x47, 0xae,
288  0xc0, 0x13, 0x00, 0x00,
289  0x00, 0x00, 0x00, 0x00,
290  0x41, 0x48, 0xcc, 0xcd,
291  0x3f, 0xa0, 0x00, 0x00,
292  0x43, 0x1a, 0x35, 0xc3,
293  0xbb, 0xa3, 0xd7, 0x0a,
294  0xbf, 0xc0, 0x00, 0x00
295  };
296  // clang-format on
297 
298  std::vector<uint8_t> usbl_memory(memory1);
299  usbl_memory.insert(usbl_memory.end(), memory2.begin(), memory2.end());
300  usbl_memory.insert(usbl_memory.end(), memory3.begin(), memory3.end());
301 
302  auto buffer = boost::asio::buffer(const_cast<const uint8_t*>(usbl_memory.data()),
303  usbl_memory.size());
304 
305  Parser::Usbl1 parser1;
306  Parser::Usbl2 parser2;
307  Parser::Usbl3 parser3;
308 
309  Data::BinaryNav binaryNav;
310 
311  parser1.parse(buffer, binaryNav);
312  parser2.parse(buffer, binaryNav);
313  parser3.parse(buffer, binaryNav);
314 
315  std::array<uint8_t, 8> ref_val = {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}};
316 
317  ASSERT_TRUE(binaryNav.usbl1.is_initialized());
318  ASSERT_EQ(254, binaryNav.usbl1.get().validityTime_100us);
319  ASSERT_EQ(24, binaryNav.usbl1.get().usbl_id);
320  ASSERT_EQ(ref_val, binaryNav.usbl1.get().beacon_id);
321  ASSERT_DOUBLE_EQ(25.68, binaryNav.usbl1.get().latitude_deg);
322  ASSERT_DOUBLE_EQ(-4.75, binaryNav.usbl1.get().longitude_deg);
323  ASSERT_FLOAT_EQ(154.21, binaryNav.usbl1.get().altitude_m);
324  ASSERT_FLOAT_EQ(1.25, binaryNav.usbl1.get().north_stddev_m);
325  ASSERT_FLOAT_EQ(12.55, binaryNav.usbl1.get().east_stddev_m);
326  ASSERT_FLOAT_EQ(-0.005, binaryNav.usbl1.get().lat_lon_cov_m2);
327  ASSERT_FLOAT_EQ(-1.5, binaryNav.usbl1.get().altitude_stddev_m);
328 
329  ASSERT_TRUE(binaryNav.usbl2.is_initialized());
330  ASSERT_EQ(58, binaryNav.usbl2.get().validityTime_100us);
331  ASSERT_EQ(4, binaryNav.usbl2.get().usbl_id);
332  ASSERT_EQ(ref_val, binaryNav.usbl2.get().beacon_id);
333  ASSERT_DOUBLE_EQ(25.68, binaryNav.usbl2.get().latitude_deg);
334  ASSERT_DOUBLE_EQ(-4.75, binaryNav.usbl2.get().longitude_deg);
335  ASSERT_FLOAT_EQ(154.21, binaryNav.usbl2.get().altitude_m);
336  ASSERT_FLOAT_EQ(1.25, binaryNav.usbl2.get().north_stddev_m);
337  ASSERT_FLOAT_EQ(12.55, binaryNav.usbl2.get().east_stddev_m);
338  ASSERT_FLOAT_EQ(-0.005, binaryNav.usbl2.get().lat_lon_cov_m2);
339  ASSERT_FLOAT_EQ(-1.5, binaryNav.usbl2.get().altitude_stddev_m);
340 
341  ASSERT_TRUE(binaryNav.usbl3.is_initialized());
342  ASSERT_EQ(254, binaryNav.usbl3.get().validityTime_100us);
343  ASSERT_EQ(24, binaryNav.usbl3.get().usbl_id);
344  ASSERT_EQ(ref_val, binaryNav.usbl3.get().beacon_id);
345  ASSERT_DOUBLE_EQ(25.68, binaryNav.usbl3.get().latitude_deg);
346  ASSERT_DOUBLE_EQ(-4.75, binaryNav.usbl3.get().longitude_deg);
347  ASSERT_FLOAT_EQ(12.55, binaryNav.usbl3.get().altitude_m);
348  ASSERT_FLOAT_EQ(1.25, binaryNav.usbl3.get().north_stddev_m);
349  ASSERT_FLOAT_EQ(154.21, binaryNav.usbl3.get().east_stddev_m);
350  ASSERT_FLOAT_EQ(-0.005, binaryNav.usbl3.get().lat_lon_cov_m2);
351  ASSERT_FLOAT_EQ(-1.5, binaryNav.usbl3.get().altitude_stddev_m);
352 
353  // We also check that buffer was completly consumed by parser.
354  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
355 }
356 
357 TEST(MemoryBocksParser, ParseDepth)
358 {
359  // Validity Time : 254 (0x000000fe)
360  // Depth : 154.21f (0x431a35c3), DepthSD : 1.25f( 0x3fa00000 )
361 
362  // clang-format off
363  const std::vector<uint8_t> memory{
364  0x00, 0x00, 0x00, 0xfe,
365  0x43, 0x1a, 0x35, 0xc3,
366  0x3f, 0xa0, 0x00, 0x00
367  };
368  // clang-format on
369  auto buffer = boost::asio::buffer(memory.data(), memory.size());
370 
371  Parser::Depth parser;
372  Data::BinaryNav binaryNav;
373  parser.parse(buffer, binaryNav);
374 
375  ASSERT_TRUE(binaryNav.depth.is_initialized());
376  ASSERT_EQ(254, binaryNav.depth.get().validityTime_100us);
377  ASSERT_FLOAT_EQ(154.21, binaryNav.depth.get().depth_m);
378  ASSERT_FLOAT_EQ(1.25, binaryNav.depth.get().depth_stddev_m);
379 
380  // We also check that buffer was completly consumed by parser.
381  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
382 }
383 
384 TEST(MemoryBocksParser, ParseDvlGroundSpeed)
385 {
386  // 1 --> Validity Time : 254 (0x000000fe), DVL Id : 24 (0x18),
387  // xv1 : 154.21f (0x431a35c3), xv2 : 1.25f (0x3fa00000), xv3 : 12.55f (0x4148cccd),
388  // Speed of Sound : -0.005f (0xbba3d70a), altitude : -1.5f (0xbfc00000),
389  // xv1SD : 8.56f (0x4108f5c3), xv2SD : -2.4f (0xc019999a), xv3SD : 42.12f (0x42287ae1)
390 
391  // 2 --> Validity Time : 58 (0x0000003a), DVL Id : 4 (0x04),
392  // xv1 : 154.21f (0x431a35c3), xv2 : 1.25f (0x3fa00000), xv3 : 12.55f (0x4148cccd),
393  // Speed of Sound : -0.005f (0xbba3d70a), altitude : -1.5f (0xbfc00000),
394  // xv1SD : 8.56f (0x4108f5c3), xv2SD : -2.4f (0xc019999a), xv3SD : 42.12f (0x42287ae1)
395 
396  // clang-format off
397  const std::vector<uint8_t> memory1{
398  0x00, 0x00, 0x00, 0xfe,
399  0x18,
400  0x43, 0x1a, 0x35, 0xc3,
401  0x3f, 0xa0, 0x00, 0x00,
402  0x41, 0x48, 0xcc, 0xcd,
403  0xbb, 0xa3, 0xd7, 0x0a,
404  0xbf, 0xc0, 0x00, 0x00,
405  0x41, 0x08, 0xf5, 0xc3,
406  0xc0, 0x19, 0x99, 0x9a,
407  0x42, 0x28, 0x7a, 0xe1
408  };
409 
410  const std::vector<uint8_t> memory2{
411  0x00, 0x00, 0x00, 0x3a,
412  0x04,
413  0x43, 0x1a, 0x35, 0xc3,
414  0x3f, 0xa0, 0x00, 0x00,
415  0x41, 0x48, 0xcc, 0xcd,
416  0xbb, 0xa3, 0xd7, 0x0a,
417  0xbf, 0xc0, 0x00, 0x00,
418  0x41, 0x08, 0xf5, 0xc3,
419  0xc0, 0x19, 0x99, 0x9a,
420  0x42, 0x28, 0x7a, 0xe1
421  };
422  // clang-format on
423  std::vector<uint8_t> dvlgroundspeed_memory(memory1);
424  dvlgroundspeed_memory.insert(dvlgroundspeed_memory.end(), memory2.begin(),
425  memory2.end());
426 
427  auto buffer =
428  boost::asio::buffer(const_cast<const uint8_t*>(dvlgroundspeed_memory.data()),
429  dvlgroundspeed_memory.size());
430 
431  Parser::DvlGroundSpeed1 parser1;
432  Parser::DvlGroundSpeed2 parser2;
433 
434  Data::BinaryNav binaryNav;
435 
436  parser1.parse(buffer, binaryNav);
437  parser2.parse(buffer, binaryNav);
438 
439  ASSERT_TRUE(binaryNav.dvlGroundSpeed1.is_initialized());
440  ASSERT_EQ(254, binaryNav.dvlGroundSpeed1.get().validityTime_100us);
441  ASSERT_EQ(24, binaryNav.dvlGroundSpeed1.get().dvl_id);
442  ASSERT_FLOAT_EQ(154.21, binaryNav.dvlGroundSpeed1.get().xv1_groundspeed_ms);
443  ASSERT_FLOAT_EQ(1.25, binaryNav.dvlGroundSpeed1.get().xv2_groundspeed_ms);
444  ASSERT_FLOAT_EQ(12.55, binaryNav.dvlGroundSpeed1.get().xv3_groundspeed_ms);
445  ASSERT_FLOAT_EQ(-0.005, binaryNav.dvlGroundSpeed1.get().dvl_speedofsound_ms);
446  ASSERT_FLOAT_EQ(-1.5, binaryNav.dvlGroundSpeed1.get().dvl_altitude_m);
447  ASSERT_FLOAT_EQ(8.56, binaryNav.dvlGroundSpeed1.get().xv1_stddev_ms);
448  ASSERT_FLOAT_EQ(-2.4, binaryNav.dvlGroundSpeed1.get().xv2_stddev_ms);
449  ASSERT_FLOAT_EQ(42.12, binaryNav.dvlGroundSpeed1.get().xv3_stddev_ms);
450 
451  ASSERT_TRUE(binaryNav.dvlGroundSpeed2.is_initialized());
452  ASSERT_EQ(58, binaryNav.dvlGroundSpeed2.get().validityTime_100us);
453  ASSERT_EQ(4, binaryNav.dvlGroundSpeed2.get().dvl_id);
454  ASSERT_FLOAT_EQ(154.21, binaryNav.dvlGroundSpeed2.get().xv1_groundspeed_ms);
455  ASSERT_FLOAT_EQ(1.25, binaryNav.dvlGroundSpeed2.get().xv2_groundspeed_ms);
456  ASSERT_FLOAT_EQ(12.55, binaryNav.dvlGroundSpeed2.get().xv3_groundspeed_ms);
457  ASSERT_FLOAT_EQ(-0.005, binaryNav.dvlGroundSpeed2.get().dvl_speedofsound_ms);
458  ASSERT_FLOAT_EQ(-1.5, binaryNav.dvlGroundSpeed2.get().dvl_altitude_m);
459  ASSERT_FLOAT_EQ(8.56, binaryNav.dvlGroundSpeed2.get().xv1_stddev_ms);
460  ASSERT_FLOAT_EQ(-2.4, binaryNav.dvlGroundSpeed2.get().xv2_stddev_ms);
461  ASSERT_FLOAT_EQ(42.12, binaryNav.dvlGroundSpeed2.get().xv3_stddev_ms);
462 
463  // We also check that buffer was completly consumed by parser.
464  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
465 }
466 
467 TEST(MemoryBocksParser, ParseDvlWaterSpeed)
468 {
469  // 1 --> Validity Time : 254 (0x000000fe), DVL Id : 24 (0x18),
470  // xv1 : 154.21f (0x431a35c3), xv2 : 1.25f (0x3fa00000), xv3 : 12.55f (0x4148cccd),
471  // Speed of Sound : -0.005f (0xbba3d70a)
472  // xv1SD : 8.56f (0x4108f5c3), xv2SD : -2.4f (0xc019999a), xv3SD : 42.12f (0x42287ae1)
473 
474  // 2 --> Validity Time : 58 (0x0000003a), DVL Id : 4 (0x04),
475  // xv1 : 154.21f (0x431a35c3), xv2 : 1.25f (0x3fa00000), xv3 : 12.55f (0x4148cccd),
476  // Speed of Sound : -0.005f (0xbba3d70a)
477  // xv1SD : 8.56f (0x4108f5c3), xv2SD : -2.4f (0xc019999a), xv3SD : 42.12f (0x42287ae1)
478 
479  // clang-format off
480  const std::vector<uint8_t> memory1{
481  0x00, 0x00, 0x00, 0xfe,
482  0x18,
483  0x43, 0x1a, 0x35, 0xc3,
484  0x3f, 0xa0, 0x00, 0x00,
485  0x41, 0x48, 0xcc, 0xcd,
486  0xbb, 0xa3, 0xd7, 0x0a,
487  0x41, 0x08, 0xf5, 0xc3,
488  0xc0, 0x19, 0x99, 0x9a,
489  0x42, 0x28, 0x7a, 0xe1
490  };
491 
492  const std::vector<uint8_t> memory2{
493  0x00, 0x00, 0x00, 0x3a,
494  0x04,
495  0x43, 0x1a, 0x35, 0xc3,
496  0x3f, 0xa0, 0x00, 0x00,
497  0x41, 0x48, 0xcc, 0xcd,
498  0xbb, 0xa3, 0xd7, 0x0a,
499  0x41, 0x08, 0xf5, 0xc3,
500  0xc0, 0x19, 0x99, 0x9a,
501  0x42, 0x28, 0x7a, 0xe1
502  };
503  // clang-format on
504 
505  std::vector<uint8_t> dvlwaterspeed_memory(memory1);
506  dvlwaterspeed_memory.insert(dvlwaterspeed_memory.end(), memory2.begin(),
507  memory2.end());
508 
509  auto buffer =
510  boost::asio::buffer(const_cast<const uint8_t*>(dvlwaterspeed_memory.data()),
511  dvlwaterspeed_memory.size());
512 
513  Parser::DvlWaterSpeed1 parser1;
514  Parser::DvlWaterSpeed2 parser2;
515 
516  Data::BinaryNav binaryNav;
517 
518  parser1.parse(buffer, binaryNav);
519  parser2.parse(buffer, binaryNav);
520 
521  ASSERT_TRUE(binaryNav.dvlWaterSpeed1.is_initialized());
522  ASSERT_EQ(254, binaryNav.dvlWaterSpeed1.get().validityTime_100us);
523  ASSERT_EQ(24, binaryNav.dvlWaterSpeed1.get().dvl_id);
524  ASSERT_FLOAT_EQ(154.21, binaryNav.dvlWaterSpeed1.get().xv1_waterspeed_ms);
525  ASSERT_FLOAT_EQ(1.25, binaryNav.dvlWaterSpeed1.get().xv2_waterspeed_ms);
526  ASSERT_FLOAT_EQ(12.55, binaryNav.dvlWaterSpeed1.get().xv3_waterspeed_ms);
527  ASSERT_FLOAT_EQ(-0.005, binaryNav.dvlWaterSpeed1.get().dvl_speedofsound_ms);
528  ASSERT_FLOAT_EQ(8.56, binaryNav.dvlWaterSpeed1.get().xv1_stddev_ms);
529  ASSERT_FLOAT_EQ(-2.4, binaryNav.dvlWaterSpeed1.get().xv2_stddev_ms);
530  ASSERT_FLOAT_EQ(42.12, binaryNav.dvlWaterSpeed1.get().xv3_stddev_ms);
531 
532  ASSERT_TRUE(binaryNav.dvlWaterSpeed2.is_initialized());
533  ASSERT_EQ(58, binaryNav.dvlWaterSpeed2.get().validityTime_100us);
534  ASSERT_EQ(4, binaryNav.dvlWaterSpeed2.get().dvl_id);
535  ASSERT_FLOAT_EQ(154.21, binaryNav.dvlWaterSpeed2.get().xv1_waterspeed_ms);
536  ASSERT_FLOAT_EQ(1.25, binaryNav.dvlWaterSpeed2.get().xv2_waterspeed_ms);
537  ASSERT_FLOAT_EQ(12.55, binaryNav.dvlWaterSpeed2.get().xv3_waterspeed_ms);
538  ASSERT_FLOAT_EQ(-0.005, binaryNav.dvlWaterSpeed2.get().dvl_speedofsound_ms);
539  ASSERT_FLOAT_EQ(8.56, binaryNav.dvlWaterSpeed2.get().xv1_stddev_ms);
540  ASSERT_FLOAT_EQ(-2.4, binaryNav.dvlWaterSpeed2.get().xv2_stddev_ms);
541  ASSERT_FLOAT_EQ(42.12, binaryNav.dvlWaterSpeed2.get().xv3_stddev_ms);
542 
543  // We also check that buffer was completly consumed by parser.
544  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
545 }
546 
547 TEST(MemoryBocksParser, ParseSoundVelocity)
548 {
549  // Validity Time : 254 (0x000000fe), Speed of sound : 154.21f (0x431a35c3)
550 
551  // clang-format off
552  const std::vector<uint8_t> memory{
553  0x00, 0x00, 0x00, 0xfe,
554  0x43, 0x1a, 0x35, 0xc3
555  };
556  // clang-format on
557  auto buffer = boost::asio::buffer(memory.data(), memory.size());
558 
559  Parser::SoundVelocity parser;
560  Data::BinaryNav binaryNav;
561  parser.parse(buffer, binaryNav);
562 
563  ASSERT_TRUE(binaryNav.soundVelocity.is_initialized());
564  ASSERT_EQ(254, binaryNav.soundVelocity.get().validityTime_100us);
565  ASSERT_FLOAT_EQ(154.21, binaryNav.soundVelocity.get().ext_speedofsound_ms);
566 
567  // We also check that buffer was completly consumed by parser.
568  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
569 }
570 
571 TEST(MemoryBocksParser, ParseDmi)
572 {
573  // Validity Time : 254 (0x000000fe), Pulse count : 154 (0x0000009a)
574 
575  // clang-format off
576  const std::vector<uint8_t> memory{
577  0x00, 0x00, 0x00, 0xfe,
578  0x00, 0x00, 0x00, 0x9a
579  };
580  // clang-format on
581  auto buffer = boost::asio::buffer(memory.data(), memory.size());
582 
583  Parser::Dmi parser;
584  Data::BinaryNav binaryNav;
585  parser.parse(buffer, binaryNav);
586 
587  ASSERT_TRUE(binaryNav.dmi.is_initialized());
588  ASSERT_EQ(254, binaryNav.dmi.get().validityTime_100us);
589  ASSERT_FLOAT_EQ(154, binaryNav.dmi.get().pulse_count);
590 
591  // We also check that buffer was completly consumed by parser.
592  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
593 }
594 
595 TEST(MemoryBocksParser, ParseLbl)
596 {
597  // 1 --> Validity Time : 254 (0x000000fe), RFU : 0 (0x00), Beacon id : abcdefgh
598  // (0x6162636465666768), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
599  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), range : 1.25f(
600  // 0x3fa00000 ), rangeSD : 12.55f (0x4148cccd)
601 
602  // 2 --> Validity Time : 58 (0x0000003a), RFU : 0 (0x00), Beacon id : abcdefgh
603  // (0x6162636465666768), latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d
604  // (0xc013000000000000), altitude : 154.21f (0x431a35c3), range : 1.25f(
605  // 0x3fa00000 ), rangeSD : 12.55f (0x4148cccd)
606 
607  // 3 --> Validity Time : 254 (0x000000fe), RFU : 0 (0x00), Beacon id : abcdefgh
608  // (0x6162636465666768), latitude : -4.75d(0xc013000000000000), longitude : 25.68d
609  // (0x4039ae147ae147ae), altitude : 154.21f (0x431a35c3), range : 1.25f( 0x3fa00000 ),
610  // rangeSD : 12.55f (0x4148cccd)
611 
612  // 4 --> Validity Time : 58 (0x0000003a), RFU : 0 (0x00), Beacon id : abcdefgh
613  // (0x6162636465666768), latitude : -4.75d(0xc013000000000000), longitude : 25.68d
614  // (0x4039ae147ae147ae), altitude : 154.21f (0x431a35c3), range : 1.25f(
615  // 0x3fa00000 ), rangeSD : 12.55f (0x4148cccd)
616 
617  // clang-format off
618  const std::vector<uint8_t> memory1{
619  0x00, 0x00, 0x00, 0xfe,
620  0x00,
621  0x61, 0x62, 0x63, 0x64,
622  0x65, 0x66, 0x67, 0x68,
623  0x40, 0x39, 0xae, 0x14,
624  0x7a, 0xe1, 0x47, 0xae,
625  0xc0, 0x13, 0x00, 0x00,
626  0x00, 0x00, 0x00, 0x00,
627  0x43, 0x1a, 0x35, 0xc3,
628  0x3f, 0xa0, 0x00, 0x00,
629  0x41, 0x48, 0xcc, 0xcd
630  };
631 
632  const std::vector<uint8_t> memory2{
633  0x00, 0x00, 0x00, 0x3a,
634  0x00,
635  0x61, 0x62, 0x63, 0x64,
636  0x65, 0x66, 0x67, 0x68,
637  0x40, 0x39, 0xae, 0x14,
638  0x7a, 0xe1, 0x47, 0xae,
639  0xc0, 0x13, 0x00, 0x00,
640  0x00, 0x00, 0x00, 0x00,
641  0x43, 0x1a, 0x35, 0xc3,
642  0x3f, 0xa0, 0x00, 0x00,
643  0x41, 0x48, 0xcc, 0xcd
644  };
645 
646  const std::vector<uint8_t> memory3{
647  0x00, 0x00, 0x00, 0xfe,
648  0x00,
649  0x61, 0x62, 0x63, 0x64,
650  0x65, 0x66, 0x67, 0x68,
651  0xc0, 0x13, 0x00, 0x00,
652  0x00, 0x00, 0x00, 0x00,
653  0x40, 0x39, 0xae, 0x14,
654  0x7a, 0xe1, 0x47, 0xae,
655  0x43, 0x1a, 0x35, 0xc3,
656  0x3f, 0xa0, 0x00, 0x00,
657  0x41, 0x48, 0xcc, 0xcd
658  };
659 
660  const std::vector<uint8_t> memory4{
661  0x00, 0x00, 0x00, 0x3a,
662  0x00,
663  0x61, 0x62, 0x63, 0x64,
664  0x65, 0x66, 0x67, 0x68,
665  0xc0, 0x13, 0x00, 0x00,
666  0x00, 0x00, 0x00, 0x00,
667  0x40, 0x39, 0xae, 0x14,
668  0x7a, 0xe1, 0x47, 0xae,
669  0x43, 0x1a, 0x35, 0xc3,
670  0x3f, 0xa0, 0x00, 0x00,
671  0x41, 0x48, 0xcc, 0xcd
672  };
673  // clang-format on
674 
675  std::vector<uint8_t> lbl_memory(memory1);
676  lbl_memory.insert(lbl_memory.end(), memory2.begin(), memory2.end());
677  lbl_memory.insert(lbl_memory.end(), memory3.begin(), memory3.end());
678  lbl_memory.insert(lbl_memory.end(), memory4.begin(), memory4.end());
679 
680  auto buffer = boost::asio::buffer(const_cast<const uint8_t*>(lbl_memory.data()),
681  lbl_memory.size());
682 
683  Parser::Lbl1 parser1;
684  Parser::Lbl2 parser2;
685  Parser::Lbl3 parser3;
686  Parser::Lbl4 parser4;
687 
688  Data::BinaryNav binaryNav;
689 
690  parser1.parse(buffer, binaryNav);
691  parser2.parse(buffer, binaryNav);
692  parser3.parse(buffer, binaryNav);
693  parser4.parse(buffer, binaryNav);
694 
695  std::array<uint8_t, 8> ref_val = {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}};
696 
697  ASSERT_TRUE(binaryNav.lbl1.is_initialized());
698  ASSERT_EQ(254, binaryNav.lbl1.get().validityTime_100us);
699  ASSERT_EQ(0, binaryNav.lbl1.get().rfu);
700  ASSERT_EQ(ref_val, binaryNav.lbl1.get().beacon_id);
701  ASSERT_DOUBLE_EQ(25.68, binaryNav.lbl1.get().beacon_latitude_deg);
702  ASSERT_DOUBLE_EQ(-4.75, binaryNav.lbl1.get().beacon_longitude_deg);
703  ASSERT_FLOAT_EQ(154.21, binaryNav.lbl1.get().beacon_altitude_m);
704  ASSERT_FLOAT_EQ(1.25, binaryNav.lbl1.get().range_m);
705  ASSERT_FLOAT_EQ(12.55, binaryNav.lbl1.get().range_stddev_m);
706 
707  ASSERT_TRUE(binaryNav.lbl2.is_initialized());
708  ASSERT_EQ(58, binaryNav.lbl2.get().validityTime_100us);
709  ASSERT_EQ(0, binaryNav.lbl2.get().rfu);
710  ASSERT_EQ(ref_val, binaryNav.lbl2.get().beacon_id);
711  ASSERT_DOUBLE_EQ(25.68, binaryNav.lbl2.get().beacon_latitude_deg);
712  ASSERT_DOUBLE_EQ(-4.75, binaryNav.lbl2.get().beacon_longitude_deg);
713  ASSERT_FLOAT_EQ(154.21, binaryNav.lbl2.get().beacon_altitude_m);
714  ASSERT_FLOAT_EQ(1.25, binaryNav.lbl2.get().range_m);
715  ASSERT_FLOAT_EQ(12.55, binaryNav.lbl2.get().range_stddev_m);
716 
717  ASSERT_TRUE(binaryNav.lbl3.is_initialized());
718  ASSERT_EQ(254, binaryNav.lbl3.get().validityTime_100us);
719  ASSERT_EQ(0, binaryNav.lbl3.get().rfu);
720  ASSERT_EQ(ref_val, binaryNav.lbl3.get().beacon_id);
721  ASSERT_DOUBLE_EQ(-4.75, binaryNav.lbl3.get().beacon_latitude_deg);
722  ASSERT_DOUBLE_EQ(25.68, binaryNav.lbl3.get().beacon_longitude_deg);
723  ASSERT_FLOAT_EQ(154.21, binaryNav.lbl3.get().beacon_altitude_m);
724  ASSERT_FLOAT_EQ(1.25, binaryNav.lbl3.get().range_m);
725  ASSERT_FLOAT_EQ(12.55, binaryNav.lbl3.get().range_stddev_m);
726 
727  ASSERT_TRUE(binaryNav.lbl4.is_initialized());
728  ASSERT_EQ(58, binaryNav.lbl4.get().validityTime_100us);
729  ASSERT_EQ(0, binaryNav.lbl4.get().rfu);
730  ASSERT_EQ(ref_val, binaryNav.lbl4.get().beacon_id);
731  ASSERT_DOUBLE_EQ(-4.75, binaryNav.lbl4.get().beacon_latitude_deg);
732  ASSERT_DOUBLE_EQ(25.68, binaryNav.lbl4.get().beacon_longitude_deg);
733  ASSERT_FLOAT_EQ(154.21, binaryNav.lbl4.get().beacon_altitude_m);
734  ASSERT_FLOAT_EQ(1.25, binaryNav.lbl4.get().range_m);
735  ASSERT_FLOAT_EQ(12.55, binaryNav.lbl4.get().range_stddev_m);
736 
737  // We also check that buffer was completly consumed by parser.
738  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
739 }
740 
741 TEST(MemoryBocksParser, ParseEventMarker)
742 {
743  // 1 --> Validity Time : 254 (0x000000fe), event id : 24 (0x18)
744  // Pulse count : 154 (0x0000009a)
745 
746  // 2 --> Validity Time : 58 (0x0000003a), event id : 24 (0x18)
747  // Pulse count : 254 (0x000000fe)
748 
749  // 3 --> Validity Time : 254 (0x000000fe), event id : 4 (0x04)
750  // Pulse count : 58 (0x0000003a)
751 
752  // clang-format off
753  const std::vector<uint8_t> memory1{
754  0x00, 0x00, 0x00, 0xfe,
755  0x18,
756  0x00, 0x00, 0x00, 0x9a
757  };
758 
759  const std::vector<uint8_t> memory2{
760  0x00, 0x00, 0x00, 0x3a,
761  0x18,
762  0x00, 0x00, 0x00, 0xfe
763  };
764 
765  const std::vector<uint8_t> memory3{
766  0x00, 0x00, 0x00, 0xfe,
767  0x04,
768  0x00, 0x00, 0x00, 0x3a
769  };
770  // clang-format on
771  std::vector<uint8_t> eventmarker_memory(memory1);
772  eventmarker_memory.insert(eventmarker_memory.end(), memory2.begin(), memory2.end());
773  eventmarker_memory.insert(eventmarker_memory.end(), memory3.begin(), memory3.end());
774 
775  auto buffer = boost::asio::buffer(
776  const_cast<const uint8_t*>(eventmarker_memory.data()), eventmarker_memory.size());
777 
778  Parser::EventMarkerA parser1;
779  Parser::EventMarkerB parser2;
780  Parser::EventMarkerC parser3;
781 
782  Data::BinaryNav binaryNav;
783 
784  parser1.parse(buffer, binaryNav);
785  parser2.parse(buffer, binaryNav);
786  parser3.parse(buffer, binaryNav);
787 
788  ASSERT_TRUE(binaryNav.eventMarkerA.is_initialized());
789  ASSERT_EQ(254, binaryNav.eventMarkerA.get().validityTime_100us);
790  ASSERT_EQ(24, binaryNav.eventMarkerA.get().event_id);
791  ASSERT_EQ(154, binaryNav.eventMarkerA.get().event_count);
792 
793  ASSERT_TRUE(binaryNav.eventMarkerB.is_initialized());
794  ASSERT_EQ(58, binaryNav.eventMarkerB.get().validityTime_100us);
795  ASSERT_EQ(24, binaryNav.eventMarkerB.get().event_id);
796  ASSERT_EQ(254, binaryNav.eventMarkerB.get().event_count);
797 
798  ASSERT_TRUE(binaryNav.eventMarkerC.is_initialized());
799  ASSERT_EQ(254, binaryNav.eventMarkerC.get().validityTime_100us);
800  ASSERT_EQ(4, binaryNav.eventMarkerC.get().event_id);
801  ASSERT_EQ(58, binaryNav.eventMarkerC.get().event_count);
802 
803  // We also check that buffer was completly consumed by parser.
804  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
805 }
806 
807 TEST(MemoryBocksParser, ParseTurretAngles)
808 {
809  // Validity Time : 254 (0x000000fe),
810  // Angle : 1.25f (0x3fa00000), Roll : 12.55f (0x4148cccd),
811  // Elevation putch : -0.005f (0xbba3d70a)
812 
813  // clang-format off
814  const std::vector<uint8_t> memory{
815  0x00, 0x00, 0x00, 0xfe,
816  0x3f, 0xa0, 0x00, 0x00,
817  0x41, 0x48, 0xcc, 0xcd,
818  0xbb, 0xa3, 0xd7, 0x0a
819  };
820  // clang-format on
821  auto buffer = boost::asio::buffer(memory.data(), memory.size());
822 
823  Parser::TurretAngles parser;
824  Data::BinaryNav binaryNav;
825  parser.parse(buffer, binaryNav);
826 
827  ASSERT_TRUE(binaryNav.turretAngles.is_initialized());
828  ASSERT_EQ(254, binaryNav.turretAngles.get().validityTime_100us);
829  ASSERT_FLOAT_EQ(1.25, binaryNav.turretAngles.get().headingbearingdrift_angle_deg);
830  ASSERT_FLOAT_EQ(12.55, binaryNav.turretAngles.get().roll_deg);
831  ASSERT_FLOAT_EQ(-0.005, binaryNav.turretAngles.get().elevationpitch_deg);
832 
833  // We also check that buffer was completly consumed by parser.
834  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
835 }
836 
837 TEST(MemoryBocksParser, ParseVtg)
838 {
839  // 1 --> Validity Time : 254 (0x000000fe), VTG Id : 24 (0x18),
840  // Angle : 1.25f (0x3fa00000), Roll : 12.55f (0x4148cccd),
841  // Elevation putch : -0.005f (0xbba3d70a)
842 
843  // 2 --> Validity Time : 58 (0x0000003a), VTG Id : 4 (0x04),
844  // Angle : 1.25f (0x3fa00000), Roll : 12.55f (0x4148cccd),
845  // Elevation putch : -0.005f (0xbba3d70a)
846 
847  // clang-format off
848  const std::vector<uint8_t> memory1{
849  0x00, 0x00, 0x00, 0xfe,
850  0x18,
851  0x3f, 0xa0, 0x00, 0x00,
852  0x41, 0x48, 0xcc, 0xcd,
853  0xbb, 0xa3, 0xd7, 0x0a
854  };
855 
856  const std::vector<uint8_t> memory2{
857  0x00, 0x00, 0x00, 0x3a,
858  0x04,
859  0x3f, 0xa0, 0x00, 0x00,
860  0x41, 0x48, 0xcc, 0xcd,
861  0xbb, 0xa3, 0xd7, 0x0a
862  };
863  // clang-format on
864  std::vector<uint8_t> vtg_memory(memory1);
865  vtg_memory.insert(vtg_memory.end(), memory2.begin(), memory2.end());
866 
867  auto buffer = boost::asio::buffer(const_cast<const uint8_t*>(vtg_memory.data()),
868  vtg_memory.size());
869 
870  Parser::Vtg1 parser1;
871  Parser::Vtg2 parser2;
872 
873  Data::BinaryNav binaryNav;
874 
875  parser1.parse(buffer, binaryNav);
876  parser2.parse(buffer, binaryNav);
877 
878  ASSERT_TRUE(binaryNav.vtg1.is_initialized());
879  ASSERT_EQ(254, binaryNav.vtg1.get().validityTime_100us);
880  ASSERT_EQ(24, binaryNav.vtg1.get().vtg_id);
881  ASSERT_FLOAT_EQ(1.25, binaryNav.vtg1.get().true_course_deg);
882  ASSERT_FLOAT_EQ(12.55, binaryNav.vtg1.get().magnetic_course_deg);
883  ASSERT_FLOAT_EQ(-0.005, binaryNav.vtg1.get().speed_over_ground_ms);
884 
885  ASSERT_TRUE(binaryNav.vtg2.is_initialized());
886  ASSERT_EQ(58, binaryNav.vtg2.get().validityTime_100us);
887  ASSERT_EQ(4, binaryNav.vtg2.get().vtg_id);
888  ASSERT_FLOAT_EQ(1.25, binaryNav.vtg2.get().true_course_deg);
889  ASSERT_FLOAT_EQ(12.55, binaryNav.vtg2.get().magnetic_course_deg);
890  ASSERT_FLOAT_EQ(-0.005, binaryNav.vtg2.get().speed_over_ground_ms);
891 
892  // We also check that buffer was completly consumed by parser.
893  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
894 }
895 
896 TEST(MemoryBocksParser, ParseLogBook)
897 {
898  // Validity Time : 254 (0x000000fe), event id : 785 (0x00000311)
899  // Pulse count : abcd (0x61626364)
900 
901  // clang-format off
902  const std::vector<uint8_t> memory{
903  0x00, 0x00, 0x00, 0xfe,
904  0x00, 0x00, 0x03, 0x11,
905  0x61, 0x62, 0x63, 0x64,
906  0x65, 0x66, 0x67, 0x68,
907  0x61, 0x62, 0x63, 0x64,
908  0x65, 0x66, 0x67, 0x68,
909  0x61, 0x62, 0x63, 0x64,
910  0x65, 0x66, 0x67, 0x68,
911  0x61, 0x62, 0x63, 0x64,
912  0x65, 0x66, 0x67, 0x68
913  };
914  // clang-format on
915  auto buffer = boost::asio::buffer(memory.data(), memory.size());
916 
917  Parser::LogBook parser;
918  Data::BinaryNav binaryNav;
919  parser.parse(buffer, binaryNav);
920 
921  std::array<uint8_t, 32> ref_val = {
922  {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
923  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}};
924 
925  ASSERT_TRUE(binaryNav.logBook.is_initialized());
926  ASSERT_EQ(254, binaryNav.logBook.get().validityTime_100us);
927  ASSERT_EQ(785, binaryNav.logBook.get().log_id);
928  ASSERT_EQ(ref_val, binaryNav.logBook.get().custom_text);
929 
930  // We also check that buffer was completly consumed by parser.
931  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
932 }
933 
934 int main(int argc, char** argv)
935 {
936  ::testing::InitGoogleTest(&argc, argv);
937  return RUN_ALL_TESTS();
938 }
boost::optional< Usbl > usbl3
Definition: stdbin.h:121
boost::optional< Lbl > lbl4
Definition: stdbin.h:130
boost::optional< EventMarker > eventMarkerB
Definition: stdbin.h:132
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: vtg2.h:14
boost::optional< Lbl > lbl2
Definition: stdbin.h:128
boost::optional< Usbl > usbl1
Definition: stdbin.h:119
boost::optional< SoundVelocity > soundVelocity
Definition: stdbin.h:125
boost::optional< Depth > depth
Definition: stdbin.h:122
boost::optional< Gnss > gnss1
Definition: stdbin.h:114
TEST(MemoryBocksParser, ParseUtc)
boost::optional< Emlog > emlog2
Definition: stdbin.h:118
boost::optional< DvlWaterSpeed > dvlWaterSpeed2
Definition: stdbin.h:135
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
boost::optional< EventMarker > eventMarkerA
Definition: stdbin.h:131
boost::optional< Vtg > vtg2
Definition: stdbin.h:138
boost::optional< DvlGroundSpeed > dvlGroundSpeed2
Definition: stdbin.h:134
boost::optional< Gnss > gnss2
Definition: stdbin.h:115
boost::optional< Vtg > vtg1
Definition: stdbin.h:137
boost::optional< TurretAngles > turretAngles
Definition: stdbin.h:136
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: lbl3.h:14
boost::optional< DvlWaterSpeed > dvlWaterSpeed1
Definition: stdbin.h:124
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: usbl2.h:14
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: lbl4.h:14
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: lbl2.h:14
boost::optional< Lbl > lbl1
Definition: stdbin.h:127
boost::optional< Usbl > usbl2
Definition: stdbin.h:120
boost::optional< Gnss > gnssManual
Definition: stdbin.h:116
int main(int argc, char **argv)
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: eventmarker_b.h:14
boost::optional< Emlog > emlog1
Definition: stdbin.h:117
boost::optional< EventMarker > eventMarkerC
Definition: stdbin.h:133
boost::optional< Utc > utc
Definition: stdbin.h:113
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: usbl3.h:14
boost::optional< Dmi > dmi
Definition: stdbin.h:126
boost::optional< LogBook > logBook
Definition: stdbin.h:139
boost::optional< DvlGroundSpeed > dvlGroundSpeed1
Definition: stdbin.h:123
void parse(boost::asio::const_buffer &buffer, Data::BinaryNav &outBinaryNav) override
Definition: eventmarker_c.h:14
boost::optional< Lbl > lbl3
Definition: stdbin.h:129


ixblue_stdbin_decoder
Author(s): Adrien BARRAL , Laure LEBROTON
autogenerated on Sat Jan 9 2021 03:13:21