From 2ab6046682add5f0ba1f2abb3cbc3b764d124b19 Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Tue, 23 Apr 2024 18:08:15 +0200 Subject: [PATCH] Add missing include for Also use full qualified names for the `uint8_t` type. The driver's `Rolling` CI pipeline was failing because of this. --- include/schunk_svh_library/SVHFirmwareInfo.h | 5 ++- .../serial/ByteOrderConversion.h | 17 ++++---- .../serial/SVHReceiveThread.h | 7 ++-- .../serial/SVHSerialInterface.h | 4 +- .../serial/SVHSerialPacket.h | 39 ++++++++++--------- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/schunk_svh_library/SVHFirmwareInfo.h b/include/schunk_svh_library/SVHFirmwareInfo.h index cf44814..5b319ad 100644 --- a/include/schunk_svh_library/SVHFirmwareInfo.h +++ b/include/schunk_svh_library/SVHFirmwareInfo.h @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -86,8 +87,8 @@ inline driver_svh::ArrayBuilder& operator>>(driver_svh::ArrayBuilder& ab, SVHFir { // Stream operator can not handle arrays (due to missing size information) to make things easy we // just copy the data around. Feel free to do something else - std::vector text(48); - std::vector svh(4); + std::vector text(48); + std::vector svh(4); ab >> svh >> data.version_major >> data.version_minor >> text; diff --git a/include/schunk_svh_library/serial/ByteOrderConversion.h b/include/schunk_svh_library/serial/ByteOrderConversion.h index 57ff9b2..6ec75aa 100644 --- a/include/schunk_svh_library/serial/ByteOrderConversion.h +++ b/include/schunk_svh_library/serial/ByteOrderConversion.h @@ -38,13 +38,14 @@ #include #include #include +#include namespace driver_svh { //! template function for adding data to an array while converting everything into correct endianess template -size_t toLittleEndian(const T& data, std::vector& array, size_t& write_pos) +size_t toLittleEndian(const T& data, std::vector& array, size_t& write_pos) { // Resize the target array in case it it to small to avoid out of bounds acces if (write_pos + sizeof(T) > array.size()) @@ -61,7 +62,7 @@ size_t toLittleEndian(const T& data, std::vector& array, size_t& write_ { // Copy each byte into the bytearray, always convert byte order to little endian regardles of // source architecture - array[write_pos + i] = static_cast((data >> (i * 8)) & 0xFF); + array[write_pos + i] = static_cast((data >> (i * 8)) & 0xFF); } return write_pos + sizeof(T); @@ -70,20 +71,20 @@ size_t toLittleEndian(const T& data, std::vector& array, size_t& write_ //! Template specialization for float as these have to be handled seperately template <> DRIVER_SVH_IMPORT_EXPORT size_t toLittleEndian(const float& data, - std::vector& array, + std::vector& array, size_t& write_pos); //! Template specialization for float as these have to be handled seperately template <> DRIVER_SVH_IMPORT_EXPORT size_t toLittleEndian(const double& data, - std::vector& array, + std::vector& array, size_t& write_pos); //! template function for reating data out of an array while converting everything into correct //! endianess template -size_t fromLittleEndian(T& data, std::vector& array, size_t& read_pos) +size_t fromLittleEndian(T& data, std::vector& array, size_t& read_pos) { // TODO: Remove once everything is tested :) // std::cout << "From Little Endian Called with: "<<" Size_T: "<< sizeof(T) << " Pos: " << @@ -119,13 +120,13 @@ size_t fromLittleEndian(T& data, std::vector& array, size_t& read_pos) //! Template specialization for float as these have to be handled seperately template <> DRIVER_SVH_IMPORT_EXPORT size_t fromLittleEndian(float& data, - std::vector& array, + std::vector& array, size_t& read_pos); //! Template specialization for float as these have to be handled seperately template <> DRIVER_SVH_IMPORT_EXPORT size_t fromLittleEndian(double& data, - std::vector& array, + std::vector& array, size_t& read_pos); //! template class holding an array and the current index for write commands. Can be used to easily @@ -160,7 +161,7 @@ class ArrayBuilder size_t read_pos; //! array of template type TArray - std::vector array; + std::vector array; //! diff --git a/include/schunk_svh_library/serial/SVHReceiveThread.h b/include/schunk_svh_library/serial/SVHReceiveThread.h index 222c74d..666dc20 100644 --- a/include/schunk_svh_library/serial/SVHReceiveThread.h +++ b/include/schunk_svh_library/serial/SVHReceiveThread.h @@ -49,6 +49,7 @@ #include #include #include +#include using driver_svh::serial::Serial; @@ -126,11 +127,11 @@ class SVHReceiveThread uint16_t m_length; //! Checksum of packet - uint8_t m_checksum1; - uint8_t m_checksum2; + std::uint8_t m_checksum1; + std::uint8_t m_checksum2; //! length of received serial data - std::vector m_data; + std::vector m_data; //! pointer to array builder object for packet receive driver_svh::ArrayBuilder m_ab; diff --git a/include/schunk_svh_library/serial/SVHSerialInterface.h b/include/schunk_svh_library/serial/SVHSerialInterface.h index 09d0616..ca39791 100644 --- a/include/schunk_svh_library/serial/SVHSerialInterface.h +++ b/include/schunk_svh_library/serial/SVHSerialInterface.h @@ -115,13 +115,13 @@ class DRIVER_SVH_IMPORT_EXPORT SVHSerialInterface //! serial device connected state bool m_connected; - uint8_t m_last_index; + std::uint8_t m_last_index; //! pointer to serial interface object std::shared_ptr m_serial_device; //! cecksum calculation - void calcCheckSum(uint8_t& check_sum1, uint8_t& check_sum2, const SVHSerialPacket& packet); + void calcCheckSum(std::uint8_t& check_sum1, std::uint8_t& check_sum2, const SVHSerialPacket& packet); //! thread for receiving serial packets std::thread m_receive_thread; diff --git a/include/schunk_svh_library/serial/SVHSerialPacket.h b/include/schunk_svh_library/serial/SVHSerialPacket.h index 95280b8..d47e35d 100644 --- a/include/schunk_svh_library/serial/SVHSerialPacket.h +++ b/include/schunk_svh_library/serial/SVHSerialPacket.h @@ -37,6 +37,7 @@ #define SVHSERIALPACKET_H #include +#include namespace driver_svh { @@ -49,29 +50,29 @@ const size_t C_PACKET_APPENDIX_SIZE = 8; //!< The packet overhead size in bytes const size_t C_DEFAULT_PACKET_SIZE = 48; //!< Default packet payload size in bytes // packet headers -const uint8_t PACKET_HEADER1 = 0x4C; //!< Header sync byte 1 -const uint8_t PACKET_HEADER2 = 0xAA; //!< Header sync byte 2 +const std::uint8_t PACKET_HEADER1 = 0x4C; //!< Header sync byte 1 +const std::uint8_t PACKET_HEADER2 = 0xAA; //!< Header sync byte 2 // adress constants for commands -const uint8_t SVH_GET_CONTROL_FEEDBACK = +const std::uint8_t SVH_GET_CONTROL_FEEDBACK = 0x00; //!< Request the position and current of a channel to be sent -const uint8_t SVH_SET_CONTROL_COMMAND = 0x01; //!< Sets the target position of a channel -const uint8_t SVH_GET_CONTROL_FEEDBACK_ALL = +const std::uint8_t SVH_SET_CONTROL_COMMAND = 0x01; //!< Sets the target position of a channel +const std::uint8_t SVH_GET_CONTROL_FEEDBACK_ALL = 0x02; //!< Requests the positions and currents of ALL channels -const uint8_t SVH_SET_CONTROL_COMMAND_ALL = 0x03; //!< Sends the target position to ALL the channels -const uint8_t SVH_GET_POSITION_SETTINGS = +const std::uint8_t SVH_SET_CONTROL_COMMAND_ALL = 0x03; //!< Sends the target position to ALL the channels +const std::uint8_t SVH_GET_POSITION_SETTINGS = 0x04; //!< Requests the active settings of the position controller -const uint8_t SVH_SET_POSITION_SETTINGS = 0x05; //!< Sets new settings for the position controller -const uint8_t SVH_GET_CURRENT_SETTINGS = +const std::uint8_t SVH_SET_POSITION_SETTINGS = 0x05; //!< Sets new settings for the position controller +const std::uint8_t SVH_GET_CURRENT_SETTINGS = 0x06; //!< Requests the active settings of the current controller -const uint8_t SVH_SET_CURRENT_SETTINGS = 0x07; //!< Sets new settings for the current controller -const uint8_t SVH_GET_CONTROLLER_STATE = +const std::uint8_t SVH_SET_CURRENT_SETTINGS = 0x07; //!< Sets new settings for the current controller +const std::uint8_t SVH_GET_CONTROLLER_STATE = 0x08; //!< Requests the state of the controller (active,faults,enabled channels) -const uint8_t SVH_SET_CONTROLLER_STATE = +const std::uint8_t SVH_SET_CONTROLLER_STATE = 0x09; //!< Sets new controller states (enable channels, clear faults) -const uint8_t SVH_GET_ENCODER_VALUES = 0x0A; //!< Request the current encoder scalings -const uint8_t SVH_SET_ENCODER_VALUES = 0x0B; //!< Set new encoder scalings -const uint8_t SVH_GET_FIRMWARE_INFO = 0x0C; //!< Request the firmware info to be transmitted +const std::uint8_t SVH_GET_ENCODER_VALUES = 0x0A; //!< Request the current encoder scalings +const std::uint8_t SVH_SET_ENCODER_VALUES = 0x0B; //!< Set new encoder scalings +const std::uint8_t SVH_GET_FIRMWARE_INFO = 0x0C; //!< Request the firmware info to be transmitted /*! * \brief The SerialPacket holds the (non generated) header and data of one message to the @@ -82,18 +83,18 @@ struct SVHSerialPacket //! \brief Continuosly incremented counter per package //! \note Continuous counter is currently not used by this software, the hw will just copy the //! send counter back to the response - uint8_t index; + std::uint8_t index; //! Adress denotes the actual function of the package - uint8_t address; + std::uint8_t address; //! Payload of the package - std::vector data; + std::vector data; /*! * \brief SVHSerialPacket contains the send and received data in raw format (bytewise) * \param data_length initial size to set the data length to. NOTE: To deserialize a packet this * value HAS TO BE SET! */ - SVHSerialPacket(size_t data_length = 0, uint8_t address = SVH_GET_CONTROL_FEEDBACK) + SVHSerialPacket(size_t data_length = 0, std::uint8_t address = SVH_GET_CONTROL_FEEDBACK) : address(address) , data(data_length, 0) {