os32c_test.cpp
Go to the documentation of this file.
1 
27 #include <gtest/gtest.h>
28 #include <boost/make_shared.hpp>
29 
35 
36 using boost::make_shared;
37 using namespace boost::asio;
38 
39 using namespace eip;
40 using namespace eip::socket;
41 using namespace eip::serialization;
42 
43 namespace omron_os32c_driver {
44 
45 class OS32CTest : public ::testing ::Test
46 {
47 public:
48  OS32CTest() : os32c(ts, ts_io)
49  {
50  }
51 
52 protected:
53  virtual void SetUp()
54  {
55  ts = make_shared<TestSocket>();
56  ts_io = make_shared<TestSocket>();
57  os32c = OS32C(ts, ts_io);
58  }
59 
63 };
64 
65 TEST_F(OS32CTest, test_calc_beam_number)
66 {
67  EXPECT_EQ(0, OS32C::calcBeamNumber(2.359685166149626)); // 135.200001 degrees
68  EXPECT_EQ(0, OS32C::calcBeamNumber(2.356194491937674)); // 135.0000001
69  // EXPECT_EQ( 0, OS32C::calcBeamNumber(2.356194490192345 )); // 135
70  EXPECT_EQ(1, OS32C::calcBeamNumber(2.3561944901748917)); // 134.999999999
71  EXPECT_EQ(1, OS32C::calcBeamNumber(2.3492131733589003)); // 134.60000001
72  EXPECT_EQ(338, OS32C::calcBeamNumber(0.0034906583294557337)); // 0.19999999
73  EXPECT_EQ(338, OS32C::calcBeamNumber(0));
74  EXPECT_EQ(338, OS32C::calcBeamNumber(-0.0034906583294557337)); // -0.19999999
75  EXPECT_EQ(675, OS32C::calcBeamNumber(-2.3492131733589003)); // -134.60000001
76  EXPECT_EQ(675, OS32C::calcBeamNumber(-2.3561944901748917)); // -134.999999999
77  // EXPECT_EQ(676, OS32C::calcBeamNumber(-2.356194490192345 )); // -135
78  EXPECT_EQ(676, OS32C::calcBeamNumber(-2.356194491937674)); // -135.0000001
79  EXPECT_EQ(676, OS32C::calcBeamNumber(-2.359685166149626)); // -135.200001 degrees
80 }
81 
82 TEST_F(OS32CTest, test_calc_beam_centre)
83 {
84  EXPECT_DOUBLE_EQ(2.3596851486963333, OS32C::calcBeamCentre(0));
85  EXPECT_DOUBLE_EQ(2.3527038316883564, OS32C::calcBeamCentre(1));
86  EXPECT_NEAR(0, OS32C::calcBeamCentre(338), 0.00000000001);
87  EXPECT_DOUBLE_EQ(-2.3527038316883564, OS32C::calcBeamCentre(675));
88  EXPECT_DOUBLE_EQ(-2.3596851486963333, OS32C::calcBeamCentre(676));
89 }
90 
91 TEST_F(OS32CTest, test_calc_beam_mask_all)
92 {
93  EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
94  memset(buffer, 0xAA, sizeof(buffer));
95  EIP_BYTE* mask = buffer + 4;
96  os32c.calcBeamMask(OS32C::ANGLE_MAX, OS32C::ANGLE_MIN, mask);
97  EXPECT_DOUBLE_EQ(2.3596851486963333, os32c.start_angle_);
98  EXPECT_DOUBLE_EQ(-2.3596851486963333, os32c.end_angle_);
99  for (size_t i = 0; i < 4; ++i)
100  {
101  EXPECT_EQ(0xAA, buffer[i]);
102  }
103  for (size_t i = 0; i < 84; ++i)
104  {
105  EXPECT_EQ(0xFF, mask[i]);
106  }
107  EXPECT_EQ(0x1F, mask[84]);
108  EXPECT_EQ(0, mask[85]);
109  EXPECT_EQ(0, mask[86]);
110  EXPECT_EQ(0, mask[87]);
111  for (size_t i = 92; i < 96; ++i)
112  {
113  EXPECT_EQ(0xAA, buffer[i]);
114  }
115 }
116 
117 TEST_F(OS32CTest, test_calc_beam_at_90)
118 {
119  EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
120  memset(buffer, 0xAA, sizeof(buffer));
121  EIP_BYTE* mask = buffer + 4;
122  os32c.calcBeamMask(0.7853981633974483, -0.7853981633974483, mask);
123  EXPECT_DOUBLE_EQ(0.788888821901437, os32c.start_angle_);
124  EXPECT_DOUBLE_EQ(-0.7819075048934596, os32c.end_angle_);
125  for (size_t i = 0; i < 4; ++i)
126  {
127  EXPECT_EQ(0xAA, buffer[i]);
128  }
129  for (size_t i = 0; i < 28; ++i)
130  {
131  EXPECT_EQ(0, mask[i]);
132  }
133  EXPECT_EQ(0xFE, mask[28]);
134  for (size_t i = 29; i < 56; ++i)
135  {
136  EXPECT_EQ(0xFF, mask[i]);
137  }
138  EXPECT_EQ(0x07, mask[56]);
139  for (size_t i = 57; i < 88; ++i)
140  {
141  EXPECT_EQ(0, mask[i]);
142  }
143  for (size_t i = 92; i < 96; ++i)
144  {
145  EXPECT_EQ(0xAA, buffer[i]);
146  }
147 }
148 
149 TEST_F(OS32CTest, test_calc_beam_boundaries)
150 {
151  EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
152  memset(buffer, 0xAA, sizeof(buffer));
153  EIP_BYTE* mask = buffer + 4;
154  os32c.calcBeamMask(0.6911503837897546, -0.7051130178057091, mask);
155  EXPECT_DOUBLE_EQ(0.6911503837897546, os32c.start_angle_);
156  EXPECT_DOUBLE_EQ(-0.70511301780570967, os32c.end_angle_);
157  for (size_t i = 0; i < 4; ++i)
158  {
159  EXPECT_EQ(0xAA, buffer[i]);
160  }
161  for (size_t i = 0; i < 29; ++i)
162  {
163  EXPECT_EQ(0, mask[i]);
164  }
165  EXPECT_EQ(0x80, mask[29]);
166  for (size_t i = 30; i < 55; ++i)
167  {
168  EXPECT_EQ(0xFF, mask[i]);
169  }
170  for (size_t i = 55; i < 88; ++i)
171  {
172  EXPECT_EQ(0, mask[i]);
173  }
174  for (size_t i = 92; i < 96; ++i)
175  {
176  EXPECT_EQ(0xAA, buffer[i]);
177  }
178 }
179 
180 TEST_F(OS32CTest, test_calc_beam_invalid_args)
181 {
182  EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
183  memset(buffer, 0xAA, sizeof(buffer));
184  EIP_BYTE* mask = buffer + 4;
185  EXPECT_THROW(os32c.calcBeamMask(2.3631758089456514, -0.7051130178057091, mask), std::invalid_argument);
186  EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, -2.3631758089456514, mask), std::invalid_argument);
187  EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, 0.6911503837897546, mask), std::invalid_argument);
188  EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, 0.6841690685271065, mask), std::invalid_argument);
189 }
190 
191 TEST_F(OS32CTest, test_select_beams)
192 {
193  // clang-format off
194  char reg_resp_packet[] = {
195  0x65, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00,
196  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198  0x01, 0x00, 0x00, 0x00,
199  };
200  // clang-format on
201 
202  ts->rx_buffer = buffer(reg_resp_packet);
203  os32c.open("example_host");
204  EXPECT_TRUE(ts->is_open);
205  EXPECT_EQ("example_host", ts->hostname);
206  EXPECT_EQ("44818", ts->port);
207  EXPECT_EQ(5, os32c.getSessionID());
208 
209  // clear out the tx buffer
210  ts->tx_count = 0;
211  memset(ts->tx_buffer, 0, sizeof(ts->tx_count));
212 
213  // response packet from OS32C docs
214  // clang-format off
215  uint8_t resp_packet[] = {
216  0x6F, 0x00, 0x14, 0x00, 0x05, 0x00, 0x00, 0x00,
217  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
218  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
220  0x00, 0x00, 0x00, 0x00, 0xB2, 0x00, 0x04, 0x00,
221  0x90, 0x00, 0x00, 0x00,
222  };
223  // clang-format on
224  ts->rx_buffer = buffer(resp_packet);
225 
226  os32c.selectBeams(OS32C::ANGLE_MAX, OS32C::ANGLE_MIN);
227 
228  // check the request packet
229  EXPECT_EQ(136, ts->tx_count);
230 
231  EXPECT_EQ(0x6F, ts->tx_buffer[0]);
232  EXPECT_EQ(0x00, ts->tx_buffer[1]);
233  EXPECT_EQ(0x70, ts->tx_buffer[2]);
234  EXPECT_EQ(0x00, ts->tx_buffer[3]);
235  EXPECT_EQ(0x05, ts->tx_buffer[4]);
236  EXPECT_EQ(0x00, ts->tx_buffer[5]);
237  EXPECT_EQ(0x00, ts->tx_buffer[6]);
238  EXPECT_EQ(0x00, ts->tx_buffer[7]);
239  EXPECT_EQ(0x00, ts->tx_buffer[8]);
240  EXPECT_EQ(0x00, ts->tx_buffer[9]);
241  EXPECT_EQ(0x00, ts->tx_buffer[10]);
242  EXPECT_EQ(0x00, ts->tx_buffer[11]);
243  EXPECT_EQ(0x00, ts->tx_buffer[12]);
244  EXPECT_EQ(0x00, ts->tx_buffer[13]);
245  EXPECT_EQ(0x00, ts->tx_buffer[14]);
246  EXPECT_EQ(0x00, ts->tx_buffer[15]);
247  EXPECT_EQ(0x00, ts->tx_buffer[16]);
248  EXPECT_EQ(0x00, ts->tx_buffer[17]);
249  EXPECT_EQ(0x00, ts->tx_buffer[18]);
250  EXPECT_EQ(0x00, ts->tx_buffer[19]);
251  EXPECT_EQ(0x00, ts->tx_buffer[20]);
252  EXPECT_EQ(0x00, ts->tx_buffer[21]);
253  EXPECT_EQ(0x00, ts->tx_buffer[22]);
254  EXPECT_EQ(0x00, ts->tx_buffer[23]);
255  EXPECT_EQ(0x00, ts->tx_buffer[24]);
256  EXPECT_EQ(0x00, ts->tx_buffer[25]);
257  EXPECT_EQ(0x00, ts->tx_buffer[26]);
258  EXPECT_EQ(0x00, ts->tx_buffer[27]);
259  EXPECT_EQ(0x00, ts->tx_buffer[28]);
260  EXPECT_EQ(0x00, ts->tx_buffer[29]);
261  EXPECT_EQ(0x02, ts->tx_buffer[30]);
262  EXPECT_EQ(0x00, ts->tx_buffer[31]);
263  EXPECT_EQ(0x00, ts->tx_buffer[32]);
264  EXPECT_EQ(0x00, ts->tx_buffer[33]);
265  EXPECT_EQ(0x00, ts->tx_buffer[34]);
266  EXPECT_EQ(0x00, ts->tx_buffer[35]);
267  EXPECT_EQ(0xB2, ts->tx_buffer[36]);
268  EXPECT_EQ(0x00, ts->tx_buffer[37]);
269  EXPECT_EQ(0x60, ts->tx_buffer[38]);
270  EXPECT_EQ(0x00, ts->tx_buffer[39]);
271  EXPECT_EQ(0x10, ts->tx_buffer[40]);
272  EXPECT_EQ(0x03, ts->tx_buffer[41]);
273  EXPECT_EQ(0x20, ts->tx_buffer[42]);
274  EXPECT_EQ(0x73, ts->tx_buffer[43]);
275  EXPECT_EQ(0x24, ts->tx_buffer[44]);
276  EXPECT_EQ(0x01, ts->tx_buffer[45]);
277  EXPECT_EQ(0x30, ts->tx_buffer[46]);
278  EXPECT_EQ(0x0C, ts->tx_buffer[47]);
279 
280  EXPECT_EQ(0xFF, ts->tx_buffer[48]);
281  EXPECT_EQ(0xFF, ts->tx_buffer[49]);
282  EXPECT_EQ(0xFF, ts->tx_buffer[50]);
283  EXPECT_EQ(0xFF, ts->tx_buffer[51]);
284  EXPECT_EQ(0xFF, ts->tx_buffer[52]);
285  EXPECT_EQ(0xFF, ts->tx_buffer[53]);
286  EXPECT_EQ(0xFF, ts->tx_buffer[54]);
287  EXPECT_EQ(0xFF, ts->tx_buffer[55]);
288  EXPECT_EQ(0xFF, ts->tx_buffer[56]);
289  EXPECT_EQ(0xFF, ts->tx_buffer[57]);
290  EXPECT_EQ(0xFF, ts->tx_buffer[58]);
291  EXPECT_EQ(0xFF, ts->tx_buffer[59]);
292  EXPECT_EQ(0xFF, ts->tx_buffer[60]);
293  EXPECT_EQ(0xFF, ts->tx_buffer[61]);
294  EXPECT_EQ(0xFF, ts->tx_buffer[62]);
295  EXPECT_EQ(0xFF, ts->tx_buffer[63]);
296  EXPECT_EQ(0xFF, ts->tx_buffer[64]);
297  EXPECT_EQ(0xFF, ts->tx_buffer[65]);
298  EXPECT_EQ(0xFF, ts->tx_buffer[66]);
299  EXPECT_EQ(0xFF, ts->tx_buffer[67]);
300  EXPECT_EQ(0xFF, ts->tx_buffer[68]);
301  EXPECT_EQ(0xFF, ts->tx_buffer[69]);
302  EXPECT_EQ(0xFF, ts->tx_buffer[70]);
303  EXPECT_EQ(0xFF, ts->tx_buffer[71]);
304  EXPECT_EQ(0xFF, ts->tx_buffer[72]);
305  EXPECT_EQ(0xFF, ts->tx_buffer[73]);
306  EXPECT_EQ(0xFF, ts->tx_buffer[74]);
307  EXPECT_EQ(0xFF, ts->tx_buffer[75]);
308  EXPECT_EQ(0xFF, ts->tx_buffer[76]);
309  EXPECT_EQ(0xFF, ts->tx_buffer[77]);
310  EXPECT_EQ(0xFF, ts->tx_buffer[78]);
311  EXPECT_EQ(0xFF, ts->tx_buffer[79]);
312  EXPECT_EQ(0xFF, ts->tx_buffer[80]);
313  EXPECT_EQ(0xFF, ts->tx_buffer[81]);
314  EXPECT_EQ(0xFF, ts->tx_buffer[82]);
315  EXPECT_EQ(0xFF, ts->tx_buffer[83]);
316  EXPECT_EQ(0xFF, ts->tx_buffer[84]);
317  EXPECT_EQ(0xFF, ts->tx_buffer[85]);
318  EXPECT_EQ(0xFF, ts->tx_buffer[86]);
319  EXPECT_EQ(0xFF, ts->tx_buffer[87]);
320  EXPECT_EQ(0xFF, ts->tx_buffer[88]);
321  EXPECT_EQ(0xFF, ts->tx_buffer[89]);
322  EXPECT_EQ(0xFF, ts->tx_buffer[90]);
323  EXPECT_EQ(0xFF, ts->tx_buffer[91]);
324  EXPECT_EQ(0xFF, ts->tx_buffer[92]);
325  EXPECT_EQ(0xFF, ts->tx_buffer[93]);
326  EXPECT_EQ(0xFF, ts->tx_buffer[94]);
327  EXPECT_EQ(0xFF, ts->tx_buffer[95]);
328  EXPECT_EQ(0xFF, ts->tx_buffer[96]);
329  EXPECT_EQ(0xFF, ts->tx_buffer[97]);
330  EXPECT_EQ(0xFF, ts->tx_buffer[98]);
331  EXPECT_EQ(0xFF, ts->tx_buffer[99]);
332  EXPECT_EQ(0xFF, ts->tx_buffer[100]);
333  EXPECT_EQ(0xFF, ts->tx_buffer[101]);
334  EXPECT_EQ(0xFF, ts->tx_buffer[102]);
335  EXPECT_EQ(0xFF, ts->tx_buffer[103]);
336  EXPECT_EQ(0xFF, ts->tx_buffer[104]);
337  EXPECT_EQ(0xFF, ts->tx_buffer[105]);
338  EXPECT_EQ(0xFF, ts->tx_buffer[106]);
339  EXPECT_EQ(0xFF, ts->tx_buffer[107]);
340  EXPECT_EQ(0xFF, ts->tx_buffer[108]);
341  EXPECT_EQ(0xFF, ts->tx_buffer[109]);
342  EXPECT_EQ(0xFF, ts->tx_buffer[110]);
343  EXPECT_EQ(0xFF, ts->tx_buffer[111]);
344  EXPECT_EQ(0xFF, ts->tx_buffer[112]);
345  EXPECT_EQ(0xFF, ts->tx_buffer[113]);
346  EXPECT_EQ(0xFF, ts->tx_buffer[114]);
347  EXPECT_EQ(0xFF, ts->tx_buffer[115]);
348  EXPECT_EQ(0xFF, ts->tx_buffer[116]);
349  EXPECT_EQ(0xFF, ts->tx_buffer[117]);
350  EXPECT_EQ(0xFF, ts->tx_buffer[118]);
351  EXPECT_EQ(0xFF, ts->tx_buffer[119]);
352  EXPECT_EQ(0xFF, ts->tx_buffer[120]);
353  EXPECT_EQ(0xFF, ts->tx_buffer[121]);
354  EXPECT_EQ(0xFF, ts->tx_buffer[122]);
355  EXPECT_EQ(0xFF, ts->tx_buffer[123]);
356  EXPECT_EQ(0xFF, ts->tx_buffer[124]);
357  EXPECT_EQ(0xFF, ts->tx_buffer[125]);
358  EXPECT_EQ(0xFF, ts->tx_buffer[126]);
359  EXPECT_EQ(0xFF, ts->tx_buffer[127]);
360  EXPECT_EQ(0xFF, ts->tx_buffer[128]);
361  EXPECT_EQ(0xFF, ts->tx_buffer[129]);
362  EXPECT_EQ(0xFF, ts->tx_buffer[130]);
363  EXPECT_EQ(0xFF, ts->tx_buffer[131]);
364  EXPECT_EQ(0x1F, ts->tx_buffer[132]);
365  EXPECT_EQ(0x00, ts->tx_buffer[133]);
366  EXPECT_EQ(0x00, ts->tx_buffer[134]);
367  EXPECT_EQ(0x00, ts->tx_buffer[135]);
368 }
369 
370 TEST_F(OS32CTest, test_convert_to_laserscan)
371 {
373  rr.header.scan_count = 0xDEADBEEF;
374  rr.header.scan_rate = 38609;
375  rr.header.scan_timestamp = 140420933;
376  rr.header.scan_beam_period = 42898;
377  rr.header.machine_state = 3;
379  rr.header.active_zone_set = 0;
380  rr.header.zone_inputs = 0;
382  rr.header.output_status = 0;
383  rr.header.input_status = 0;
384  rr.header.display_status = 0x1B1B;
387  rr.header.num_beams = 10;
388  rr.range_data.resize(10);
389  rr.range_data[0] = 1000;
390  rr.range_data[1] = 1253;
391  rr.range_data[2] = 1000;
392  rr.range_data[3] = 1;
393  rr.range_data[4] = 48750;
394  rr.range_data[5] = 49999;
395  rr.range_data[6] = 50001;
396  rr.range_data[7] = 48135;
397  rr.range_data[8] = 0xFFFF;
398  rr.range_data[9] = 0xFFFF;
399  rr.reflectance_data.resize(10);
400  rr.reflectance_data[0] = 44000;
401  rr.reflectance_data[1] = 42123;
402  rr.reflectance_data[2] = 53987;
403  rr.reflectance_data[3] = 0;
404  rr.reflectance_data[4] = 123;
405  rr.reflectance_data[5] = 555;
406  rr.reflectance_data[6] = 65535;
407  rr.reflectance_data[7] = 1013;
408  rr.reflectance_data[8] = 0;
409  rr.reflectance_data[9] = 0;
410 
411  sensor_msgs::LaserScan ls;
412  OS32C::convertToLaserScan(rr, &ls);
413  EXPECT_FLOAT_EQ(42898E-9, ls.time_increment);
414  EXPECT_FLOAT_EQ(1.0, ls.ranges[0]);
415  EXPECT_FLOAT_EQ(1.253, ls.ranges[1]);
416  EXPECT_FLOAT_EQ(1.0, ls.ranges[2]);
417  EXPECT_FLOAT_EQ(0.0, ls.ranges[3]);
418  EXPECT_FLOAT_EQ(48.750, ls.ranges[4]);
419  EXPECT_FLOAT_EQ(49.999, ls.ranges[5]);
420  EXPECT_FLOAT_EQ(50.001, ls.ranges[6]);
421  EXPECT_FLOAT_EQ(48.135, ls.ranges[7]);
422  EXPECT_FLOAT_EQ(50.000, ls.ranges[8]);
423  EXPECT_FLOAT_EQ(50.000, ls.ranges[9]);
424  EXPECT_FLOAT_EQ(44000, ls.intensities[0]);
425  EXPECT_FLOAT_EQ(42123, ls.intensities[1]);
426  EXPECT_FLOAT_EQ(53987, ls.intensities[2]);
427  EXPECT_FLOAT_EQ(0, ls.intensities[3]);
428  EXPECT_FLOAT_EQ(123, ls.intensities[4]);
429  EXPECT_FLOAT_EQ(555, ls.intensities[5]);
430  EXPECT_FLOAT_EQ(65535, ls.intensities[6]);
431  EXPECT_FLOAT_EQ(1013, ls.intensities[7]);
432  EXPECT_FLOAT_EQ(0, ls.intensities[8]);
433  EXPECT_FLOAT_EQ(0, ls.intensities[9]);
434 }
435 
436 
437 TEST_F(OS32CTest, test_receive_measurement_report)
438 {
439  // clang-format off
440  uint8_t io_packet[] = {
441  0x02, 0x00, 0x02, 0x80, 0x08, 0x00, 0x04, 0x00,
442  0x02, 0x00, 0x15, 0x00, 0x00, 0x00, 0xB1, 0x00,
443  0x62, 0x00, 0xA1, 0x00, 0x76, 0x53, 0x04, 0x00,
444  0x64, 0x96, 0x00, 0x00, 0x18, 0xBE, 0x97, 0x8A,
445  0x19, 0xA7, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00,
446  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
447  0x00, 0x00, 0x08, 0x07, 0x88, 0x33, 0xAE, 0x31,
448  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
449  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
450  0x00, 0x00, 0x14, 0x00, 0x52, 0x08, 0x42, 0x08,
451  0x52, 0x08, 0x40, 0x08, 0x52, 0x08, 0x40, 0x08,
452  0x53, 0x08, 0x58, 0x08, 0x52, 0x08, 0x40, 0x08,
453  0x58, 0x08, 0x58, 0x08, 0x58, 0x08, 0x5E, 0x08,
454  0x67, 0x08, 0x5D, 0x08, 0x67, 0x08, 0x5E, 0x08,
455  0x5E, 0x08, 0x6F, 0x08,
456  };
457  // clang-format on
458 
459  ts_io->rx_buffer = buffer(io_packet);
460  MeasurementReport data = os32c.receiveMeasurementReportUDP();
461  EXPECT_EQ(0x0060, data.getLength());
462  EXPECT_EQ(0x00045376, data.header.scan_count);
463  EXPECT_EQ(0x00009664, data.header.scan_rate);
464  EXPECT_EQ(0x8a97BE18, data.header.scan_timestamp);
465  EXPECT_EQ(0x0000A719, data.header.scan_beam_period);
466  EXPECT_EQ(3, data.header.machine_state);
467  EXPECT_EQ(7, data.header.machine_stop_reasons);
468  EXPECT_EQ(0, data.header.active_zone_set);
469  EXPECT_EQ(0, data.header.zone_inputs);
470  EXPECT_EQ(0, data.header.detection_zone_status);
471  EXPECT_EQ(1, data.header.output_status);
472  EXPECT_EQ(0, data.header.input_status);
473  EXPECT_EQ(0x0708, data.header.display_status);
474  EXPECT_EQ(0x3388, data.header.non_safety_config_checksum);
475  EXPECT_EQ(0x31AE, data.header.safety_config_checksum);
476  EXPECT_EQ(1, data.header.range_report_format);
477  EXPECT_EQ(2, data.header.refletivity_report_format);
478  EXPECT_EQ(20, data.header.num_beams);
479  ASSERT_EQ(20, data.measurement_data.size());
480  EXPECT_EQ(0x0852, data.measurement_data[0]);
481  EXPECT_EQ(0x0842, data.measurement_data[1]);
482  EXPECT_EQ(0x0852, data.measurement_data[2]);
483  EXPECT_EQ(0x0840, data.measurement_data[3]);
484  EXPECT_EQ(0x0852, data.measurement_data[4]);
485  EXPECT_EQ(0x0840, data.measurement_data[5]);
486  EXPECT_EQ(0x0853, data.measurement_data[6]);
487  EXPECT_EQ(0x0858, data.measurement_data[7]);
488  EXPECT_EQ(0x0852, data.measurement_data[8]);
489  EXPECT_EQ(0x0840, data.measurement_data[9]);
490  EXPECT_EQ(0x0858, data.measurement_data[10]);
491  EXPECT_EQ(0x0858, data.measurement_data[11]);
492  EXPECT_EQ(0x0858, data.measurement_data[12]);
493  EXPECT_EQ(0x085E, data.measurement_data[13]);
494  EXPECT_EQ(0x0867, data.measurement_data[14]);
495  EXPECT_EQ(0x085D, data.measurement_data[15]);
496  EXPECT_EQ(0x0867, data.measurement_data[16]);
497  EXPECT_EQ(0x085E, data.measurement_data[17]);
498  EXPECT_EQ(0x085E, data.measurement_data[18]);
499  EXPECT_EQ(0x086F, data.measurement_data[19]);
500 }
501 
502 
503 } // namespace omron_os32c_driver
data
shared_ptr< TestSocket > ts
Definition: os32c_test.cpp:60
uint8_t EIP_BYTE
TEST_F(OS32CTest, test_receive_measurement_report)
Definition: os32c_test.cpp:437
shared_ptr< TestSocket > ts_io
Definition: os32c_test.cpp:61


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Fri Nov 27 2020 03:06:12