os32c_test.cpp
Go to the documentation of this file.
00001 
00027 #include <gtest/gtest.h>
00028 #include <boost/make_shared.hpp>
00029 
00030 #include "omron_os32c_driver/os32c.h"
00031 #include "odva_ethernetip/socket/test_socket.h"
00032 #include "odva_ethernetip/rr_data_response.h"
00033 #include "odva_ethernetip/serialization/serializable_buffer.h"
00034 #include "odva_ethernetip/serialization/serializable_primitive.h"
00035 
00036 using boost::make_shared;
00037 using namespace boost::asio;
00038 
00039 using namespace eip;
00040 using namespace eip::socket;
00041 using namespace eip::serialization;
00042 
00043 namespace omron_os32c_driver {
00044 
00045 class OS32CTest : public :: testing :: Test
00046 {
00047 public:
00048   OS32CTest() : os32c(ts, ts_io) { }
00049 
00050 protected:
00051   virtual void SetUp()
00052   {
00053     ts = make_shared<TestSocket> ();
00054     ts_io = make_shared<TestSocket> ();
00055     os32c = OS32C(ts, ts_io);
00056   }
00057 
00058   shared_ptr<TestSocket> ts;
00059   shared_ptr<TestSocket> ts_io;
00060   OS32C os32c;
00061 
00062 };
00063 
00064 TEST_F(OS32CTest, test_calc_beam_number)
00065 {
00066   EXPECT_EQ(  0, OS32C::calcBeamNumber(2.359685166149626 )); // 135.200001 degrees
00067   EXPECT_EQ(  0, OS32C::calcBeamNumber(2.356194491937674 )); // 135.0000001
00068   // EXPECT_EQ(  0, OS32C::calcBeamNumber(2.356194490192345 )); // 135
00069   EXPECT_EQ(  1, OS32C::calcBeamNumber(2.3561944901748917)); // 134.999999999
00070   EXPECT_EQ(  1, OS32C::calcBeamNumber(2.3492131733589003)); // 134.60000001
00071   EXPECT_EQ(338, OS32C::calcBeamNumber(0.0034906583294557337)); // 0.19999999
00072   EXPECT_EQ(338, OS32C::calcBeamNumber(0));
00073   EXPECT_EQ(338, OS32C::calcBeamNumber(-0.0034906583294557337)); // -0.19999999
00074   EXPECT_EQ(675, OS32C::calcBeamNumber(-2.3492131733589003)); // -134.60000001
00075   EXPECT_EQ(675, OS32C::calcBeamNumber(-2.3561944901748917)); // -134.999999999
00076   // EXPECT_EQ(676, OS32C::calcBeamNumber(-2.356194490192345 )); // -135
00077   EXPECT_EQ(676, OS32C::calcBeamNumber(-2.356194491937674 )); // -135.0000001
00078   EXPECT_EQ(676, OS32C::calcBeamNumber(-2.359685166149626 )); // -135.200001 degrees
00079 }
00080 
00081 TEST_F(OS32CTest, test_calc_beam_centre)
00082 {
00083   EXPECT_DOUBLE_EQ(2.3596851486963333, OS32C::calcBeamCentre(0));
00084   EXPECT_DOUBLE_EQ(2.3527038316883564, OS32C::calcBeamCentre(1));
00085   EXPECT_NEAR(0, OS32C::calcBeamCentre(338), 0.00000000001);
00086   EXPECT_DOUBLE_EQ(-2.3527038316883564, OS32C::calcBeamCentre(675));
00087   EXPECT_DOUBLE_EQ(-2.3596851486963333, OS32C::calcBeamCentre(676));
00088 }
00089 
00090 TEST_F(OS32CTest, test_calc_beam_mask_all)
00091 {
00092   EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
00093   memset(buffer, 0xAA, sizeof(buffer));
00094   EIP_BYTE* mask = buffer + 4;
00095   os32c.calcBeamMask(OS32C::ANGLE_MAX, OS32C::ANGLE_MIN, mask);
00096   EXPECT_DOUBLE_EQ(2.3596851486963333, os32c.start_angle_);
00097   EXPECT_DOUBLE_EQ(-2.3596851486963333, os32c.end_angle_);
00098   for (size_t i = 0; i < 4; ++i)
00099   {
00100     EXPECT_EQ(0xAA, buffer[i]);
00101   }
00102   for (size_t i = 0; i < 84; ++i)
00103   {
00104     EXPECT_EQ(0xFF, mask[i]);
00105   }
00106   EXPECT_EQ(0x1F, mask[84]);
00107   EXPECT_EQ(0, mask[85]);
00108   EXPECT_EQ(0, mask[86]);
00109   EXPECT_EQ(0, mask[87]);
00110   for (size_t i = 92; i < 96; ++i)
00111   {
00112     EXPECT_EQ(0xAA, buffer[i]);
00113   }
00114 }
00115 
00116 TEST_F(OS32CTest, test_calc_beam_at_90)
00117 {
00118   EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
00119   memset(buffer, 0xAA, sizeof(buffer));
00120   EIP_BYTE* mask = buffer + 4;
00121   os32c.calcBeamMask(0.7853981633974483, -0.7853981633974483, mask);
00122   EXPECT_DOUBLE_EQ(0.788888821901437, os32c.start_angle_);
00123   EXPECT_DOUBLE_EQ(-0.7819075048934596, os32c.end_angle_);
00124   for (size_t i = 0; i < 4; ++i)
00125   {
00126     EXPECT_EQ(0xAA, buffer[i]);
00127   }
00128   for (size_t i = 0; i < 28; ++i)
00129   {
00130     EXPECT_EQ(0, mask[i]);
00131   }
00132   EXPECT_EQ(0xFE, mask[28]);
00133   for (size_t i = 29; i < 56; ++i)
00134   {
00135     EXPECT_EQ(0xFF, mask[i]);
00136   }
00137   EXPECT_EQ(0x07, mask[56]);
00138   for (size_t i = 57; i < 88; ++i)
00139   {
00140     EXPECT_EQ(0, mask[i]);
00141   }
00142   for (size_t i = 92; i < 96; ++i)
00143   {
00144     EXPECT_EQ(0xAA, buffer[i]);
00145   }
00146 }
00147 
00148 TEST_F(OS32CTest, test_calc_beam_boundaries)
00149 {
00150   EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
00151   memset(buffer, 0xAA, sizeof(buffer));
00152   EIP_BYTE* mask = buffer + 4;
00153   os32c.calcBeamMask(0.6911503837897546, -0.7051130178057091, mask);
00154   EXPECT_DOUBLE_EQ(0.6911503837897546, os32c.start_angle_);
00155   EXPECT_DOUBLE_EQ(-0.70511301780570967, os32c.end_angle_);
00156   for (size_t i = 0; i < 4; ++i)
00157   {
00158     EXPECT_EQ(0xAA, buffer[i]);
00159   }
00160   for (size_t i = 0; i < 29; ++i)
00161   {
00162     EXPECT_EQ(0, mask[i]);
00163   }
00164   EXPECT_EQ(0x80, mask[29]);
00165   for (size_t i = 30; i < 55; ++i)
00166   {
00167     EXPECT_EQ(0xFF, mask[i]);
00168   }
00169   for (size_t i = 55; i < 88; ++i)
00170   {
00171     EXPECT_EQ(0, mask[i]);
00172   }
00173   for (size_t i = 92; i < 96; ++i)
00174   {
00175     EXPECT_EQ(0xAA, buffer[i]);
00176   }
00177 }
00178 
00179 TEST_F(OS32CTest, test_calc_beam_invalid_args)
00180 {
00181   EIP_BYTE buffer[96]; // plus 32 bits on each end as guards
00182   memset(buffer, 0xAA, sizeof(buffer));
00183   EIP_BYTE* mask = buffer + 4;
00184   EXPECT_THROW(os32c.calcBeamMask(2.3631758089456514, -0.7051130178057091, mask),
00185     std::invalid_argument);
00186   EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, -2.3631758089456514, mask),
00187     std::invalid_argument);
00188   EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, 0.6911503837897546, mask),
00189     std::invalid_argument);
00190   EXPECT_THROW(os32c.calcBeamMask(0.6911503837897546, 0.6841690685271065, mask),
00191     std::invalid_argument);
00192 }
00193 
00194 TEST_F(OS32CTest, test_select_beams)
00195 {
00196   char reg_resp_packet[] = {
00197     0x65, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00,
00198     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00199     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00200     0x01, 0x00, 0x00, 0x00,
00201   };
00202 
00203   ts->rx_buffer = buffer(reg_resp_packet);
00204   os32c.open("example_host");
00205   EXPECT_TRUE(ts->is_open);
00206   EXPECT_EQ("example_host", ts->hostname);
00207   EXPECT_EQ("44818", ts->port);
00208   EXPECT_EQ(5, os32c.getSessionID());
00209 
00210   // clear out the tx buffer
00211   ts->tx_count = 0;
00212   memset(ts->tx_buffer, 0, sizeof(ts->tx_count));
00213 
00214   // response packet from OS32C docs
00215   char resp_packet[] = {
00216     0x6F, 0x00, 0x14, 0x00, 0x05, 0x00, 0x00, 0x00,
00217     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00218     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00219     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
00220     0x00, 0x00, 0x00, 0x00, 0xB2, 0x00, 0x04, 0x00,
00221     0x90, 0x00, 0x00, 0x00,
00222   };
00223   ts->rx_buffer = buffer(resp_packet);
00224 
00225   os32c.selectBeams(OS32C::ANGLE_MAX, OS32C::ANGLE_MIN);
00226 
00227   // check the request packet
00228   EXPECT_EQ(136, ts->tx_count);
00229 
00230   EXPECT_EQ(0x6F, ts->tx_buffer[0]);
00231   EXPECT_EQ(0x00, ts->tx_buffer[1]);
00232   EXPECT_EQ(0x70, ts->tx_buffer[2]);
00233   EXPECT_EQ(0x00, ts->tx_buffer[3]);
00234   EXPECT_EQ(0x05, ts->tx_buffer[4]);
00235   EXPECT_EQ(0x00, ts->tx_buffer[5]);
00236   EXPECT_EQ(0x00, ts->tx_buffer[6]);
00237   EXPECT_EQ(0x00, ts->tx_buffer[7]);
00238   EXPECT_EQ(0x00, ts->tx_buffer[8]);
00239   EXPECT_EQ(0x00, ts->tx_buffer[9]);
00240   EXPECT_EQ(0x00, ts->tx_buffer[10]);
00241   EXPECT_EQ(0x00, ts->tx_buffer[11]);
00242   EXPECT_EQ(0x00, ts->tx_buffer[12]);
00243   EXPECT_EQ(0x00, ts->tx_buffer[13]);
00244   EXPECT_EQ(0x00, ts->tx_buffer[14]);
00245   EXPECT_EQ(0x00, ts->tx_buffer[15]);
00246   EXPECT_EQ(0x00, ts->tx_buffer[16]);
00247   EXPECT_EQ(0x00, ts->tx_buffer[17]);
00248   EXPECT_EQ(0x00, ts->tx_buffer[18]);
00249   EXPECT_EQ(0x00, ts->tx_buffer[19]);
00250   EXPECT_EQ(0x00, ts->tx_buffer[20]);
00251   EXPECT_EQ(0x00, ts->tx_buffer[21]);
00252   EXPECT_EQ(0x00, ts->tx_buffer[22]);
00253   EXPECT_EQ(0x00, ts->tx_buffer[23]);
00254   EXPECT_EQ(0x00, ts->tx_buffer[24]);
00255   EXPECT_EQ(0x00, ts->tx_buffer[25]);
00256   EXPECT_EQ(0x00, ts->tx_buffer[26]);
00257   EXPECT_EQ(0x00, ts->tx_buffer[27]);
00258   EXPECT_EQ(0x00, ts->tx_buffer[28]);
00259   EXPECT_EQ(0x00, ts->tx_buffer[29]);
00260   EXPECT_EQ(0x02, ts->tx_buffer[30]);
00261   EXPECT_EQ(0x00, ts->tx_buffer[31]);
00262   EXPECT_EQ(0x00, ts->tx_buffer[32]);
00263   EXPECT_EQ(0x00, ts->tx_buffer[33]);
00264   EXPECT_EQ(0x00, ts->tx_buffer[34]);
00265   EXPECT_EQ(0x00, ts->tx_buffer[35]);
00266   EXPECT_EQ(0xB2, ts->tx_buffer[36]);
00267   EXPECT_EQ(0x00, ts->tx_buffer[37]);
00268   EXPECT_EQ(0x60, ts->tx_buffer[38]);
00269   EXPECT_EQ(0x00, ts->tx_buffer[39]);
00270   EXPECT_EQ(0x10, ts->tx_buffer[40]);
00271   EXPECT_EQ(0x03, ts->tx_buffer[41]);
00272   EXPECT_EQ(0x20, ts->tx_buffer[42]);
00273   EXPECT_EQ(0x73, ts->tx_buffer[43]);
00274   EXPECT_EQ(0x24, ts->tx_buffer[44]);
00275   EXPECT_EQ(0x01, ts->tx_buffer[45]);
00276   EXPECT_EQ(0x30, ts->tx_buffer[46]);
00277   EXPECT_EQ(0x0C, ts->tx_buffer[47]);
00278 
00279   EXPECT_EQ(0xFF, ts->tx_buffer[48]);
00280   EXPECT_EQ(0xFF, ts->tx_buffer[49]);
00281   EXPECT_EQ(0xFF, ts->tx_buffer[50]);
00282   EXPECT_EQ(0xFF, ts->tx_buffer[51]);
00283   EXPECT_EQ(0xFF, ts->tx_buffer[52]);
00284   EXPECT_EQ(0xFF, ts->tx_buffer[53]);
00285   EXPECT_EQ(0xFF, ts->tx_buffer[54]);
00286   EXPECT_EQ(0xFF, ts->tx_buffer[55]);
00287   EXPECT_EQ(0xFF, ts->tx_buffer[56]);
00288   EXPECT_EQ(0xFF, ts->tx_buffer[57]);
00289   EXPECT_EQ(0xFF, ts->tx_buffer[58]);
00290   EXPECT_EQ(0xFF, ts->tx_buffer[59]);
00291   EXPECT_EQ(0xFF, ts->tx_buffer[60]);
00292   EXPECT_EQ(0xFF, ts->tx_buffer[61]);
00293   EXPECT_EQ(0xFF, ts->tx_buffer[62]);
00294   EXPECT_EQ(0xFF, ts->tx_buffer[63]);
00295   EXPECT_EQ(0xFF, ts->tx_buffer[64]);
00296   EXPECT_EQ(0xFF, ts->tx_buffer[65]);
00297   EXPECT_EQ(0xFF, ts->tx_buffer[66]);
00298   EXPECT_EQ(0xFF, ts->tx_buffer[67]);
00299   EXPECT_EQ(0xFF, ts->tx_buffer[68]);
00300   EXPECT_EQ(0xFF, ts->tx_buffer[69]);
00301   EXPECT_EQ(0xFF, ts->tx_buffer[70]);
00302   EXPECT_EQ(0xFF, ts->tx_buffer[71]);
00303   EXPECT_EQ(0xFF, ts->tx_buffer[72]);
00304   EXPECT_EQ(0xFF, ts->tx_buffer[73]);
00305   EXPECT_EQ(0xFF, ts->tx_buffer[74]);
00306   EXPECT_EQ(0xFF, ts->tx_buffer[75]);
00307   EXPECT_EQ(0xFF, ts->tx_buffer[76]);
00308   EXPECT_EQ(0xFF, ts->tx_buffer[77]);
00309   EXPECT_EQ(0xFF, ts->tx_buffer[78]);
00310   EXPECT_EQ(0xFF, ts->tx_buffer[79]);
00311   EXPECT_EQ(0xFF, ts->tx_buffer[80]);
00312   EXPECT_EQ(0xFF, ts->tx_buffer[81]);
00313   EXPECT_EQ(0xFF, ts->tx_buffer[82]);
00314   EXPECT_EQ(0xFF, ts->tx_buffer[83]);
00315   EXPECT_EQ(0xFF, ts->tx_buffer[84]);
00316   EXPECT_EQ(0xFF, ts->tx_buffer[85]);
00317   EXPECT_EQ(0xFF, ts->tx_buffer[86]);
00318   EXPECT_EQ(0xFF, ts->tx_buffer[87]);
00319   EXPECT_EQ(0xFF, ts->tx_buffer[88]);
00320   EXPECT_EQ(0xFF, ts->tx_buffer[89]);
00321   EXPECT_EQ(0xFF, ts->tx_buffer[90]);
00322   EXPECT_EQ(0xFF, ts->tx_buffer[91]);
00323   EXPECT_EQ(0xFF, ts->tx_buffer[92]);
00324   EXPECT_EQ(0xFF, ts->tx_buffer[93]);
00325   EXPECT_EQ(0xFF, ts->tx_buffer[94]);
00326   EXPECT_EQ(0xFF, ts->tx_buffer[95]);
00327   EXPECT_EQ(0xFF, ts->tx_buffer[96]);
00328   EXPECT_EQ(0xFF, ts->tx_buffer[97]);
00329   EXPECT_EQ(0xFF, ts->tx_buffer[98]);
00330   EXPECT_EQ(0xFF, ts->tx_buffer[99]);
00331   EXPECT_EQ(0xFF, ts->tx_buffer[100]);
00332   EXPECT_EQ(0xFF, ts->tx_buffer[101]);
00333   EXPECT_EQ(0xFF, ts->tx_buffer[102]);
00334   EXPECT_EQ(0xFF, ts->tx_buffer[103]);
00335   EXPECT_EQ(0xFF, ts->tx_buffer[104]);
00336   EXPECT_EQ(0xFF, ts->tx_buffer[105]);
00337   EXPECT_EQ(0xFF, ts->tx_buffer[106]);
00338   EXPECT_EQ(0xFF, ts->tx_buffer[107]);
00339   EXPECT_EQ(0xFF, ts->tx_buffer[108]);
00340   EXPECT_EQ(0xFF, ts->tx_buffer[109]);
00341   EXPECT_EQ(0xFF, ts->tx_buffer[110]);
00342   EXPECT_EQ(0xFF, ts->tx_buffer[111]);
00343   EXPECT_EQ(0xFF, ts->tx_buffer[112]);
00344   EXPECT_EQ(0xFF, ts->tx_buffer[113]);
00345   EXPECT_EQ(0xFF, ts->tx_buffer[114]);
00346   EXPECT_EQ(0xFF, ts->tx_buffer[115]);
00347   EXPECT_EQ(0xFF, ts->tx_buffer[116]);
00348   EXPECT_EQ(0xFF, ts->tx_buffer[117]);
00349   EXPECT_EQ(0xFF, ts->tx_buffer[118]);
00350   EXPECT_EQ(0xFF, ts->tx_buffer[119]);
00351   EXPECT_EQ(0xFF, ts->tx_buffer[120]);
00352   EXPECT_EQ(0xFF, ts->tx_buffer[121]);
00353   EXPECT_EQ(0xFF, ts->tx_buffer[122]);
00354   EXPECT_EQ(0xFF, ts->tx_buffer[123]);
00355   EXPECT_EQ(0xFF, ts->tx_buffer[124]);
00356   EXPECT_EQ(0xFF, ts->tx_buffer[125]);
00357   EXPECT_EQ(0xFF, ts->tx_buffer[126]);
00358   EXPECT_EQ(0xFF, ts->tx_buffer[127]);
00359   EXPECT_EQ(0xFF, ts->tx_buffer[128]);
00360   EXPECT_EQ(0xFF, ts->tx_buffer[129]);
00361   EXPECT_EQ(0xFF, ts->tx_buffer[130]);
00362   EXPECT_EQ(0xFF, ts->tx_buffer[131]);
00363   EXPECT_EQ(0x1F, ts->tx_buffer[132]);
00364   EXPECT_EQ(0x00, ts->tx_buffer[133]);
00365   EXPECT_EQ(0x00, ts->tx_buffer[134]);
00366   EXPECT_EQ(0x00, ts->tx_buffer[135]);
00367 }
00368 
00369 TEST_F(OS32CTest, test_convert_to_laserscan)
00370 {
00371   RangeAndReflectanceMeasurement rr;
00372   rr.header.scan_count = 0xDEADBEEF;
00373   rr.header.scan_rate = 38609;
00374   rr.header.scan_timestamp = 140420933;
00375   rr.header.scan_beam_period = 42898;
00376   rr.header.machine_state = 3;
00377   rr.header.machine_stop_reasons = 7;
00378   rr.header.active_zone_set = 0;
00379   rr.header.zone_inputs = 0;
00380   rr.header.detection_zone_status = 0;
00381   rr.header.output_status = 0;
00382   rr.header.input_status = 0;
00383   rr.header.display_status = 0x1B1B;
00384   rr.header.range_report_format = RANGE_MEASURE_50M;
00385   rr.header.refletivity_report_format = REFLECTIVITY_MEASURE_TOT_4PS;
00386   rr.header.num_beams = 10;
00387   rr.range_data.resize(10);
00388   rr.range_data[0] = 1000;
00389   rr.range_data[1] = 1253;
00390   rr.range_data[2] = 1000;
00391   rr.range_data[3] = 1;
00392   rr.range_data[4] = 48750;
00393   rr.range_data[5] = 49999;
00394   rr.range_data[6] = 50001;
00395   rr.range_data[7] = 48135;
00396   rr.range_data[8] = 0xFFFF;
00397   rr.range_data[9] = 0xFFFF;
00398   rr.reflectance_data.resize(10);
00399   rr.reflectance_data[0] = 44000;
00400   rr.reflectance_data[1] = 42123;
00401   rr.reflectance_data[2] = 53987;
00402   rr.reflectance_data[3] = 0;
00403   rr.reflectance_data[4] = 123;
00404   rr.reflectance_data[5] = 555;
00405   rr.reflectance_data[6] = 65535;
00406   rr.reflectance_data[7] = 1013;
00407   rr.reflectance_data[8] = 0;
00408   rr.reflectance_data[9] = 0;
00409 
00410   sensor_msgs::LaserScan ls;
00411   OS32C::convertToLaserScan(rr, &ls);
00412   EXPECT_FLOAT_EQ(42898E-9, ls.time_increment);
00413   EXPECT_FLOAT_EQ( 1.0  , ls.ranges[0]);
00414   EXPECT_FLOAT_EQ( 1.253, ls.ranges[1]);
00415   EXPECT_FLOAT_EQ( 1.0  , ls.ranges[2]);
00416   EXPECT_FLOAT_EQ( 0.0  , ls.ranges[3]);
00417   EXPECT_FLOAT_EQ(48.750, ls.ranges[4]);
00418   EXPECT_FLOAT_EQ(49.999, ls.ranges[5]);
00419   EXPECT_FLOAT_EQ(50.001, ls.ranges[6]);
00420   EXPECT_FLOAT_EQ(48.135, ls.ranges[7]);
00421   EXPECT_FLOAT_EQ(50.000, ls.ranges[8]);
00422   EXPECT_FLOAT_EQ(50.000, ls.ranges[9]);
00423   EXPECT_FLOAT_EQ(44000, ls.intensities[0]);
00424   EXPECT_FLOAT_EQ(42123, ls.intensities[1]);
00425   EXPECT_FLOAT_EQ(53987, ls.intensities[2]);
00426   EXPECT_FLOAT_EQ(0, ls.intensities[3]);
00427   EXPECT_FLOAT_EQ(123, ls.intensities[4]);
00428   EXPECT_FLOAT_EQ(555, ls.intensities[5]);
00429   EXPECT_FLOAT_EQ(65535, ls.intensities[6]);
00430   EXPECT_FLOAT_EQ(1013, ls.intensities[7]);
00431   EXPECT_FLOAT_EQ(0, ls.intensities[8]);
00432   EXPECT_FLOAT_EQ(0, ls.intensities[9]);
00433 }
00434 
00435 
00436 TEST_F(OS32CTest, test_receive_measurement_report)
00437 {
00438   char io_packet[] = {
00439     0x02, 0x00, 0x02, 0x80, 0x08, 0x00, 0x04, 0x00,
00440     0x02, 0x00, 0x15, 0x00, 0x00, 0x00, 0xB1, 0x00,
00441     0x62, 0x00, 0xA1, 0x00, 0x76, 0x53, 0x04, 0x00,
00442     0x64, 0x96, 0x00, 0x00, 0x18, 0xBE, 0x97, 0x8A,
00443     0x19, 0xA7, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00,
00444     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
00445     0x00, 0x00, 0x08, 0x07, 0x88, 0x33, 0xAE, 0x31,
00446     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00447     0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
00448     0x00, 0x00, 0x14, 0x00, 0x52, 0x08, 0x42, 0x08,
00449     0x52, 0x08, 0x40, 0x08, 0x52, 0x08, 0x40, 0x08,
00450     0x53, 0x08, 0x58, 0x08, 0x52, 0x08, 0x40, 0x08,
00451     0x58, 0x08, 0x58, 0x08, 0x58, 0x08, 0x5E, 0x08,
00452     0x67, 0x08, 0x5D, 0x08, 0x67, 0x08, 0x5E, 0x08,
00453     0x5E, 0x08, 0x6F, 0x08,
00454   };
00455 
00456   ts_io->rx_buffer = buffer(io_packet);
00457   MeasurementReport data = os32c.receiveMeasurementReportUDP();
00458   EXPECT_EQ(0x0060, data.getLength());
00459   EXPECT_EQ(0x00045376, data.header.scan_count);
00460   EXPECT_EQ(0x00009664, data.header.scan_rate);
00461   EXPECT_EQ(0x8a97BE18, data.header.scan_timestamp);
00462   EXPECT_EQ(0x0000A719, data.header.scan_beam_period);
00463   EXPECT_EQ(3, data.header.machine_state);
00464   EXPECT_EQ(7, data.header.machine_stop_reasons);
00465   EXPECT_EQ(0, data.header.active_zone_set);
00466   EXPECT_EQ(0, data.header.zone_inputs);
00467   EXPECT_EQ(0, data.header.detection_zone_status);
00468   EXPECT_EQ(1, data.header.output_status);
00469   EXPECT_EQ(0, data.header.input_status);
00470   EXPECT_EQ(0x0708, data.header.display_status);
00471   EXPECT_EQ(0x3388, data.header.non_safety_config_checksum);
00472   EXPECT_EQ(0x31AE, data.header.safety_config_checksum);
00473   EXPECT_EQ(1, data.header.range_report_format);
00474   EXPECT_EQ(2, data.header.refletivity_report_format);
00475   EXPECT_EQ(20, data.header.num_beams);
00476   ASSERT_EQ(20, data.measurement_data.size());
00477   EXPECT_EQ(0x0852, data.measurement_data[0]);
00478   EXPECT_EQ(0x0842, data.measurement_data[1]);
00479   EXPECT_EQ(0x0852, data.measurement_data[2]);
00480   EXPECT_EQ(0x0840, data.measurement_data[3]);
00481   EXPECT_EQ(0x0852, data.measurement_data[4]);
00482   EXPECT_EQ(0x0840, data.measurement_data[5]);
00483   EXPECT_EQ(0x0853, data.measurement_data[6]);
00484   EXPECT_EQ(0x0858, data.measurement_data[7]);
00485   EXPECT_EQ(0x0852, data.measurement_data[8]);
00486   EXPECT_EQ(0x0840, data.measurement_data[9]);
00487   EXPECT_EQ(0x0858, data.measurement_data[10]);
00488   EXPECT_EQ(0x0858, data.measurement_data[11]);
00489   EXPECT_EQ(0x0858, data.measurement_data[12]);
00490   EXPECT_EQ(0x085E, data.measurement_data[13]);
00491   EXPECT_EQ(0x0867, data.measurement_data[14]);
00492   EXPECT_EQ(0x085D, data.measurement_data[15]);
00493   EXPECT_EQ(0x0867, data.measurement_data[16]);
00494   EXPECT_EQ(0x085E, data.measurement_data[17]);
00495   EXPECT_EQ(0x085E, data.measurement_data[18]);
00496   EXPECT_EQ(0x086F, data.measurement_data[19]);
00497 }
00498 
00499 
00500 } // namespace os32c


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Thu Jun 6 2019 19:00:54