rtde/package_header.h
Go to the documentation of this file.
1 
2 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 // -- BEGIN LICENSE BLOCK ----------------------------------------------
5 // Copyright 2019 FZI Forschungszentrum Informatik
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // -- END LICENSE BLOCK ------------------------------------------------
19 
20 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 
29 #ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
30 #define UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
31 
32 #include <cstddef>
33 #include <endian.h>
36 
37 namespace urcl
38 {
39 namespace rtde_interface
40 {
44 enum class PackageType : uint8_t
45 {
46  RTDE_REQUEST_PROTOCOL_VERSION = 86, // ascii V
47  RTDE_GET_URCONTROL_VERSION = 118, // ascii v
48  RTDE_TEXT_MESSAGE = 77, // ascii M
49  RTDE_DATA_PACKAGE = 85, // ascii U
50  RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS = 79, // ascii O
51  RTDE_CONTROL_PACKAGE_SETUP_INPUTS = 73, // ascii I
52  RTDE_CONTROL_PACKAGE_START = 83, // ascii S
53  RTDE_CONTROL_PACKAGE_PAUSE = 80 // ascii P
54 };
55 
60 {
61 public:
62  PackageHeader() = default;
63  virtual ~PackageHeader() = default;
64  using _package_size_type = uint16_t;
65 
73  static size_t getPackageLength(uint8_t* buf)
74  {
75  return be16toh(*(reinterpret_cast<_package_size_type*>(buf)));
76  }
77 
87  static size_t serializeHeader(uint8_t* buffer, PackageType package_type, uint16_t payload_length)
88  {
89  uint16_t header_size = sizeof(_package_size_type) + sizeof(PackageType);
90  uint16_t size = header_size + payload_length;
92  comm::PackageSerializer::serialize(buffer + sizeof(size), package_type);
93  return header_size;
94  }
95 };
96 
97 } // namespace rtde_interface
98 } // namespace urcl
99 
100 #endif // #ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
PackageType
Possible package types.
static size_t getPackageLength(uint8_t *buf)
Reads a buffer, interpreting the next bytes as the size of the contained package. ...
This class represents the header for RTDE packages.
static size_t serialize(uint8_t *buffer, T val)
A generalized serialization method for arbitrary datatypes.
static size_t serializeHeader(uint8_t *buffer, PackageType package_type, uint16_t payload_length)
Creates a serialization of a header based on given values.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26