1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-12 11:00:47 +02:00

implemented serialization of general rtde headers and the request

protocol version package
This commit is contained in:
Tristan Schnell
2019-04-10 19:26:39 +02:00
parent 742bc11c8f
commit b604af749f
4 changed files with 114 additions and 1 deletions

View File

@@ -19,6 +19,7 @@
#include <cstddef>
#include <endian.h>
#include "ur_rtde_driver/types.h"
#include "ur_rtde_driver/comm/package_serializer.h"
namespace ur_driver
{
@@ -51,6 +52,15 @@ public:
return be16toh(*(reinterpret_cast<_package_size_type*>(buf)));
}
static size_t serializeHeader(uint8_t* buffer, PackageType package_type, uint16_t payload_length)
{
uint16_t header_size = sizeof(_package_size_type) + sizeof(PackageType);
uint16_t size = header_size+payload_length;
comm::PackageSerializer::serialize(buffer, size);
comm::PackageSerializer::serialize(buffer + sizeof(size), package_type);
return header_size;
}
private:
_package_size_type package_size_;
PackageType package_type_;

View File

@@ -29,6 +29,7 @@
#define UR_RTDE_DRIVER_REQUEST_PROTOCOL_VERSION_H_INCLUDED
#include "ur_rtde_driver/rtde/rtde_package.h"
#include "ur_rtde_driver/rtde/package_header.h"
namespace ur_driver
{
@@ -52,7 +53,13 @@ public:
RequestProtocolVersionRequest() = default;
virtual ~RequestProtocolVersionRequest() = default;
static size_t generateSerializedRequest(uint8_t* buffer, uint16_t version);
uint16_t protocol_version_;
private:
static const uint16_t PAYLOAD_SIZE = sizeof(uint16_t);
static const PackageType PACKAGE_TYPE = PackageType::RTDE_REQUEST_PROTOCOL_VERSION;
};
} // namespace rtde_interface