test_rtde_get_urcontrol_version.cpp
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
2 // Copyright 2022 Universal Robots A/S
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // * Neither the name of the {copyright_holder} nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 // POSSIBILITY OF SUCH DAMAGE.
29 // -- END LICENSE BLOCK ------------------------------------------------
30 
31 #include <gtest/gtest.h>
33 
34 using namespace urcl;
35 
36 TEST(rtde_get_urcontrol_version, generate_serialized_get_urcontrol_version_request)
37 {
38  uint8_t buffer[4096];
39  size_t expected_size = 3;
41 
42  EXPECT_EQ(expected_size, actual_size);
43 
44  uint8_t expected[] = { 0x00, 0x03, 0x76 };
45  for (unsigned int i = 0; i < actual_size; ++i)
46  {
47  EXPECT_EQ(expected[i], buffer[i]);
48  }
49 }
50 
51 TEST(rtde_get_urcontrol_version, parse_get_urcontrol_version)
52 {
53  uint8_t urcontrol_version_answer[] = { 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0c,
54  0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 };
55  comm::BinParser bp(urcontrol_version_answer, sizeof(urcontrol_version_answer));
56  rtde_interface::GetUrcontrolVersion ur_control_version;
57 
58  EXPECT_TRUE(ur_control_version.parseWith(bp));
59 
60  VersionInformation expected_version_information;
61  expected_version_information.major = 5;
62  expected_version_information.minor = 12;
63  expected_version_information.bugfix = 2;
64  expected_version_information.build = 0;
65 
66  EXPECT_EQ(expected_version_information.major, ur_control_version.version_information_.major);
67  EXPECT_EQ(expected_version_information.minor, ur_control_version.version_information_.minor);
68  EXPECT_EQ(expected_version_information.bugfix, ur_control_version.version_information_.bugfix);
69  EXPECT_EQ(expected_version_information.build, ur_control_version.version_information_.build);
70 }
71 
72 int main(int argc, char* argv[])
73 {
74  ::testing::InitGoogleTest(&argc, argv);
75 
76  return RUN_ALL_TESTS();
77 }
virtual bool parseWith(comm::BinParser &bp)
Sets the attributes of the package by parsing a serialized representation of the package.
The BinParser class handles a byte buffer and functionality to iteratively parse the content...
Definition: bin_parser.h:44
uint32_t minor
Minor version number.
uint32_t bugfix
Bugfix version number.
Struct containing a robot&#39;s version information.
This class handles the package detailing the UR control version sent by the robot.
TEST(rtde_get_urcontrol_version, generate_serialized_get_urcontrol_version_request)
static size_t generateSerializedRequest(uint8_t *buffer)
Generates a serialized package.
uint32_t major
Major version number.
uint32_t build
Build number.
int main(int argc, char *argv[])


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47