diff --git a/src/nunavut_out/ds015/physics/kinematics/geodetic/Point_0_1.h b/src/nunavut_out/ds015/physics/kinematics/geodetic/Point_0_1.h new file mode 100644 index 0000000..90799e3 --- /dev/null +++ b/src/nunavut_out/ds015/physics/kinematics/geodetic/Point_0_1.h @@ -0,0 +1,290 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl +// Generated at: 2024-11-23 10:35:26.969766 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: ds015.physics.kinematics.geodetic.Point +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef DS015_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ +#define DS015_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define ds015_physics_kinematics_geodetic_Point_0_1_HAS_FIXED_PORT_ID_ false + +#define ds015_physics_kinematics_geodetic_Point_0_1_FULL_NAME_ "ds015.physics.kinematics.geodetic.Point" +#define ds015_physics_kinematics_geodetic_Point_0_1_FULL_NAME_AND_VERSION_ "ds015.physics.kinematics.geodetic.Point.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define ds015_physics_kinematics_geodetic_Point_0_1_EXTENT_BYTES_ 20UL +#define ds015_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 20UL +static_assert(ds015_physics_kinematics_geodetic_Point_0_1_EXTENT_BYTES_ >= ds015_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float64 latitude + double latitude; + + /// saturated float64 longitude + double longitude; + + /// uavcan.si.unit.length.Scalar.1.0 altitude + uavcan_si_unit_length_Scalar_1_0 altitude; +} ds015_physics_kinematics_geodetic_Point_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see ds015_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_physics_kinematics_geodetic_Point_0_1_serialize_( + const ds015_physics_kinematics_geodetic_Point_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 160UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64 latitude + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->latitude, 8U); + offset_bits += 64U; + } + + + + + { // saturated float64 longitude + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->longitude, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.length.Scalar.1.0 altitude + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_si_unit_length_Scalar_1_0_serialize_( + &obj->altitude, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_physics_kinematics_geodetic_Point_0_1_deserialize_( + ds015_physics_kinematics_geodetic_Point_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64 latitude + out_obj->latitude = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + + + // saturated float64 longitude + out_obj->longitude = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.length.Scalar.1.0 altitude + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_si_unit_length_Scalar_1_0_deserialize_( + &out_obj->altitude, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void ds015_physics_kinematics_geodetic_Point_0_1_initialize_(ds015_physics_kinematics_geodetic_Point_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = ds015_physics_kinematics_geodetic_Point_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // DS015_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ diff --git a/src/nunavut_out/ds015/service/gnss/Covariance_0_1.h b/src/nunavut_out/ds015/service/gnss/Covariance_0_1.h new file mode 100644 index 0000000..56662ac --- /dev/null +++ b/src/nunavut_out/ds015/service/gnss/Covariance_0_1.h @@ -0,0 +1,293 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.067880 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: ds015.service.gnss.Covariance +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef DS015_SERVICE_GNSS_COVARIANCE_0_1_INCLUDED_ +#define DS015_SERVICE_GNSS_COVARIANCE_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Covariance.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define ds015_service_gnss_Covariance_0_1_HAS_FIXED_PORT_ID_ false + +#define ds015_service_gnss_Covariance_0_1_FULL_NAME_ "ds015.service.gnss.Covariance" +#define ds015_service_gnss_Covariance_0_1_FULL_NAME_AND_VERSION_ "ds015.service.gnss.Covariance.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define ds015_service_gnss_Covariance_0_1_EXTENT_BYTES_ 24UL +#define ds015_service_gnss_Covariance_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(ds015_service_gnss_Covariance_0_1_EXTENT_BYTES_ >= ds015_service_gnss_Covariance_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] point_covariance_urt +#define ds015_service_gnss_Covariance_0_1_point_covariance_urt_ARRAY_CAPACITY_ 6U +#define ds015_service_gnss_Covariance_0_1_point_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated float16[6] velocity_covariance_urt +#define ds015_service_gnss_Covariance_0_1_velocity_covariance_urt_ARRAY_CAPACITY_ 6U +#define ds015_service_gnss_Covariance_0_1_velocity_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[6] point_covariance_urt + float point_covariance_urt[6]; + + /// saturated float16[6] velocity_covariance_urt + float velocity_covariance_urt[6]; +} ds015_service_gnss_Covariance_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see ds015_service_gnss_Covariance_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Covariance_0_1_serialize_( + const ds015_service_gnss_Covariance_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[6] point_covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->point_covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + + + { // saturated float16[6] velocity_covariance_urt + const size_t _origin1_ = offset_bits; + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + float _sat1_ = obj->velocity_covariance_urt[_index1_]; + if (isfinite(_sat1_)) + { + if (_sat1_ < ((float) -65504.0)) + { + _sat1_ = ((float) -65504.0); + } + if (_sat1_ > ((float) 65504.0)) + { + _sat1_ = ((float) 65504.0); + } + } + const uint16_t _half1_ = nunavutFloat16Pack(_sat1_); + (void) memmove(&buffer[offset_bits / 8U], &_half1_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin1_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Covariance_0_1_deserialize_( + ds015_service_gnss_Covariance_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[6] point_covariance_urt + for (size_t _index2_ = 0U; _index2_ < 6UL; ++_index2_) + { + out_obj->point_covariance_urt[_index2_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + + + // saturated float16[6] velocity_covariance_urt + for (size_t _index3_ = 0U; _index3_ < 6UL; ++_index3_) + { + out_obj->velocity_covariance_urt[_index3_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void ds015_service_gnss_Covariance_0_1_initialize_(ds015_service_gnss_Covariance_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = ds015_service_gnss_Covariance_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // DS015_SERVICE_GNSS_COVARIANCE_0_1_INCLUDED_ diff --git a/src/nunavut_out/ds015/service/gnss/Gnss_0_1.h b/src/nunavut_out/ds015/service/gnss/Gnss_0_1.h new file mode 100644 index 0000000..ef093f8 --- /dev/null +++ b/src/nunavut_out/ds015/service/gnss/Gnss_0_1.h @@ -0,0 +1,630 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.070467 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: ds015.service.gnss.Gnss +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef DS015_SERVICE_GNSS_GNSS_0_1_INCLUDED_ +#define DS015_SERVICE_GNSS_GNSS_0_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Gnss.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define ds015_service_gnss_Gnss_0_1_HAS_FIXED_PORT_ID_ false + +#define ds015_service_gnss_Gnss_0_1_FULL_NAME_ "ds015.service.gnss.Gnss" +#define ds015_service_gnss_Gnss_0_1_FULL_NAME_AND_VERSION_ "ds015.service.gnss.Gnss.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define ds015_service_gnss_Gnss_0_1_EXTENT_BYTES_ 59UL +#define ds015_service_gnss_Gnss_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 59UL +static_assert(ds015_service_gnss_Gnss_0_1_EXTENT_BYTES_ >= ds015_service_gnss_Gnss_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// ds015.service.gnss.Status.0.1 status + ds015_service_gnss_Status_0_1 status; + + /// saturated uint32 time_week_ms + uint32_t time_week_ms; + + /// saturated uint16 time_week + uint16_t time_week; + + /// ds015.physics.kinematics.geodetic.Point.0.1 point + ds015_physics_kinematics_geodetic_Point_0_1 point; + + /// uavcan.si.unit.velocity.Vector3.1.0 velocity + uavcan_si_unit_velocity_Vector3_1_0 velocity; + + /// uavcan.si.unit.angle.Scalar.1.0 yaw + uavcan_si_unit_angle_Scalar_1_0 yaw; + + /// saturated float16 horizontal_accuracy + float horizontal_accuracy; + + /// saturated float16 vertical_accuracy + float vertical_accuracy; + + /// saturated float16 speed_accuracy + float speed_accuracy; + + /// uavcan.si.unit.angle.Scalar.1.0 yaw_accuracy + uavcan_si_unit_angle_Scalar_1_0 yaw_accuracy; + + /// saturated float16 hdop + float hdop; + + /// saturated float16 vdop + float vdop; + + /// saturated uint8 num_sats + uint8_t num_sats; +} ds015_service_gnss_Gnss_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see ds015_service_gnss_Gnss_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Gnss_0_1_serialize_( + const ds015_service_gnss_Gnss_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 472UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // ds015.service.gnss.Status.0.1 status + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = ds015_service_gnss_Status_0_1_serialize_( + &obj->status, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint32 time_week_ms + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->time_week_ms, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint16 time_week + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->time_week, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // ds015.physics.kinematics.geodetic.Point.0.1 point + size_t _size_bytes1_ = 20UL; // Nested object (max) size, in bytes. + int8_t _err2_ = ds015_physics_kinematics_geodetic_Point_0_1_serialize_( + &obj->point, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.velocity.Vector3.1.0 velocity + size_t _size_bytes2_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_velocity_Vector3_1_0_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + + { // uavcan.si.unit.angle.Scalar.1.0 yaw + size_t _size_bytes3_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err6_ = uavcan_si_unit_angle_Scalar_1_0_serialize_( + &obj->yaw, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16 horizontal_accuracy + float _sat0_ = obj->horizontal_accuracy; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + + + + + { // saturated float16 vertical_accuracy + float _sat1_ = obj->vertical_accuracy; + if (isfinite(_sat1_)) + { + if (_sat1_ < ((float) -65504.0)) + { + _sat1_ = ((float) -65504.0); + } + if (_sat1_ > ((float) 65504.0)) + { + _sat1_ = ((float) 65504.0); + } + } + const uint16_t _half1_ = nunavutFloat16Pack(_sat1_); + (void) memmove(&buffer[offset_bits / 8U], &_half1_, 2U); + offset_bits += 16U; + } + + + + + { // saturated float16 speed_accuracy + float _sat2_ = obj->speed_accuracy; + if (isfinite(_sat2_)) + { + if (_sat2_ < ((float) -65504.0)) + { + _sat2_ = ((float) -65504.0); + } + if (_sat2_ > ((float) 65504.0)) + { + _sat2_ = ((float) 65504.0); + } + } + const uint16_t _half2_ = nunavutFloat16Pack(_sat2_); + (void) memmove(&buffer[offset_bits / 8U], &_half2_, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _pad3_; + } + + { // uavcan.si.unit.angle.Scalar.1.0 yaw_accuracy + size_t _size_bytes4_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err8_ = uavcan_si_unit_angle_Scalar_1_0_serialize_( + &obj->yaw_accuracy, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16 hdop + float _sat3_ = obj->hdop; + if (isfinite(_sat3_)) + { + if (_sat3_ < ((float) -65504.0)) + { + _sat3_ = ((float) -65504.0); + } + if (_sat3_ > ((float) 65504.0)) + { + _sat3_ = ((float) 65504.0); + } + } + const uint16_t _half3_ = nunavutFloat16Pack(_sat3_); + (void) memmove(&buffer[offset_bits / 8U], &_half3_, 2U); + offset_bits += 16U; + } + + + + + { // saturated float16 vdop + float _sat4_ = obj->vdop; + if (isfinite(_sat4_)) + { + if (_sat4_ < ((float) -65504.0)) + { + _sat4_ = ((float) -65504.0); + } + if (_sat4_ > ((float) 65504.0)) + { + _sat4_ = ((float) 65504.0); + } + } + const uint16_t _half4_ = nunavutFloat16Pack(_sat4_); + (void) memmove(&buffer[offset_bits / 8U], &_half4_, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8 num_sats + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->num_sats); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad4_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err9_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad4_); // Optimize? + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _pad4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Gnss_0_1_deserialize_( + ds015_service_gnss_Gnss_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // ds015.service.gnss.Status.0.1 status + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err10_ = ds015_service_gnss_Status_0_1_deserialize_( + &out_obj->status, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint32 time_week_ms + out_obj->time_week_ms = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint16 time_week + out_obj->time_week = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // ds015.physics.kinematics.geodetic.Point.0.1 point + { + size_t _size_bytes6_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err11_ = ds015_physics_kinematics_geodetic_Point_0_1_deserialize_( + &out_obj->point, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err11_ < 0) + { + return _err11_; + } + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.velocity.Vector3.1.0 velocity + { + size_t _size_bytes7_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err12_ = uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err12_ < 0) + { + return _err12_; + } + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angle.Scalar.1.0 yaw + { + size_t _size_bytes8_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err13_ = uavcan_si_unit_angle_Scalar_1_0_deserialize_( + &out_obj->yaw, &buffer[offset_bits / 8U], &_size_bytes8_); + if (_err13_ < 0) + { + return _err13_; + } + offset_bits += _size_bytes8_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16 horizontal_accuracy + out_obj->horizontal_accuracy = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated float16 vertical_accuracy + out_obj->vertical_accuracy = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated float16 speed_accuracy + out_obj->speed_accuracy = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angle.Scalar.1.0 yaw_accuracy + { + size_t _size_bytes9_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err14_ = uavcan_si_unit_angle_Scalar_1_0_deserialize_( + &out_obj->yaw_accuracy, &buffer[offset_bits / 8U], &_size_bytes9_); + if (_err14_ < 0) + { + return _err14_; + } + offset_bits += _size_bytes9_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16 hdop + out_obj->hdop = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated float16 vdop + out_obj->vdop = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated uint8 num_sats + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->num_sats = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->num_sats = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void ds015_service_gnss_Gnss_0_1_initialize_(ds015_service_gnss_Gnss_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = ds015_service_gnss_Gnss_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // DS015_SERVICE_GNSS_GNSS_0_1_INCLUDED_ diff --git a/src/nunavut_out/ds015/service/gnss/RelativePosition_0_1.h b/src/nunavut_out/ds015/service/gnss/RelativePosition_0_1.h new file mode 100644 index 0000000..92df2b7 --- /dev/null +++ b/src/nunavut_out/ds015/service/gnss/RelativePosition_0_1.h @@ -0,0 +1,287 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.076022 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: ds015.service.gnss.RelativePosition +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef DS015_SERVICE_GNSS_RELATIVE_POSITION_0_1_INCLUDED_ +#define DS015_SERVICE_GNSS_RELATIVE_POSITION_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/RelativePosition.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define ds015_service_gnss_RelativePosition_0_1_HAS_FIXED_PORT_ID_ false + +#define ds015_service_gnss_RelativePosition_0_1_FULL_NAME_ "ds015.service.gnss.RelativePosition" +#define ds015_service_gnss_RelativePosition_0_1_FULL_NAME_AND_VERSION_ "ds015.service.gnss.RelativePosition.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define ds015_service_gnss_RelativePosition_0_1_EXTENT_BYTES_ 18UL +#define ds015_service_gnss_RelativePosition_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 18UL +static_assert(ds015_service_gnss_RelativePosition_0_1_EXTENT_BYTES_ >= ds015_service_gnss_RelativePosition_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 time_week_ms + uint32_t time_week_ms; + + /// saturated uint16 time_week + uint16_t time_week; + + /// uavcan.si.unit.length.Vector3.1.0 relative_position + uavcan_si_unit_length_Vector3_1_0 relative_position; +} ds015_service_gnss_RelativePosition_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see ds015_service_gnss_RelativePosition_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_RelativePosition_0_1_serialize_( + const ds015_service_gnss_RelativePosition_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 144UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 time_week_ms + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->time_week_ms, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint16 time_week + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->time_week, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.length.Vector3.1.0 relative_position + size_t _size_bytes0_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_si_unit_length_Vector3_1_0_serialize_( + &obj->relative_position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_RelativePosition_0_1_deserialize_( + ds015_service_gnss_RelativePosition_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 time_week_ms + out_obj->time_week_ms = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint16 time_week + out_obj->time_week = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.length.Vector3.1.0 relative_position + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_si_unit_length_Vector3_1_0_deserialize_( + &out_obj->relative_position, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void ds015_service_gnss_RelativePosition_0_1_initialize_(ds015_service_gnss_RelativePosition_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = ds015_service_gnss_RelativePosition_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // DS015_SERVICE_GNSS_RELATIVE_POSITION_0_1_INCLUDED_ diff --git a/src/nunavut_out/ds015/service/gnss/Status_0_1.h b/src/nunavut_out/ds015/service/gnss/Status_0_1.h new file mode 100644 index 0000000..cd84727 --- /dev/null +++ b/src/nunavut_out/ds015/service/gnss/Status_0_1.h @@ -0,0 +1,363 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.078580 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: ds015.service.gnss.Status +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef DS015_SERVICE_GNSS_STATUS_0_1_INCLUDED_ +#define DS015_SERVICE_GNSS_STATUS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/ds015/service/gnss/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define ds015_service_gnss_Status_0_1_HAS_FIXED_PORT_ID_ false + +#define ds015_service_gnss_Status_0_1_FULL_NAME_ "ds015.service.gnss.Status" +#define ds015_service_gnss_Status_0_1_FULL_NAME_AND_VERSION_ "ds015.service.gnss.Status.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define ds015_service_gnss_Status_0_1_EXTENT_BYTES_ 2UL +#define ds015_service_gnss_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(ds015_service_gnss_Status_0_1_EXTENT_BYTES_ >= ds015_service_gnss_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint2 STATUS_NO_FIX = 0 +#define ds015_service_gnss_Status_0_1_STATUS_NO_FIX (0U) +/// saturated uint2 STATUS_TIME_ONLY = 1 +#define ds015_service_gnss_Status_0_1_STATUS_TIME_ONLY (1U) +/// saturated uint2 STATUS_2D_FIX = 2 +#define ds015_service_gnss_Status_0_1_STATUS_2D_FIX (2U) +/// saturated uint2 STATUS_3D_FIX = 3 +#define ds015_service_gnss_Status_0_1_STATUS_3D_FIX (3U) +/// saturated uint2 MODE_SINGLE = 0 +#define ds015_service_gnss_Status_0_1_MODE_SINGLE (0U) +/// saturated uint2 MODE_DGPS = 1 +#define ds015_service_gnss_Status_0_1_MODE_DGPS (1U) +/// saturated uint2 MODE_RTK = 2 +#define ds015_service_gnss_Status_0_1_MODE_RTK (2U) +/// saturated uint2 MODE_PPP = 3 +#define ds015_service_gnss_Status_0_1_MODE_PPP (3U) +/// saturated uint2 SUB_MODE_DGPS_OTHER = 0 +#define ds015_service_gnss_Status_0_1_SUB_MODE_DGPS_OTHER (0U) +/// saturated uint2 SUB_MODE_DGPS_SBAS = 1 +#define ds015_service_gnss_Status_0_1_SUB_MODE_DGPS_SBAS (1U) +/// saturated uint2 SUB_MODE_RTK_FLOAT = 0 +#define ds015_service_gnss_Status_0_1_SUB_MODE_RTK_FLOAT (0U) +/// saturated uint2 SUB_MODE_RTK_FIXED = 1 +#define ds015_service_gnss_Status_0_1_SUB_MODE_RTK_FIXED (1U) +/// saturated uint2 JAMMING_STATE_UNKNOWN = 0 +#define ds015_service_gnss_Status_0_1_JAMMING_STATE_UNKNOWN (0U) +/// saturated uint2 JAMMING_STATE_OK = 1 +#define ds015_service_gnss_Status_0_1_JAMMING_STATE_OK (1U) +/// saturated uint2 JAMMING_STATE_WARNING = 2 +#define ds015_service_gnss_Status_0_1_JAMMING_STATE_WARNING (2U) +/// saturated uint2 JAMMING_STATE_CRITICAL = 3 +#define ds015_service_gnss_Status_0_1_JAMMING_STATE_CRITICAL (3U) +/// saturated uint2 SPOOFING_STATE_UNKNOWN = 0 +#define ds015_service_gnss_Status_0_1_SPOOFING_STATE_UNKNOWN (0U) +/// saturated uint2 SPOOFING_STATE_NONE = 1 +#define ds015_service_gnss_Status_0_1_SPOOFING_STATE_NONE (1U) +/// saturated uint2 SPOOFING_STATE_INDICATED = 2 +#define ds015_service_gnss_Status_0_1_SPOOFING_STATE_INDICATED (2U) +/// saturated uint2 SPOOFING_STATE_MULTIPLE = 3 +#define ds015_service_gnss_Status_0_1_SPOOFING_STATE_MULTIPLE (3U) + +typedef struct +{ + /// truncated uint2 status + uint8_t status; + + /// truncated uint2 mode + uint8_t mode; + + /// truncated uint2 sub_mode + uint8_t sub_mode; + + /// truncated uint2 jamming_state + uint8_t jamming_state; + + /// truncated uint2 spoofing_state + uint8_t spoofing_state; +} ds015_service_gnss_Status_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see ds015_service_gnss_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Status_0_1_serialize_( + const ds015_service_gnss_Status_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint2 status + buffer[offset_bits / 8U] = (uint8_t)(obj->status); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 2U; + } + + + + + { // truncated uint2 mode + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, obj->mode, 2U); + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 2U; + } + + + + + { // truncated uint2 sub_mode + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, obj->sub_mode, 2U); + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += 2U; + } + + + + + { // truncated uint2 jamming_state + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, obj->jamming_state, 2U); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += 2U; + } + + + + + { // truncated uint2 spoofing_state + buffer[offset_bits / 8U] = (uint8_t)(obj->spoofing_state); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 2U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t ds015_service_gnss_Status_0_1_deserialize_( + ds015_service_gnss_Status_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint2 status + if ((offset_bits + 2U) <= capacity_bits) + { + out_obj->status = buffer[offset_bits / 8U] & 3U; + } + else + { + out_obj->status = 0U; + } + offset_bits += 2U; + + + + + // truncated uint2 mode + out_obj->mode = nunavutGetU8(&buffer[0], capacity_bytes, offset_bits, 2); + offset_bits += 2U; + + + + + // truncated uint2 sub_mode + out_obj->sub_mode = nunavutGetU8(&buffer[0], capacity_bytes, offset_bits, 2); + offset_bits += 2U; + + + + + // truncated uint2 jamming_state + out_obj->jamming_state = nunavutGetU8(&buffer[0], capacity_bytes, offset_bits, 2); + offset_bits += 2U; + + + + + // truncated uint2 spoofing_state + if ((offset_bits + 2U) <= capacity_bits) + { + out_obj->spoofing_state = buffer[offset_bits / 8U] & 3U; + } + else + { + out_obj->spoofing_state = 0U; + } + offset_bits += 2U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void ds015_service_gnss_Status_0_1_initialize_(ds015_service_gnss_Status_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = ds015_service_gnss_Status_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // DS015_SERVICE_GNSS_STATUS_0_1_INCLUDED_ diff --git a/src/nunavut_out/nunavut/support/serialization.h b/src/nunavut_out/nunavut/support/serialization.h new file mode 100644 index 0000000..4a85b31 --- /dev/null +++ b/src/nunavut_out/nunavut/support/serialization.h @@ -0,0 +1,572 @@ +// UAVCAN common serialization support routines. +-+ +-+ +// This file is based on canard_dsdl.h, which is part of Libcanard. | | | | +// \ - / +// AUTOGENERATED, DO NOT EDIT. --- +// o +//--------------------------------------------------------------------------------------------------------------------- +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef NUNAVUT_SUPPORT_SERIALIZATION_H_INCLUDED +#define NUNAVUT_SUPPORT_SERIALIZATION_H_INCLUDED + +#ifdef __cplusplus +# if (__cplusplus < 201100L) +# error "Unsupported language: ISO C11, C++11, or a newer version of either is required." +# endif +extern "C" +{ +#else +# if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 201112L) +# error "Unsupported language: ISO C11 or a newer version is required." +# endif +#endif + +#include + +#include +#include // For isfinite(). +#include +#include +#include // For static_assert (C11) and assert() if NUNAVUT_ASSERT is used. + +static_assert(sizeof(size_t) >= sizeof(size_t), + "The bit-length type used by Nunavut, size_t, " + "is smaller than this platform's size_t type. " + "Nunavut serialization relies on size_t to size_t conversions " + "that do not lose data. You will need to regenerate Nunavut serialization support with a larger " + "unsigned_bit_length type specified."); + +#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS 434322821 +#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT 0 +#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS 0 +#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY 0 +#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT 2368206204 + +/// Nunavut returns 0 for success and < 0 for any failure. It is always adequate to check that error_value < 0 +/// to detect errors or error_value == 0 for success. +/// +/// Nunavut serialization will never define more than 127 errors and the reserved error numbers are [-1,-127] +/// (-128 is not used). Error code 1 is currently also not used to avoid conflicts with 3rd-party software. +/// +/// Return values > 0 for Nunavut serialization are undefined. +#define NUNAVUT_SUCCESS 0 +// API usage errors: +#define NUNAVUT_ERROR_INVALID_ARGUMENT 2 +#define NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL 3 +// Invalid representation (caused by bad input data, not API misuse): +#define NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH 10 +#define NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG 11 +#define NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER 12 + +/// Detect whether the target platform is compatible with IEEE 754. +#define NUNAVUT_PLATFORM_IEEE754_FLOAT \ + ((FLT_RADIX == 2) && (FLT_MANT_DIG == 24) && (FLT_MIN_EXP == -125) && (FLT_MAX_EXP == 128)) +#define NUNAVUT_PLATFORM_IEEE754_DOUBLE \ + ((FLT_RADIX == 2) && (DBL_MANT_DIG == 53) && (DBL_MIN_EXP == -1021) && (DBL_MAX_EXP == 1024)) + +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +# error "This code has been generated for little-endian platforms only. " \ + "To generate portable endianness-invariant code, set the Nunavut option target_endianness='any' " \ + "and regenerate the code. This change will have some performance impact for little-endian machines." +#endif + +// ---------------------------------------------------- HELPERS ---------------------------------------------------- + +/// Returns the smallest value. +static inline size_t nunavutChooseMin(const size_t a, const size_t b) +{ + return (a < b) ? a : b; +} + +/// Calculate the number of bits to safely copy from/to a serialized buffer. +/// Mind the units! By convention, buffer size is specified in bytes, but fragment length and offset are in bits. +/// +/// buffer buffer +/// origin end +/// [------------------------- buffer_size_bytes ------------------------] +/// [--------------- fragment_offset_bits ---------------][--- fragment_length_bits ---] +/// [-- out bits --] +/// +static inline size_t nunavutSaturateBufferFragmentBitLength( + const size_t buffer_size_bytes, const size_t fragment_offset_bits, const size_t fragment_length_bits) +{ + const size_t size_bits = (size_t)buffer_size_bytes * 8U; + const size_t tail_bits = size_bits - nunavutChooseMin(size_bits, fragment_offset_bits); + return nunavutChooseMin(fragment_length_bits, tail_bits); +} + +// ---------------------------------------------------- BIT ARRAY ---------------------------------------------------- + +/// Copy the specified number of bits from the source buffer into the destination buffer in accordance with the +/// DSDL bit-level serialization specification. The offsets may be arbitrary (may exceed 8 bits). +/// If both offsets are byte-aligned, the function invokes memmove() and possibly adjusts the last byte separately. +/// If the source and the destination overlap AND the offsets are not byte-aligned, the behavior is undefined. +/// If either source or destination pointers are NULL, the behavior is undefined. +/// Arguments: +/// dst Destination buffer. Shall be at least ceil(length_bits/8) bytes large. +/// dst_offset_bits Offset in bits from the destination pointer. May exceed 8. +/// length_bits The number of bits to copy. Both source and destination shall be large enough. +/// src Source buffer. Shall be at least ceil(length_bits/8) bytes large. +/// src_offset_bits Offset in bits from the source pointer. May exceed 8. +static inline void nunavutCopyBits(void* const dst, + const size_t dst_offset_bits, + const size_t length_bits, + const void* const src, + const size_t src_offset_bits) +{ + + + + if ((0U == (src_offset_bits % 8U)) && (0U == (dst_offset_bits % 8U))) // Aligned copy, optimized, most common case. + { + const size_t length_bytes = (size_t)(length_bits / 8U); + // Intentional violation of MISRA: Pointer arithmetics. This is done to remove the API constraint that + // offsets be under 8 bits. Fewer constraints reduce the chance of API misuse. + const uint8_t* const psrc = (src_offset_bits / 8U) + (const uint8_t*) src; // NOSONAR NOLINT + uint8_t* const pdst = (dst_offset_bits / 8U) + (uint8_t*) dst; // NOSONAR NOLINT + (void) memmove(pdst, psrc, length_bytes); + const uint8_t length_mod = (uint8_t)(length_bits % 8U); + if (0U != length_mod) // If the length is unaligned, the last byte requires special treatment. + { + // Intentional violation of MISRA: Pointer arithmetics. It is unavoidable in this context. + const uint8_t* const last_src = psrc + length_bytes; // NOLINT NOSONAR + uint8_t* const last_dst = pdst + length_bytes; // NOLINT NOSONAR + + const uint8_t mask = (uint8_t)((1U << length_mod) - 1U); + *last_dst = (*last_dst & (uint8_t)~mask) | (*last_src & mask); + } + } + else + { + // The algorithm was originally designed by Ben Dyer for Libuavcan v0: + // https://github.com/OpenCyphal/libuavcan/blob/legacy-v0/libuavcan/src/marshal/uc_bit_array_copy.cpp + // This version is modified for v1 where the bit order is the opposite. + const uint8_t* const psrc = (const uint8_t*) src; + uint8_t* const pdst = (uint8_t*) dst; + size_t src_off = src_offset_bits; + size_t dst_off = dst_offset_bits; + const size_t last_bit = src_off + length_bits; + + + while (last_bit > src_off) + { + const uint8_t src_mod = (uint8_t)(src_off % 8U); + const uint8_t dst_mod = (uint8_t)(dst_off % 8U); + const uint8_t max_mod = (src_mod > dst_mod) ? src_mod : dst_mod; + const uint8_t size = (uint8_t) nunavutChooseMin(8U - max_mod, last_bit - src_off); + + + // Suppress a false warning from Clang-Tidy & Sonar that size is being over-shifted. It's not. + const uint8_t mask = (uint8_t)((((1U << size) - 1U) << dst_mod) & 0xFFU); // NOLINT NOSONAR + + // Intentional violation of MISRA: indexing on a pointer. + // This simplifies the implementation greatly and avoids pointer arithmetics. + const uint8_t in = (uint8_t)((uint8_t)(psrc[src_off / 8U] >> src_mod) << dst_mod) & 0xFFU; // NOSONAR + // Intentional violation of MISRA: indexing on a pointer. + // This simplifies the implementation greatly and avoids pointer arithmetics. + const uint8_t a = pdst[dst_off / 8U] & ((uint8_t) ~mask); // NOSONAR + const uint8_t b = in & mask; + // Intentional violation of MISRA: indexing on a pointer. + // This simplifies the implementation greatly and avoids pointer arithmetics. + pdst[dst_off / 8U] = a | b; // NOSONAR + src_off += size; + dst_off += size; + } + + } +} + +/// This function is intended for deserialization of contiguous sequences of zero-cost primitives. +/// It extracts (len_bits) bits that are offset by (off_bits) from the origin of (buf) whose size is (buf_size_bytes). +/// If the requested (len_bits+off_bits) overruns the buffer, the missing bits are implicitly zero-extended. +/// If (len_bits % 8 != 0), the output buffer is right-zero-padded up to the next byte boundary. +/// If (off_bits % 8 == 0), the operation is delegated to memmove(); otherwise, a much slower unaligned bit copy +/// algorithm is employed. See @ref nunavutCopyBits() for further details. +static inline void nunavutGetBits(void* const output, + const void* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const size_t len_bits) +{ + + + const size_t sat_bits = nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, len_bits); + // Apply implicit zero extension. Normally, this is a no-op unless (len_bits > sat_bits) or (len_bits % 8 != 0). + // The former case ensures that if we're copying <8 bits, the MSB in the destination will be zeroed out. + (void) memset(((uint8_t*)output) + (sat_bits / 8U), 0, ((len_bits + 7U) / 8U) - (sat_bits / 8U)); + nunavutCopyBits(output, 0U, sat_bits, buf, off_bits); +} + +// ---------------------------------------------------- INTEGER ---------------------------------------------------- + +/// Serialize a DSDL field value at the specified bit offset from the beginning of the destination buffer. +/// The behavior is undefined if the input pointer is NULL. The time complexity is linear of the bit length. +/// One-bit-wide signed integers are processed without raising an error but the result is unspecified. +/// +/// Arguments: +/// buf Destination buffer where the result will be stored. +/// buf_size_bytes Size of the above, in bytes. +/// off_bits Offset, in bits, from the beginning of the buffer. May exceed one byte. +/// value The value itself (in case of integers it is promoted to 64-bit for unification). +/// len_bits Length of the serialized representation, in bits. Zero has no effect. Values >64 bit saturated. + +static inline int8_t nunavutSetBit( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const bool value) +{ + + if ((buf_size_bytes * 8) <= off_bits) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + const uint8_t val = value ? 1U : 0U; + nunavutCopyBits(buf, off_bits, 1U, &val, 0U); + return NUNAVUT_SUCCESS; +} + +static inline int8_t nunavutSetUxx( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint64_t value, + const uint8_t len_bits) +{ + static_assert(64U == (sizeof(uint64_t) * 8U), "Unexpected size of uint64_t"); + + if ((buf_size_bytes * 8) < (off_bits + len_bits)) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + const size_t saturated_len_bits = nunavutChooseMin(len_bits, 64U); + nunavutCopyBits(buf, off_bits, saturated_len_bits, (const uint8_t*) &value, 0U); + return NUNAVUT_SUCCESS; +} + +static inline int8_t nunavutSetIxx( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const int64_t value, + const uint8_t len_bits) +{ + // The naive sign conversion is safe and portable according to the C standard: + // 6.3.1.3.3: if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more + // than the maximum value that can be represented in the new type until the value is in the range of the new type. + return nunavutSetUxx(buf, buf_size_bytes, off_bits, (uint64_t) value, len_bits); +} + +/// Deserialize a DSDL field value located at the specified bit offset from the beginning of the source buffer. +/// If the deserialized value extends beyond the end of the buffer, the missing bits are taken as zero, as required +/// by the DSDL specification (see Implicit Zero Extension Rule, IZER). +/// +/// If len_bits is greater than the return type, extra bits will be truncated per standard narrowing conversion rules. +/// If len_bits is shorter than the return type, missing bits will be zero per standard integer promotion rules. +/// Essentially, for integers, it would be enough to have 64-bit versions only; narrower variants exist only to avoid +/// narrowing type conversions of the result and for some performance gains. +/// +/// The behavior is undefined if the input pointer is NULL. The time complexity is linear of the bit length. +/// One-bit-wide signed integers are processed without raising an error but the result is unspecified. +/// +/// Arguments: +/// buf Source buffer where the serialized representation will be read from. +/// buf_size_bytes The size of the source buffer, in bytes. Reads past this limit will return zero bits. +/// off_bits Offset, in bits, from the beginning of the buffer. May exceed one byte. +/// len_bits Length of the serialized representation, in bits. Zero returns 0. Out-of-range values saturated. + +static inline uint8_t nunavutGetU8(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits); + +static inline bool nunavutGetBit(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits) +{ + return 1U == nunavutGetU8(buf, buf_size_bytes, off_bits, 1U); +} + +static inline uint8_t nunavutGetU8(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + + const size_t bits = nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, nunavutChooseMin(len_bits, 8U)); + + uint8_t val = 0; + nunavutCopyBits(&val, 0U, bits, buf, off_bits); + return val; +} + +static inline uint16_t nunavutGetU16(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + + const size_t bits = nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, nunavutChooseMin(len_bits, 16U)); + + uint16_t val = 0U; + nunavutCopyBits(&val, 0U, bits, buf, off_bits); + return val; +} + +static inline uint32_t nunavutGetU32(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + + const size_t bits = nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, nunavutChooseMin(len_bits, 32U)); + + uint32_t val = 0U; + nunavutCopyBits(&val, 0U, bits, buf, off_bits); + return val; +} + +static inline uint64_t nunavutGetU64(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + + const size_t bits = nunavutSaturateBufferFragmentBitLength(buf_size_bytes, off_bits, nunavutChooseMin(len_bits, 64U)); + + uint64_t val = 0U; + nunavutCopyBits(&val, 0U, bits, buf, off_bits); + return val; +} + +static inline int8_t nunavutGetI8(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + const uint8_t sat = (uint8_t) nunavutChooseMin(len_bits, 8U); + uint8_t val = nunavutGetU8(buf, buf_size_bytes, off_bits, sat); + const bool neg = (sat > 0U) && ((val & (1ULL << (sat - 1U))) != 0U); + val = ((sat < 8U) && neg) ? (uint8_t)(val | ~((1U << sat) - 1U)) : val; // Sign extension + return neg ? (int8_t)((-(int8_t)(uint8_t) ~val) - 1) : (int8_t) val; +} + +static inline int16_t nunavutGetI16(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + const uint8_t sat = (uint8_t) nunavutChooseMin(len_bits, 16U); + uint16_t val = nunavutGetU16(buf, buf_size_bytes, off_bits, sat); + const bool neg = (sat > 0U) && ((val & (1ULL << (sat - 1U))) != 0U); + val = ((sat < 16U) && neg) ? (uint16_t)(val | ~((1U << sat) - 1U)) : val; // Sign extension + return neg ? (int16_t)((-(int16_t)(uint16_t) ~val) - 1) : (int16_t) val; +} + +static inline int32_t nunavutGetI32(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + const uint8_t sat = (uint8_t) nunavutChooseMin(len_bits, 32U); + uint32_t val = nunavutGetU32(buf, buf_size_bytes, off_bits, sat); + const bool neg = (sat > 0U) && ((val & (1ULL << (sat - 1U))) != 0U); + val = ((sat < 32U) && neg) ? (uint32_t)(val | ~((1UL << sat) - 1U)) : val; // Sign extension + return neg ? (int32_t)((-(int32_t) ~val) - 1) : (int32_t) val; +} + +static inline int64_t nunavutGetI64(const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const uint8_t len_bits) +{ + const uint8_t sat = (uint8_t) nunavutChooseMin(len_bits, 64U); + uint64_t val = nunavutGetU64(buf, buf_size_bytes, off_bits, sat); + const bool neg = (sat > 0U) && ((val & (1ULL << (sat - 1U))) != 0U); + val = ((sat < 64U) && neg) ? (uint64_t)(val | ~((1ULL << sat) - 1U)) : val; // Sign extension + return neg ? (int64_t)((-(int64_t) ~val) - 1) : (int64_t) val; +} + +// ---------------------------------------------------- FLOAT16 ---------------------------------------------------- + +static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, + "The target platform does not support IEEE754 floating point operations."); +static_assert(32U == (sizeof(float) * 8U), "Unsupported floating point model"); + +/// Converts a single-precision float into the binary representation of the value as a half-precision IEEE754 value. +static inline uint16_t nunavutFloat16Pack(const float value) +{ + typedef union // NOSONAR + { + uint32_t bits; + float real; + } Float32Bits; + + // The no-lint statements suppress the warning about the use of union. This is required for low-level bit access. + const uint32_t round_mask = ~(uint32_t) 0x0FFFU; + Float32Bits f32inf; // NOSONAR + Float32Bits f16inf; // NOSONAR + Float32Bits magic; // NOSONAR + Float32Bits in; // NOSONAR + f32inf.bits = ((uint32_t) 255U) << 23U; + f16inf.bits = ((uint32_t) 31U) << 23U; + magic.bits = ((uint32_t) 15U) << 23U; + in.real = value; + const uint32_t sign = in.bits & (((uint32_t) 1U) << 31U); + in.bits ^= sign; + uint16_t out = 0; + if (in.bits >= f32inf.bits) + { + if ((in.bits & 0x7FFFFFUL) != 0) + { + out = 0x7E00U; + } + else + { + out = (in.bits > f32inf.bits) ? (uint16_t) 0x7FFFU : (uint16_t) 0x7C00U; + } + } + else + { + in.bits &= round_mask; + in.real *= magic.real; + in.bits -= round_mask; + if (in.bits > f16inf.bits) + { + in.bits = f16inf.bits; + } + out = (uint16_t)(in.bits >> 13U); + } + out |= (uint16_t)(sign >> 16U); + return out; +} + +static inline float nunavutFloat16Unpack(const uint16_t value) +{ + typedef union // NOSONAR + { + uint32_t bits; + float real; + } Float32Bits; + + // The no-lint statements suppress the warning about the use of union. This is required for low-level bit access. + Float32Bits magic; // NOSONAR + Float32Bits inf_nan; // NOSONAR + Float32Bits out; // NOSONAR + magic.bits = ((uint32_t) 0xEFU) << 23U; + inf_nan.bits = ((uint32_t) 0x8FU) << 23U; + out.bits = ((uint32_t)(value & 0x7FFFU)) << 13U; + out.real *= magic.real; + if (out.real >= inf_nan.real) + { + out.bits |= ((uint32_t) 0xFFU) << 23U; + } + out.bits |= ((uint32_t)(value & 0x8000U)) << 16U; + return out.real; +} + +static inline int8_t nunavutSetF16( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const float value) +{ + return nunavutSetUxx(buf, buf_size_bytes, off_bits, nunavutFloat16Pack(value), 16U); +} + +static inline float nunavutGetF16( + const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits) +{ + return nunavutFloat16Unpack(nunavutGetU16(buf, buf_size_bytes, off_bits, 16U)); +} + +// ---------------------------------------------------- FLOAT32 ---------------------------------------------------- + +static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, + "The target platform does not support IEEE754 floating point operations."); +static_assert(32U == (sizeof(float) * 8U), "Unsupported floating point model"); + +static inline int8_t nunavutSetF32( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const float value) +{ + // Intentional violation of MISRA: use union to perform fast conversion from an IEEE 754-compatible native + // representation into a serializable integer. The assumptions about the target platform properties are made + // clear. In the future we may add a more generic conversion that is platform-invariant. + union // NOSONAR + { + float fl; + uint32_t in; + } const tmp = {value}; // NOSONAR + return nunavutSetUxx(buf, buf_size_bytes, off_bits, tmp.in, sizeof(tmp) * 8U); +} + +static inline float nunavutGetF32( + const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits) +{ + // Intentional violation of MISRA: use union to perform fast conversion to an IEEE 754-compatible native + // representation into a serializable integer. The assumptions about the target platform properties are made + // clear. In the future we may add a more generic conversion that is platform-invariant. + union // NOSONAR + { + uint32_t in; + float fl; + } const tmp = {nunavutGetU32(buf, buf_size_bytes, off_bits, 32U)}; + return tmp.fl; +} + +// ---------------------------------------------------- FLOAT64 ---------------------------------------------------- + +static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, + "The target platform does not support IEEE754 double-precision floating point operations."); +static_assert(64U == (sizeof(double) * 8U), "Unsupported floating point model"); + +static inline int8_t nunavutSetF64( + uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits, + const double value) +{ + // Intentional violation of MISRA: use union to perform fast conversion from an IEEE 754-compatible native + // representation into a serializable integer. The assumptions about the target platform properties are made + // clear. In the future we may add a more generic conversion that is platform-invariant. + union // NOSONAR + { + double fl; + uint64_t in; + } const tmp = {value}; // NOSONAR + return nunavutSetUxx(buf, buf_size_bytes, off_bits, tmp.in, sizeof(tmp) * 8U); +} + +static inline double nunavutGetF64( + const uint8_t* const buf, + const size_t buf_size_bytes, + const size_t off_bits) +{ + // Intentional violation of MISRA: use union to perform fast conversion to an IEEE 754-compatible native + // representation into a serializable integer. The assumptions about the target platform properties are made + // clear. In the future we may add a more generic conversion that is platform-invariant. + union // NOSONAR + { + uint64_t in; + double fl; + } const tmp = {nunavutGetU64(buf, buf_size_bytes, off_bits, 64U)}; + return tmp.fl; +} + +#ifdef __cplusplus +} +#endif + +#endif // NUNAVUT_SUPPORT_SERIALIZATION_H_INCLUDED diff --git a/src/nunavut_out/reg/udral/physics/acoustics/Note_0_1.h b/src/nunavut_out/reg/udral/physics/acoustics/Note_0_1.h new file mode 100644 index 0000000..7557d3a --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/acoustics/Note_0_1.h @@ -0,0 +1,325 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.730998 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.acoustics.Note +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_ACOUSTICS_NOTE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_ACOUSTICS_NOTE_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/acoustics/Note.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_acoustics_Note_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_acoustics_Note_0_1_FULL_NAME_ "reg.udral.physics.acoustics.Note" +#define reg_udral_physics_acoustics_Note_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.acoustics.Note.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_acoustics_Note_0_1_EXTENT_BYTES_ 12UL +#define reg_udral_physics_acoustics_Note_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_physics_acoustics_Note_0_1_EXTENT_BYTES_ >= reg_udral_physics_acoustics_Note_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.frequency.Scalar.1.0 frequency + uavcan_si_unit_frequency_Scalar_1_0 frequency; + + /// uavcan.si.unit.duration.Scalar.1.0 duration + uavcan_si_unit_duration_Scalar_1_0 duration; + + /// uavcan.si.unit.power.Scalar.1.0 acoustic_power + uavcan_si_unit_power_Scalar_1_0 acoustic_power; +} reg_udral_physics_acoustics_Note_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_acoustics_Note_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_acoustics_Note_0_1_serialize_( + const reg_udral_physics_acoustics_Note_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.frequency.Scalar.1.0 frequency + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_frequency_Scalar_1_0_serialize_( + &obj->frequency, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.duration.Scalar.1.0 duration + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_duration_Scalar_1_0_serialize_( + &obj->duration, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.power.Scalar.1.0 acoustic_power + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_power_Scalar_1_0_serialize_( + &obj->acoustic_power, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_acoustics_Note_0_1_deserialize_( + reg_udral_physics_acoustics_Note_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.frequency.Scalar.1.0 frequency + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_si_unit_frequency_Scalar_1_0_deserialize_( + &out_obj->frequency, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.duration.Scalar.1.0 duration + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_duration_Scalar_1_0_deserialize_( + &out_obj->duration, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.power.Scalar.1.0 acoustic_power + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_si_unit_power_Scalar_1_0_deserialize_( + &out_obj->acoustic_power, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_acoustics_Note_0_1_initialize_(reg_udral_physics_acoustics_Note_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_acoustics_Note_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_ACOUSTICS_NOTE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/dynamics/rotation/PlanarTs_0_1.h b/src/nunavut_out/reg/udral/physics/dynamics/rotation/PlanarTs_0_1.h new file mode 100644 index 0000000..b86dac5 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/dynamics/rotation/PlanarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.647024 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.dynamics.rotation.PlanarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_dynamics_rotation_PlanarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_dynamics_rotation_PlanarTs_0_1_FULL_NAME_ "reg.udral.physics.dynamics.rotation.PlanarTs" +#define reg_udral_physics_dynamics_rotation_PlanarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.dynamics.rotation.PlanarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_dynamics_rotation_PlanarTs_0_1_EXTENT_BYTES_ 23UL +#define reg_udral_physics_dynamics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 23UL +static_assert(reg_udral_physics_dynamics_rotation_PlanarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_dynamics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.dynamics.rotation.Planar.0.1 value + reg_udral_physics_dynamics_rotation_Planar_0_1 value; +} reg_udral_physics_dynamics_rotation_PlanarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_dynamics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_rotation_PlanarTs_0_1_serialize_( + const reg_udral_physics_dynamics_rotation_PlanarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.dynamics.rotation.Planar.0.1 value + size_t _size_bytes1_ = 16UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_dynamics_rotation_Planar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_rotation_PlanarTs_0_1_deserialize_( + reg_udral_physics_dynamics_rotation_PlanarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.dynamics.rotation.Planar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_dynamics_rotation_Planar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_dynamics_rotation_PlanarTs_0_1_initialize_(reg_udral_physics_dynamics_rotation_PlanarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_dynamics_rotation_PlanarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/dynamics/rotation/Planar_0_1.h b/src/nunavut_out/reg/udral/physics/dynamics/rotation/Planar_0_1.h new file mode 100644 index 0000000..41b2683 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/dynamics/rotation/Planar_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.644888 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.dynamics.rotation.Planar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_dynamics_rotation_Planar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_dynamics_rotation_Planar_0_1_FULL_NAME_ "reg.udral.physics.dynamics.rotation.Planar" +#define reg_udral_physics_dynamics_rotation_Planar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.dynamics.rotation.Planar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_dynamics_rotation_Planar_0_1_EXTENT_BYTES_ 16UL +#define reg_udral_physics_dynamics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 16UL +static_assert(reg_udral_physics_dynamics_rotation_Planar_0_1_EXTENT_BYTES_ >= reg_udral_physics_dynamics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.rotation.Planar.0.1 kinematics + reg_udral_physics_kinematics_rotation_Planar_0_1 kinematics; + + /// uavcan.si.unit.torque.Scalar.1.0 torque + uavcan_si_unit_torque_Scalar_1_0 _torque; +} reg_udral_physics_dynamics_rotation_Planar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_dynamics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_rotation_Planar_0_1_serialize_( + const reg_udral_physics_dynamics_rotation_Planar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.rotation.Planar.0.1 kinematics + size_t _size_bytes0_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_rotation_Planar_0_1_serialize_( + &obj->kinematics, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.torque.Scalar.1.0 torque + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_torque_Scalar_1_0_serialize_( + &obj->_torque, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_rotation_Planar_0_1_deserialize_( + reg_udral_physics_dynamics_rotation_Planar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.rotation.Planar.0.1 kinematics + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_rotation_Planar_0_1_deserialize_( + &out_obj->kinematics, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.torque.Scalar.1.0 torque + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_torque_Scalar_1_0_deserialize_( + &out_obj->_torque, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_dynamics_rotation_Planar_0_1_initialize_(reg_udral_physics_dynamics_rotation_Planar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_dynamics_rotation_Planar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_DYNAMICS_ROTATION_PLANAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/dynamics/translation/LinearTs_0_1.h b/src/nunavut_out/reg/udral/physics/dynamics/translation/LinearTs_0_1.h new file mode 100644 index 0000000..2d40898 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/dynamics/translation/LinearTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.651177 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.dynamics.translation.LinearTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_dynamics_translation_LinearTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_dynamics_translation_LinearTs_0_1_FULL_NAME_ "reg.udral.physics.dynamics.translation.LinearTs" +#define reg_udral_physics_dynamics_translation_LinearTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.dynamics.translation.LinearTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_dynamics_translation_LinearTs_0_1_EXTENT_BYTES_ 23UL +#define reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 23UL +static_assert(reg_udral_physics_dynamics_translation_LinearTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.dynamics.translation.Linear.0.1 value + reg_udral_physics_dynamics_translation_Linear_0_1 value; +} reg_udral_physics_dynamics_translation_LinearTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_translation_LinearTs_0_1_serialize_( + const reg_udral_physics_dynamics_translation_LinearTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.dynamics.translation.Linear.0.1 value + size_t _size_bytes1_ = 16UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_dynamics_translation_Linear_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_translation_LinearTs_0_1_deserialize_( + reg_udral_physics_dynamics_translation_LinearTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.dynamics.translation.Linear.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_dynamics_translation_Linear_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_dynamics_translation_LinearTs_0_1_initialize_(reg_udral_physics_dynamics_translation_LinearTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_dynamics_translation_LinearTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/dynamics/translation/Linear_0_1.h b/src/nunavut_out/reg/udral/physics/dynamics/translation/Linear_0_1.h new file mode 100644 index 0000000..dd6ceb1 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/dynamics/translation/Linear_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.649055 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.dynamics.translation.Linear +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/dynamics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_dynamics_translation_Linear_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_dynamics_translation_Linear_0_1_FULL_NAME_ "reg.udral.physics.dynamics.translation.Linear" +#define reg_udral_physics_dynamics_translation_Linear_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.dynamics.translation.Linear.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_dynamics_translation_Linear_0_1_EXTENT_BYTES_ 16UL +#define reg_udral_physics_dynamics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 16UL +static_assert(reg_udral_physics_dynamics_translation_Linear_0_1_EXTENT_BYTES_ >= reg_udral_physics_dynamics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.translation.Linear.0.1 kinematics + reg_udral_physics_kinematics_translation_Linear_0_1 kinematics; + + /// uavcan.si.unit.force.Scalar.1.0 force + uavcan_si_unit_force_Scalar_1_0 force; +} reg_udral_physics_dynamics_translation_Linear_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_dynamics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_translation_Linear_0_1_serialize_( + const reg_udral_physics_dynamics_translation_Linear_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.translation.Linear.0.1 kinematics + size_t _size_bytes0_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_translation_Linear_0_1_serialize_( + &obj->kinematics, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.force.Scalar.1.0 force + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_force_Scalar_1_0_serialize_( + &obj->force, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_dynamics_translation_Linear_0_1_deserialize_( + reg_udral_physics_dynamics_translation_Linear_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.translation.Linear.0.1 kinematics + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_translation_Linear_0_1_deserialize_( + &out_obj->kinematics, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.force.Scalar.1.0 force + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_force_Scalar_1_0_deserialize_( + &out_obj->force, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_dynamics_translation_Linear_0_1_initialize_(reg_udral_physics_dynamics_translation_Linear_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_dynamics_translation_Linear_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_DYNAMICS_TRANSLATION_LINEAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/electricity/PowerTs_0_1.h b/src/nunavut_out/reg/udral/physics/electricity/PowerTs_0_1.h new file mode 100644 index 0000000..16b5664 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/electricity/PowerTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.719862 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.electricity.PowerTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_ELECTRICITY_POWER_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_ELECTRICITY_POWER_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/PowerTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_electricity_PowerTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_electricity_PowerTs_0_1_FULL_NAME_ "reg.udral.physics.electricity.PowerTs" +#define reg_udral_physics_electricity_PowerTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.electricity.PowerTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_electricity_PowerTs_0_1_EXTENT_BYTES_ 15UL +#define reg_udral_physics_electricity_PowerTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 15UL +static_assert(reg_udral_physics_electricity_PowerTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_electricity_PowerTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.electricity.Power.0.1 value + reg_udral_physics_electricity_Power_0_1 value; +} reg_udral_physics_electricity_PowerTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_electricity_PowerTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_PowerTs_0_1_serialize_( + const reg_udral_physics_electricity_PowerTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.electricity.Power.0.1 value + size_t _size_bytes1_ = 8UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_electricity_Power_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_PowerTs_0_1_deserialize_( + reg_udral_physics_electricity_PowerTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.electricity.Power.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_electricity_Power_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_electricity_PowerTs_0_1_initialize_(reg_udral_physics_electricity_PowerTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_electricity_PowerTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_ELECTRICITY_POWER_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/electricity/Power_0_1.h b/src/nunavut_out/reg/udral/physics/electricity/Power_0_1.h new file mode 100644 index 0000000..673748d --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/electricity/Power_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.717861 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.electricity.Power +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_ELECTRICITY_POWER_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_ELECTRICITY_POWER_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Power.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_electricity_Power_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_electricity_Power_0_1_FULL_NAME_ "reg.udral.physics.electricity.Power" +#define reg_udral_physics_electricity_Power_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.electricity.Power.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_electricity_Power_0_1_EXTENT_BYTES_ 8UL +#define reg_udral_physics_electricity_Power_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(reg_udral_physics_electricity_Power_0_1_EXTENT_BYTES_ >= reg_udral_physics_electricity_Power_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.electric_current.Scalar.1.0 current + uavcan_si_unit_electric_current_Scalar_1_0 current; + + /// uavcan.si.unit.voltage.Scalar.1.0 voltage + uavcan_si_unit_voltage_Scalar_1_0 voltage; +} reg_udral_physics_electricity_Power_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_electricity_Power_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_Power_0_1_serialize_( + const reg_udral_physics_electricity_Power_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.electric_current.Scalar.1.0 current + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->current, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.voltage.Scalar.1.0 voltage + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_voltage_Scalar_1_0_serialize_( + &obj->voltage, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_Power_0_1_deserialize_( + reg_udral_physics_electricity_Power_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.electric_current.Scalar.1.0 current + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->current, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.voltage.Scalar.1.0 voltage + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_voltage_Scalar_1_0_deserialize_( + &out_obj->voltage, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_electricity_Power_0_1_initialize_(reg_udral_physics_electricity_Power_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_electricity_Power_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_ELECTRICITY_POWER_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/electricity/SourceTs_0_1.h b/src/nunavut_out/reg/udral/physics/electricity/SourceTs_0_1.h new file mode 100644 index 0000000..80e43fe --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/electricity/SourceTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.724211 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.electricity.SourceTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/SourceTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_electricity_SourceTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_electricity_SourceTs_0_1_FULL_NAME_ "reg.udral.physics.electricity.SourceTs" +#define reg_udral_physics_electricity_SourceTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.electricity.SourceTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_electricity_SourceTs_0_1_EXTENT_BYTES_ 23UL +#define reg_udral_physics_electricity_SourceTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 23UL +static_assert(reg_udral_physics_electricity_SourceTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_electricity_SourceTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.electricity.Source.0.1 value + reg_udral_physics_electricity_Source_0_1 value; +} reg_udral_physics_electricity_SourceTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_electricity_SourceTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_SourceTs_0_1_serialize_( + const reg_udral_physics_electricity_SourceTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.electricity.Source.0.1 value + size_t _size_bytes1_ = 16UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_electricity_Source_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_SourceTs_0_1_deserialize_( + reg_udral_physics_electricity_SourceTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.electricity.Source.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_electricity_Source_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_electricity_SourceTs_0_1_initialize_(reg_udral_physics_electricity_SourceTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_electricity_SourceTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/electricity/Source_0_1.h b/src/nunavut_out/reg/udral/physics/electricity/Source_0_1.h new file mode 100644 index 0000000..00533e7 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/electricity/Source_0_1.h @@ -0,0 +1,324 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.721909 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.electricity.Source +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/electricity/Source.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_electricity_Source_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_electricity_Source_0_1_FULL_NAME_ "reg.udral.physics.electricity.Source" +#define reg_udral_physics_electricity_Source_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.electricity.Source.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_electricity_Source_0_1_EXTENT_BYTES_ 16UL +#define reg_udral_physics_electricity_Source_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 16UL +static_assert(reg_udral_physics_electricity_Source_0_1_EXTENT_BYTES_ >= reg_udral_physics_electricity_Source_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.electricity.Power.0.1 power + reg_udral_physics_electricity_Power_0_1 power; + + /// uavcan.si.unit.energy.Scalar.1.0 energy + uavcan_si_unit_energy_Scalar_1_0 energy; + + /// uavcan.si.unit.energy.Scalar.1.0 full_energy + uavcan_si_unit_energy_Scalar_1_0 full_energy; +} reg_udral_physics_electricity_Source_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_electricity_Source_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_Source_0_1_serialize_( + const reg_udral_physics_electricity_Source_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.electricity.Power.0.1 power + size_t _size_bytes0_ = 8UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_electricity_Power_0_1_serialize_( + &obj->power, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.energy.Scalar.1.0 energy + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_energy_Scalar_1_0_serialize_( + &obj->energy, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.energy.Scalar.1.0 full_energy + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_energy_Scalar_1_0_serialize_( + &obj->full_energy, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_electricity_Source_0_1_deserialize_( + reg_udral_physics_electricity_Source_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.electricity.Power.0.1 power + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = reg_udral_physics_electricity_Power_0_1_deserialize_( + &out_obj->power, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.energy.Scalar.1.0 energy + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_energy_Scalar_1_0_deserialize_( + &out_obj->energy, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.energy.Scalar.1.0 full_energy + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_si_unit_energy_Scalar_1_0_deserialize_( + &out_obj->full_energy, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_electricity_Source_0_1_initialize_(reg_udral_physics_electricity_Source_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_electricity_Source_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_ELECTRICITY_SOURCE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVarTs_0_1.h new file mode 100644 index 0000000..92e371b --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.695749 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PointStateVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PointStateVarTs" +#define reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PointStateVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_EXTENT_BYTES_ 67UL +#define reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 67UL +static_assert(reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.cartesian.PointStateVar.0.1 value + reg_udral_physics_kinematics_cartesian_PointStateVar_0_1 value; +} reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 536UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.PointStateVar.0.1 value + size_t _size_bytes1_ = 60UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.PointStateVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PointStateVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVar_0_1.h new file mode 100644 index 0000000..5ca5d68 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointStateVar_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.693721 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PointStateVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PointStateVar" +#define reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PointStateVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_EXTENT_BYTES_ 60UL +#define reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 60UL +static_assert(reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.PointVar.0.1 position + reg_udral_physics_kinematics_cartesian_PointVar_0_1 position; + + /// reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + reg_udral_physics_kinematics_translation_Velocity3Var_0_2 velocity; +} reg_udral_physics_kinematics_cartesian_PointStateVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PointStateVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 480UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.PointVar.0.1 position + size_t _size_bytes0_ = 36UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_PointVar_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + size_t _size_bytes1_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_translation_Velocity3Var_0_2_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PointStateVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.PointVar.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_cartesian_PointVar_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_translation_Velocity3Var_0_2_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PointStateVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PointStateVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointState_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointState_0_1.h new file mode 100644 index 0000000..1fee0b5 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointState_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.691854 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PointState +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PointState_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PointState_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PointState" +#define reg_udral_physics_kinematics_cartesian_PointState_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PointState.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PointState_0_1_EXTENT_BYTES_ 36UL +#define reg_udral_physics_kinematics_cartesian_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 36UL +static_assert(reg_udral_physics_kinematics_cartesian_PointState_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Point.0.1 position + reg_udral_physics_kinematics_cartesian_Point_0_1 position; + + /// uavcan.si.unit.velocity.Vector3.1.0 velocity + uavcan_si_unit_velocity_Vector3_1_0 velocity; +} reg_udral_physics_kinematics_cartesian_PointState_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointState_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PointState_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 288UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Point.0.1 position + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Point_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.velocity.Vector3.1.0 velocity + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_velocity_Vector3_1_0_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointState_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PointState_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Point.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_cartesian_Point_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.velocity.Vector3.1.0 velocity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PointState_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PointState_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PointState_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_STATE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointVar_0_1.h new file mode 100644 index 0000000..7e69064 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PointVar_0_1.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.697644 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PointVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PointVar" +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PointVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_EXTENT_BYTES_ 36UL +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 36UL +static_assert(reg_udral_physics_kinematics_cartesian_PointVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] covariance_urt +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_covariance_urt_ARRAY_CAPACITY_ 6U +#define reg_udral_physics_kinematics_cartesian_PointVar_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Point.0.1 value + reg_udral_physics_kinematics_cartesian_Point_0_1 value; + + /// saturated float16[6] covariance_urt + float covariance_urt[6]; +} reg_udral_physics_kinematics_cartesian_PointVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointVar_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PointVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 288UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Point.0.1 value + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Point_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[6] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PointVar_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PointVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Point.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_cartesian_Point_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[6] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PointVar_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PointVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PointVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Point_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Point_0_1.h new file mode 100644 index 0000000..5f7b312 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Point_0_1.h @@ -0,0 +1,239 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.690223 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.Point +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_Point_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_Point_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.Point" +#define reg_udral_physics_kinematics_cartesian_Point_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.Point.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_Point_0_1_EXTENT_BYTES_ 24UL +#define reg_udral_physics_kinematics_cartesian_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(reg_udral_physics_kinematics_cartesian_Point_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.length.WideVector3.1.0 value + uavcan_si_unit_length_WideVector3_1_0 value; +} reg_udral_physics_kinematics_cartesian_Point_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Point_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_Point_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.length.WideVector3.1.0 value + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_length_WideVector3_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Point_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_Point_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.length.WideVector3.1.0 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_si_unit_length_WideVector3_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_Point_0_1_initialize_(reg_udral_physics_kinematics_cartesian_Point_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_Point_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POINT_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVarTs_0_1.h new file mode 100644 index 0000000..e68aea4 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.703535 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PoseVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PoseVarTs" +#define reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PoseVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_EXTENT_BYTES_ 89UL +#define reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 89UL +static_assert(reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.cartesian.PoseVar.0.1 value + reg_udral_physics_kinematics_cartesian_PoseVar_0_1 value; +} reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 712UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.PoseVar.0.1 value + size_t _size_bytes1_ = 82UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_PoseVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.PoseVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_PoseVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PoseVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVar_0_1.h new file mode 100644 index 0000000..06a68be --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/PoseVar_0_1.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.701523 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.PoseVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.PoseVar" +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.PoseVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_EXTENT_BYTES_ 82UL +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 82UL +static_assert(reg_udral_physics_kinematics_cartesian_PoseVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[21] covariance_urt +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_covariance_urt_ARRAY_CAPACITY_ 21U +#define reg_udral_physics_kinematics_cartesian_PoseVar_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Pose.0.1 value + reg_udral_physics_kinematics_cartesian_Pose_0_1 value; + + /// saturated float16[21] covariance_urt + float covariance_urt[21]; +} reg_udral_physics_kinematics_cartesian_PoseVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PoseVar_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_PoseVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 656UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Pose.0.1 value + size_t _size_bytes0_ = 40UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Pose_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[21] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 21UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_PoseVar_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_PoseVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Pose.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_cartesian_Pose_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[21] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 21UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_PoseVar_0_1_initialize_(reg_udral_physics_kinematics_cartesian_PoseVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_PoseVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Pose_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Pose_0_1.h new file mode 100644 index 0000000..0bad8b0 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Pose_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.699627 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.Pose +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_Pose_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_Pose_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.Pose" +#define reg_udral_physics_kinematics_cartesian_Pose_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.Pose.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_Pose_0_1_EXTENT_BYTES_ 40UL +#define reg_udral_physics_kinematics_cartesian_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 40UL +static_assert(reg_udral_physics_kinematics_cartesian_Pose_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Point.0.1 position + reg_udral_physics_kinematics_cartesian_Point_0_1 position; + + /// uavcan.si.unit.angle.Quaternion.1.0 orientation + uavcan_si_unit_angle_Quaternion_1_0 orientation; +} reg_udral_physics_kinematics_cartesian_Pose_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Pose_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_Pose_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 320UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Point.0.1 position + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Point_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.angle.Quaternion.1.0 orientation + size_t _size_bytes1_ = 16UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_angle_Quaternion_1_0_serialize_( + &obj->orientation, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Pose_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_Pose_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Point.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_cartesian_Point_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angle.Quaternion.1.0 orientation + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_angle_Quaternion_1_0_deserialize_( + &out_obj->orientation, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_Pose_0_1_initialize_(reg_udral_physics_kinematics_cartesian_Pose_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_Pose_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_POSE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVarTs_0_1.h new file mode 100644 index 0000000..0ca2d3c --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.709325 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.StateVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.StateVarTs" +#define reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.StateVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_EXTENT_BYTES_ 155UL +#define reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 155UL +static_assert(reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.cartesian.StateVar.0.1 value + reg_udral_physics_kinematics_cartesian_StateVar_0_1 value; +} reg_udral_physics_kinematics_cartesian_StateVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_StateVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1240UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.StateVar.0.1 value + size_t _size_bytes1_ = 148UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_StateVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_StateVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.StateVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_StateVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_initialize_(reg_udral_physics_kinematics_cartesian_StateVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_StateVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVar_0_1.h new file mode 100644 index 0000000..3f023c8 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/StateVar_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.707416 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.StateVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_StateVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_StateVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.StateVar" +#define reg_udral_physics_kinematics_cartesian_StateVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.StateVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_StateVar_0_1_EXTENT_BYTES_ 148UL +#define reg_udral_physics_kinematics_cartesian_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 148UL +static_assert(reg_udral_physics_kinematics_cartesian_StateVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.PoseVar.0.1 pose + reg_udral_physics_kinematics_cartesian_PoseVar_0_1 pose; + + /// reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + reg_udral_physics_kinematics_cartesian_TwistVar_0_1 twist; +} reg_udral_physics_kinematics_cartesian_StateVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_StateVar_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_StateVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.PoseVar.0.1 pose + size_t _size_bytes0_ = 82UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_PoseVar_0_1_serialize_( + &obj->pose, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + size_t _size_bytes1_ = 66UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_serialize_( + &obj->twist, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_StateVar_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_StateVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.PoseVar.0.1 pose + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_cartesian_PoseVar_0_1_deserialize_( + &out_obj->pose, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_deserialize_( + &out_obj->twist, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_StateVar_0_1_initialize_(reg_udral_physics_kinematics_cartesian_StateVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_StateVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/State_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/State_0_1.h new file mode 100644 index 0000000..5080572 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/State_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.705490 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.State +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_State_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_State_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.State" +#define reg_udral_physics_kinematics_cartesian_State_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.State.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_State_0_1_EXTENT_BYTES_ 64UL +#define reg_udral_physics_kinematics_cartesian_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 64UL +static_assert(reg_udral_physics_kinematics_cartesian_State_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Pose.0.1 pose + reg_udral_physics_kinematics_cartesian_Pose_0_1 pose; + + /// reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + reg_udral_physics_kinematics_cartesian_Twist_0_1 twist; +} reg_udral_physics_kinematics_cartesian_State_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_State_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_State_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 512UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Pose.0.1 pose + size_t _size_bytes0_ = 40UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Pose_0_1_serialize_( + &obj->pose, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + size_t _size_bytes1_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_serialize_( + &obj->twist, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_State_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_State_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Pose.0.1 pose + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_cartesian_Pose_0_1_deserialize_( + &out_obj->pose, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_deserialize_( + &out_obj->twist, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_State_0_1_initialize_(reg_udral_physics_kinematics_cartesian_State_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_State_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_STATE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVarTs_0_1.h new file mode 100644 index 0000000..af6eb47 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.715625 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.TwistVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.TwistVarTs" +#define reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.TwistVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_EXTENT_BYTES_ 73UL +#define reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 73UL +static_assert(reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.cartesian.TwistVar.0.1 value + reg_udral_physics_kinematics_cartesian_TwistVar_0_1 value; +} reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 584UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 value + size_t _size_bytes1_ = 66UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_initialize_(reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_TwistVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVar_0_1.h new file mode 100644 index 0000000..76a31fb --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/TwistVar_0_1.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.713145 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.TwistVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/TwistVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.TwistVar" +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.TwistVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_EXTENT_BYTES_ 66UL +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 66UL +static_assert(reg_udral_physics_kinematics_cartesian_TwistVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_TwistVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[21] covariance_urt +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_covariance_urt_ARRAY_CAPACITY_ 21U +#define reg_udral_physics_kinematics_cartesian_TwistVar_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// reg.udral.physics.kinematics.cartesian.Twist.0.1 value + reg_udral_physics_kinematics_cartesian_Twist_0_1 value; + + /// saturated float16[21] covariance_urt + float covariance_urt[21]; +} reg_udral_physics_kinematics_cartesian_TwistVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_TwistVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_TwistVar_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_TwistVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 528UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.cartesian.Twist.0.1 value + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[21] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 21UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_TwistVar_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_TwistVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.cartesian.Twist.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[21] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 21UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_TwistVar_0_1_initialize_(reg_udral_physics_kinematics_cartesian_TwistVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Twist_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Twist_0_1.h new file mode 100644 index 0000000..6d9635c --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/cartesian/Twist_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.711247 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.cartesian.Twist +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/cartesian/Twist.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_cartesian_Twist_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_cartesian_Twist_0_1_FULL_NAME_ "reg.udral.physics.kinematics.cartesian.Twist" +#define reg_udral_physics_kinematics_cartesian_Twist_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.cartesian.Twist.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_cartesian_Twist_0_1_EXTENT_BYTES_ 24UL +#define reg_udral_physics_kinematics_cartesian_Twist_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(reg_udral_physics_kinematics_cartesian_Twist_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_cartesian_Twist_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.velocity.Vector3.1.0 linear + uavcan_si_unit_velocity_Vector3_1_0 linear; + + /// uavcan.si.unit.angular_velocity.Vector3.1.0 angular + uavcan_si_unit_angular_velocity_Vector3_1_0 angular; +} reg_udral_physics_kinematics_cartesian_Twist_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_cartesian_Twist_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Twist_0_1_serialize_( + const reg_udral_physics_kinematics_cartesian_Twist_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.velocity.Vector3.1.0 linear + size_t _size_bytes0_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_velocity_Vector3_1_0_serialize_( + &obj->linear, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.angular_velocity.Vector3.1.0 angular + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_angular_velocity_Vector3_1_0_serialize_( + &obj->angular, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_cartesian_Twist_0_1_deserialize_( + reg_udral_physics_kinematics_cartesian_Twist_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.velocity.Vector3.1.0 linear + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + &out_obj->linear, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angular_velocity.Vector3.1.0 angular + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_angular_velocity_Vector3_1_0_deserialize_( + &out_obj->angular, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_cartesian_Twist_0_1_initialize_(reg_udral_physics_kinematics_cartesian_Twist_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_cartesian_Twist_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_CARTESIAN_TWIST_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVarTs_0_1.h new file mode 100644 index 0000000..ecb8084 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.671900 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.PointStateVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.PointStateVarTs" +#define reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.PointStateVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_EXTENT_BYTES_ 67UL +#define reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 67UL +static_assert(reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.geodetic.PointStateVar.0.1 value + reg_udral_physics_kinematics_geodetic_PointStateVar_0_1 value; +} reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 536UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.geodetic.PointStateVar.0.1 value + size_t _size_bytes1_ = 60UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.geodetic.PointStateVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_initialize_(reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_PointStateVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVar_0_1.h new file mode 100644 index 0000000..16a8de1 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointStateVar_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.669959 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.PointStateVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointStateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.PointStateVar" +#define reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.PointStateVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_EXTENT_BYTES_ 60UL +#define reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 60UL +static_assert(reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.PointVar.0.1 position + reg_udral_physics_kinematics_geodetic_PointVar_0_1 position; + + /// reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + reg_udral_physics_kinematics_translation_Velocity3Var_0_2 velocity; +} reg_udral_physics_kinematics_geodetic_PointStateVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_PointStateVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 480UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.PointVar.0.1 position + size_t _size_bytes0_ = 36UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_PointVar_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + size_t _size_bytes1_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_translation_Velocity3Var_0_2_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_PointStateVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.PointVar.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_geodetic_PointVar_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.translation.Velocity3Var.0.2 velocity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_translation_Velocity3Var_0_2_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_initialize_(reg_udral_physics_kinematics_geodetic_PointStateVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_PointStateVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointState_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointState_0_1.h new file mode 100644 index 0000000..00c8aaa --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointState_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.668106 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.PointState +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointState.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_PointState_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_PointState_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.PointState" +#define reg_udral_physics_kinematics_geodetic_PointState_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.PointState.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_PointState_0_1_EXTENT_BYTES_ 36UL +#define reg_udral_physics_kinematics_geodetic_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 36UL +static_assert(reg_udral_physics_kinematics_geodetic_PointState_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.Point.0.1 position + reg_udral_physics_kinematics_geodetic_Point_0_1 position; + + /// uavcan.si.unit.velocity.Vector3.1.0 velocity + uavcan_si_unit_velocity_Vector3_1_0 velocity; +} reg_udral_physics_kinematics_geodetic_PointState_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_PointState_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointState_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_PointState_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 288UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.Point.0.1 position + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_Point_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.velocity.Vector3.1.0 velocity + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_velocity_Vector3_1_0_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointState_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_PointState_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.Point.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_geodetic_Point_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.velocity.Vector3.1.0 velocity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_PointState_0_1_initialize_(reg_udral_physics_kinematics_geodetic_PointState_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_PointState_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_STATE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointVar_0_1.h new file mode 100644 index 0000000..380eeaf --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PointVar_0_1.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.673867 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.PointVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PointVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.PointVar" +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.PointVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_EXTENT_BYTES_ 36UL +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 36UL +static_assert(reg_udral_physics_kinematics_geodetic_PointVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] covariance_urt +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_covariance_urt_ARRAY_CAPACITY_ 6U +#define reg_udral_physics_kinematics_geodetic_PointVar_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.Point.0.1 value + reg_udral_physics_kinematics_geodetic_Point_0_1 value; + + /// saturated float16[6] covariance_urt + float covariance_urt[6]; +} reg_udral_physics_kinematics_geodetic_PointVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_PointVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointVar_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_PointVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 288UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.Point.0.1 value + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_Point_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[6] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PointVar_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_PointVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.Point.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_geodetic_Point_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[6] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_PointVar_0_1_initialize_(reg_udral_physics_kinematics_geodetic_PointVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_PointVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Point_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Point_0_1.h new file mode 100644 index 0000000..7244e6f --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Point_0_1.h @@ -0,0 +1,290 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.666026 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.Point +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Point.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_Point_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_Point_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.Point" +#define reg_udral_physics_kinematics_geodetic_Point_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.Point.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_Point_0_1_EXTENT_BYTES_ 24UL +#define reg_udral_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(reg_udral_physics_kinematics_geodetic_Point_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float64 latitude + double latitude; + + /// saturated float64 longitude + double longitude; + + /// uavcan.si.unit.length.WideScalar.1.0 altitude + uavcan_si_unit_length_WideScalar_1_0 altitude; +} reg_udral_physics_kinematics_geodetic_Point_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_Point_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_Point_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_Point_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64 latitude + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->latitude, 8U); + offset_bits += 64U; + } + + + + + { // saturated float64 longitude + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->longitude, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.length.WideScalar.1.0 altitude + size_t _size_bytes0_ = 8UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_si_unit_length_WideScalar_1_0_serialize_( + &obj->altitude, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_Point_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_Point_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64 latitude + out_obj->latitude = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + + + // saturated float64 longitude + out_obj->longitude = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.length.WideScalar.1.0 altitude + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_si_unit_length_WideScalar_1_0_deserialize_( + &out_obj->altitude, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_Point_0_1_initialize_(reg_udral_physics_kinematics_geodetic_Point_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_Point_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POINT_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PoseVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PoseVar_0_1.h new file mode 100644 index 0000000..4be409e --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/PoseVar_0_1.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.677744 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.PoseVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/PoseVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.PoseVar" +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.PoseVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_EXTENT_BYTES_ 82UL +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 82UL +static_assert(reg_udral_physics_kinematics_geodetic_PoseVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[21] covariance_urt +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_covariance_urt_ARRAY_CAPACITY_ 21U +#define reg_udral_physics_kinematics_geodetic_PoseVar_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.Pose.0.1 value + reg_udral_physics_kinematics_geodetic_Pose_0_1 value; + + /// saturated float16[21] covariance_urt + float covariance_urt[21]; +} reg_udral_physics_kinematics_geodetic_PoseVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_PoseVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PoseVar_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_PoseVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 656UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.Pose.0.1 value + size_t _size_bytes0_ = 40UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_Pose_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[21] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 21UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_PoseVar_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_PoseVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.Pose.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_geodetic_Pose_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[21] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 21UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_PoseVar_0_1_initialize_(reg_udral_physics_kinematics_geodetic_PoseVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_PoseVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Pose_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Pose_0_1.h new file mode 100644 index 0000000..9d5dba4 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/Pose_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.675788 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.Pose +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/Pose.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_Pose_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_Pose_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.Pose" +#define reg_udral_physics_kinematics_geodetic_Pose_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.Pose.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_Pose_0_1_EXTENT_BYTES_ 40UL +#define reg_udral_physics_kinematics_geodetic_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 40UL +static_assert(reg_udral_physics_kinematics_geodetic_Pose_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.Point.0.1 position + reg_udral_physics_kinematics_geodetic_Point_0_1 position; + + /// uavcan.si.unit.angle.Quaternion.1.0 orientation + uavcan_si_unit_angle_Quaternion_1_0 orientation; +} reg_udral_physics_kinematics_geodetic_Pose_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_Pose_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_Pose_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_Pose_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 320UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.Point.0.1 position + size_t _size_bytes0_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_Point_0_1_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.angle.Quaternion.1.0 orientation + size_t _size_bytes1_ = 16UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_angle_Quaternion_1_0_serialize_( + &obj->orientation, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_Pose_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_Pose_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.Point.0.1 position + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_geodetic_Point_0_1_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angle.Quaternion.1.0 orientation + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_angle_Quaternion_1_0_deserialize_( + &out_obj->orientation, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_Pose_0_1_initialize_(reg_udral_physics_kinematics_geodetic_Pose_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_Pose_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_POSE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVarTs_0_1.h new file mode 100644 index 0000000..fb09c5d --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.683674 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.StateVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.StateVarTs" +#define reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.StateVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_EXTENT_BYTES_ 155UL +#define reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 155UL +static_assert(reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.geodetic.StateVar.0.1 value + reg_udral_physics_kinematics_geodetic_StateVar_0_1 value; +} reg_udral_physics_kinematics_geodetic_StateVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_StateVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1240UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.geodetic.StateVar.0.1 value + size_t _size_bytes1_ = 148UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_geodetic_StateVar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_StateVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.geodetic.StateVar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_geodetic_StateVar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_initialize_(reg_udral_physics_kinematics_geodetic_StateVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_StateVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVar_0_1.h new file mode 100644 index 0000000..c515c04 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/StateVar_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.681701 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.StateVar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/StateVar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_StateVar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_StateVar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.StateVar" +#define reg_udral_physics_kinematics_geodetic_StateVar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.StateVar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_StateVar_0_1_EXTENT_BYTES_ 148UL +#define reg_udral_physics_kinematics_geodetic_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 148UL +static_assert(reg_udral_physics_kinematics_geodetic_StateVar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.PoseVar.0.1 pose + reg_udral_physics_kinematics_geodetic_PoseVar_0_1 pose; + + /// reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + reg_udral_physics_kinematics_cartesian_TwistVar_0_1 twist; +} reg_udral_physics_kinematics_geodetic_StateVar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_StateVar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_StateVar_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_StateVar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.PoseVar.0.1 pose + size_t _size_bytes0_ = 82UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_PoseVar_0_1_serialize_( + &obj->pose, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + size_t _size_bytes1_ = 66UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_serialize_( + &obj->twist, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_StateVar_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_StateVar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.PoseVar.0.1 pose + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_geodetic_PoseVar_0_1_deserialize_( + &out_obj->pose, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.TwistVar.0.1 twist + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_TwistVar_0_1_deserialize_( + &out_obj->twist, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_StateVar_0_1_initialize_(reg_udral_physics_kinematics_geodetic_StateVar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_StateVar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/geodetic/State_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/State_0_1.h new file mode 100644 index 0000000..7483df0 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/geodetic/State_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.679719 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.geodetic.State +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/geodetic/State.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_geodetic_State_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_geodetic_State_0_1_FULL_NAME_ "reg.udral.physics.kinematics.geodetic.State" +#define reg_udral_physics_kinematics_geodetic_State_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.geodetic.State.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_geodetic_State_0_1_EXTENT_BYTES_ 64UL +#define reg_udral_physics_kinematics_geodetic_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 64UL +static_assert(reg_udral_physics_kinematics_geodetic_State_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_geodetic_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.geodetic.Pose.0.1 pose + reg_udral_physics_kinematics_geodetic_Pose_0_1 pose; + + /// reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + reg_udral_physics_kinematics_cartesian_Twist_0_1 twist; +} reg_udral_physics_kinematics_geodetic_State_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_geodetic_State_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_State_0_1_serialize_( + const reg_udral_physics_kinematics_geodetic_State_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 512UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.geodetic.Pose.0.1 pose + size_t _size_bytes0_ = 40UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_geodetic_Pose_0_1_serialize_( + &obj->pose, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + size_t _size_bytes1_ = 24UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_serialize_( + &obj->twist, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_geodetic_State_0_1_deserialize_( + reg_udral_physics_kinematics_geodetic_State_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.geodetic.Pose.0.1 pose + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_physics_kinematics_geodetic_Pose_0_1_deserialize_( + &out_obj->pose, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.cartesian.Twist.0.1 twist + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_cartesian_Twist_0_1_deserialize_( + &out_obj->twist, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_geodetic_State_0_1_initialize_(reg_udral_physics_kinematics_geodetic_State_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_geodetic_State_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_GEODETIC_STATE_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/rotation/PlanarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/rotation/PlanarTs_0_1.h new file mode 100644 index 0000000..f4010cb --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/rotation/PlanarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.688234 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.rotation.PlanarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/PlanarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_rotation_PlanarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_rotation_PlanarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.rotation.PlanarTs" +#define reg_udral_physics_kinematics_rotation_PlanarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.rotation.PlanarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_rotation_PlanarTs_0_1_EXTENT_BYTES_ 19UL +#define reg_udral_physics_kinematics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(reg_udral_physics_kinematics_rotation_PlanarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.rotation.Planar.0.1 value + reg_udral_physics_kinematics_rotation_Planar_0_1 value; +} reg_udral_physics_kinematics_rotation_PlanarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_rotation_PlanarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_rotation_PlanarTs_0_1_serialize_( + const reg_udral_physics_kinematics_rotation_PlanarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.rotation.Planar.0.1 value + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_rotation_Planar_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_rotation_PlanarTs_0_1_deserialize_( + reg_udral_physics_kinematics_rotation_PlanarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.rotation.Planar.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_rotation_Planar_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_rotation_PlanarTs_0_1_initialize_(reg_udral_physics_kinematics_rotation_PlanarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_rotation_PlanarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/rotation/Planar_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/rotation/Planar_0_1.h new file mode 100644 index 0000000..265a73c --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/rotation/Planar_0_1.h @@ -0,0 +1,325 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.685683 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.rotation.Planar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/rotation/Planar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_rotation_Planar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_rotation_Planar_0_1_FULL_NAME_ "reg.udral.physics.kinematics.rotation.Planar" +#define reg_udral_physics_kinematics_rotation_Planar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.rotation.Planar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_rotation_Planar_0_1_EXTENT_BYTES_ 12UL +#define reg_udral_physics_kinematics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_physics_kinematics_rotation_Planar_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.angle.Scalar.1.0 angular_position + uavcan_si_unit_angle_Scalar_1_0 angular_position; + + /// uavcan.si.unit.angular_velocity.Scalar.1.0 angular_velocity + uavcan_si_unit_angular_velocity_Scalar_1_0 angular_velocity; + + /// uavcan.si.unit.angular_acceleration.Scalar.1.0 angular_acceleration + uavcan_si_unit_angular_acceleration_Scalar_1_0 angular_acceleration; +} reg_udral_physics_kinematics_rotation_Planar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_rotation_Planar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_rotation_Planar_0_1_serialize_( + const reg_udral_physics_kinematics_rotation_Planar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.angle.Scalar.1.0 angular_position + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_angle_Scalar_1_0_serialize_( + &obj->angular_position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.angular_velocity.Scalar.1.0 angular_velocity + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_angular_velocity_Scalar_1_0_serialize_( + &obj->angular_velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.angular_acceleration.Scalar.1.0 angular_acceleration + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_angular_acceleration_Scalar_1_0_serialize_( + &obj->angular_acceleration, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_rotation_Planar_0_1_deserialize_( + reg_udral_physics_kinematics_rotation_Planar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.angle.Scalar.1.0 angular_position + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_si_unit_angle_Scalar_1_0_deserialize_( + &out_obj->angular_position, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angular_velocity.Scalar.1.0 angular_velocity + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_angular_velocity_Scalar_1_0_deserialize_( + &out_obj->angular_velocity, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.angular_acceleration.Scalar.1.0 angular_acceleration + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_si_unit_angular_acceleration_Scalar_1_0_deserialize_( + &out_obj->angular_acceleration, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_rotation_Planar_0_1_initialize_(reg_udral_physics_kinematics_rotation_Planar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_rotation_Planar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_ROTATION_PLANAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearTs_0_1.h new file mode 100644 index 0000000..dba8560 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.655607 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.LinearTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_LinearTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_LinearTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.translation.LinearTs" +#define reg_udral_physics_kinematics_translation_LinearTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.LinearTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_LinearTs_0_1_EXTENT_BYTES_ 19UL +#define reg_udral_physics_kinematics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(reg_udral_physics_kinematics_translation_LinearTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.kinematics.translation.Linear.0.1 value + reg_udral_physics_kinematics_translation_Linear_0_1 value; +} reg_udral_physics_kinematics_translation_LinearTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_LinearTs_0_1_serialize_( + const reg_udral_physics_kinematics_translation_LinearTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.kinematics.translation.Linear.0.1 value + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_kinematics_translation_Linear_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_LinearTs_0_1_deserialize_( + reg_udral_physics_kinematics_translation_LinearTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.kinematics.translation.Linear.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_kinematics_translation_Linear_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_LinearTs_0_1_initialize_(reg_udral_physics_kinematics_translation_LinearTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_LinearTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearVarTs_0_1.h new file mode 100644 index 0000000..ad46d9c --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/LinearVarTs_0_1.h @@ -0,0 +1,332 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.657591 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.LinearVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/LinearVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_LinearVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_LinearVarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.translation.LinearVarTs" +#define reg_udral_physics_kinematics_translation_LinearVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.LinearVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_LinearVarTs_0_1_EXTENT_BYTES_ 25UL +#define reg_udral_physics_kinematics_translation_LinearVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 25UL +static_assert(reg_udral_physics_kinematics_translation_LinearVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_LinearVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.kinematics.translation.LinearTs.0.1 value + reg_udral_physics_kinematics_translation_LinearTs_0_1 value; + + /// saturated float16 position_error_variance + float position_error_variance; + + /// saturated float16 velocity_error_variance + float velocity_error_variance; + + /// saturated float16 acceleration_error_variance + float acceleration_error_variance; +} reg_udral_physics_kinematics_translation_LinearVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_LinearVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_LinearVarTs_0_1_serialize_( + const reg_udral_physics_kinematics_translation_LinearVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 200UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.kinematics.translation.LinearTs.0.1 value + size_t _size_bytes0_ = 19UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_kinematics_translation_LinearTs_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16 position_error_variance + float _sat0_ = obj->position_error_variance; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + + + + + { // saturated float16 velocity_error_variance + float _sat1_ = obj->velocity_error_variance; + if (isfinite(_sat1_)) + { + if (_sat1_ < ((float) -65504.0)) + { + _sat1_ = ((float) -65504.0); + } + if (_sat1_ > ((float) 65504.0)) + { + _sat1_ = ((float) 65504.0); + } + } + const uint16_t _half1_ = nunavutFloat16Pack(_sat1_); + (void) memmove(&buffer[offset_bits / 8U], &_half1_, 2U); + offset_bits += 16U; + } + + + + + { // saturated float16 acceleration_error_variance + float _sat2_ = obj->acceleration_error_variance; + if (isfinite(_sat2_)) + { + if (_sat2_ < ((float) -65504.0)) + { + _sat2_ = ((float) -65504.0); + } + if (_sat2_ > ((float) 65504.0)) + { + _sat2_ = ((float) 65504.0); + } + } + const uint16_t _half2_ = nunavutFloat16Pack(_sat2_); + (void) memmove(&buffer[offset_bits / 8U], &_half2_, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_LinearVarTs_0_1_deserialize_( + reg_udral_physics_kinematics_translation_LinearVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.kinematics.translation.LinearTs.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_kinematics_translation_LinearTs_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16 position_error_variance + out_obj->position_error_variance = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated float16 velocity_error_variance + out_obj->velocity_error_variance = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + + + // saturated float16 acceleration_error_variance + out_obj->acceleration_error_variance = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_LinearVarTs_0_1_initialize_(reg_udral_physics_kinematics_translation_LinearVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_LinearVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/Linear_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/Linear_0_1.h new file mode 100644 index 0000000..10f1fc8 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/Linear_0_1.h @@ -0,0 +1,325 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.653108 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.Linear +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Linear.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_Linear_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_Linear_0_1_FULL_NAME_ "reg.udral.physics.kinematics.translation.Linear" +#define reg_udral_physics_kinematics_translation_Linear_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.Linear.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_Linear_0_1_EXTENT_BYTES_ 12UL +#define reg_udral_physics_kinematics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_physics_kinematics_translation_Linear_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.length.Scalar.1.0 position + uavcan_si_unit_length_Scalar_1_0 position; + + /// uavcan.si.unit.velocity.Scalar.1.0 velocity + uavcan_si_unit_velocity_Scalar_1_0 velocity; + + /// uavcan.si.unit.acceleration.Scalar.1.0 acceleration + uavcan_si_unit_acceleration_Scalar_1_0 acceleration; +} reg_udral_physics_kinematics_translation_Linear_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_Linear_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Linear_0_1_serialize_( + const reg_udral_physics_kinematics_translation_Linear_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.length.Scalar.1.0 position + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_length_Scalar_1_0_serialize_( + &obj->position, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.velocity.Scalar.1.0 velocity + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_velocity_Scalar_1_0_serialize_( + &obj->velocity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.acceleration.Scalar.1.0 acceleration + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_acceleration_Scalar_1_0_serialize_( + &obj->acceleration, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Linear_0_1_deserialize_( + reg_udral_physics_kinematics_translation_Linear_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.length.Scalar.1.0 position + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_si_unit_length_Scalar_1_0_deserialize_( + &out_obj->position, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.velocity.Scalar.1.0 velocity + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_velocity_Scalar_1_0_deserialize_( + &out_obj->velocity, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.acceleration.Scalar.1.0 acceleration + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_si_unit_acceleration_Scalar_1_0_deserialize_( + &out_obj->acceleration, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_Linear_0_1_initialize_(reg_udral_physics_kinematics_translation_Linear_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_Linear_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_LINEAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity1VarTs_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity1VarTs_0_1.h new file mode 100644 index 0000000..31c47c5 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity1VarTs_0_1.h @@ -0,0 +1,270 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.659952 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.Velocity1VarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY1VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY1VAR_TS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity1VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_FULL_NAME_ "reg.udral.physics.kinematics.translation.Velocity1VarTs" +#define reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.Velocity1VarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_EXTENT_BYTES_ 13UL +#define reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 13UL +static_assert(reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.sample.velocity.Scalar.1.0 value + uavcan_si_sample_velocity_Scalar_1_0 value; + + /// saturated float16 error_variance + float error_variance; +} reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_serialize_( + const reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 104UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.sample.velocity.Scalar.1.0 value + size_t _size_bytes0_ = 11UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_sample_velocity_Scalar_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16 error_variance + float _sat0_ = obj->error_variance; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_deserialize_( + reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.sample.velocity.Scalar.1.0 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_si_sample_velocity_Scalar_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16 error_variance + out_obj->error_variance = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_initialize_(reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_Velocity1VarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY1VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_1.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_1.h new file mode 100644 index 0000000..0cf453a --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_1.h @@ -0,0 +1,293 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.664021 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.Velocity3Var +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_FULL_NAME_ "reg.udral.physics.kinematics.translation.Velocity3Var" +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.Velocity3Var.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_EXTENT_BYTES_ 31UL +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 31UL +static_assert(reg_udral_physics_kinematics_translation_Velocity3Var_0_1_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_Velocity3Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] covariance_urt +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_covariance_urt_ARRAY_CAPACITY_ 6U +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.si.sample.velocity.Vector3.1.0 value + uavcan_si_sample_velocity_Vector3_1_0 value; + + /// saturated float16[6] covariance_urt + float covariance_urt[6]; +} reg_udral_physics_kinematics_translation_Velocity3Var_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_Velocity3Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity3Var_0_1_serialize_( + const reg_udral_physics_kinematics_translation_Velocity3Var_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 248UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.sample.velocity.Vector3.1.0 value + size_t _size_bytes0_ = 19UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_sample_velocity_Vector3_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[6] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity3Var_0_1_deserialize_( + reg_udral_physics_kinematics_translation_Velocity3Var_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.sample.velocity.Vector3.1.0 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_si_sample_velocity_Vector3_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[6] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_Velocity3Var_0_1_initialize_(reg_udral_physics_kinematics_translation_Velocity3Var_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_Velocity3Var_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_2.h b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_2.h new file mode 100644 index 0000000..f47918e --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/kinematics/translation/Velocity3Var_0_2.h @@ -0,0 +1,284 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl +// Generated at: 2024-11-23 10:35:27.661950 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.kinematics.translation.Velocity3Var +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_2_INCLUDED_ +#define REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_2_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/kinematics/translation/Velocity3Var.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_FULL_NAME_ "reg.udral.physics.kinematics.translation.Velocity3Var" +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_FULL_NAME_AND_VERSION_ "reg.udral.physics.kinematics.translation.Velocity3Var.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_EXTENT_BYTES_ 24UL +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(reg_udral_physics_kinematics_translation_Velocity3Var_0_2_EXTENT_BYTES_ >= reg_udral_physics_kinematics_translation_Velocity3Var_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] covariance_urt +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_covariance_urt_ARRAY_CAPACITY_ 6U +#define reg_udral_physics_kinematics_translation_Velocity3Var_0_2_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.si.unit.velocity.Vector3.1.0 value + uavcan_si_unit_velocity_Vector3_1_0 value; + + /// saturated float16[6] covariance_urt + float covariance_urt[6]; +} reg_udral_physics_kinematics_translation_Velocity3Var_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_kinematics_translation_Velocity3Var_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity3Var_0_2_serialize_( + const reg_udral_physics_kinematics_translation_Velocity3Var_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.velocity.Vector3.1.0 value + size_t _size_bytes0_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_velocity_Vector3_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[6] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_kinematics_translation_Velocity3Var_0_2_deserialize_( + reg_udral_physics_kinematics_translation_Velocity3Var_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.velocity.Vector3.1.0 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[6] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_kinematics_translation_Velocity3Var_0_2_initialize_(reg_udral_physics_kinematics_translation_Velocity3Var_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_kinematics_translation_Velocity3Var_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_KINEMATICS_TRANSLATION_VELOCITY3VAR_0_2_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/optics/HighColor_0_1.h b/src/nunavut_out/reg/udral/physics/optics/HighColor_0_1.h new file mode 100644 index 0000000..a8544a3 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/optics/HighColor_0_1.h @@ -0,0 +1,297 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.728946 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.optics.HighColor +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_OPTICS_HIGH_COLOR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_OPTICS_HIGH_COLOR_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/optics/HighColor.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_optics_HighColor_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_optics_HighColor_0_1_FULL_NAME_ "reg.udral.physics.optics.HighColor" +#define reg_udral_physics_optics_HighColor_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.optics.HighColor.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_optics_HighColor_0_1_EXTENT_BYTES_ 2UL +#define reg_udral_physics_optics_HighColor_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(reg_udral_physics_optics_HighColor_0_1_EXTENT_BYTES_ >= reg_udral_physics_optics_HighColor_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint5 MAX_RED = 31 +#define reg_udral_physics_optics_HighColor_0_1_MAX_RED (31U) +/// saturated uint6 MAX_GREEN = 63 +#define reg_udral_physics_optics_HighColor_0_1_MAX_GREEN (63U) +/// saturated uint5 MAX_BLUE = 31 +#define reg_udral_physics_optics_HighColor_0_1_MAX_BLUE (31U) + +typedef struct +{ + /// saturated uint5 red + uint8_t red; + + /// saturated uint6 green + uint8_t green; + + /// saturated uint5 blue + uint8_t blue; +} reg_udral_physics_optics_HighColor_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_optics_HighColor_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_optics_HighColor_0_1_serialize_( + const reg_udral_physics_optics_HighColor_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint5 red + uint8_t _sat0_ = obj->red; + if (_sat0_ > 31U) + { + _sat0_ = 31U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 5U; + } + + + + + { // saturated uint6 green + uint8_t _sat1_ = obj->green; + if (_sat1_ > 63U) + { + _sat1_ = 63U; + } + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, _sat1_, 6U); + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 6U; + } + + + + + { // saturated uint5 blue + uint8_t _sat2_ = obj->blue; + if (_sat2_ > 31U) + { + _sat2_ = 31U; + } + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, _sat2_, 5U); + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += 5U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_optics_HighColor_0_1_deserialize_( + reg_udral_physics_optics_HighColor_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint5 red + if ((offset_bits + 5U) <= capacity_bits) + { + out_obj->red = buffer[offset_bits / 8U] & 31U; + } + else + { + out_obj->red = 0U; + } + offset_bits += 5U; + + + + + // saturated uint6 green + out_obj->green = nunavutGetU8(&buffer[0], capacity_bytes, offset_bits, 6); + offset_bits += 6U; + + + + + // saturated uint5 blue + out_obj->blue = nunavutGetU8(&buffer[0], capacity_bytes, offset_bits, 5); + offset_bits += 5U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_optics_HighColor_0_1_initialize_(reg_udral_physics_optics_HighColor_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_optics_HighColor_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_OPTICS_HIGH_COLOR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/thermodynamics/PressureTempVarTs_0_1.h b/src/nunavut_out/reg/udral/physics/thermodynamics/PressureTempVarTs_0_1.h new file mode 100644 index 0000000..f9cdacb --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/thermodynamics/PressureTempVarTs_0_1.h @@ -0,0 +1,370 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.726181 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.thermodynamics.PressureTempVarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_THERMODYNAMICS_PRESSURE_TEMP_VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_THERMODYNAMICS_PRESSURE_TEMP_VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/thermodynamics/PressureTempVarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_FULL_NAME_ "reg.udral.physics.thermodynamics.PressureTempVarTs" +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.thermodynamics.PressureTempVarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_EXTENT_BYTES_ 21UL +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 21UL +static_assert(reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[3] covariance_urt +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_covariance_urt_ARRAY_CAPACITY_ 3U +#define reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_covariance_urt_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// uavcan.si.unit.pressure.Scalar.1.0 pressure + uavcan_si_unit_pressure_Scalar_1_0 pressure; + + /// uavcan.si.unit.temperature.Scalar.1.0 temperature + uavcan_si_unit_temperature_Scalar_1_0 temperature; + + /// saturated float16[3] covariance_urt + float covariance_urt[3]; +} reg_udral_physics_thermodynamics_PressureTempVarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_serialize_( + const reg_udral_physics_thermodynamics_PressureTempVarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 168UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.pressure.Scalar.1.0 pressure + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_pressure_Scalar_1_0_serialize_( + &obj->pressure, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.temperature.Scalar.1.0 temperature + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_temperature_Scalar_1_0_serialize_( + &obj->temperature, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[3] covariance_urt + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 3UL; ++_index0_) + { + float _sat0_ = obj->covariance_urt[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_deserialize_( + reg_udral_physics_thermodynamics_PressureTempVarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.pressure.Scalar.1.0 pressure + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_pressure_Scalar_1_0_deserialize_( + &out_obj->pressure, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.temperature.Scalar.1.0 temperature + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + &out_obj->temperature, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[3] covariance_urt + for (size_t _index1_ = 0U; _index1_ < 3UL; ++_index1_) + { + out_obj->covariance_urt[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_initialize_(reg_udral_physics_thermodynamics_PressureTempVarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_thermodynamics_PressureTempVarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_THERMODYNAMICS_PRESSURE_TEMP_VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/time/TAI64VarTs_0_1.h b/src/nunavut_out/reg/udral/physics/time/TAI64VarTs_0_1.h new file mode 100644 index 0000000..2cc309c --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/time/TAI64VarTs_0_1.h @@ -0,0 +1,282 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.736670 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.time.TAI64VarTs +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_TIME_TAI64VAR_TS_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_TIME_TAI64VAR_TS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64VarTs.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_time_TAI64VarTs_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_time_TAI64VarTs_0_1_FULL_NAME_ "reg.udral.physics.time.TAI64VarTs" +#define reg_udral_physics_time_TAI64VarTs_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.time.TAI64VarTs.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_time_TAI64VarTs_0_1_EXTENT_BYTES_ 19UL +#define reg_udral_physics_time_TAI64VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(reg_udral_physics_time_TAI64VarTs_0_1_EXTENT_BYTES_ >= reg_udral_physics_time_TAI64VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// reg.udral.physics.time.TAI64Var.0.1 value + reg_udral_physics_time_TAI64Var_0_1 value; +} reg_udral_physics_time_TAI64VarTs_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_time_TAI64VarTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64VarTs_0_1_serialize_( + const reg_udral_physics_time_TAI64VarTs_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // reg.udral.physics.time.TAI64Var.0.1 value + size_t _size_bytes1_ = 12UL; // Nested object (max) size, in bytes. + int8_t _err2_ = reg_udral_physics_time_TAI64Var_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64VarTs_0_1_deserialize_( + reg_udral_physics_time_TAI64VarTs_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.physics.time.TAI64Var.0.1 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = reg_udral_physics_time_TAI64Var_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_time_TAI64VarTs_0_1_initialize_(reg_udral_physics_time_TAI64VarTs_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_time_TAI64VarTs_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_TIME_TAI64VAR_TS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/time/TAI64Var_0_1.h b/src/nunavut_out/reg/udral/physics/time/TAI64Var_0_1.h new file mode 100644 index 0000000..03845c4 --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/time/TAI64Var_0_1.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.734929 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.time.TAI64Var +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_TIME_TAI64VAR_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_TIME_TAI64VAR_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64Var.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_time_TAI64Var_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_time_TAI64Var_0_1_FULL_NAME_ "reg.udral.physics.time.TAI64Var" +#define reg_udral_physics_time_TAI64Var_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.time.TAI64Var.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_time_TAI64Var_0_1_EXTENT_BYTES_ 12UL +#define reg_udral_physics_time_TAI64Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_physics_time_TAI64Var_0_1_EXTENT_BYTES_ >= reg_udral_physics_time_TAI64Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.physics.time.TAI64.0.1 value + reg_udral_physics_time_TAI64_0_1 value; + + /// saturated float32 error_variance + float error_variance; +} reg_udral_physics_time_TAI64Var_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_time_TAI64Var_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64Var_0_1_serialize_( + const reg_udral_physics_time_TAI64Var_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.physics.time.TAI64.0.1 value + size_t _size_bytes0_ = 8UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_physics_time_TAI64_0_1_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 error_variance + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->error_variance, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64Var_0_1_deserialize_( + reg_udral_physics_time_TAI64Var_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.physics.time.TAI64.0.1 value + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_physics_time_TAI64_0_1_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 error_variance + out_obj->error_variance = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_time_TAI64Var_0_1_initialize_(reg_udral_physics_time_TAI64Var_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_time_TAI64Var_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_TIME_TAI64VAR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/physics/time/TAI64_0_1.h b/src/nunavut_out/reg/udral/physics/time/TAI64_0_1.h new file mode 100644 index 0000000..e3c9b2a --- /dev/null +++ b/src/nunavut_out/reg/udral/physics/time/TAI64_0_1.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.733353 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.physics.time.TAI64 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_PHYSICS_TIME_TAI64_0_1_INCLUDED_ +#define REG_UDRAL_PHYSICS_TIME_TAI64_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/physics/time/TAI64.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_physics_time_TAI64_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_physics_time_TAI64_0_1_FULL_NAME_ "reg.udral.physics.time.TAI64" +#define reg_udral_physics_time_TAI64_0_1_FULL_NAME_AND_VERSION_ "reg.udral.physics.time.TAI64.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_physics_time_TAI64_0_1_EXTENT_BYTES_ 8UL +#define reg_udral_physics_time_TAI64_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(reg_udral_physics_time_TAI64_0_1_EXTENT_BYTES_ >= reg_udral_physics_time_TAI64_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated int64 tai64n + int64_t tai64n; +} reg_udral_physics_time_TAI64_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_physics_time_TAI64_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64_0_1_serialize_( + const reg_udral_physics_time_TAI64_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int64 tai64n + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->tai64n, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_physics_time_TAI64_0_1_deserialize_( + reg_udral_physics_time_TAI64_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int64 tai64n + out_obj->tai64n = nunavutGetI64(&buffer[0], capacity_bytes, offset_bits, 64); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_physics_time_TAI64_0_1_initialize_(reg_udral_physics_time_TAI64_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_physics_time_TAI64_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_PHYSICS_TIME_TAI64_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/actuator/common/FaultFlags_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/FaultFlags_0_1.h new file mode 100644 index 0000000..f767ce8 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/FaultFlags_0_1.h @@ -0,0 +1,530 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.597806 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.FaultFlags +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_FAULT_FLAGS_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_FAULT_FLAGS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/FaultFlags.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_FaultFlags_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_FaultFlags_0_1_FULL_NAME_ "reg.udral.service.actuator.common.FaultFlags" +#define reg_udral_service_actuator_common_FaultFlags_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.FaultFlags.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_FaultFlags_0_1_EXTENT_BYTES_ 2UL +#define reg_udral_service_actuator_common_FaultFlags_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(reg_udral_service_actuator_common_FaultFlags_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_FaultFlags_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated bool overload + bool overload; + + /// saturated bool voltage + bool voltage; + + /// saturated bool motor_temperature + bool motor_temperature; + + /// saturated bool controller_temperature + bool controller_temperature; + + /// saturated bool velocity + bool velocity; + + /// saturated bool mechanical + bool mechanical; + + /// saturated bool vibration + bool vibration; + + /// saturated bool configuration + bool configuration; + + /// saturated bool control_mode + bool control_mode; + + /// saturated bool other + bool other; +} reg_udral_service_actuator_common_FaultFlags_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_FaultFlags_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_FaultFlags_0_1_serialize_( + const reg_udral_service_actuator_common_FaultFlags_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool overload + buffer[offset_bits / 8U] = obj->overload ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool voltage + if (obj->voltage) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool motor_temperature + if (obj->motor_temperature) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool controller_temperature + if (obj->controller_temperature) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool velocity + if (obj->velocity) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool mechanical + if (obj->mechanical) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool vibration + if (obj->vibration) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool configuration + if (obj->configuration) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool control_mode + buffer[offset_bits / 8U] = obj->control_mode ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // void6 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 6U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 6UL; + } + + + + + { // saturated bool other + if (obj->other) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_FaultFlags_0_1_deserialize_( + reg_udral_service_actuator_common_FaultFlags_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool overload + if (offset_bits < capacity_bits) + { + out_obj->overload = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->overload = false; + } + offset_bits += 1U; + + + + + // saturated bool voltage + if (offset_bits < capacity_bits) + { + out_obj->voltage = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->voltage = false; + } + offset_bits += 1U; + + + + + // saturated bool motor_temperature + if (offset_bits < capacity_bits) + { + out_obj->motor_temperature = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->motor_temperature = false; + } + offset_bits += 1U; + + + + + // saturated bool controller_temperature + if (offset_bits < capacity_bits) + { + out_obj->controller_temperature = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->controller_temperature = false; + } + offset_bits += 1U; + + + + + // saturated bool velocity + if (offset_bits < capacity_bits) + { + out_obj->velocity = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->velocity = false; + } + offset_bits += 1U; + + + + + // saturated bool mechanical + if (offset_bits < capacity_bits) + { + out_obj->mechanical = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->mechanical = false; + } + offset_bits += 1U; + + + + + // saturated bool vibration + if (offset_bits < capacity_bits) + { + out_obj->vibration = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->vibration = false; + } + offset_bits += 1U; + + + + + // saturated bool configuration + if (offset_bits < capacity_bits) + { + out_obj->configuration = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->configuration = false; + } + offset_bits += 1U; + + + + + // saturated bool control_mode + if (offset_bits < capacity_bits) + { + out_obj->control_mode = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->control_mode = false; + } + offset_bits += 1U; + + + + + // void6 + offset_bits += 6; + + + + + // saturated bool other + if (offset_bits < capacity_bits) + { + out_obj->other = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->other = false; + } + offset_bits += 1U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_FaultFlags_0_1_initialize_(reg_udral_service_actuator_common_FaultFlags_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_FaultFlags_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_FAULT_FLAGS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/actuator/common/Feedback_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/Feedback_0_1.h new file mode 100644 index 0000000..d41df68 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/Feedback_0_1.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.601836 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.Feedback +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_FEEDBACK_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_FEEDBACK_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Feedback.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_Feedback_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_Feedback_0_1_FULL_NAME_ "reg.udral.service.actuator.common.Feedback" +#define reg_udral_service_actuator_common_Feedback_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.Feedback.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_ 63UL +#define reg_udral_service_actuator_common_Feedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 3UL +static_assert(reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_Feedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// reg.udral.service.common.Heartbeat.0.1 heartbeat + reg_udral_service_common_Heartbeat_0_1 heartbeat; + + /// saturated int8 demand_factor_pct + int8_t demand_factor_pct; +} reg_udral_service_actuator_common_Feedback_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_Feedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_Feedback_0_1_serialize_( + const reg_udral_service_actuator_common_Feedback_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 24UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.service.common.Heartbeat.0.1 heartbeat + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_service_common_Heartbeat_0_1_serialize_( + &obj->heartbeat, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated int8 demand_factor_pct + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->demand_factor_pct); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_Feedback_0_1_deserialize_( + reg_udral_service_actuator_common_Feedback_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.service.common.Heartbeat.0.1 heartbeat + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = reg_udral_service_common_Heartbeat_0_1_deserialize_( + &out_obj->heartbeat, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated int8 demand_factor_pct + out_obj->demand_factor_pct = nunavutGetI8(&buffer[0], capacity_bytes, offset_bits, 8); + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_Feedback_0_1_initialize_(reg_udral_service_actuator_common_Feedback_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_Feedback_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_FEEDBACK_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/Status_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/Status_0_1.h new file mode 100644 index 0000000..6ca40c8 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/Status_0_1.h @@ -0,0 +1,345 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.603925 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.Status +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_STATUS_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_STATUS_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_Status_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_Status_0_1_FULL_NAME_ "reg.udral.service.actuator.common.Status" +#define reg_udral_service_actuator_common_Status_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.Status.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_Status_0_1_EXTENT_BYTES_ 63UL +#define reg_udral_service_actuator_common_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 14UL +static_assert(reg_udral_service_actuator_common_Status_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.si.unit.temperature.Scalar.1.0 motor_temperature + uavcan_si_unit_temperature_Scalar_1_0 motor_temperature; + + /// uavcan.si.unit.temperature.Scalar.1.0 controller_temperature + uavcan_si_unit_temperature_Scalar_1_0 controller_temperature; + + /// saturated uint32 error_count + uint32_t error_count; + + /// reg.udral.service.actuator.common.FaultFlags.0.1 fault_flags + reg_udral_service_actuator_common_FaultFlags_0_1 fault_flags; +} reg_udral_service_actuator_common_Status_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_Status_0_1_serialize_( + const reg_udral_service_actuator_common_Status_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 112UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.temperature.Scalar.1.0 motor_temperature + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_temperature_Scalar_1_0_serialize_( + &obj->motor_temperature, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.temperature.Scalar.1.0 controller_temperature + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_temperature_Scalar_1_0_serialize_( + &obj->controller_temperature, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint32 error_count + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->error_count, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // reg.udral.service.actuator.common.FaultFlags.0.1 fault_flags + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err4_ = reg_udral_service_actuator_common_FaultFlags_0_1_serialize_( + &obj->fault_flags, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_Status_0_1_deserialize_( + reg_udral_service_actuator_common_Status_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.temperature.Scalar.1.0 motor_temperature + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + &out_obj->motor_temperature, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.temperature.Scalar.1.0 controller_temperature + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + &out_obj->controller_temperature, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint32 error_count + out_obj->error_count = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.service.actuator.common.FaultFlags.0.1 fault_flags + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = reg_udral_service_actuator_common_FaultFlags_0_1_deserialize_( + &out_obj->fault_flags, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_Status_0_1_initialize_(reg_udral_service_actuator_common_Status_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_Status_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_STATUS_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/_0_1.h new file mode 100644 index 0000000..5a42f84 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/_0_1.h @@ -0,0 +1,177 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.606768 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common._ +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON___0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON___0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common___0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common___0_1_FULL_NAME_ "reg.udral.service.actuator.common._" +#define reg_udral_service_actuator_common___0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common._.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common___0_1_EXTENT_BYTES_ 0UL +#define reg_udral_service_actuator_common___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(reg_udral_service_actuator_common___0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated float32 CONTROL_TIMEOUT = 1 +#define reg_udral_service_actuator_common___0_1_CONTROL_TIMEOUT (((float) 1.0)) +/// saturated uint8 MAX_PUBLICATION_PERIOD = 1 +#define reg_udral_service_actuator_common___0_1_MAX_PUBLICATION_PERIOD (1U) + +typedef struct +{ + uint8_t _dummy_; +} reg_udral_service_actuator_common___0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common___0_1_serialize_( + const reg_udral_service_actuator_common___0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common___0_1_deserialize_( + reg_udral_service_actuator_common___0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common___0_1_initialize_(reg_udral_service_actuator_common___0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common___0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON___0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Scalar_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Scalar_0_1.h new file mode 100644 index 0000000..5c6f885 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Scalar_0_1.h @@ -0,0 +1,237 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.608039 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Scalar +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_SCALAR_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_SCALAR_0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Scalar.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Scalar_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Scalar_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Scalar" +#define reg_udral_service_actuator_common_sp_Scalar_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Scalar.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Scalar_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Scalar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(reg_udral_service_actuator_common_sp_Scalar_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Scalar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float16 value + float value; +} reg_udral_service_actuator_common_sp_Scalar_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Scalar_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Scalar_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Scalar_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16 value + float _sat0_ = obj->value; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Scalar_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Scalar_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16 value + out_obj->value = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Scalar_0_1_initialize_(reg_udral_service_actuator_common_sp_Scalar_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Scalar_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_SCALAR_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector2_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector2_0_1.h new file mode 100644 index 0000000..7684e00 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector2_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.609950 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector2 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR2_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR2_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector2.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector2_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector2_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector2" +#define reg_udral_service_actuator_common_sp_Vector2_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector2.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector2_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector2_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(reg_udral_service_actuator_common_sp_Vector2_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector2_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[2] value +#define reg_udral_service_actuator_common_sp_Vector2_0_1_value_ARRAY_CAPACITY_ 2U +#define reg_udral_service_actuator_common_sp_Vector2_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[2] value + float value[2]; +} reg_udral_service_actuator_common_sp_Vector2_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector2_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector2_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector2_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[2] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 2UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector2_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector2_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[2] value + for (size_t _index1_ = 0U; _index1_ < 2UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector2_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector2_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector2_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR2_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector31_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector31_0_1.h new file mode 100644 index 0000000..c77b8d2 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector31_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.613673 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector31 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR31_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR31_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector31_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector31_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector31" +#define reg_udral_service_actuator_common_sp_Vector31_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector31.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector31_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector31_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 62UL +static_assert(reg_udral_service_actuator_common_sp_Vector31_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector31_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[31] value +#define reg_udral_service_actuator_common_sp_Vector31_0_1_value_ARRAY_CAPACITY_ 31U +#define reg_udral_service_actuator_common_sp_Vector31_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[31] value + float value[31]; +} reg_udral_service_actuator_common_sp_Vector31_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector31_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector31_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector31_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 496UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[31] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 31UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector31_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector31_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[31] value + for (size_t _index1_ = 0U; _index1_ < 31UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector31_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector31_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector31_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR31_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector3_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector3_0_1.h new file mode 100644 index 0000000..f814c5a --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector3_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.611862 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector3 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR3_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR3_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector3.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector3_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector3_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector3" +#define reg_udral_service_actuator_common_sp_Vector3_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector3.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector3_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector3_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 6UL +static_assert(reg_udral_service_actuator_common_sp_Vector3_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector3_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[3] value +#define reg_udral_service_actuator_common_sp_Vector3_0_1_value_ARRAY_CAPACITY_ 3U +#define reg_udral_service_actuator_common_sp_Vector3_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[3] value + float value[3]; +} reg_udral_service_actuator_common_sp_Vector3_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector3_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector3_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector3_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 48UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[3] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 3UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector3_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector3_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[3] value + for (size_t _index1_ = 0U; _index1_ < 3UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector3_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector3_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector3_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR3_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector4_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector4_0_1.h new file mode 100644 index 0000000..d89a114 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector4_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.615444 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector4 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR4_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR4_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector4.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector4_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector4_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector4" +#define reg_udral_service_actuator_common_sp_Vector4_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector4.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector4_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector4_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(reg_udral_service_actuator_common_sp_Vector4_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector4_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[4] value +#define reg_udral_service_actuator_common_sp_Vector4_0_1_value_ARRAY_CAPACITY_ 4U +#define reg_udral_service_actuator_common_sp_Vector4_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[4] value + float value[4]; +} reg_udral_service_actuator_common_sp_Vector4_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector4_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector4_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector4_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[4] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 4UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector4_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector4_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[4] value + for (size_t _index1_ = 0U; _index1_ < 4UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector4_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector4_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector4_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR4_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector6_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector6_0_1.h new file mode 100644 index 0000000..3ca4807 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector6_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.617243 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector6 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR6_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR6_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector6.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector6_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector6_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector6" +#define reg_udral_service_actuator_common_sp_Vector6_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector6.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector6_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector6_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_service_actuator_common_sp_Vector6_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector6_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[6] value +#define reg_udral_service_actuator_common_sp_Vector6_0_1_value_ARRAY_CAPACITY_ 6U +#define reg_udral_service_actuator_common_sp_Vector6_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[6] value + float value[6]; +} reg_udral_service_actuator_common_sp_Vector6_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector6_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector6_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector6_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[6] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 6UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector6_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector6_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[6] value + for (size_t _index1_ = 0U; _index1_ < 6UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector6_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector6_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector6_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR6_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector8_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector8_0_1.h new file mode 100644 index 0000000..a7842e5 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/Vector8_0_1.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.619023 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp.Vector8 +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR8_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR8_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/Vector8.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp_Vector8_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp_Vector8_0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp.Vector8" +#define reg_udral_service_actuator_common_sp_Vector8_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp.Vector8.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp_Vector8_0_1_EXTENT_BYTES_ 512UL +#define reg_udral_service_actuator_common_sp_Vector8_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 16UL +static_assert(reg_udral_service_actuator_common_sp_Vector8_0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp_Vector8_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[8] value +#define reg_udral_service_actuator_common_sp_Vector8_0_1_value_ARRAY_CAPACITY_ 8U +#define reg_udral_service_actuator_common_sp_Vector8_0_1_value_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float16[8] value + float value[8]; +} reg_udral_service_actuator_common_sp_Vector8_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp_Vector8_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector8_0_1_serialize_( + const reg_udral_service_actuator_common_sp_Vector8_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[8] value + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 8UL; ++_index0_) + { + float _sat0_ = obj->value[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp_Vector8_0_1_deserialize_( + reg_udral_service_actuator_common_sp_Vector8_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[8] value + for (size_t _index1_ = 0U; _index1_ < 8UL; ++_index1_) + { + out_obj->value[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp_Vector8_0_1_initialize_(reg_udral_service_actuator_common_sp_Vector8_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp_Vector8_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP_VECTOR8_0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/common/sp/_0_1.h b/src/nunavut_out/reg/udral/service/actuator/common/sp/_0_1.h new file mode 100644 index 0000000..6405be6 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/common/sp/_0_1.h @@ -0,0 +1,174 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.620971 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.common.sp._ +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP___0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP___0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/common/sp/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_common_sp___0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_common_sp___0_1_FULL_NAME_ "reg.udral.service.actuator.common.sp._" +#define reg_udral_service_actuator_common_sp___0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.common.sp._.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_common_sp___0_1_EXTENT_BYTES_ 0UL +#define reg_udral_service_actuator_common_sp___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(reg_udral_service_actuator_common_sp___0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_common_sp___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated float16 EPSILON = 1/2048 +#define reg_udral_service_actuator_common_sp___0_1_EPSILON (((float) (1.0 / 2048.0))) + +typedef struct +{ + uint8_t _dummy_; +} reg_udral_service_actuator_common_sp___0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_common_sp___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp___0_1_serialize_( + const reg_udral_service_actuator_common_sp___0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_common_sp___0_1_deserialize_( + reg_udral_service_actuator_common_sp___0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_common_sp___0_1_initialize_(reg_udral_service_actuator_common_sp___0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_common_sp___0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_COMMON_SP___0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/esc/_0_1.h b/src/nunavut_out/reg/udral/service/actuator/esc/_0_1.h new file mode 100644 index 0000000..a2370f8 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/esc/_0_1.h @@ -0,0 +1,171 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.502048 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.esc._ +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_ESC___0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_ESC___0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/esc/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_esc___0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_esc___0_1_FULL_NAME_ "reg.udral.service.actuator.esc._" +#define reg_udral_service_actuator_esc___0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.esc._.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_esc___0_1_EXTENT_BYTES_ 0UL +#define reg_udral_service_actuator_esc___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(reg_udral_service_actuator_esc___0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_esc___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} reg_udral_service_actuator_esc___0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_esc___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_esc___0_1_serialize_( + const reg_udral_service_actuator_esc___0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_esc___0_1_deserialize_( + reg_udral_service_actuator_esc___0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_esc___0_1_initialize_(reg_udral_service_actuator_esc___0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_esc___0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_ESC___0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/actuator/servo/_0_1.h b/src/nunavut_out/reg/udral/service/actuator/servo/_0_1.h new file mode 100644 index 0000000..f567dbc --- /dev/null +++ b/src/nunavut_out/reg/udral/service/actuator/servo/_0_1.h @@ -0,0 +1,171 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.596383 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.actuator.servo._ +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_ACTUATOR_SERVO___0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_ACTUATOR_SERVO___0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/actuator/servo/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_actuator_servo___0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_actuator_servo___0_1_FULL_NAME_ "reg.udral.service.actuator.servo._" +#define reg_udral_service_actuator_servo___0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.actuator.servo._.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_actuator_servo___0_1_EXTENT_BYTES_ 0UL +#define reg_udral_service_actuator_servo___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(reg_udral_service_actuator_servo___0_1_EXTENT_BYTES_ >= reg_udral_service_actuator_servo___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} reg_udral_service_actuator_servo___0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_actuator_servo___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_servo___0_1_serialize_( + const reg_udral_service_actuator_servo___0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_actuator_servo___0_1_deserialize_( + reg_udral_service_actuator_servo___0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_actuator_servo___0_1_initialize_(reg_udral_service_actuator_servo___0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_actuator_servo___0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_ACTUATOR_SERVO___0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/battery/Error_0_1.h b/src/nunavut_out/reg/udral/service/battery/Error_0_1.h new file mode 100644 index 0000000..e9d2ba5 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/battery/Error_0_1.h @@ -0,0 +1,257 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.628514 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.battery.Error +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_BATTERY_ERROR_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_BATTERY_ERROR_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_battery_Error_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_battery_Error_0_1_FULL_NAME_ "reg.udral.service.battery.Error" +#define reg_udral_service_battery_Error_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.battery.Error.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_battery_Error_0_1_EXTENT_BYTES_ 1UL +#define reg_udral_service_battery_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(reg_udral_service_battery_Error_0_1_EXTENT_BYTES_ >= reg_udral_service_battery_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 NONE = 0 +#define reg_udral_service_battery_Error_0_1_NONE (0U) +/// saturated uint8 BAD_BATTERY = 10 +#define reg_udral_service_battery_Error_0_1_BAD_BATTERY (10U) +/// saturated uint8 NEEDS_SERVICE = 11 +#define reg_udral_service_battery_Error_0_1_NEEDS_SERVICE (11U) +/// saturated uint8 BMS_ERROR = 20 +#define reg_udral_service_battery_Error_0_1_BMS_ERROR (20U) +/// saturated uint8 CONFIGURATION = 30 +#define reg_udral_service_battery_Error_0_1_CONFIGURATION (30U) +/// saturated uint8 OVERDISCHARGE = 50 +#define reg_udral_service_battery_Error_0_1_OVERDISCHARGE (50U) +/// saturated uint8 OVERLOAD = 51 +#define reg_udral_service_battery_Error_0_1_OVERLOAD (51U) +/// saturated uint8 CELL_OVERVOLTAGE = 60 +#define reg_udral_service_battery_Error_0_1_CELL_OVERVOLTAGE (60U) +/// saturated uint8 CELL_UNDERVOLTAGE = 61 +#define reg_udral_service_battery_Error_0_1_CELL_UNDERVOLTAGE (61U) +/// saturated uint8 CELL_COUNT = 62 +#define reg_udral_service_battery_Error_0_1_CELL_COUNT (62U) +/// saturated uint8 TEMPERATURE_HOT = 100 +#define reg_udral_service_battery_Error_0_1_TEMPERATURE_HOT (100U) +/// saturated uint8 TEMPERATURE_COLD = 101 +#define reg_udral_service_battery_Error_0_1_TEMPERATURE_COLD (101U) + +typedef struct +{ + /// saturated uint8 value + uint8_t value; +} reg_udral_service_battery_Error_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_battery_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Error_0_1_serialize_( + const reg_udral_service_battery_Error_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 value + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Error_0_1_deserialize_( + reg_udral_service_battery_Error_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 value + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_battery_Error_0_1_initialize_(reg_udral_service_battery_Error_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_battery_Error_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_BATTERY_ERROR_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/battery/Parameters_0_3.h b/src/nunavut_out/reg/udral/service/battery/Parameters_0_3.h new file mode 100644 index 0000000..80f8f5d --- /dev/null +++ b/src/nunavut_out/reg/udral/service/battery/Parameters_0_3.h @@ -0,0 +1,878 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl +// Generated at: 2024-11-23 10:35:27.630460 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.battery.Parameters +// Version: 0.3 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_BATTERY_PARAMETERS_0_3_INCLUDED_ +#define REG_UDRAL_SERVICE_BATTERY_PARAMETERS_0_3_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Parameters.0.3.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_battery_Parameters_0_3_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_battery_Parameters_0_3_FULL_NAME_ "reg.udral.service.battery.Parameters" +#define reg_udral_service_battery_Parameters_0_3_FULL_NAME_AND_VERSION_ "reg.udral.service.battery.Parameters.0.3" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_battery_Parameters_0_3_EXTENT_BYTES_ 300UL +#define reg_udral_service_battery_Parameters_0_3_SERIALIZATION_BUFFER_SIZE_BYTES_ 128UL +static_assert(reg_udral_service_battery_Parameters_0_3_EXTENT_BYTES_ >= reg_udral_service_battery_Parameters_0_3_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: uavcan.si.unit.voltage.Scalar.1.0[2] design_cell_voltage_min_max +#define reg_udral_service_battery_Parameters_0_3_design_cell_voltage_min_max_ARRAY_CAPACITY_ 2U +#define reg_udral_service_battery_Parameters_0_3_design_cell_voltage_min_max_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated uint8[<=64] name +#define reg_udral_service_battery_Parameters_0_3_name_ARRAY_CAPACITY_ 64U +#define reg_udral_service_battery_Parameters_0_3_name_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// truncated uint64 unique_id + uint64_t unique_id; + + /// uavcan.si.unit.mass.Scalar.1.0 mass + uavcan_si_unit_mass_Scalar_1_0 mass; + + /// uavcan.si.unit.electric_charge.Scalar.1.0 design_capacity + uavcan_si_unit_electric_charge_Scalar_1_0 design_capacity; + + /// uavcan.si.unit.voltage.Scalar.1.0[2] design_cell_voltage_min_max + uavcan_si_unit_voltage_Scalar_1_0 design_cell_voltage_min_max[2]; + + /// uavcan.si.unit.electric_current.Scalar.1.0 discharge_current + uavcan_si_unit_electric_current_Scalar_1_0 discharge_current; + + /// uavcan.si.unit.electric_current.Scalar.1.0 discharge_current_burst + uavcan_si_unit_electric_current_Scalar_1_0 discharge_current_burst; + + /// uavcan.si.unit.electric_current.Scalar.1.0 charge_current + uavcan_si_unit_electric_current_Scalar_1_0 charge_current; + + /// uavcan.si.unit.electric_current.Scalar.1.0 charge_current_fast + uavcan_si_unit_electric_current_Scalar_1_0 charge_current_fast; + + /// uavcan.si.unit.electric_current.Scalar.1.0 charge_termination_threshold + uavcan_si_unit_electric_current_Scalar_1_0 charge_termination_threshold; + + /// uavcan.si.unit.voltage.Scalar.1.0 charge_voltage + uavcan_si_unit_voltage_Scalar_1_0 charge_voltage; + + /// saturated uint16 cycle_count + uint16_t cycle_count; + + /// saturated uint8 series_cell_count + uint8_t series_cell_count; + + /// saturated uint7 state_of_health_pct + uint8_t state_of_health_pct; + + /// reg.udral.service.battery.Technology.0.1 technology + reg_udral_service_battery_Technology_0_1 technology; + + /// uavcan.si.unit.voltage.Scalar.1.0 nominal_voltage + uavcan_si_unit_voltage_Scalar_1_0 nominal_voltage; + + /// truncated uint40 unix_manufacture_time + uint64_t unix_manufacture_time; + + /// saturated uint8[<=64] name + struct /// Array address equivalence guarantee: &elements[0] == &name + { + uint8_t elements[reg_udral_service_battery_Parameters_0_3_name_ARRAY_CAPACITY_]; + size_t count; + } name; +} reg_udral_service_battery_Parameters_0_3; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_battery_Parameters_0_3_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Parameters_0_3_serialize_( + const reg_udral_service_battery_Parameters_0_3* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1024UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint64 unique_id + (void) memmove(&buffer[offset_bits / 8U], &obj->unique_id, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.mass.Scalar.1.0 mass + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_si_unit_mass_Scalar_1_0_serialize_( + &obj->mass, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.electric_charge.Scalar.1.0 design_capacity + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_si_unit_electric_charge_Scalar_1_0_serialize_( + &obj->design_capacity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + + { // uavcan.si.unit.voltage.Scalar.1.0[2] design_cell_voltage_min_max + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 2UL; ++_index0_) + { + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err5_ = uavcan_si_unit_voltage_Scalar_1_0_serialize_( + &obj->design_cell_voltage_min_max[_index0_], &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err6_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _pad3_; + } + + { // uavcan.si.unit.electric_current.Scalar.1.0 discharge_current + size_t _size_bytes3_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err7_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->discharge_current, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err7_ < 0) + { + return _err7_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad4_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err8_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad4_); // Optimize? + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _pad4_; + } + + { // uavcan.si.unit.electric_current.Scalar.1.0 discharge_current_burst + size_t _size_bytes4_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err9_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->discharge_current_burst, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err9_ < 0) + { + return _err9_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad5_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err10_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad5_); // Optimize? + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _pad5_; + } + + { // uavcan.si.unit.electric_current.Scalar.1.0 charge_current + size_t _size_bytes5_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err11_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->charge_current, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err11_ < 0) + { + return _err11_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad6_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err12_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad6_); // Optimize? + if (_err12_ < 0) + { + return _err12_; + } + offset_bits += _pad6_; + } + + { // uavcan.si.unit.electric_current.Scalar.1.0 charge_current_fast + size_t _size_bytes6_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err13_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->charge_current_fast, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err13_ < 0) + { + return _err13_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad7_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err14_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad7_); // Optimize? + if (_err14_ < 0) + { + return _err14_; + } + offset_bits += _pad7_; + } + + { // uavcan.si.unit.electric_current.Scalar.1.0 charge_termination_threshold + size_t _size_bytes7_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err15_ = uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + &obj->charge_termination_threshold, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err15_ < 0) + { + return _err15_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad8_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err16_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad8_); // Optimize? + if (_err16_ < 0) + { + return _err16_; + } + offset_bits += _pad8_; + } + + { // uavcan.si.unit.voltage.Scalar.1.0 charge_voltage + size_t _size_bytes8_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err17_ = uavcan_si_unit_voltage_Scalar_1_0_serialize_( + &obj->charge_voltage, &buffer[offset_bits / 8U], &_size_bytes8_); + if (_err17_ < 0) + { + return _err17_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes8_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint16 cycle_count + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->cycle_count, 2U); + offset_bits += 16U; + } + + + + + { // void8 + buffer[offset_bits / 8U] = 0U; + offset_bits += 8UL; + } + + + + + { // saturated uint8 series_cell_count + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->series_cell_count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + + + { // saturated uint7 state_of_health_pct + uint8_t _sat0_ = obj->state_of_health_pct; + if (_sat0_ > 127U) + { + _sat0_ = 127U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 7U; + } + + + + + { // void1 + const int8_t _err18_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 1U); // Optimize? + if (_err18_ < 0) + { + return _err18_; + } + offset_bits += 1UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad9_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err19_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad9_); // Optimize? + if (_err19_ < 0) + { + return _err19_; + } + offset_bits += _pad9_; + } + + { // reg.udral.service.battery.Technology.0.1 technology + size_t _size_bytes9_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err20_ = reg_udral_service_battery_Technology_0_1_serialize_( + &obj->technology, &buffer[offset_bits / 8U], &_size_bytes9_); + if (_err20_ < 0) + { + return _err20_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes9_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad10_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err21_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad10_); // Optimize? + if (_err21_ < 0) + { + return _err21_; + } + offset_bits += _pad10_; + } + + { // uavcan.si.unit.voltage.Scalar.1.0 nominal_voltage + size_t _size_bytes10_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err22_ = uavcan_si_unit_voltage_Scalar_1_0_serialize_( + &obj->nominal_voltage, &buffer[offset_bits / 8U], &_size_bytes10_); + if (_err22_ < 0) + { + return _err22_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes10_ * 8U; // Advance by the size of the nested object. + } + + + + + { // truncated uint40 unix_manufacture_time + (void) memmove(&buffer[offset_bits / 8U], &obj->unix_manufacture_time, 5U); + offset_bits += 40U; + } + + + + + { // saturated uint8[<=64] name + if (obj->name.count > 64) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->name.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->name.count * 8U, &obj->name.elements[0], 0U); + offset_bits += obj->name.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad11_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err23_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad11_); // Optimize? + if (_err23_ < 0) + { + return _err23_; + } + offset_bits += _pad11_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Parameters_0_3_deserialize_( + reg_udral_service_battery_Parameters_0_3* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint64 unique_id + out_obj->unique_id = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 64); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.mass.Scalar.1.0 mass + { + size_t _size_bytes11_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err24_ = uavcan_si_unit_mass_Scalar_1_0_deserialize_( + &out_obj->mass, &buffer[offset_bits / 8U], &_size_bytes11_); + if (_err24_ < 0) + { + return _err24_; + } + offset_bits += _size_bytes11_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_charge.Scalar.1.0 design_capacity + { + size_t _size_bytes12_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err25_ = uavcan_si_unit_electric_charge_Scalar_1_0_deserialize_( + &out_obj->design_capacity, &buffer[offset_bits / 8U], &_size_bytes12_); + if (_err25_ < 0) + { + return _err25_; + } + offset_bits += _size_bytes12_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.voltage.Scalar.1.0[2] design_cell_voltage_min_max + for (size_t _index1_ = 0U; _index1_ < 2UL; ++_index1_) + { + { + size_t _size_bytes13_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err26_ = uavcan_si_unit_voltage_Scalar_1_0_deserialize_( + &out_obj->design_cell_voltage_min_max[_index1_], &buffer[offset_bits / 8U], &_size_bytes13_); + if (_err26_ < 0) + { + return _err26_; + } + offset_bits += _size_bytes13_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_current.Scalar.1.0 discharge_current + { + size_t _size_bytes14_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err27_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->discharge_current, &buffer[offset_bits / 8U], &_size_bytes14_); + if (_err27_ < 0) + { + return _err27_; + } + offset_bits += _size_bytes14_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_current.Scalar.1.0 discharge_current_burst + { + size_t _size_bytes15_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err28_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->discharge_current_burst, &buffer[offset_bits / 8U], &_size_bytes15_); + if (_err28_ < 0) + { + return _err28_; + } + offset_bits += _size_bytes15_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_current.Scalar.1.0 charge_current + { + size_t _size_bytes16_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err29_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->charge_current, &buffer[offset_bits / 8U], &_size_bytes16_); + if (_err29_ < 0) + { + return _err29_; + } + offset_bits += _size_bytes16_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_current.Scalar.1.0 charge_current_fast + { + size_t _size_bytes17_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err30_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->charge_current_fast, &buffer[offset_bits / 8U], &_size_bytes17_); + if (_err30_ < 0) + { + return _err30_; + } + offset_bits += _size_bytes17_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_current.Scalar.1.0 charge_termination_threshold + { + size_t _size_bytes18_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err31_ = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + &out_obj->charge_termination_threshold, &buffer[offset_bits / 8U], &_size_bytes18_); + if (_err31_ < 0) + { + return _err31_; + } + offset_bits += _size_bytes18_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.voltage.Scalar.1.0 charge_voltage + { + size_t _size_bytes19_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err32_ = uavcan_si_unit_voltage_Scalar_1_0_deserialize_( + &out_obj->charge_voltage, &buffer[offset_bits / 8U], &_size_bytes19_); + if (_err32_ < 0) + { + return _err32_; + } + offset_bits += _size_bytes19_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint16 cycle_count + out_obj->cycle_count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // void8 + offset_bits += 8; + + + + + // saturated uint8 series_cell_count + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->series_cell_count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->series_cell_count = 0U; + } + offset_bits += 8U; + + + + + // saturated uint7 state_of_health_pct + if ((offset_bits + 7U) <= capacity_bits) + { + out_obj->state_of_health_pct = buffer[offset_bits / 8U] & 127U; + } + else + { + out_obj->state_of_health_pct = 0U; + } + offset_bits += 7U; + + + + + // void1 + offset_bits += 1; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.service.battery.Technology.0.1 technology + { + size_t _size_bytes20_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err33_ = reg_udral_service_battery_Technology_0_1_deserialize_( + &out_obj->technology, &buffer[offset_bits / 8U], &_size_bytes20_); + if (_err33_ < 0) + { + return _err33_; + } + offset_bits += _size_bytes20_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.voltage.Scalar.1.0 nominal_voltage + { + size_t _size_bytes21_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err34_ = uavcan_si_unit_voltage_Scalar_1_0_deserialize_( + &out_obj->nominal_voltage, &buffer[offset_bits / 8U], &_size_bytes21_); + if (_err34_ < 0) + { + return _err34_; + } + offset_bits += _size_bytes21_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // truncated uint40 unix_manufacture_time + out_obj->unix_manufacture_time = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // saturated uint8[<=64] name + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->name.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->name.count = 0U; + } + offset_bits += 8U; + if (out_obj->name.count > 64U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->name.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->name.count * 8U); + offset_bits += out_obj->name.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_battery_Parameters_0_3_initialize_(reg_udral_service_battery_Parameters_0_3* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_battery_Parameters_0_3_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_BATTERY_PARAMETERS_0_3_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/battery/Status_0_2.h b/src/nunavut_out/reg/udral/service/battery/Status_0_2.h new file mode 100644 index 0000000..6204e4f --- /dev/null +++ b/src/nunavut_out/reg/udral/service/battery/Status_0_2.h @@ -0,0 +1,452 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl +// Generated at: 2024-11-23 10:35:27.638127 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.battery.Status +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_BATTERY_STATUS_0_2_INCLUDED_ +#define REG_UDRAL_SERVICE_BATTERY_STATUS_0_2_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Status.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_battery_Status_0_2_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_battery_Status_0_2_FULL_NAME_ "reg.udral.service.battery.Status" +#define reg_udral_service_battery_Status_0_2_FULL_NAME_AND_VERSION_ "reg.udral.service.battery.Status.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_battery_Status_0_2_EXTENT_BYTES_ 600UL +#define reg_udral_service_battery_Status_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 526UL +static_assert(reg_udral_service_battery_Status_0_2_EXTENT_BYTES_ >= reg_udral_service_battery_Status_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_CELLS = 255 +#define reg_udral_service_battery_Status_0_2_MAX_CELLS (255U) + +/// Array metadata for: uavcan.si.unit.temperature.Scalar.1.0[2] temperature_min_max +#define reg_udral_service_battery_Status_0_2_temperature_min_max_ARRAY_CAPACITY_ 2U +#define reg_udral_service_battery_Status_0_2_temperature_min_max_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated float16[<=255] cell_voltages +#define reg_udral_service_battery_Status_0_2_cell_voltages_ARRAY_CAPACITY_ 255U +#define reg_udral_service_battery_Status_0_2_cell_voltages_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// reg.udral.service.common.Heartbeat.0.1 heartbeat + reg_udral_service_common_Heartbeat_0_1 heartbeat; + + /// uavcan.si.unit.temperature.Scalar.1.0[2] temperature_min_max + uavcan_si_unit_temperature_Scalar_1_0 temperature_min_max[2]; + + /// uavcan.si.unit.electric_charge.Scalar.1.0 available_charge + uavcan_si_unit_electric_charge_Scalar_1_0 available_charge; + + /// reg.udral.service.battery.Error.0.1 error + reg_udral_service_battery_Error_0_1 _error; + + /// saturated float16[<=255] cell_voltages + struct /// Array address equivalence guarantee: &elements[0] == &cell_voltages + { + float elements[reg_udral_service_battery_Status_0_2_cell_voltages_ARRAY_CAPACITY_]; + size_t count; + } cell_voltages; +} reg_udral_service_battery_Status_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_battery_Status_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Status_0_2_serialize_( + const reg_udral_service_battery_Status_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4208UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.service.common.Heartbeat.0.1 heartbeat + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_service_common_Heartbeat_0_1_serialize_( + &obj->heartbeat, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.temperature.Scalar.1.0[2] temperature_min_max + const size_t _origin0_ = offset_bits; + for (size_t _index0_ = 0U; _index0_ < 2UL; ++_index0_) + { + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_temperature_Scalar_1_0_serialize_( + &obj->temperature_min_max[_index0_], &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + (void) _origin0_; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.si.unit.electric_charge.Scalar.1.0 available_charge + size_t _size_bytes2_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_si_unit_electric_charge_Scalar_1_0_serialize_( + &obj->available_charge, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + + { // reg.udral.service.battery.Error.0.1 error + size_t _size_bytes3_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err6_ = reg_udral_service_battery_Error_0_1_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float16[<=255] cell_voltages + if (obj->cell_voltages.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->cell_voltages.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index1_ = 0U; _index1_ < obj->cell_voltages.count; ++_index1_) + { + float _sat0_ = obj->cell_voltages.elements[_index1_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Status_0_2_deserialize_( + reg_udral_service_battery_Status_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.service.common.Heartbeat.0.1 heartbeat + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = reg_udral_service_common_Heartbeat_0_1_deserialize_( + &out_obj->heartbeat, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.temperature.Scalar.1.0[2] temperature_min_max + for (size_t _index2_ = 0U; _index2_ < 2UL; ++_index2_) + { + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err9_ = uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + &out_obj->temperature_min_max[_index2_], &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.electric_charge.Scalar.1.0 available_charge + { + size_t _size_bytes6_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err10_ = uavcan_si_unit_electric_charge_Scalar_1_0_deserialize_( + &out_obj->available_charge, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // reg.udral.service.battery.Error.0.1 error + { + size_t _size_bytes7_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err11_ = reg_udral_service_battery_Error_0_1_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err11_ < 0) + { + return _err11_; + } + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float16[<=255] cell_voltages + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->cell_voltages.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->cell_voltages.count = 0U; + } + offset_bits += 8U; + if (out_obj->cell_voltages.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index3_ = 0U; _index3_ < out_obj->cell_voltages.count; ++_index3_) + { + out_obj->cell_voltages.elements[_index3_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_battery_Status_0_2_initialize_(reg_udral_service_battery_Status_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_battery_Status_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_BATTERY_STATUS_0_2_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/battery/Technology_0_1.h b/src/nunavut_out/reg/udral/service/battery/Technology_0_1.h new file mode 100644 index 0000000..6be463a --- /dev/null +++ b/src/nunavut_out/reg/udral/service/battery/Technology_0_1.h @@ -0,0 +1,281 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.641817 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.battery.Technology +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_BATTERY_TECHNOLOGY_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_BATTERY_TECHNOLOGY_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/Technology.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_battery_Technology_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_battery_Technology_0_1_FULL_NAME_ "reg.udral.service.battery.Technology" +#define reg_udral_service_battery_Technology_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.battery.Technology.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_battery_Technology_0_1_EXTENT_BYTES_ 1UL +#define reg_udral_service_battery_Technology_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(reg_udral_service_battery_Technology_0_1_EXTENT_BYTES_ >= reg_udral_service_battery_Technology_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 OTHER = 0 +#define reg_udral_service_battery_Technology_0_1_OTHER (0U) +/// saturated uint8 LI_SOCL2 = 10 +#define reg_udral_service_battery_Technology_0_1_LI_SOCL2 (10U) +/// saturated uint8 LI_BCX = 11 +#define reg_udral_service_battery_Technology_0_1_LI_BCX (11U) +/// saturated uint8 LI_MNO2 = 12 +#define reg_udral_service_battery_Technology_0_1_LI_MNO2 (12U) +/// saturated uint8 ZN_O2 = 20 +#define reg_udral_service_battery_Technology_0_1_ZN_O2 (20U) +/// saturated uint8 AL_O2 = 21 +#define reg_udral_service_battery_Technology_0_1_AL_O2 (21U) +/// saturated uint8 ZN_MNO2_NH4CL = 30 +#define reg_udral_service_battery_Technology_0_1_ZN_MNO2_NH4CL (30U) +/// saturated uint8 ZN_MNO2_ZNCL2 = 31 +#define reg_udral_service_battery_Technology_0_1_ZN_MNO2_ZNCL2 (31U) +/// saturated uint8 ZN_MNO2_KOH = 32 +#define reg_udral_service_battery_Technology_0_1_ZN_MNO2_KOH (32U) +/// saturated uint8 LI_LCO = 100 +#define reg_udral_service_battery_Technology_0_1_LI_LCO (100U) +/// saturated uint8 LI_LFP = 101 +#define reg_udral_service_battery_Technology_0_1_LI_LFP (101U) +/// saturated uint8 LI_NMC = 102 +#define reg_udral_service_battery_Technology_0_1_LI_NMC (102U) +/// saturated uint8 LI_NCA = 103 +#define reg_udral_service_battery_Technology_0_1_LI_NCA (103U) +/// saturated uint8 LI_LMO = 104 +#define reg_udral_service_battery_Technology_0_1_LI_LMO (104U) +/// saturated uint8 LI_S = 105 +#define reg_udral_service_battery_Technology_0_1_LI_S (105U) +/// saturated uint8 LI_LCO_POUCH = 110 +#define reg_udral_service_battery_Technology_0_1_LI_LCO_POUCH (110U) +/// saturated uint8 LI_LFP_POUCH = 111 +#define reg_udral_service_battery_Technology_0_1_LI_LFP_POUCH (111U) +/// saturated uint8 NI_MH = 120 +#define reg_udral_service_battery_Technology_0_1_NI_MH (120U) +/// saturated uint8 NI_CD = 121 +#define reg_udral_service_battery_Technology_0_1_NI_CD (121U) +/// saturated uint8 NI_ZN = 122 +#define reg_udral_service_battery_Technology_0_1_NI_ZN (122U) +/// saturated uint8 NI_FE = 123 +#define reg_udral_service_battery_Technology_0_1_NI_FE (123U) +/// saturated uint8 PB_AC = 130 +#define reg_udral_service_battery_Technology_0_1_PB_AC (130U) +/// saturated uint8 PB_AC_SEALED = 131 +#define reg_udral_service_battery_Technology_0_1_PB_AC_SEALED (131U) +/// saturated uint8 EDLC = 200 +#define reg_udral_service_battery_Technology_0_1_EDLC (200U) + +typedef struct +{ + /// saturated uint8 value + uint8_t value; +} reg_udral_service_battery_Technology_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_battery_Technology_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Technology_0_1_serialize_( + const reg_udral_service_battery_Technology_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 value + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery_Technology_0_1_deserialize_( + reg_udral_service_battery_Technology_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 value + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_battery_Technology_0_1_initialize_(reg_udral_service_battery_Technology_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_battery_Technology_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_BATTERY_TECHNOLOGY_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/battery/_0_1.h b/src/nunavut_out/reg/udral/service/battery/_0_1.h new file mode 100644 index 0000000..13f8250 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/battery/_0_1.h @@ -0,0 +1,171 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.643739 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.battery._ +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_BATTERY___0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_BATTERY___0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/battery/_.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_battery___0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_battery___0_1_FULL_NAME_ "reg.udral.service.battery._" +#define reg_udral_service_battery___0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.battery._.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_battery___0_1_EXTENT_BYTES_ 0UL +#define reg_udral_service_battery___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(reg_udral_service_battery___0_1_EXTENT_BYTES_ >= reg_udral_service_battery___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} reg_udral_service_battery___0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_battery___0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery___0_1_serialize_( + const reg_udral_service_battery___0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_battery___0_1_deserialize_( + reg_udral_service_battery___0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_battery___0_1_initialize_(reg_udral_service_battery___0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_battery___0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_BATTERY___0_1_INCLUDED_ + diff --git a/src/nunavut_out/reg/udral/service/common/Heartbeat_0_1.h b/src/nunavut_out/reg/udral/service/common/Heartbeat_0_1.h new file mode 100644 index 0000000..a1f3dc5 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/common/Heartbeat_0_1.h @@ -0,0 +1,286 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.624642 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.common.Heartbeat +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_COMMON_HEARTBEAT_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_COMMON_HEARTBEAT_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Heartbeat.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_common_Heartbeat_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_common_Heartbeat_0_1_FULL_NAME_ "reg.udral.service.common.Heartbeat" +#define reg_udral_service_common_Heartbeat_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.common.Heartbeat.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_common_Heartbeat_0_1_EXTENT_BYTES_ 2UL +#define reg_udral_service_common_Heartbeat_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(reg_udral_service_common_Heartbeat_0_1_EXTENT_BYTES_ >= reg_udral_service_common_Heartbeat_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_PUBLICATION_PERIOD = 1 +#define reg_udral_service_common_Heartbeat_0_1_MAX_PUBLICATION_PERIOD (1U) + +typedef struct +{ + /// reg.udral.service.common.Readiness.0.1 readiness + reg_udral_service_common_Readiness_0_1 readiness; + + /// uavcan.node.Health.1.0 health + uavcan_node_Health_1_0 health; +} reg_udral_service_common_Heartbeat_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_common_Heartbeat_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_common_Heartbeat_0_1_serialize_( + const reg_udral_service_common_Heartbeat_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // reg.udral.service.common.Readiness.0.1 readiness + size_t _size_bytes0_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err0_ = reg_udral_service_common_Readiness_0_1_serialize_( + &obj->readiness, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.Health.1.0 health + size_t _size_bytes1_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_node_Health_1_0_serialize_( + &obj->health, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_common_Heartbeat_0_1_deserialize_( + reg_udral_service_common_Heartbeat_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // reg.udral.service.common.Readiness.0.1 readiness + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = reg_udral_service_common_Readiness_0_1_deserialize_( + &out_obj->readiness, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.Health.1.0 health + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_node_Health_1_0_deserialize_( + &out_obj->health, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_common_Heartbeat_0_1_initialize_(reg_udral_service_common_Heartbeat_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_common_Heartbeat_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_COMMON_HEARTBEAT_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/common/Readiness_0_1.h b/src/nunavut_out/reg/udral/service/common/Readiness_0_1.h new file mode 100644 index 0000000..fb3b252 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/common/Readiness_0_1.h @@ -0,0 +1,238 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.626858 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.common.Readiness +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_COMMON_READINESS_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_COMMON_READINESS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/common/Readiness.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_common_Readiness_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_common_Readiness_0_1_FULL_NAME_ "reg.udral.service.common.Readiness" +#define reg_udral_service_common_Readiness_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.common.Readiness.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_common_Readiness_0_1_EXTENT_BYTES_ 1UL +#define reg_udral_service_common_Readiness_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(reg_udral_service_common_Readiness_0_1_EXTENT_BYTES_ >= reg_udral_service_common_Readiness_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint2 SLEEP = 0 +#define reg_udral_service_common_Readiness_0_1_SLEEP (0U) +/// saturated uint2 STANDBY = 2 +#define reg_udral_service_common_Readiness_0_1_STANDBY (2U) +/// saturated uint2 ENGAGED = 3 +#define reg_udral_service_common_Readiness_0_1_ENGAGED (3U) + +typedef struct +{ + /// truncated uint2 value + uint8_t value; +} reg_udral_service_common_Readiness_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_common_Readiness_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_common_Readiness_0_1_serialize_( + const reg_udral_service_common_Readiness_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint2 value + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 2U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_common_Readiness_0_1_deserialize_( + reg_udral_service_common_Readiness_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint2 value + if ((offset_bits + 2U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 3U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 2U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_common_Readiness_0_1_initialize_(reg_udral_service_common_Readiness_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_common_Readiness_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_COMMON_READINESS_0_1_INCLUDED_ diff --git a/src/nunavut_out/reg/udral/service/sensor/Status_0_1.h b/src/nunavut_out/reg/udral/service/sensor/Status_0_1.h new file mode 100644 index 0000000..538da34 --- /dev/null +++ b/src/nunavut_out/reg/udral/service/sensor/Status_0_1.h @@ -0,0 +1,306 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl +// Generated at: 2024-11-23 10:35:27.622209 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: reg.udral.service.sensor.Status +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef REG_UDRAL_SERVICE_SENSOR_STATUS_0_1_INCLUDED_ +#define REG_UDRAL_SERVICE_SENSOR_STATUS_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/reg/udral/service/sensor/Status.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define reg_udral_service_sensor_Status_0_1_HAS_FIXED_PORT_ID_ false + +#define reg_udral_service_sensor_Status_0_1_FULL_NAME_ "reg.udral.service.sensor.Status" +#define reg_udral_service_sensor_Status_0_1_FULL_NAME_AND_VERSION_ "reg.udral.service.sensor.Status.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define reg_udral_service_sensor_Status_0_1_EXTENT_BYTES_ 63UL +#define reg_udral_service_sensor_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(reg_udral_service_sensor_Status_0_1_EXTENT_BYTES_ >= reg_udral_service_sensor_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_PUBLICATION_PERIOD = 1 +#define reg_udral_service_sensor_Status_0_1_MAX_PUBLICATION_PERIOD (1U) + +typedef struct +{ + /// uavcan.si.unit.duration.Scalar.1.0 data_validity_period + uavcan_si_unit_duration_Scalar_1_0 data_validity_period; + + /// saturated uint32 error_count + uint32_t error_count; + + /// uavcan.si.unit.temperature.Scalar.1.0 sensor_temperature + uavcan_si_unit_temperature_Scalar_1_0 sensor_temperature; +} reg_udral_service_sensor_Status_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see reg_udral_service_sensor_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_sensor_Status_0_1_serialize_( + const reg_udral_service_sensor_Status_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.si.unit.duration.Scalar.1.0 data_validity_period + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_si_unit_duration_Scalar_1_0_serialize_( + &obj->data_validity_period, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint32 error_count + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->error_count, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.si.unit.temperature.Scalar.1.0 sensor_temperature + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_si_unit_temperature_Scalar_1_0_serialize_( + &obj->sensor_temperature, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t reg_udral_service_sensor_Status_0_1_deserialize_( + reg_udral_service_sensor_Status_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.si.unit.duration.Scalar.1.0 data_validity_period + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_si_unit_duration_Scalar_1_0_deserialize_( + &out_obj->data_validity_period, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint32 error_count + out_obj->error_count = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.si.unit.temperature.Scalar.1.0 sensor_temperature + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + &out_obj->sensor_temperature, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void reg_udral_service_sensor_Status_0_1_initialize_(reg_udral_service_sensor_Status_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = reg_udral_service_sensor_Status_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // REG_UDRAL_SERVICE_SENSOR_STATUS_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/_register/Access_1_0.h b/src/nunavut_out/uavcan/_register/Access_1_0.h new file mode 100644 index 0000000..7aef912 --- /dev/null +++ b/src/nunavut_out/uavcan/_register/Access_1_0.h @@ -0,0 +1,577 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.429174 UTC +// Is deprecated: no +// Fixed port-ID: 384 +// Full name: uavcan.register.Access +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_REGISTER_ACCESS_1_0_INCLUDED_ +#define UAVCAN_REGISTER_ACCESS_1_0_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/384.Access.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_register_Access_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_register_Access_1_0_FIXED_PORT_ID_ 384U + +#define uavcan_register_Access_1_0_FULL_NAME_ "uavcan.register.Access" +#define uavcan_register_Access_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.Access.1.0" + +#define uavcan_register_Access_Request_1_0_FULL_NAME_ "uavcan.register.Access.Request" +#define uavcan_register_Access_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.Access.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_Access_Request_1_0_EXTENT_BYTES_ 515UL +#define uavcan_register_Access_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 515UL +static_assert(uavcan_register_Access_Request_1_0_EXTENT_BYTES_ >= uavcan_register_Access_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.register.Name.1.0 name + uavcan_register_Name_1_0 name; + + /// uavcan.register.Value.1.0 value + uavcan_register_Value_1_0 value; +} uavcan_register_Access_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_Access_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Access_Request_1_0_serialize_( + const uavcan_register_Access_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.register.Name.1.0 name + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_register_Name_1_0_serialize_( + &obj->name, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.register.Value.1.0 value + size_t _size_bytes1_ = 259UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_register_Value_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Access_Request_1_0_deserialize_( + uavcan_register_Access_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.register.Name.1.0 name + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_register_Name_1_0_deserialize_( + &out_obj->name, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.register.Value.1.0 value + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_register_Value_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_Access_Request_1_0_initialize_(uavcan_register_Access_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_Access_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_register_Access_Response_1_0_FULL_NAME_ "uavcan.register.Access.Response" +#define uavcan_register_Access_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.Access.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_Access_Response_1_0_EXTENT_BYTES_ 267UL +#define uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 267UL +static_assert(uavcan_register_Access_Response_1_0_EXTENT_BYTES_ >= uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated bool mutable + bool _mutable; + + /// saturated bool persistent + bool persistent; + + /// uavcan.register.Value.1.0 value + uavcan_register_Value_1_0 value; +} uavcan_register_Access_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Access_Response_1_0_serialize_( + const uavcan_register_Access_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2136UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes4_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err6_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated bool mutable + buffer[offset_bits / 8U] = obj->_mutable ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool persistent + if (obj->persistent) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void6 + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 6U); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += 6UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err8_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _pad2_; + } + + { // uavcan.register.Value.1.0 value + size_t _size_bytes5_ = 259UL; // Nested object (max) size, in bytes. + int8_t _err9_ = uavcan_register_Value_1_0_serialize_( + &obj->value, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err10_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Access_Response_1_0_deserialize_( + uavcan_register_Access_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes6_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err11_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err11_ < 0) + { + return _err11_; + } + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated bool mutable + if (offset_bits < capacity_bits) + { + out_obj->_mutable = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->_mutable = false; + } + offset_bits += 1U; + + + + + // saturated bool persistent + if (offset_bits < capacity_bits) + { + out_obj->persistent = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->persistent = false; + } + offset_bits += 1U; + + + + + // void6 + offset_bits += 6; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.register.Value.1.0 value + { + size_t _size_bytes7_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err12_ = uavcan_register_Value_1_0_deserialize_( + &out_obj->value, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err12_ < 0) + { + return _err12_; + } + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_Access_Response_1_0_initialize_(uavcan_register_Access_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_Access_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_REGISTER_ACCESS_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/_register/List_1_0.h b/src/nunavut_out/uavcan/_register/List_1_0.h new file mode 100644 index 0000000..ea79aa8 --- /dev/null +++ b/src/nunavut_out/uavcan/_register/List_1_0.h @@ -0,0 +1,401 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.433852 UTC +// Is deprecated: no +// Fixed port-ID: 385 +// Full name: uavcan.register.List +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_REGISTER_LIST_1_0_INCLUDED_ +#define UAVCAN_REGISTER_LIST_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/385.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_register_List_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_register_List_1_0_FIXED_PORT_ID_ 385U + +#define uavcan_register_List_1_0_FULL_NAME_ "uavcan.register.List" +#define uavcan_register_List_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.List.1.0" + +#define uavcan_register_List_Request_1_0_FULL_NAME_ "uavcan.register.List.Request" +#define uavcan_register_List_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.List.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_List_Request_1_0_EXTENT_BYTES_ 2UL +#define uavcan_register_List_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_register_List_Request_1_0_EXTENT_BYTES_ >= uavcan_register_List_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint16 index + uint16_t index; +} uavcan_register_List_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_List_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_List_Request_1_0_serialize_( + const uavcan_register_List_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 index + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->index, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_List_Request_1_0_deserialize_( + uavcan_register_List_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 index + out_obj->index = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_List_Request_1_0_initialize_(uavcan_register_List_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_List_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_register_List_Response_1_0_FULL_NAME_ "uavcan.register.List.Response" +#define uavcan_register_List_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.List.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_List_Response_1_0_EXTENT_BYTES_ 256UL +#define uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 256UL +static_assert(uavcan_register_List_Response_1_0_EXTENT_BYTES_ >= uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.register.Name.1.0 name + uavcan_register_Name_1_0 name; +} uavcan_register_List_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_List_Response_1_0_serialize_( + const uavcan_register_List_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2048UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.register.Name.1.0 name + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_register_Name_1_0_serialize_( + &obj->name, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_List_Response_1_0_deserialize_( + uavcan_register_List_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.register.Name.1.0 name + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_register_Name_1_0_deserialize_( + &out_obj->name, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_List_Response_1_0_initialize_(uavcan_register_List_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_List_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_REGISTER_LIST_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/_register/Name_1_0.h b/src/nunavut_out/uavcan/_register/Name_1_0.h new file mode 100644 index 0000000..ffbcb34 --- /dev/null +++ b/src/nunavut_out/uavcan/_register/Name_1_0.h @@ -0,0 +1,255 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.436475 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.register.Name +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_REGISTER_NAME_1_0_INCLUDED_ +#define UAVCAN_REGISTER_NAME_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Name.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_register_Name_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_register_Name_1_0_FULL_NAME_ "uavcan.register.Name" +#define uavcan_register_Name_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.Name.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_Name_1_0_EXTENT_BYTES_ 256UL +#define uavcan_register_Name_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 256UL +static_assert(uavcan_register_Name_1_0_EXTENT_BYTES_ >= uavcan_register_Name_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=255] name +#define uavcan_register_Name_1_0_name_ARRAY_CAPACITY_ 255U +#define uavcan_register_Name_1_0_name_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=255] name + struct /// Array address equivalence guarantee: &elements[0] == &name + { + uint8_t elements[uavcan_register_Name_1_0_name_ARRAY_CAPACITY_]; + size_t count; + } name; +} uavcan_register_Name_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_Name_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Name_1_0_serialize_( + const uavcan_register_Name_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2048UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=255] name + if (obj->name.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->name.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->name.count * 8U, &obj->name.elements[0], 0U); + offset_bits += obj->name.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Name_1_0_deserialize_( + uavcan_register_Name_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=255] name + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->name.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->name.count = 0U; + } + offset_bits += 8U; + if (out_obj->name.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->name.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->name.count * 8U); + offset_bits += out_obj->name.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_Name_1_0_initialize_(uavcan_register_Name_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_Name_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_REGISTER_NAME_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/_register/Value_1_0.h b/src/nunavut_out/uavcan/_register/Value_1_0.h new file mode 100644 index 0000000..47e7bd7 --- /dev/null +++ b/src/nunavut_out/uavcan/_register/Value_1_0.h @@ -0,0 +1,897 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.438792 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.register.Value +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_REGISTER_VALUE_1_0_INCLUDED_ +#define UAVCAN_REGISTER_VALUE_1_0_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/register/Value.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_register_Value_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_register_Value_1_0_FULL_NAME_ "uavcan.register.Value" +#define uavcan_register_Value_1_0_FULL_NAME_AND_VERSION_ "uavcan.register.Value.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_register_Value_1_0_EXTENT_BYTES_ 259UL +#define uavcan_register_Value_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 259UL +static_assert(uavcan_register_Value_1_0_EXTENT_BYTES_ >= uavcan_register_Value_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_register_Value_1_0_UNION_OPTION_COUNT_ 15U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// uavcan.primitive.Empty.1.0 empty + uavcan_primitive_Empty_1_0 empty; + + /// uavcan.primitive.String.1.0 string + uavcan_primitive_String_1_0 _string; + + /// uavcan.primitive.Unstructured.1.0 unstructured + uavcan_primitive_Unstructured_1_0 unstructured; + + /// uavcan.primitive.array.Bit.1.0 bit + uavcan_primitive_array_Bit_1_0 bit; + + /// uavcan.primitive.array.Integer64.1.0 integer64 + uavcan_primitive_array_Integer64_1_0 integer64; + + /// uavcan.primitive.array.Integer32.1.0 integer32 + uavcan_primitive_array_Integer32_1_0 integer32; + + /// uavcan.primitive.array.Integer16.1.0 integer16 + uavcan_primitive_array_Integer16_1_0 integer16; + + /// uavcan.primitive.array.Integer8.1.0 integer8 + uavcan_primitive_array_Integer8_1_0 integer8; + + /// uavcan.primitive.array.Natural64.1.0 natural64 + uavcan_primitive_array_Natural64_1_0 natural64; + + /// uavcan.primitive.array.Natural32.1.0 natural32 + uavcan_primitive_array_Natural32_1_0 natural32; + + /// uavcan.primitive.array.Natural16.1.0 natural16 + uavcan_primitive_array_Natural16_1_0 natural16; + + /// uavcan.primitive.array.Natural8.1.0 natural8 + uavcan_primitive_array_Natural8_1_0 natural8; + + /// uavcan.primitive.array.Real64.1.0 real64 + uavcan_primitive_array_Real64_1_0 real64; + + /// uavcan.primitive.array.Real32.1.0 real32 + uavcan_primitive_array_Real32_1_0 real32; + + /// uavcan.primitive.array.Real16.1.0 real16 + uavcan_primitive_array_Real16_1_0 real16; + }; + uint8_t _tag_; +} uavcan_register_Value_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_register_Value_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Value_1_0_serialize_( + const uavcan_register_Value_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2072UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // uavcan.primitive.Empty.1.0 empty + { + size_t _size_bytes0_ = 0UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_primitive_Empty_1_0_serialize_( + &obj->empty, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + else if (1U == obj->_tag_) // uavcan.primitive.String.1.0 string + { + size_t _size_bytes1_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_primitive_String_1_0_serialize_( + &obj->_string, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else if (2U == obj->_tag_) // uavcan.primitive.Unstructured.1.0 unstructured + { + size_t _size_bytes2_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_primitive_Unstructured_1_0_serialize_( + &obj->unstructured, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + else if (3U == obj->_tag_) // uavcan.primitive.array.Bit.1.0 bit + { + size_t _size_bytes3_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_primitive_array_Bit_1_0_serialize_( + &obj->bit, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + else if (4U == obj->_tag_) // uavcan.primitive.array.Integer64.1.0 integer64 + { + size_t _size_bytes4_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_primitive_array_Integer64_1_0_serialize_( + &obj->integer64, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + else if (5U == obj->_tag_) // uavcan.primitive.array.Integer32.1.0 integer32 + { + size_t _size_bytes5_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err5_ = uavcan_primitive_array_Integer32_1_0_serialize_( + &obj->integer32, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err5_ < 0) + { + return _err5_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested object. + } + else if (6U == obj->_tag_) // uavcan.primitive.array.Integer16.1.0 integer16 + { + size_t _size_bytes6_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err6_ = uavcan_primitive_array_Integer16_1_0_serialize_( + &obj->integer16, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested object. + } + else if (7U == obj->_tag_) // uavcan.primitive.array.Integer8.1.0 integer8 + { + size_t _size_bytes7_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err7_ = uavcan_primitive_array_Integer8_1_0_serialize_( + &obj->integer8, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err7_ < 0) + { + return _err7_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested object. + } + else if (8U == obj->_tag_) // uavcan.primitive.array.Natural64.1.0 natural64 + { + size_t _size_bytes8_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err8_ = uavcan_primitive_array_Natural64_1_0_serialize_( + &obj->natural64, &buffer[offset_bits / 8U], &_size_bytes8_); + if (_err8_ < 0) + { + return _err8_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes8_ * 8U; // Advance by the size of the nested object. + } + else if (9U == obj->_tag_) // uavcan.primitive.array.Natural32.1.0 natural32 + { + size_t _size_bytes9_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err9_ = uavcan_primitive_array_Natural32_1_0_serialize_( + &obj->natural32, &buffer[offset_bits / 8U], &_size_bytes9_); + if (_err9_ < 0) + { + return _err9_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes9_ * 8U; // Advance by the size of the nested object. + } + else if (10U == obj->_tag_) // uavcan.primitive.array.Natural16.1.0 natural16 + { + size_t _size_bytes10_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err10_ = uavcan_primitive_array_Natural16_1_0_serialize_( + &obj->natural16, &buffer[offset_bits / 8U], &_size_bytes10_); + if (_err10_ < 0) + { + return _err10_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes10_ * 8U; // Advance by the size of the nested object. + } + else if (11U == obj->_tag_) // uavcan.primitive.array.Natural8.1.0 natural8 + { + size_t _size_bytes11_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err11_ = uavcan_primitive_array_Natural8_1_0_serialize_( + &obj->natural8, &buffer[offset_bits / 8U], &_size_bytes11_); + if (_err11_ < 0) + { + return _err11_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes11_ * 8U; // Advance by the size of the nested object. + } + else if (12U == obj->_tag_) // uavcan.primitive.array.Real64.1.0 real64 + { + size_t _size_bytes12_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err12_ = uavcan_primitive_array_Real64_1_0_serialize_( + &obj->real64, &buffer[offset_bits / 8U], &_size_bytes12_); + if (_err12_ < 0) + { + return _err12_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes12_ * 8U; // Advance by the size of the nested object. + } + else if (13U == obj->_tag_) // uavcan.primitive.array.Real32.1.0 real32 + { + size_t _size_bytes13_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err13_ = uavcan_primitive_array_Real32_1_0_serialize_( + &obj->real32, &buffer[offset_bits / 8U], &_size_bytes13_); + if (_err13_ < 0) + { + return _err13_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes13_ * 8U; // Advance by the size of the nested object. + } + else if (14U == obj->_tag_) // uavcan.primitive.array.Real16.1.0 real16 + { + size_t _size_bytes14_ = 257UL; // Nested object (max) size, in bytes. + int8_t _err14_ = uavcan_primitive_array_Real16_1_0_serialize_( + &obj->real16, &buffer[offset_bits / 8U], &_size_bytes14_); + if (_err14_ < 0) + { + return _err14_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes14_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err15_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err15_ < 0) + { + return _err15_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_register_Value_1_0_deserialize_( + uavcan_register_Value_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // uavcan.primitive.Empty.1.0 empty + { + { + size_t _size_bytes15_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err16_ = uavcan_primitive_Empty_1_0_deserialize_( + &out_obj->empty, &buffer[offset_bits / 8U], &_size_bytes15_); + if (_err16_ < 0) + { + return _err16_; + } + offset_bits += _size_bytes15_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (1U == out_obj->_tag_) // uavcan.primitive.String.1.0 string + { + { + size_t _size_bytes16_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err17_ = uavcan_primitive_String_1_0_deserialize_( + &out_obj->_string, &buffer[offset_bits / 8U], &_size_bytes16_); + if (_err17_ < 0) + { + return _err17_; + } + offset_bits += _size_bytes16_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (2U == out_obj->_tag_) // uavcan.primitive.Unstructured.1.0 unstructured + { + { + size_t _size_bytes17_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err18_ = uavcan_primitive_Unstructured_1_0_deserialize_( + &out_obj->unstructured, &buffer[offset_bits / 8U], &_size_bytes17_); + if (_err18_ < 0) + { + return _err18_; + } + offset_bits += _size_bytes17_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (3U == out_obj->_tag_) // uavcan.primitive.array.Bit.1.0 bit + { + { + size_t _size_bytes18_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err19_ = uavcan_primitive_array_Bit_1_0_deserialize_( + &out_obj->bit, &buffer[offset_bits / 8U], &_size_bytes18_); + if (_err19_ < 0) + { + return _err19_; + } + offset_bits += _size_bytes18_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (4U == out_obj->_tag_) // uavcan.primitive.array.Integer64.1.0 integer64 + { + { + size_t _size_bytes19_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err20_ = uavcan_primitive_array_Integer64_1_0_deserialize_( + &out_obj->integer64, &buffer[offset_bits / 8U], &_size_bytes19_); + if (_err20_ < 0) + { + return _err20_; + } + offset_bits += _size_bytes19_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (5U == out_obj->_tag_) // uavcan.primitive.array.Integer32.1.0 integer32 + { + { + size_t _size_bytes20_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err21_ = uavcan_primitive_array_Integer32_1_0_deserialize_( + &out_obj->integer32, &buffer[offset_bits / 8U], &_size_bytes20_); + if (_err21_ < 0) + { + return _err21_; + } + offset_bits += _size_bytes20_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (6U == out_obj->_tag_) // uavcan.primitive.array.Integer16.1.0 integer16 + { + { + size_t _size_bytes21_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err22_ = uavcan_primitive_array_Integer16_1_0_deserialize_( + &out_obj->integer16, &buffer[offset_bits / 8U], &_size_bytes21_); + if (_err22_ < 0) + { + return _err22_; + } + offset_bits += _size_bytes21_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (7U == out_obj->_tag_) // uavcan.primitive.array.Integer8.1.0 integer8 + { + { + size_t _size_bytes22_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err23_ = uavcan_primitive_array_Integer8_1_0_deserialize_( + &out_obj->integer8, &buffer[offset_bits / 8U], &_size_bytes22_); + if (_err23_ < 0) + { + return _err23_; + } + offset_bits += _size_bytes22_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (8U == out_obj->_tag_) // uavcan.primitive.array.Natural64.1.0 natural64 + { + { + size_t _size_bytes23_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err24_ = uavcan_primitive_array_Natural64_1_0_deserialize_( + &out_obj->natural64, &buffer[offset_bits / 8U], &_size_bytes23_); + if (_err24_ < 0) + { + return _err24_; + } + offset_bits += _size_bytes23_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (9U == out_obj->_tag_) // uavcan.primitive.array.Natural32.1.0 natural32 + { + { + size_t _size_bytes24_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err25_ = uavcan_primitive_array_Natural32_1_0_deserialize_( + &out_obj->natural32, &buffer[offset_bits / 8U], &_size_bytes24_); + if (_err25_ < 0) + { + return _err25_; + } + offset_bits += _size_bytes24_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (10U == out_obj->_tag_) // uavcan.primitive.array.Natural16.1.0 natural16 + { + { + size_t _size_bytes25_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err26_ = uavcan_primitive_array_Natural16_1_0_deserialize_( + &out_obj->natural16, &buffer[offset_bits / 8U], &_size_bytes25_); + if (_err26_ < 0) + { + return _err26_; + } + offset_bits += _size_bytes25_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (11U == out_obj->_tag_) // uavcan.primitive.array.Natural8.1.0 natural8 + { + { + size_t _size_bytes26_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err27_ = uavcan_primitive_array_Natural8_1_0_deserialize_( + &out_obj->natural8, &buffer[offset_bits / 8U], &_size_bytes26_); + if (_err27_ < 0) + { + return _err27_; + } + offset_bits += _size_bytes26_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (12U == out_obj->_tag_) // uavcan.primitive.array.Real64.1.0 real64 + { + { + size_t _size_bytes27_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err28_ = uavcan_primitive_array_Real64_1_0_deserialize_( + &out_obj->real64, &buffer[offset_bits / 8U], &_size_bytes27_); + if (_err28_ < 0) + { + return _err28_; + } + offset_bits += _size_bytes27_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (13U == out_obj->_tag_) // uavcan.primitive.array.Real32.1.0 real32 + { + { + size_t _size_bytes28_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err29_ = uavcan_primitive_array_Real32_1_0_deserialize_( + &out_obj->real32, &buffer[offset_bits / 8U], &_size_bytes28_); + if (_err29_ < 0) + { + return _err29_; + } + offset_bits += _size_bytes28_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (14U == out_obj->_tag_) // uavcan.primitive.array.Real16.1.0 real16 + { + { + size_t _size_bytes29_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err30_ = uavcan_primitive_array_Real16_1_0_deserialize_( + &out_obj->real16, &buffer[offset_bits / 8U], &_size_bytes29_); + if (_err30_ < 0) + { + return _err30_; + } + offset_bits += _size_bytes29_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_register_Value_1_0_initialize_(uavcan_register_Value_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_register_Value_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "empty" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_empty_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "empty" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_empty_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "string" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_string_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "string" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_string_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +/// Mark option "unstructured" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_unstructured_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 2; + } +} + +/// Check if option "unstructured" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_unstructured_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 2)); +} + +/// Mark option "bit" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_bit_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 3; + } +} + +/// Check if option "bit" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_bit_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 3)); +} + +/// Mark option "integer64" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_integer64_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 4; + } +} + +/// Check if option "integer64" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_integer64_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 4)); +} + +/// Mark option "integer32" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_integer32_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 5; + } +} + +/// Check if option "integer32" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_integer32_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 5)); +} + +/// Mark option "integer16" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_integer16_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 6; + } +} + +/// Check if option "integer16" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_integer16_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 6)); +} + +/// Mark option "integer8" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_integer8_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 7; + } +} + +/// Check if option "integer8" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_integer8_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 7)); +} + +/// Mark option "natural64" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_natural64_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 8; + } +} + +/// Check if option "natural64" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_natural64_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 8)); +} + +/// Mark option "natural32" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_natural32_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 9; + } +} + +/// Check if option "natural32" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_natural32_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 9)); +} + +/// Mark option "natural16" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_natural16_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 10; + } +} + +/// Check if option "natural16" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_natural16_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 10)); +} + +/// Mark option "natural8" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_natural8_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 11; + } +} + +/// Check if option "natural8" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_natural8_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 11)); +} + +/// Mark option "real64" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_real64_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 12; + } +} + +/// Check if option "real64" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_real64_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 12)); +} + +/// Mark option "real32" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_real32_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 13; + } +} + +/// Check if option "real32" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_real32_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 13)); +} + +/// Mark option "real16" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_register_Value_1_0_select_real16_(uavcan_register_Value_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 14; + } +} + +/// Check if option "real16" is active. Returns false if @param obj is NULL. +static inline bool uavcan_register_Value_1_0_is_real16_(const uavcan_register_Value_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 14)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_REGISTER_VALUE_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/diagnostic/Record_1_0.h b/src/nunavut_out/uavcan/diagnostic/Record_1_0.h new file mode 100644 index 0000000..32f3256 --- /dev/null +++ b/src/nunavut_out/uavcan/diagnostic/Record_1_0.h @@ -0,0 +1,342 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.377608 UTC +// Is deprecated: yes +// Fixed port-ID: 8184 +// Full name: uavcan.diagnostic.Record +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_DIAGNOSTIC_RECORD_1_0_INCLUDED_ +#define UAVCAN_DIAGNOSTIC_RECORD_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_diagnostic_Record_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_diagnostic_Record_1_0_FIXED_PORT_ID_ 8184U + +#define uavcan_diagnostic_Record_1_0_FULL_NAME_ "uavcan.diagnostic.Record" +#define uavcan_diagnostic_Record_1_0_FULL_NAME_AND_VERSION_ "uavcan.diagnostic.Record.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_diagnostic_Record_1_0_EXTENT_BYTES_ 300UL +#define uavcan_diagnostic_Record_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 121UL +static_assert(uavcan_diagnostic_Record_1_0_EXTENT_BYTES_ >= uavcan_diagnostic_Record_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=112] text +#define uavcan_diagnostic_Record_1_0_text_ARRAY_CAPACITY_ 112U +#define uavcan_diagnostic_Record_1_0_text_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// uavcan.diagnostic.Severity.1.0 severity + uavcan_diagnostic_Severity_1_0 severity; + + /// saturated uint8[<=112] text + struct /// Array address equivalence guarantee: &elements[0] == &text + { + uint8_t elements[uavcan_diagnostic_Record_1_0_text_ARRAY_CAPACITY_]; + size_t count; + } text; +} uavcan_diagnostic_Record_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_diagnostic_Record_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Record_1_0_serialize_( + const uavcan_diagnostic_Record_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 968UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.diagnostic.Severity.1.0 severity + size_t _size_bytes1_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_diagnostic_Severity_1_0_serialize_( + &obj->severity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=112] text + if (obj->text.count > 112) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->text.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->text.count * 8U, &obj->text.elements[0], 0U); + offset_bits += obj->text.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Record_1_0_deserialize_( + uavcan_diagnostic_Record_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.diagnostic.Severity.1.0 severity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_diagnostic_Severity_1_0_deserialize_( + &out_obj->severity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=112] text + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->text.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->text.count = 0U; + } + offset_bits += 8U; + if (out_obj->text.count > 112U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->text.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->text.count * 8U); + offset_bits += out_obj->text.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_diagnostic_Record_1_0_initialize_(uavcan_diagnostic_Record_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_diagnostic_Record_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_DIAGNOSTIC_RECORD_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/diagnostic/Record_1_1.h b/src/nunavut_out/uavcan/diagnostic/Record_1_1.h new file mode 100644 index 0000000..f6fd492 --- /dev/null +++ b/src/nunavut_out/uavcan/diagnostic/Record_1_1.h @@ -0,0 +1,333 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.274742 UTC +// Is deprecated: no +// Fixed port-ID: 8184 +// Full name: uavcan.diagnostic.Record +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_DIAGNOSTIC_RECORD_1_1_INCLUDED_ +#define UAVCAN_DIAGNOSTIC_RECORD_1_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/8184.Record.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_diagnostic_Record_1_1_HAS_FIXED_PORT_ID_ true +#define uavcan_diagnostic_Record_1_1_FIXED_PORT_ID_ 8184U + +#define uavcan_diagnostic_Record_1_1_FULL_NAME_ "uavcan.diagnostic.Record" +#define uavcan_diagnostic_Record_1_1_FULL_NAME_AND_VERSION_ "uavcan.diagnostic.Record.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_diagnostic_Record_1_1_EXTENT_BYTES_ 300UL +#define uavcan_diagnostic_Record_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 264UL +static_assert(uavcan_diagnostic_Record_1_1_EXTENT_BYTES_ >= uavcan_diagnostic_Record_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=255] text +#define uavcan_diagnostic_Record_1_1_text_ARRAY_CAPACITY_ 255U +#define uavcan_diagnostic_Record_1_1_text_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// uavcan.diagnostic.Severity.1.0 severity + uavcan_diagnostic_Severity_1_0 severity; + + /// saturated uint8[<=255] text + struct /// Array address equivalence guarantee: &elements[0] == &text + { + uint8_t elements[uavcan_diagnostic_Record_1_1_text_ARRAY_CAPACITY_]; + size_t count; + } text; +} uavcan_diagnostic_Record_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_diagnostic_Record_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Record_1_1_serialize_( + const uavcan_diagnostic_Record_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2112UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.diagnostic.Severity.1.0 severity + size_t _size_bytes1_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_diagnostic_Severity_1_0_serialize_( + &obj->severity, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=255] text + if (obj->text.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->text.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->text.count * 8U, &obj->text.elements[0], 0U); + offset_bits += obj->text.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Record_1_1_deserialize_( + uavcan_diagnostic_Record_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.diagnostic.Severity.1.0 severity + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_diagnostic_Severity_1_0_deserialize_( + &out_obj->severity, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=255] text + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->text.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->text.count = 0U; + } + offset_bits += 8U; + if (out_obj->text.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->text.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->text.count * 8U); + offset_bits += out_obj->text.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_diagnostic_Record_1_1_initialize_(uavcan_diagnostic_Record_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_diagnostic_Record_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_DIAGNOSTIC_RECORD_1_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/diagnostic/Severity_1_0.h b/src/nunavut_out/uavcan/diagnostic/Severity_1_0.h new file mode 100644 index 0000000..9a8702e --- /dev/null +++ b/src/nunavut_out/uavcan/diagnostic/Severity_1_0.h @@ -0,0 +1,253 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.380362 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.diagnostic.Severity +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_DIAGNOSTIC_SEVERITY_1_0_INCLUDED_ +#define UAVCAN_DIAGNOSTIC_SEVERITY_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/diagnostic/Severity.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_diagnostic_Severity_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_diagnostic_Severity_1_0_FULL_NAME_ "uavcan.diagnostic.Severity" +#define uavcan_diagnostic_Severity_1_0_FULL_NAME_AND_VERSION_ "uavcan.diagnostic.Severity.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_diagnostic_Severity_1_0_EXTENT_BYTES_ 1UL +#define uavcan_diagnostic_Severity_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_diagnostic_Severity_1_0_EXTENT_BYTES_ >= uavcan_diagnostic_Severity_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint3 TRACE = 0 +#define uavcan_diagnostic_Severity_1_0_TRACE (0U) +/// saturated uint3 DEBUG = 1 +#define uavcan_diagnostic_Severity_1_0_DEBUG (1U) +/// saturated uint3 INFO = 2 +#define uavcan_diagnostic_Severity_1_0_INFO (2U) +/// saturated uint3 NOTICE = 3 +#define uavcan_diagnostic_Severity_1_0_NOTICE (3U) +/// saturated uint3 WARNING = 4 +#define uavcan_diagnostic_Severity_1_0_WARNING (4U) +/// saturated uint3 ERROR = 5 +#define uavcan_diagnostic_Severity_1_0_ERROR (5U) +/// saturated uint3 CRITICAL = 6 +#define uavcan_diagnostic_Severity_1_0_CRITICAL (6U) +/// saturated uint3 ALERT = 7 +#define uavcan_diagnostic_Severity_1_0_ALERT (7U) + +typedef struct +{ + /// saturated uint3 value + uint8_t value; +} uavcan_diagnostic_Severity_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_diagnostic_Severity_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Severity_1_0_serialize_( + const uavcan_diagnostic_Severity_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint3 value + uint8_t _sat0_ = obj->value; + if (_sat0_ > 7U) + { + _sat0_ = 7U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 3U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_diagnostic_Severity_1_0_deserialize_( + uavcan_diagnostic_Severity_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint3 value + if ((offset_bits + 3U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 7U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 3U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_diagnostic_Severity_1_0_initialize_(uavcan_diagnostic_Severity_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_diagnostic_Severity_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_DIAGNOSTIC_SEVERITY_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Error_1_0.h b/src/nunavut_out/uavcan/file/Error_1_0.h new file mode 100644 index 0000000..4a9daa5 --- /dev/null +++ b/src/nunavut_out/uavcan/file/Error_1_0.h @@ -0,0 +1,246 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.699163 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.file.Error +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_ERROR_1_0_INCLUDED_ +#define UAVCAN_FILE_ERROR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Error.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_file_Error_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_file_Error_1_0_FULL_NAME_ "uavcan.file.Error" +#define uavcan_file_Error_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Error.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Error_1_0_EXTENT_BYTES_ 2UL +#define uavcan_file_Error_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_file_Error_1_0_EXTENT_BYTES_ >= uavcan_file_Error_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 OK = 0 +#define uavcan_file_Error_1_0_OK (0U) +/// saturated uint16 UNKNOWN_ERROR = 65535 +#define uavcan_file_Error_1_0_UNKNOWN_ERROR (65535U) +/// saturated uint16 NOT_FOUND = 2 +#define uavcan_file_Error_1_0_NOT_FOUND (2U) +/// saturated uint16 IO_ERROR = 5 +#define uavcan_file_Error_1_0_IO_ERROR (5U) +/// saturated uint16 ACCESS_DENIED = 13 +#define uavcan_file_Error_1_0_ACCESS_DENIED (13U) +/// saturated uint16 IS_DIRECTORY = 21 +#define uavcan_file_Error_1_0_IS_DIRECTORY (21U) +/// saturated uint16 INVALID_VALUE = 22 +#define uavcan_file_Error_1_0_INVALID_VALUE (22U) +/// saturated uint16 FILE_TOO_LARGE = 27 +#define uavcan_file_Error_1_0_FILE_TOO_LARGE (27U) +/// saturated uint16 OUT_OF_SPACE = 28 +#define uavcan_file_Error_1_0_OUT_OF_SPACE (28U) +/// saturated uint16 NOT_SUPPORTED = 38 +#define uavcan_file_Error_1_0_NOT_SUPPORTED (38U) + +typedef struct +{ + /// saturated uint16 value + uint16_t value; +} uavcan_file_Error_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Error_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Error_1_0_serialize_( + const uavcan_file_Error_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Error_1_0_deserialize_( + uavcan_file_Error_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Error_1_0_initialize_(uavcan_file_Error_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Error_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_ERROR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/GetInfo_0_1.h b/src/nunavut_out/uavcan/file/GetInfo_0_1.h new file mode 100644 index 0000000..2153053 --- /dev/null +++ b/src/nunavut_out/uavcan/file/GetInfo_0_1.h @@ -0,0 +1,601 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.705333 UTC +// Is deprecated: yes +// Fixed port-ID: 405 +// Full name: uavcan.file.GetInfo +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_GET_INFO_0_1_INCLUDED_ +#define UAVCAN_FILE_GET_INFO_0_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_GetInfo_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_file_GetInfo_0_1_FIXED_PORT_ID_ 405U + +#define uavcan_file_GetInfo_0_1_FULL_NAME_ "uavcan.file.GetInfo" +#define uavcan_file_GetInfo_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.0.1" + +#define uavcan_file_GetInfo_Request_0_1_FULL_NAME_ "uavcan.file.GetInfo.Request" +#define uavcan_file_GetInfo_Request_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.Request.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_GetInfo_Request_0_1_EXTENT_BYTES_ 300UL +#define uavcan_file_GetInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 113UL +static_assert(uavcan_file_GetInfo_Request_0_1_EXTENT_BYTES_ >= uavcan_file_GetInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Path.1.0 path + uavcan_file_Path_1_0 path; +} uavcan_file_GetInfo_Request_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_GetInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Request_0_1_serialize_( + const uavcan_file_GetInfo_Request_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 904UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Path.1.0 path + size_t _size_bytes0_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_file_Path_1_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Request_0_1_deserialize_( + uavcan_file_GetInfo_Request_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Path.1.0 path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_GetInfo_Request_0_1_initialize_(uavcan_file_GetInfo_Request_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_GetInfo_Request_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_GetInfo_Response_0_1_FULL_NAME_ "uavcan.file.GetInfo.Response" +#define uavcan_file_GetInfo_Response_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.Response.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_GetInfo_Response_0_1_EXTENT_BYTES_ 48UL +#define uavcan_file_GetInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 13UL +static_assert(uavcan_file_GetInfo_Response_0_1_EXTENT_BYTES_ >= uavcan_file_GetInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; + + /// truncated uint40 size + uint64_t size; + + /// truncated uint40 unix_timestamp_of_last_modification + uint64_t unix_timestamp_of_last_modification; + + /// saturated bool is_file_not_directory + bool is_file_not_directory; + + /// saturated bool is_link + bool is_link; + + /// saturated bool is_readable + bool is_readable; + + /// saturated bool is_writeable + bool is_writeable; +} uavcan_file_GetInfo_Response_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_GetInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Response_0_1_serialize_( + const uavcan_file_GetInfo_Response_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 104UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // truncated uint40 size + (void) memmove(&buffer[offset_bits / 8U], &obj->size, 5U); + offset_bits += 40U; + } + + + + + { // truncated uint40 unix_timestamp_of_last_modification + (void) memmove(&buffer[offset_bits / 8U], &obj->unix_timestamp_of_last_modification, 5U); + offset_bits += 40U; + } + + + + + { // saturated bool is_file_not_directory + buffer[offset_bits / 8U] = obj->is_file_not_directory ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool is_link + if (obj->is_link) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool is_readable + if (obj->is_readable) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool is_writeable + if (obj->is_writeable) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void4 + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 4U); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += 4UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Response_0_1_deserialize_( + uavcan_file_GetInfo_Response_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // truncated uint40 size + out_obj->size = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // truncated uint40 unix_timestamp_of_last_modification + out_obj->unix_timestamp_of_last_modification = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // saturated bool is_file_not_directory + if (offset_bits < capacity_bits) + { + out_obj->is_file_not_directory = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->is_file_not_directory = false; + } + offset_bits += 1U; + + + + + // saturated bool is_link + if (offset_bits < capacity_bits) + { + out_obj->is_link = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_link = false; + } + offset_bits += 1U; + + + + + // saturated bool is_readable + if (offset_bits < capacity_bits) + { + out_obj->is_readable = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_readable = false; + } + offset_bits += 1U; + + + + + // saturated bool is_writeable + if (offset_bits < capacity_bits) + { + out_obj->is_writeable = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_writeable = false; + } + offset_bits += 1U; + + + + + // void4 + offset_bits += 4; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_GetInfo_Response_0_1_initialize_(uavcan_file_GetInfo_Response_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_GetInfo_Response_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_GET_INFO_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/GetInfo_0_2.h b/src/nunavut_out/uavcan/file/GetInfo_0_2.h new file mode 100644 index 0000000..8f1cd6a --- /dev/null +++ b/src/nunavut_out/uavcan/file/GetInfo_0_2.h @@ -0,0 +1,592 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.701050 UTC +// Is deprecated: no +// Fixed port-ID: 405 +// Full name: uavcan.file.GetInfo +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_GET_INFO_0_2_INCLUDED_ +#define UAVCAN_FILE_GET_INFO_0_2_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/405.GetInfo.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_GetInfo_0_2_HAS_FIXED_PORT_ID_ true +#define uavcan_file_GetInfo_0_2_FIXED_PORT_ID_ 405U + +#define uavcan_file_GetInfo_0_2_FULL_NAME_ "uavcan.file.GetInfo" +#define uavcan_file_GetInfo_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.0.2" + +#define uavcan_file_GetInfo_Request_0_2_FULL_NAME_ "uavcan.file.GetInfo.Request" +#define uavcan_file_GetInfo_Request_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.Request.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_GetInfo_Request_0_2_EXTENT_BYTES_ 300UL +#define uavcan_file_GetInfo_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 256UL +static_assert(uavcan_file_GetInfo_Request_0_2_EXTENT_BYTES_ >= uavcan_file_GetInfo_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Path.2.0 path + uavcan_file_Path_2_0 path; +} uavcan_file_GetInfo_Request_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_GetInfo_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Request_0_2_serialize_( + const uavcan_file_GetInfo_Request_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2048UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Path.2.0 path + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_file_Path_2_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Request_0_2_deserialize_( + uavcan_file_GetInfo_Request_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Path.2.0 path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_GetInfo_Request_0_2_initialize_(uavcan_file_GetInfo_Request_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_GetInfo_Request_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_GetInfo_Response_0_2_FULL_NAME_ "uavcan.file.GetInfo.Response" +#define uavcan_file_GetInfo_Response_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.GetInfo.Response.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_GetInfo_Response_0_2_EXTENT_BYTES_ 48UL +#define uavcan_file_GetInfo_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 13UL +static_assert(uavcan_file_GetInfo_Response_0_2_EXTENT_BYTES_ >= uavcan_file_GetInfo_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; + + /// truncated uint40 size + uint64_t size; + + /// truncated uint40 unix_timestamp_of_last_modification + uint64_t unix_timestamp_of_last_modification; + + /// saturated bool is_file_not_directory + bool is_file_not_directory; + + /// saturated bool is_link + bool is_link; + + /// saturated bool is_readable + bool is_readable; + + /// saturated bool is_writeable + bool is_writeable; +} uavcan_file_GetInfo_Response_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_GetInfo_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Response_0_2_serialize_( + const uavcan_file_GetInfo_Response_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 104UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // truncated uint40 size + (void) memmove(&buffer[offset_bits / 8U], &obj->size, 5U); + offset_bits += 40U; + } + + + + + { // truncated uint40 unix_timestamp_of_last_modification + (void) memmove(&buffer[offset_bits / 8U], &obj->unix_timestamp_of_last_modification, 5U); + offset_bits += 40U; + } + + + + + { // saturated bool is_file_not_directory + buffer[offset_bits / 8U] = obj->is_file_not_directory ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool is_link + if (obj->is_link) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool is_readable + if (obj->is_readable) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // saturated bool is_writeable + if (obj->is_writeable) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void4 + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 4U); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += 4UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_GetInfo_Response_0_2_deserialize_( + uavcan_file_GetInfo_Response_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // truncated uint40 size + out_obj->size = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // truncated uint40 unix_timestamp_of_last_modification + out_obj->unix_timestamp_of_last_modification = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // saturated bool is_file_not_directory + if (offset_bits < capacity_bits) + { + out_obj->is_file_not_directory = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->is_file_not_directory = false; + } + offset_bits += 1U; + + + + + // saturated bool is_link + if (offset_bits < capacity_bits) + { + out_obj->is_link = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_link = false; + } + offset_bits += 1U; + + + + + // saturated bool is_readable + if (offset_bits < capacity_bits) + { + out_obj->is_readable = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_readable = false; + } + offset_bits += 1U; + + + + + // saturated bool is_writeable + if (offset_bits < capacity_bits) + { + out_obj->is_writeable = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->is_writeable = false; + } + offset_bits += 1U; + + + + + // void4 + offset_bits += 4; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_GetInfo_Response_0_2_initialize_(uavcan_file_GetInfo_Response_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_GetInfo_Response_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_GET_INFO_0_2_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/List_0_1.h b/src/nunavut_out/uavcan/file/List_0_1.h new file mode 100644 index 0000000..c2b485b --- /dev/null +++ b/src/nunavut_out/uavcan/file/List_0_1.h @@ -0,0 +1,490 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.712605 UTC +// Is deprecated: yes +// Fixed port-ID: 406 +// Full name: uavcan.file.List +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_LIST_0_1_INCLUDED_ +#define UAVCAN_FILE_LIST_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_List_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_file_List_0_1_FIXED_PORT_ID_ 406U + +#define uavcan_file_List_0_1_FULL_NAME_ "uavcan.file.List" +#define uavcan_file_List_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.List.0.1" + +#define uavcan_file_List_Request_0_1_FULL_NAME_ "uavcan.file.List.Request" +#define uavcan_file_List_Request_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.List.Request.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_List_Request_0_1_EXTENT_BYTES_ 300UL +#define uavcan_file_List_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 121UL +static_assert(uavcan_file_List_Request_0_1_EXTENT_BYTES_ >= uavcan_file_List_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 entry_index + uint32_t entry_index; + + /// uavcan.file.Path.1.0 directory_path + uavcan_file_Path_1_0 directory_path; +} uavcan_file_List_Request_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_List_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Request_0_1_serialize_( + const uavcan_file_List_Request_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 968UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 entry_index + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->entry_index, 4U); + offset_bits += 32U; + } + + + + + { // void32 + (void) memset(&buffer[offset_bits / 8U], 0, 4); + offset_bits += 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.1.0 directory_path + size_t _size_bytes0_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_1_0_serialize_( + &obj->directory_path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Request_0_1_deserialize_( + uavcan_file_List_Request_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 entry_index + out_obj->entry_index = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // void32 + offset_bits += 32; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 directory_path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->directory_path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_List_Request_0_1_initialize_(uavcan_file_List_Request_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_List_Request_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_List_Response_0_1_FULL_NAME_ "uavcan.file.List.Response" +#define uavcan_file_List_Response_0_1_FULL_NAME_AND_VERSION_ "uavcan.file.List.Response.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_List_Response_0_1_EXTENT_BYTES_ 300UL +#define uavcan_file_List_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 117UL +static_assert(uavcan_file_List_Response_0_1_EXTENT_BYTES_ >= uavcan_file_List_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Path.1.0 entry_base_name + uavcan_file_Path_1_0 entry_base_name; +} uavcan_file_List_Response_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_List_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Response_0_1_serialize_( + const uavcan_file_List_Response_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 936UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // void32 + (void) memset(&buffer[offset_bits / 8U], 0, 4); + offset_bits += 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + + { // uavcan.file.Path.1.0 entry_base_name + size_t _size_bytes2_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err5_ = uavcan_file_Path_1_0_serialize_( + &obj->entry_base_name, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err6_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Response_0_1_deserialize_( + uavcan_file_List_Response_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // void32 + offset_bits += 32; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 entry_base_name + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->entry_base_name, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_List_Response_0_1_initialize_(uavcan_file_List_Response_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_List_Response_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_LIST_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/List_0_2.h b/src/nunavut_out/uavcan/file/List_0_2.h new file mode 100644 index 0000000..afe57f0 --- /dev/null +++ b/src/nunavut_out/uavcan/file/List_0_2.h @@ -0,0 +1,481 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.709277 UTC +// Is deprecated: no +// Fixed port-ID: 406 +// Full name: uavcan.file.List +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_LIST_0_2_INCLUDED_ +#define UAVCAN_FILE_LIST_0_2_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/406.List.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_List_0_2_HAS_FIXED_PORT_ID_ true +#define uavcan_file_List_0_2_FIXED_PORT_ID_ 406U + +#define uavcan_file_List_0_2_FULL_NAME_ "uavcan.file.List" +#define uavcan_file_List_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.List.0.2" + +#define uavcan_file_List_Request_0_2_FULL_NAME_ "uavcan.file.List.Request" +#define uavcan_file_List_Request_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.List.Request.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_List_Request_0_2_EXTENT_BYTES_ 300UL +#define uavcan_file_List_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 264UL +static_assert(uavcan_file_List_Request_0_2_EXTENT_BYTES_ >= uavcan_file_List_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 entry_index + uint32_t entry_index; + + /// uavcan.file.Path.2.0 directory_path + uavcan_file_Path_2_0 directory_path; +} uavcan_file_List_Request_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_List_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Request_0_2_serialize_( + const uavcan_file_List_Request_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2112UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 entry_index + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->entry_index, 4U); + offset_bits += 32U; + } + + + + + { // void32 + (void) memset(&buffer[offset_bits / 8U], 0, 4); + offset_bits += 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.2.0 directory_path + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_2_0_serialize_( + &obj->directory_path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Request_0_2_deserialize_( + uavcan_file_List_Request_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 entry_index + out_obj->entry_index = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // void32 + offset_bits += 32; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 directory_path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->directory_path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_List_Request_0_2_initialize_(uavcan_file_List_Request_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_List_Request_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_List_Response_0_2_FULL_NAME_ "uavcan.file.List.Response" +#define uavcan_file_List_Response_0_2_FULL_NAME_AND_VERSION_ "uavcan.file.List.Response.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_List_Response_0_2_EXTENT_BYTES_ 300UL +#define uavcan_file_List_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 260UL +static_assert(uavcan_file_List_Response_0_2_EXTENT_BYTES_ >= uavcan_file_List_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Path.2.0 entry_base_name + uavcan_file_Path_2_0 entry_base_name; +} uavcan_file_List_Response_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_List_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Response_0_2_serialize_( + const uavcan_file_List_Response_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2080UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // void32 + (void) memset(&buffer[offset_bits / 8U], 0, 4); + offset_bits += 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + + { // uavcan.file.Path.2.0 entry_base_name + size_t _size_bytes2_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err5_ = uavcan_file_Path_2_0_serialize_( + &obj->entry_base_name, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err6_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_List_Response_0_2_deserialize_( + uavcan_file_List_Response_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // void32 + offset_bits += 32; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 entry_base_name + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->entry_base_name, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_List_Response_0_2_initialize_(uavcan_file_List_Response_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_List_Response_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_LIST_0_2_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Modify_1_0.h b/src/nunavut_out/uavcan/file/Modify_1_0.h new file mode 100644 index 0000000..386e59f --- /dev/null +++ b/src/nunavut_out/uavcan/file/Modify_1_0.h @@ -0,0 +1,551 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.719420 UTC +// Is deprecated: yes +// Fixed port-ID: 407 +// Full name: uavcan.file.Modify +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_MODIFY_1_0_INCLUDED_ +#define UAVCAN_FILE_MODIFY_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Modify_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Modify_1_0_FIXED_PORT_ID_ 407U + +#define uavcan_file_Modify_1_0_FULL_NAME_ "uavcan.file.Modify" +#define uavcan_file_Modify_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.1.0" + +#define uavcan_file_Modify_Request_1_0_FULL_NAME_ "uavcan.file.Modify.Request" +#define uavcan_file_Modify_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Modify_Request_1_0_EXTENT_BYTES_ 600UL +#define uavcan_file_Modify_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 230UL +static_assert(uavcan_file_Modify_Request_1_0_EXTENT_BYTES_ >= uavcan_file_Modify_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated bool preserve_source + bool preserve_source; + + /// saturated bool overwrite_destination + bool overwrite_destination; + + /// uavcan.file.Path.1.0 source + uavcan_file_Path_1_0 source; + + /// uavcan.file.Path.1.0 destination + uavcan_file_Path_1_0 destination; +} uavcan_file_Modify_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Modify_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Request_1_0_serialize_( + const uavcan_file_Modify_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 1840UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool preserve_source + buffer[offset_bits / 8U] = obj->preserve_source ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool overwrite_destination + if (obj->overwrite_destination) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void30 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 30U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 30UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.1.0 source + size_t _size_bytes0_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_file_Path_1_0_serialize_( + &obj->source, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.file.Path.1.0 destination + size_t _size_bytes1_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_file_Path_1_0_serialize_( + &obj->destination, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Request_1_0_deserialize_( + uavcan_file_Modify_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool preserve_source + if (offset_bits < capacity_bits) + { + out_obj->preserve_source = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->preserve_source = false; + } + offset_bits += 1U; + + + + + // saturated bool overwrite_destination + if (offset_bits < capacity_bits) + { + out_obj->overwrite_destination = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->overwrite_destination = false; + } + offset_bits += 1U; + + + + + // void30 + offset_bits += 30; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 source + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->source, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 destination + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->destination, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Modify_Request_1_0_initialize_(uavcan_file_Modify_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Modify_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Modify_Response_1_0_FULL_NAME_ "uavcan.file.Modify.Response" +#define uavcan_file_Modify_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Modify_Response_1_0_EXTENT_BYTES_ 48UL +#define uavcan_file_Modify_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_file_Modify_Response_1_0_EXTENT_BYTES_ >= uavcan_file_Modify_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; +} uavcan_file_Modify_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Modify_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Response_1_0_serialize_( + const uavcan_file_Modify_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes4_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err8_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err9_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Response_1_0_deserialize_( + uavcan_file_Modify_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err10_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Modify_Response_1_0_initialize_(uavcan_file_Modify_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Modify_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_MODIFY_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Modify_1_1.h b/src/nunavut_out/uavcan/file/Modify_1_1.h new file mode 100644 index 0000000..2e587a4 --- /dev/null +++ b/src/nunavut_out/uavcan/file/Modify_1_1.h @@ -0,0 +1,542 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.715777 UTC +// Is deprecated: no +// Fixed port-ID: 407 +// Full name: uavcan.file.Modify +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_MODIFY_1_1_INCLUDED_ +#define UAVCAN_FILE_MODIFY_1_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/407.Modify.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Modify_1_1_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Modify_1_1_FIXED_PORT_ID_ 407U + +#define uavcan_file_Modify_1_1_FULL_NAME_ "uavcan.file.Modify" +#define uavcan_file_Modify_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.1.1" + +#define uavcan_file_Modify_Request_1_1_FULL_NAME_ "uavcan.file.Modify.Request" +#define uavcan_file_Modify_Request_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.Request.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Modify_Request_1_1_EXTENT_BYTES_ 600UL +#define uavcan_file_Modify_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 516UL +static_assert(uavcan_file_Modify_Request_1_1_EXTENT_BYTES_ >= uavcan_file_Modify_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated bool preserve_source + bool preserve_source; + + /// saturated bool overwrite_destination + bool overwrite_destination; + + /// uavcan.file.Path.2.0 source + uavcan_file_Path_2_0 source; + + /// uavcan.file.Path.2.0 destination + uavcan_file_Path_2_0 destination; +} uavcan_file_Modify_Request_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Modify_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Request_1_1_serialize_( + const uavcan_file_Modify_Request_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool preserve_source + buffer[offset_bits / 8U] = obj->preserve_source ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool overwrite_destination + if (obj->overwrite_destination) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void30 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 30U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 30UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.2.0 source + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_file_Path_2_0_serialize_( + &obj->source, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.file.Path.2.0 destination + size_t _size_bytes1_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_file_Path_2_0_serialize_( + &obj->destination, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Request_1_1_deserialize_( + uavcan_file_Modify_Request_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool preserve_source + if (offset_bits < capacity_bits) + { + out_obj->preserve_source = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->preserve_source = false; + } + offset_bits += 1U; + + + + + // saturated bool overwrite_destination + if (offset_bits < capacity_bits) + { + out_obj->overwrite_destination = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->overwrite_destination = false; + } + offset_bits += 1U; + + + + + // void30 + offset_bits += 30; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 source + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->source, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 destination + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->destination, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Modify_Request_1_1_initialize_(uavcan_file_Modify_Request_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Modify_Request_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Modify_Response_1_1_FULL_NAME_ "uavcan.file.Modify.Response" +#define uavcan_file_Modify_Response_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Modify.Response.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Modify_Response_1_1_EXTENT_BYTES_ 48UL +#define uavcan_file_Modify_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_file_Modify_Response_1_1_EXTENT_BYTES_ >= uavcan_file_Modify_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; +} uavcan_file_Modify_Response_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Modify_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Response_1_1_serialize_( + const uavcan_file_Modify_Response_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes4_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err8_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err9_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Modify_Response_1_1_deserialize_( + uavcan_file_Modify_Response_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err10_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err10_ < 0) + { + return _err10_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Modify_Response_1_1_initialize_(uavcan_file_Modify_Response_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Modify_Response_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_MODIFY_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Path_1_0.h b/src/nunavut_out/uavcan/file/Path_1_0.h new file mode 100644 index 0000000..7b2d6b9 --- /dev/null +++ b/src/nunavut_out/uavcan/file/Path_1_0.h @@ -0,0 +1,269 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.724816 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.file.Path +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_PATH_1_0_INCLUDED_ +#define UAVCAN_FILE_PATH_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_file_Path_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_file_Path_1_0_FULL_NAME_ "uavcan.file.Path" +#define uavcan_file_Path_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Path.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Path_1_0_EXTENT_BYTES_ 113UL +#define uavcan_file_Path_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 113UL +static_assert(uavcan_file_Path_1_0_EXTENT_BYTES_ >= uavcan_file_Path_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 SEPARATOR = 47 +#define uavcan_file_Path_1_0_SEPARATOR (47U) +/// saturated uint8 MAX_LENGTH = 112 +#define uavcan_file_Path_1_0_MAX_LENGTH (112U) + +/// Array metadata for: saturated uint8[<=112] path +#define uavcan_file_Path_1_0_path_ARRAY_CAPACITY_ 112U +#define uavcan_file_Path_1_0_path_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=112] path + struct /// Array address equivalence guarantee: &elements[0] == &path + { + uint8_t elements[uavcan_file_Path_1_0_path_ARRAY_CAPACITY_]; + size_t count; + } path; +} uavcan_file_Path_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Path_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Path_1_0_serialize_( + const uavcan_file_Path_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 904UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=112] path + if (obj->path.count > 112) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->path.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->path.count * 8U, &obj->path.elements[0], 0U); + offset_bits += obj->path.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Path_1_0_deserialize_( + uavcan_file_Path_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=112] path + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->path.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->path.count = 0U; + } + offset_bits += 8U; + if (out_obj->path.count > 112U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->path.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->path.count * 8U); + offset_bits += out_obj->path.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Path_1_0_initialize_(uavcan_file_Path_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Path_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_PATH_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Path_2_0.h b/src/nunavut_out/uavcan/file/Path_2_0.h new file mode 100644 index 0000000..35fd68f --- /dev/null +++ b/src/nunavut_out/uavcan/file/Path_2_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl +// Generated at: 2024-11-23 10:35:29.723023 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.file.Path +// Version: 2.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_PATH_2_0_INCLUDED_ +#define UAVCAN_FILE_PATH_2_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/Path.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_file_Path_2_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_file_Path_2_0_FULL_NAME_ "uavcan.file.Path" +#define uavcan_file_Path_2_0_FULL_NAME_AND_VERSION_ "uavcan.file.Path.2.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Path_2_0_EXTENT_BYTES_ 256UL +#define uavcan_file_Path_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 256UL +static_assert(uavcan_file_Path_2_0_EXTENT_BYTES_ >= uavcan_file_Path_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 SEPARATOR = 47 +#define uavcan_file_Path_2_0_SEPARATOR (47U) +/// saturated uint8 MAX_LENGTH = 255 +#define uavcan_file_Path_2_0_MAX_LENGTH (255U) + +/// Array metadata for: saturated uint8[<=255] path +#define uavcan_file_Path_2_0_path_ARRAY_CAPACITY_ 255U +#define uavcan_file_Path_2_0_path_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=255] path + struct /// Array address equivalence guarantee: &elements[0] == &path + { + uint8_t elements[uavcan_file_Path_2_0_path_ARRAY_CAPACITY_]; + size_t count; + } path; +} uavcan_file_Path_2_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Path_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Path_2_0_serialize_( + const uavcan_file_Path_2_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2048UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=255] path + if (obj->path.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->path.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->path.count * 8U, &obj->path.elements[0], 0U); + offset_bits += obj->path.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Path_2_0_deserialize_( + uavcan_file_Path_2_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=255] path + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->path.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->path.count = 0U; + } + offset_bits += 8U; + if (out_obj->path.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->path.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->path.count * 8U); + offset_bits += out_obj->path.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Path_2_0_initialize_(uavcan_file_Path_2_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Path_2_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_PATH_2_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Read_1_0.h b/src/nunavut_out/uavcan/file/Read_1_0.h new file mode 100644 index 0000000..f054afe --- /dev/null +++ b/src/nunavut_out/uavcan/file/Read_1_0.h @@ -0,0 +1,494 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.729820 UTC +// Is deprecated: yes +// Fixed port-ID: 408 +// Full name: uavcan.file.Read +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_READ_1_0_INCLUDED_ +#define UAVCAN_FILE_READ_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Read_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Read_1_0_FIXED_PORT_ID_ 408U + +#define uavcan_file_Read_1_0_FULL_NAME_ "uavcan.file.Read" +#define uavcan_file_Read_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Read.1.0" + +#define uavcan_file_Read_Request_1_0_FULL_NAME_ "uavcan.file.Read.Request" +#define uavcan_file_Read_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Read.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Read_Request_1_0_EXTENT_BYTES_ 300UL +#define uavcan_file_Read_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 118UL +static_assert(uavcan_file_Read_Request_1_0_EXTENT_BYTES_ >= uavcan_file_Read_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint40 offset + uint64_t offset; + + /// uavcan.file.Path.1.0 path + uavcan_file_Path_1_0 path; +} uavcan_file_Read_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Read_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Request_1_0_serialize_( + const uavcan_file_Read_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 944UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint40 offset + (void) memmove(&buffer[offset_bits / 8U], &obj->offset, 5U); + offset_bits += 40U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.1.0 path + size_t _size_bytes0_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_1_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Request_1_0_deserialize_( + uavcan_file_Read_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint40 offset + out_obj->offset = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Read_Request_1_0_initialize_(uavcan_file_Read_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Read_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Read_Response_1_0_FULL_NAME_ "uavcan.file.Read.Response" +#define uavcan_file_Read_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Read.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Read_Response_1_0_EXTENT_BYTES_ 300UL +#define uavcan_file_Read_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 260UL +static_assert(uavcan_file_Read_Response_1_0_EXTENT_BYTES_ >= uavcan_file_Read_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=256] data +#define uavcan_file_Read_Response_1_0_data_ARRAY_CAPACITY_ 256U +#define uavcan_file_Read_Response_1_0_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; + + /// saturated uint8[<=256] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_file_Read_Response_1_0_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_file_Read_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Read_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Response_1_0_serialize_( + const uavcan_file_Read_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2080UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=256] data + if (obj->data.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->data.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Response_1_0_deserialize_( + uavcan_file_Read_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=256] data + // Array length prefix: truncated uint16 + out_obj->data.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->data.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Read_Response_1_0_initialize_(uavcan_file_Read_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Read_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_READ_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Read_1_1.h b/src/nunavut_out/uavcan/file/Read_1_1.h new file mode 100644 index 0000000..db85637 --- /dev/null +++ b/src/nunavut_out/uavcan/file/Read_1_1.h @@ -0,0 +1,487 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.726558 UTC +// Is deprecated: no +// Fixed port-ID: 408 +// Full name: uavcan.file.Read +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_READ_1_1_INCLUDED_ +#define UAVCAN_FILE_READ_1_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/408.Read.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Read_1_1_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Read_1_1_FIXED_PORT_ID_ 408U + +#define uavcan_file_Read_1_1_FULL_NAME_ "uavcan.file.Read" +#define uavcan_file_Read_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Read.1.1" + +#define uavcan_file_Read_Request_1_1_FULL_NAME_ "uavcan.file.Read.Request" +#define uavcan_file_Read_Request_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Read.Request.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Read_Request_1_1_EXTENT_BYTES_ 300UL +#define uavcan_file_Read_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 261UL +static_assert(uavcan_file_Read_Request_1_1_EXTENT_BYTES_ >= uavcan_file_Read_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint40 offset + uint64_t offset; + + /// uavcan.file.Path.2.0 path + uavcan_file_Path_2_0 path; +} uavcan_file_Read_Request_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Read_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Request_1_1_serialize_( + const uavcan_file_Read_Request_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2088UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint40 offset + (void) memmove(&buffer[offset_bits / 8U], &obj->offset, 5U); + offset_bits += 40U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.2.0 path + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_2_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Request_1_1_deserialize_( + uavcan_file_Read_Request_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint40 offset + out_obj->offset = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Read_Request_1_1_initialize_(uavcan_file_Read_Request_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Read_Request_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Read_Response_1_1_FULL_NAME_ "uavcan.file.Read.Response" +#define uavcan_file_Read_Response_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Read.Response.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Read_Response_1_1_EXTENT_BYTES_ 300UL +#define uavcan_file_Read_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 260UL +static_assert(uavcan_file_Read_Response_1_1_EXTENT_BYTES_ >= uavcan_file_Read_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; + + /// uavcan.primitive.Unstructured.1.0 data + uavcan_primitive_Unstructured_1_0 data; +} uavcan_file_Read_Response_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Read_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Response_1_1_serialize_( + const uavcan_file_Read_Response_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2080UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + + { // uavcan.primitive.Unstructured.1.0 data + size_t _size_bytes3_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err6_ = uavcan_primitive_Unstructured_1_0_serialize_( + &obj->data, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Read_Response_1_1_deserialize_( + uavcan_file_Read_Response_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.primitive.Unstructured.1.0 data + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err9_ = uavcan_primitive_Unstructured_1_0_deserialize_( + &out_obj->data, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Read_Response_1_1_initialize_(uavcan_file_Read_Response_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Read_Response_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_READ_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Write_1_0.h b/src/nunavut_out/uavcan/file/Write_1_0.h new file mode 100644 index 0000000..6c63e0e --- /dev/null +++ b/src/nunavut_out/uavcan/file/Write_1_0.h @@ -0,0 +1,500 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.736392 UTC +// Is deprecated: yes +// Fixed port-ID: 409 +// Full name: uavcan.file.Write +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_FILE_WRITE_1_0_INCLUDED_ +#define UAVCAN_FILE_WRITE_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Write_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Write_1_0_FIXED_PORT_ID_ 409U + +#define uavcan_file_Write_1_0_FULL_NAME_ "uavcan.file.Write" +#define uavcan_file_Write_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Write.1.0" + +#define uavcan_file_Write_Request_1_0_FULL_NAME_ "uavcan.file.Write.Request" +#define uavcan_file_Write_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Write.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Write_Request_1_0_EXTENT_BYTES_ 600UL +#define uavcan_file_Write_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 311UL +static_assert(uavcan_file_Write_Request_1_0_EXTENT_BYTES_ >= uavcan_file_Write_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=192] data +#define uavcan_file_Write_Request_1_0_data_ARRAY_CAPACITY_ 192U +#define uavcan_file_Write_Request_1_0_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// truncated uint40 offset + uint64_t offset; + + /// uavcan.file.Path.1.0 path + uavcan_file_Path_1_0 path; + + /// saturated uint8[<=192] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_file_Write_Request_1_0_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_file_Write_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Write_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Request_1_0_serialize_( + const uavcan_file_Write_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2488UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint40 offset + (void) memmove(&buffer[offset_bits / 8U], &obj->offset, 5U); + offset_bits += 40U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.1.0 path + size_t _size_bytes0_ = 113UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_1_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=192] data + if (obj->data.count > 192) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->data.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Request_1_0_deserialize_( + uavcan_file_Write_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint40 offset + out_obj->offset = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.1.0 path + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_file_Path_1_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=192] data + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->data.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->data.count = 0U; + } + offset_bits += 8U; + if (out_obj->data.count > 192U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Write_Request_1_0_initialize_(uavcan_file_Write_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Write_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Write_Response_1_0_FULL_NAME_ "uavcan.file.Write.Response" +#define uavcan_file_Write_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.file.Write.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Write_Response_1_0_EXTENT_BYTES_ 48UL +#define uavcan_file_Write_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_file_Write_Response_1_0_EXTENT_BYTES_ >= uavcan_file_Write_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; +} uavcan_file_Write_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Write_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Response_1_0_serialize_( + const uavcan_file_Write_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Response_1_0_deserialize_( + uavcan_file_Write_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Write_Response_1_0_initialize_(uavcan_file_Write_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Write_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_WRITE_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/file/Write_1_1.h b/src/nunavut_out/uavcan/file/Write_1_1.h new file mode 100644 index 0000000..da4115c --- /dev/null +++ b/src/nunavut_out/uavcan/file/Write_1_1.h @@ -0,0 +1,486 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.733178 UTC +// Is deprecated: no +// Fixed port-ID: 409 +// Full name: uavcan.file.Write +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_FILE_WRITE_1_1_INCLUDED_ +#define UAVCAN_FILE_WRITE_1_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/file/409.Write.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_file_Write_1_1_HAS_FIXED_PORT_ID_ true +#define uavcan_file_Write_1_1_FIXED_PORT_ID_ 409U + +#define uavcan_file_Write_1_1_FULL_NAME_ "uavcan.file.Write" +#define uavcan_file_Write_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Write.1.1" + +#define uavcan_file_Write_Request_1_1_FULL_NAME_ "uavcan.file.Write.Request" +#define uavcan_file_Write_Request_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Write.Request.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Write_Request_1_1_EXTENT_BYTES_ 600UL +#define uavcan_file_Write_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 519UL +static_assert(uavcan_file_Write_Request_1_1_EXTENT_BYTES_ >= uavcan_file_Write_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint40 offset + uint64_t offset; + + /// uavcan.file.Path.2.0 path + uavcan_file_Path_2_0 path; + + /// uavcan.primitive.Unstructured.1.0 data + uavcan_primitive_Unstructured_1_0 data; +} uavcan_file_Write_Request_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Write_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Request_1_1_serialize_( + const uavcan_file_Write_Request_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint40 offset + (void) memmove(&buffer[offset_bits / 8U], &obj->offset, 5U); + offset_bits += 40U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.file.Path.2.0 path + size_t _size_bytes0_ = 256UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_file_Path_2_0_serialize_( + &obj->path, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + + { // uavcan.primitive.Unstructured.1.0 data + size_t _size_bytes1_ = 258UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_primitive_Unstructured_1_0_serialize_( + &obj->data, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Request_1_1_deserialize_( + uavcan_file_Write_Request_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint40 offset + out_obj->offset = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.file.Path.2.0 path + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_file_Path_2_0_deserialize_( + &out_obj->path, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.primitive.Unstructured.1.0 data + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_primitive_Unstructured_1_0_deserialize_( + &out_obj->data, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Write_Request_1_1_initialize_(uavcan_file_Write_Request_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Write_Request_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_file_Write_Response_1_1_FULL_NAME_ "uavcan.file.Write.Response" +#define uavcan_file_Write_Response_1_1_FULL_NAME_AND_VERSION_ "uavcan.file.Write.Response.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_file_Write_Response_1_1_EXTENT_BYTES_ 48UL +#define uavcan_file_Write_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_file_Write_Response_1_1_EXTENT_BYTES_ >= uavcan_file_Write_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.file.Error.1.0 error + uavcan_file_Error_1_0 _error; +} uavcan_file_Write_Response_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_file_Write_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Response_1_1_serialize_( + const uavcan_file_Write_Response_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.file.Error.1.0 error + size_t _size_bytes4_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err7_ = uavcan_file_Error_1_0_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err8_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_file_Write_Response_1_1_deserialize_( + uavcan_file_Write_Response_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.file.Error.1.0 error + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err9_ = uavcan_file_Error_1_0_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_file_Write_Response_1_1_initialize_(uavcan_file_Write_Response_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_file_Write_Response_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_FILE_WRITE_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_1.h b/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_1.h new file mode 100644 index 0000000..23793bf --- /dev/null +++ b/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_1.h @@ -0,0 +1,382 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.510669 UTC +// Is deprecated: yes +// Fixed port-ID: 500 +// Full name: uavcan.internet.udp.HandleIncomingPacket +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_1_INCLUDED_ +#define UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_internet_udp_HandleIncomingPacket_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_internet_udp_HandleIncomingPacket_0_1_FIXED_PORT_ID_ 500U + +#define uavcan_internet_udp_HandleIncomingPacket_0_1_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket" +#define uavcan_internet_udp_HandleIncomingPacket_0_1_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.0.1" + +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket.Request" +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.Request.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_EXTENT_BYTES_ 600UL +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 313UL +static_assert(uavcan_internet_udp_HandleIncomingPacket_Request_0_1_EXTENT_BYTES_ >= uavcan_internet_udp_HandleIncomingPacket_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=309] payload +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_payload_ARRAY_CAPACITY_ 309U +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_1_payload_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 session_id + uint16_t session_id; + + /// saturated uint8[<=309] payload + struct /// Array address equivalence guarantee: &elements[0] == &payload + { + uint8_t elements[uavcan_internet_udp_HandleIncomingPacket_Request_0_1_payload_ARRAY_CAPACITY_]; + size_t count; + } payload; +} uavcan_internet_udp_HandleIncomingPacket_Request_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_HandleIncomingPacket_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Request_0_1_serialize_( + const uavcan_internet_udp_HandleIncomingPacket_Request_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2504UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 session_id + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->session_id, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=309] payload + if (obj->payload.count > 309) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->payload.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->payload.count * 8U, &obj->payload.elements[0], 0U); + offset_bits += obj->payload.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Request_0_1_deserialize_( + uavcan_internet_udp_HandleIncomingPacket_Request_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 session_id + out_obj->session_id = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=309] payload + // Array length prefix: truncated uint16 + out_obj->payload.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->payload.count > 309U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->payload.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->payload.count * 8U); + offset_bits += out_obj->payload.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_HandleIncomingPacket_Request_0_1_initialize_(uavcan_internet_udp_HandleIncomingPacket_Request_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_HandleIncomingPacket_Request_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_1_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket.Response" +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_1_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.Response.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_1_EXTENT_BYTES_ 63UL +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_internet_udp_HandleIncomingPacket_Response_0_1_EXTENT_BYTES_ >= uavcan_internet_udp_HandleIncomingPacket_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_internet_udp_HandleIncomingPacket_Response_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_HandleIncomingPacket_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Response_0_1_serialize_( + const uavcan_internet_udp_HandleIncomingPacket_Response_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Response_0_1_deserialize_( + uavcan_internet_udp_HandleIncomingPacket_Response_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_HandleIncomingPacket_Response_0_1_initialize_(uavcan_internet_udp_HandleIncomingPacket_Response_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_HandleIncomingPacket_Response_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_2.h b/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_2.h new file mode 100644 index 0000000..ffec1f7 --- /dev/null +++ b/src/nunavut_out/uavcan/internet/udp/HandleIncomingPacket_0_2.h @@ -0,0 +1,373 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.508030 UTC +// Is deprecated: no +// Fixed port-ID: 500 +// Full name: uavcan.internet.udp.HandleIncomingPacket +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_2_INCLUDED_ +#define UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_2_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/500.HandleIncomingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_internet_udp_HandleIncomingPacket_0_2_HAS_FIXED_PORT_ID_ true +#define uavcan_internet_udp_HandleIncomingPacket_0_2_FIXED_PORT_ID_ 500U + +#define uavcan_internet_udp_HandleIncomingPacket_0_2_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket" +#define uavcan_internet_udp_HandleIncomingPacket_0_2_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.0.2" + +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket.Request" +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.Request.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_EXTENT_BYTES_ 600UL +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 512UL +static_assert(uavcan_internet_udp_HandleIncomingPacket_Request_0_2_EXTENT_BYTES_ >= uavcan_internet_udp_HandleIncomingPacket_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=508] payload +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_payload_ARRAY_CAPACITY_ 508U +#define uavcan_internet_udp_HandleIncomingPacket_Request_0_2_payload_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 session_id + uint16_t session_id; + + /// saturated uint8[<=508] payload + struct /// Array address equivalence guarantee: &elements[0] == &payload + { + uint8_t elements[uavcan_internet_udp_HandleIncomingPacket_Request_0_2_payload_ARRAY_CAPACITY_]; + size_t count; + } payload; +} uavcan_internet_udp_HandleIncomingPacket_Request_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_HandleIncomingPacket_Request_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Request_0_2_serialize_( + const uavcan_internet_udp_HandleIncomingPacket_Request_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4096UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 session_id + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->session_id, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=508] payload + if (obj->payload.count > 508) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->payload.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->payload.count * 8U, &obj->payload.elements[0], 0U); + offset_bits += obj->payload.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Request_0_2_deserialize_( + uavcan_internet_udp_HandleIncomingPacket_Request_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 session_id + out_obj->session_id = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=508] payload + // Array length prefix: truncated uint16 + out_obj->payload.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->payload.count > 508U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->payload.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->payload.count * 8U); + offset_bits += out_obj->payload.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_HandleIncomingPacket_Request_0_2_initialize_(uavcan_internet_udp_HandleIncomingPacket_Request_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_HandleIncomingPacket_Request_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_2_FULL_NAME_ "uavcan.internet.udp.HandleIncomingPacket.Response" +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_2_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.HandleIncomingPacket.Response.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_2_EXTENT_BYTES_ 63UL +#define uavcan_internet_udp_HandleIncomingPacket_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_internet_udp_HandleIncomingPacket_Response_0_2_EXTENT_BYTES_ >= uavcan_internet_udp_HandleIncomingPacket_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_internet_udp_HandleIncomingPacket_Response_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_HandleIncomingPacket_Response_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Response_0_2_serialize_( + const uavcan_internet_udp_HandleIncomingPacket_Response_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_HandleIncomingPacket_Response_0_2_deserialize_( + uavcan_internet_udp_HandleIncomingPacket_Response_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_HandleIncomingPacket_Response_0_2_initialize_(uavcan_internet_udp_HandleIncomingPacket_Response_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_HandleIncomingPacket_Response_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_INTERNET_UDP_HANDLE_INCOMING_PACKET_0_2_INCLUDED_ diff --git a/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_1.h b/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_1.h new file mode 100644 index 0000000..643c1ab --- /dev/null +++ b/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_1.h @@ -0,0 +1,422 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.516271 UTC +// Is deprecated: yes +// Fixed port-ID: 8174 +// Full name: uavcan.internet.udp.OutgoingPacket +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_1_INCLUDED_ +#define UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_internet_udp_OutgoingPacket_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_internet_udp_OutgoingPacket_0_1_FIXED_PORT_ID_ 8174U + +#define uavcan_internet_udp_OutgoingPacket_0_1_FULL_NAME_ "uavcan.internet.udp.OutgoingPacket" +#define uavcan_internet_udp_OutgoingPacket_0_1_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.OutgoingPacket.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_OutgoingPacket_0_1_EXTENT_BYTES_ 600UL +#define uavcan_internet_udp_OutgoingPacket_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 313UL +static_assert(uavcan_internet_udp_OutgoingPacket_0_1_EXTENT_BYTES_ >= uavcan_internet_udp_OutgoingPacket_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint32 NAT_ENTRY_MIN_TTL = 86400 +#define uavcan_internet_udp_OutgoingPacket_0_1_NAT_ENTRY_MIN_TTL (86400UL) + +/// Array metadata for: saturated uint8[<=45] destination_address +#define uavcan_internet_udp_OutgoingPacket_0_1_destination_address_ARRAY_CAPACITY_ 45U +#define uavcan_internet_udp_OutgoingPacket_0_1_destination_address_ARRAY_IS_VARIABLE_LENGTH_ true +/// Array metadata for: saturated uint8[<=260] payload +#define uavcan_internet_udp_OutgoingPacket_0_1_payload_ARRAY_CAPACITY_ 260U +#define uavcan_internet_udp_OutgoingPacket_0_1_payload_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 session_id + uint16_t session_id; + + /// saturated uint16 destination_port + uint16_t destination_port; + + /// saturated uint8[<=45] destination_address + struct /// Array address equivalence guarantee: &elements[0] == &destination_address + { + uint8_t elements[uavcan_internet_udp_OutgoingPacket_0_1_destination_address_ARRAY_CAPACITY_]; + size_t count; + } destination_address; + + /// saturated bool use_masquerading + bool use_masquerading; + + /// saturated bool use_dtls + bool use_dtls; + + /// saturated uint8[<=260] payload + struct /// Array address equivalence guarantee: &elements[0] == &payload + { + uint8_t elements[uavcan_internet_udp_OutgoingPacket_0_1_payload_ARRAY_CAPACITY_]; + size_t count; + } payload; +} uavcan_internet_udp_OutgoingPacket_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_OutgoingPacket_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_OutgoingPacket_0_1_serialize_( + const uavcan_internet_udp_OutgoingPacket_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2504UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 session_id + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->session_id, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint16 destination_port + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->destination_port, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=45] destination_address + if (obj->destination_address.count > 45) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->destination_address.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->destination_address.count * 8U, &obj->destination_address.elements[0], 0U); + offset_bits += obj->destination_address.count * 8U; + } + + + + + { // saturated bool use_masquerading + buffer[offset_bits / 8U] = obj->use_masquerading ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool use_dtls + if (obj->use_dtls) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void6 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 6U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 6UL; + } + + + + + { // saturated uint8[<=260] payload + if (obj->payload.count > 260) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->payload.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->payload.count * 8U, &obj->payload.elements[0], 0U); + offset_bits += obj->payload.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_OutgoingPacket_0_1_deserialize_( + uavcan_internet_udp_OutgoingPacket_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 session_id + out_obj->session_id = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint16 destination_port + out_obj->destination_port = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=45] destination_address + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->destination_address.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->destination_address.count = 0U; + } + offset_bits += 8U; + if (out_obj->destination_address.count > 45U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->destination_address.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->destination_address.count * 8U); + offset_bits += out_obj->destination_address.count * 8U; + + + + + // saturated bool use_masquerading + if (offset_bits < capacity_bits) + { + out_obj->use_masquerading = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->use_masquerading = false; + } + offset_bits += 1U; + + + + + // saturated bool use_dtls + if (offset_bits < capacity_bits) + { + out_obj->use_dtls = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->use_dtls = false; + } + offset_bits += 1U; + + + + + // void6 + offset_bits += 6; + + + + + // saturated uint8[<=260] payload + // Array length prefix: truncated uint16 + out_obj->payload.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->payload.count > 260U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->payload.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->payload.count * 8U); + offset_bits += out_obj->payload.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_OutgoingPacket_0_1_initialize_(uavcan_internet_udp_OutgoingPacket_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_OutgoingPacket_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_2.h b/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_2.h new file mode 100644 index 0000000..b87083e --- /dev/null +++ b/src/nunavut_out/uavcan/internet/udp/OutgoingPacket_0_2.h @@ -0,0 +1,413 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.513148 UTC +// Is deprecated: no +// Fixed port-ID: 8174 +// Full name: uavcan.internet.udp.OutgoingPacket +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_2_INCLUDED_ +#define UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_2_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/internet/udp/8174.OutgoingPacket.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_internet_udp_OutgoingPacket_0_2_HAS_FIXED_PORT_ID_ true +#define uavcan_internet_udp_OutgoingPacket_0_2_FIXED_PORT_ID_ 8174U + +#define uavcan_internet_udp_OutgoingPacket_0_2_FULL_NAME_ "uavcan.internet.udp.OutgoingPacket" +#define uavcan_internet_udp_OutgoingPacket_0_2_FULL_NAME_AND_VERSION_ "uavcan.internet.udp.OutgoingPacket.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_internet_udp_OutgoingPacket_0_2_EXTENT_BYTES_ 600UL +#define uavcan_internet_udp_OutgoingPacket_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 561UL +static_assert(uavcan_internet_udp_OutgoingPacket_0_2_EXTENT_BYTES_ >= uavcan_internet_udp_OutgoingPacket_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint32 NAT_ENTRY_MIN_TTL = 86400 +#define uavcan_internet_udp_OutgoingPacket_0_2_NAT_ENTRY_MIN_TTL (86400UL) + +/// Array metadata for: saturated uint8[<=45] destination_address +#define uavcan_internet_udp_OutgoingPacket_0_2_destination_address_ARRAY_CAPACITY_ 45U +#define uavcan_internet_udp_OutgoingPacket_0_2_destination_address_ARRAY_IS_VARIABLE_LENGTH_ true +/// Array metadata for: saturated uint8[<=508] payload +#define uavcan_internet_udp_OutgoingPacket_0_2_payload_ARRAY_CAPACITY_ 508U +#define uavcan_internet_udp_OutgoingPacket_0_2_payload_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 session_id + uint16_t session_id; + + /// saturated uint16 destination_port + uint16_t destination_port; + + /// saturated uint8[<=45] destination_address + struct /// Array address equivalence guarantee: &elements[0] == &destination_address + { + uint8_t elements[uavcan_internet_udp_OutgoingPacket_0_2_destination_address_ARRAY_CAPACITY_]; + size_t count; + } destination_address; + + /// saturated bool use_masquerading + bool use_masquerading; + + /// saturated bool use_dtls + bool use_dtls; + + /// saturated uint8[<=508] payload + struct /// Array address equivalence guarantee: &elements[0] == &payload + { + uint8_t elements[uavcan_internet_udp_OutgoingPacket_0_2_payload_ARRAY_CAPACITY_]; + size_t count; + } payload; +} uavcan_internet_udp_OutgoingPacket_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_internet_udp_OutgoingPacket_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_OutgoingPacket_0_2_serialize_( + const uavcan_internet_udp_OutgoingPacket_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 4488UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 session_id + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->session_id, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint16 destination_port + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->destination_port, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=45] destination_address + if (obj->destination_address.count > 45) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->destination_address.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->destination_address.count * 8U, &obj->destination_address.elements[0], 0U); + offset_bits += obj->destination_address.count * 8U; + } + + + + + { // saturated bool use_masquerading + buffer[offset_bits / 8U] = obj->use_masquerading ? 1U : 0U; + offset_bits += 1U; + } + + + + + { // saturated bool use_dtls + if (obj->use_dtls) + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] | (1U << (offset_bits % 8U))); + } + else + { + buffer[offset_bits / 8U] = (uint8_t)(buffer[offset_bits / 8U] & ~(1U << (offset_bits % 8U))); + } + offset_bits += 1U; + } + + + + + { // void6 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 6U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 6UL; + } + + + + + { // saturated uint8[<=508] payload + if (obj->payload.count > 508) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->payload.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->payload.count * 8U, &obj->payload.elements[0], 0U); + offset_bits += obj->payload.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_internet_udp_OutgoingPacket_0_2_deserialize_( + uavcan_internet_udp_OutgoingPacket_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 session_id + out_obj->session_id = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint16 destination_port + out_obj->destination_port = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=45] destination_address + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->destination_address.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->destination_address.count = 0U; + } + offset_bits += 8U; + if (out_obj->destination_address.count > 45U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->destination_address.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->destination_address.count * 8U); + offset_bits += out_obj->destination_address.count * 8U; + + + + + // saturated bool use_masquerading + if (offset_bits < capacity_bits) + { + out_obj->use_masquerading = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->use_masquerading = false; + } + offset_bits += 1U; + + + + + // saturated bool use_dtls + if (offset_bits < capacity_bits) + { + out_obj->use_dtls = (buffer[offset_bits / 8U] & (1U << (offset_bits % 8U))) != 0U; + } + else + { + out_obj->use_dtls = false; + } + offset_bits += 1U; + + + + + // void6 + offset_bits += 6; + + + + + // saturated uint8[<=508] payload + // Array length prefix: truncated uint16 + out_obj->payload.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->payload.count > 508U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->payload.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->payload.count * 8U); + offset_bits += out_obj->payload.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_internet_udp_OutgoingPacket_0_2_initialize_(uavcan_internet_udp_OutgoingPacket_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_internet_udp_OutgoingPacket_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_INTERNET_UDP_OUTGOING_PACKET_0_2_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/metatransport/can/ArbitrationID_0_1.h b/src/nunavut_out/uavcan/metatransport/can/ArbitrationID_0_1.h new file mode 100644 index 0000000..6c8f606 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/ArbitrationID_0_1.h @@ -0,0 +1,324 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.523724 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.ArbitrationID +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_ARBITRATION_ID_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_ARBITRATION_ID_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_ArbitrationID_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_ArbitrationID_0_1_FULL_NAME_ "uavcan.metatransport.can.ArbitrationID" +#define uavcan_metatransport_can_ArbitrationID_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.ArbitrationID.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_ArbitrationID_0_1_EXTENT_BYTES_ 5UL +#define uavcan_metatransport_can_ArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 5UL +static_assert(uavcan_metatransport_can_ArbitrationID_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_ArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_metatransport_can_ArbitrationID_0_1_UNION_OPTION_COUNT_ 2U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// uavcan.metatransport.can.BaseArbitrationID.0.1 base + uavcan_metatransport_can_BaseArbitrationID_0_1 base; + + /// uavcan.metatransport.can.ExtendedArbitrationID.0.1 extended + uavcan_metatransport_can_ExtendedArbitrationID_0_1 extended; + }; + uint8_t _tag_; +} uavcan_metatransport_can_ArbitrationID_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_ArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_ArbitrationID_0_1_serialize_( + const uavcan_metatransport_can_ArbitrationID_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 40UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // uavcan.metatransport.can.BaseArbitrationID.0.1 base + { + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_BaseArbitrationID_0_1_serialize_( + &obj->base, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + else if (1U == obj->_tag_) // uavcan.metatransport.can.ExtendedArbitrationID.0.1 extended + { + size_t _size_bytes1_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_metatransport_can_ExtendedArbitrationID_0_1_serialize_( + &obj->extended, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_ArbitrationID_0_1_deserialize_( + uavcan_metatransport_can_ArbitrationID_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // uavcan.metatransport.can.BaseArbitrationID.0.1 base + { + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_metatransport_can_BaseArbitrationID_0_1_deserialize_( + &out_obj->base, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (1U == out_obj->_tag_) // uavcan.metatransport.can.ExtendedArbitrationID.0.1 extended + { + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_metatransport_can_ExtendedArbitrationID_0_1_deserialize_( + &out_obj->extended, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_ArbitrationID_0_1_initialize_(uavcan_metatransport_can_ArbitrationID_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_ArbitrationID_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "base" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_ArbitrationID_0_1_select_base_(uavcan_metatransport_can_ArbitrationID_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "base" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_ArbitrationID_0_1_is_base_(const uavcan_metatransport_can_ArbitrationID_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "extended" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_ArbitrationID_0_1_select_extended_(uavcan_metatransport_can_ArbitrationID_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "extended" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_ArbitrationID_0_1_is_extended_(const uavcan_metatransport_can_ArbitrationID_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_ARBITRATION_ID_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/metatransport/can/BaseArbitrationID_0_1.h b/src/nunavut_out/uavcan/metatransport/can/BaseArbitrationID_0_1.h new file mode 100644 index 0000000..96045e7 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/BaseArbitrationID_0_1.h @@ -0,0 +1,242 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.526025 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.BaseArbitrationID +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_BASE_ARBITRATION_ID_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_BASE_ARBITRATION_ID_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/BaseArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_BaseArbitrationID_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_BaseArbitrationID_0_1_FULL_NAME_ "uavcan.metatransport.can.BaseArbitrationID" +#define uavcan_metatransport_can_BaseArbitrationID_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.BaseArbitrationID.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_BaseArbitrationID_0_1_EXTENT_BYTES_ 4UL +#define uavcan_metatransport_can_BaseArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_metatransport_can_BaseArbitrationID_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_BaseArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint11 value + uint16_t value; +} uavcan_metatransport_can_BaseArbitrationID_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_BaseArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_BaseArbitrationID_0_1_serialize_( + const uavcan_metatransport_can_BaseArbitrationID_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint11 value + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 11U; + } + + + + + { // void21 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 21U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 21UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_BaseArbitrationID_0_1_deserialize_( + uavcan_metatransport_can_BaseArbitrationID_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint11 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 11); + offset_bits += 11U; + + + + + // void21 + offset_bits += 21; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_BaseArbitrationID_0_1_initialize_(uavcan_metatransport_can_BaseArbitrationID_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_BaseArbitrationID_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_BASE_ARBITRATION_ID_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/DataClassic_0_1.h b/src/nunavut_out/uavcan/metatransport/can/DataClassic_0_1.h new file mode 100644 index 0000000..2db1a3b --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/DataClassic_0_1.h @@ -0,0 +1,289 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.527702 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.DataClassic +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_DATA_CLASSIC_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_DATA_CLASSIC_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataClassic.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_DataClassic_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_DataClassic_0_1_FULL_NAME_ "uavcan.metatransport.can.DataClassic" +#define uavcan_metatransport_can_DataClassic_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.DataClassic.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_DataClassic_0_1_EXTENT_BYTES_ 14UL +#define uavcan_metatransport_can_DataClassic_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 14UL +static_assert(uavcan_metatransport_can_DataClassic_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_DataClassic_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=8] data +#define uavcan_metatransport_can_DataClassic_0_1_data_ARRAY_CAPACITY_ 8U +#define uavcan_metatransport_can_DataClassic_0_1_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + uavcan_metatransport_can_ArbitrationID_0_1 arbitration_id; + + /// saturated uint8[<=8] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_metatransport_can_DataClassic_0_1_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_metatransport_can_DataClassic_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_DataClassic_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_DataClassic_0_1_serialize_( + const uavcan_metatransport_can_DataClassic_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 112UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + size_t _size_bytes0_ = 5UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_ArbitrationID_0_1_serialize_( + &obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=8] data + if (obj->data.count > 8) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->data.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_DataClassic_0_1_deserialize_( + uavcan_metatransport_can_DataClassic_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_metatransport_can_ArbitrationID_0_1_deserialize_( + &out_obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=8] data + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->data.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->data.count = 0U; + } + offset_bits += 8U; + if (out_obj->data.count > 8U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_DataClassic_0_1_initialize_(uavcan_metatransport_can_DataClassic_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_DataClassic_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_DATA_CLASSIC_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/DataFD_0_1.h b/src/nunavut_out/uavcan/metatransport/can/DataFD_0_1.h new file mode 100644 index 0000000..3dcc513 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/DataFD_0_1.h @@ -0,0 +1,289 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.530486 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.DataFD +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_DATA_FD_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_DATA_FD_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/DataFD.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_DataFD_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_DataFD_0_1_FULL_NAME_ "uavcan.metatransport.can.DataFD" +#define uavcan_metatransport_can_DataFD_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.DataFD.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_DataFD_0_1_EXTENT_BYTES_ 70UL +#define uavcan_metatransport_can_DataFD_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 70UL +static_assert(uavcan_metatransport_can_DataFD_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_DataFD_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=64] data +#define uavcan_metatransport_can_DataFD_0_1_data_ARRAY_CAPACITY_ 64U +#define uavcan_metatransport_can_DataFD_0_1_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + uavcan_metatransport_can_ArbitrationID_0_1 arbitration_id; + + /// saturated uint8[<=64] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_metatransport_can_DataFD_0_1_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_metatransport_can_DataFD_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_DataFD_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_DataFD_0_1_serialize_( + const uavcan_metatransport_can_DataFD_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 560UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + size_t _size_bytes0_ = 5UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_ArbitrationID_0_1_serialize_( + &obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=64] data + if (obj->data.count > 64) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->data.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_DataFD_0_1_deserialize_( + uavcan_metatransport_can_DataFD_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_metatransport_can_ArbitrationID_0_1_deserialize_( + &out_obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=64] data + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->data.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->data.count = 0U; + } + offset_bits += 8U; + if (out_obj->data.count > 64U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_DataFD_0_1_initialize_(uavcan_metatransport_can_DataFD_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_DataFD_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_DATA_FD_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/Error_0_1.h b/src/nunavut_out/uavcan/metatransport/can/Error_0_1.h new file mode 100644 index 0000000..33ac26d --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/Error_0_1.h @@ -0,0 +1,221 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.532651 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.Error +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_ERROR_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_ERROR_0_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Error.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_Error_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_Error_0_1_FULL_NAME_ "uavcan.metatransport.can.Error" +#define uavcan_metatransport_can_Error_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.Error.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_Error_0_1_EXTENT_BYTES_ 4UL +#define uavcan_metatransport_can_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_metatransport_can_Error_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_metatransport_can_Error_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_Error_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Error_0_1_serialize_( + const uavcan_metatransport_can_Error_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // void32 + (void) memset(&buffer[offset_bits / 8U], 0, 4); + offset_bits += 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Error_0_1_deserialize_( + uavcan_metatransport_can_Error_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // void32 + offset_bits += 32; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_Error_0_1_initialize_(uavcan_metatransport_can_Error_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_Error_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_ERROR_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/ExtendedArbitrationID_0_1.h b/src/nunavut_out/uavcan/metatransport/can/ExtendedArbitrationID_0_1.h new file mode 100644 index 0000000..d3e1dd5 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/ExtendedArbitrationID_0_1.h @@ -0,0 +1,242 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.534201 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.ExtendedArbitrationID +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_EXTENDED_ARBITRATION_ID_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_EXTENDED_ARBITRATION_ID_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/ExtendedArbitrationID.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_ExtendedArbitrationID_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_ExtendedArbitrationID_0_1_FULL_NAME_ "uavcan.metatransport.can.ExtendedArbitrationID" +#define uavcan_metatransport_can_ExtendedArbitrationID_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.ExtendedArbitrationID.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_ExtendedArbitrationID_0_1_EXTENT_BYTES_ 4UL +#define uavcan_metatransport_can_ExtendedArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_metatransport_can_ExtendedArbitrationID_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_ExtendedArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint29 value + uint32_t value; +} uavcan_metatransport_can_ExtendedArbitrationID_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_ExtendedArbitrationID_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_ExtendedArbitrationID_0_1_serialize_( + const uavcan_metatransport_can_ExtendedArbitrationID_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint29 value + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 4U); + offset_bits += 29U; + } + + + + + { // void3 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 3U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 3UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_ExtendedArbitrationID_0_1_deserialize_( + uavcan_metatransport_can_ExtendedArbitrationID_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint29 value + out_obj->value = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 29); + offset_bits += 29U; + + + + + // void3 + offset_bits += 3; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_ExtendedArbitrationID_0_1_initialize_(uavcan_metatransport_can_ExtendedArbitrationID_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_ExtendedArbitrationID_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_EXTENDED_ARBITRATION_ID_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/Frame_0_1.h b/src/nunavut_out/uavcan/metatransport/can/Frame_0_1.h new file mode 100644 index 0000000..0481335 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/Frame_0_1.h @@ -0,0 +1,292 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.538933 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.Frame +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_METATRANSPORT_CAN_FRAME_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_FRAME_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_Frame_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_Frame_0_1_FULL_NAME_ "uavcan.metatransport.can.Frame" +#define uavcan_metatransport_can_Frame_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.Frame.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_Frame_0_1_EXTENT_BYTES_ 78UL +#define uavcan_metatransport_can_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 78UL +static_assert(uavcan_metatransport_can_Frame_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// uavcan.metatransport.can.Manifestation.0.1 manifestation + uavcan_metatransport_can_Manifestation_0_1 manifestation; +} uavcan_metatransport_can_Frame_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Frame_0_1_serialize_( + const uavcan_metatransport_can_Frame_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 624UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.metatransport.can.Manifestation.0.1 manifestation + size_t _size_bytes1_ = 71UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_metatransport_can_Manifestation_0_1_serialize_( + &obj->manifestation, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Frame_0_1_deserialize_( + uavcan_metatransport_can_Frame_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.metatransport.can.Manifestation.0.1 manifestation + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_metatransport_can_Manifestation_0_1_deserialize_( + &out_obj->manifestation, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_Frame_0_1_initialize_(uavcan_metatransport_can_Frame_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_Frame_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_FRAME_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/can/Frame_0_2.h b/src/nunavut_out/uavcan/metatransport/can/Frame_0_2.h new file mode 100644 index 0000000..622ea60 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/Frame_0_2.h @@ -0,0 +1,413 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.535891 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.Frame +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_FRAME_0_2_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_FRAME_0_2_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Frame.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_Frame_0_2_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_Frame_0_2_FULL_NAME_ "uavcan.metatransport.can.Frame" +#define uavcan_metatransport_can_Frame_0_2_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.Frame.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_Frame_0_2_EXTENT_BYTES_ 71UL +#define uavcan_metatransport_can_Frame_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 71UL +static_assert(uavcan_metatransport_can_Frame_0_2_EXTENT_BYTES_ >= uavcan_metatransport_can_Frame_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_metatransport_can_Frame_0_2_UNION_OPTION_COUNT_ 4U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// uavcan.metatransport.can.Error.0.1 error + uavcan_metatransport_can_Error_0_1 _error; + + /// uavcan.metatransport.can.DataFD.0.1 data_fd + uavcan_metatransport_can_DataFD_0_1 data_fd; + + /// uavcan.metatransport.can.DataClassic.0.1 data_classic + uavcan_metatransport_can_DataClassic_0_1 data_classic; + + /// uavcan.metatransport.can.RTR.0.1 remote_transmission_request + uavcan_metatransport_can_RTR_0_1 remote_transmission_request; + }; + uint8_t _tag_; +} uavcan_metatransport_can_Frame_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_Frame_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Frame_0_2_serialize_( + const uavcan_metatransport_can_Frame_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 568UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // uavcan.metatransport.can.Error.0.1 error + { + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_Error_0_1_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + else if (1U == obj->_tag_) // uavcan.metatransport.can.DataFD.0.1 data_fd + { + size_t _size_bytes1_ = 70UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_metatransport_can_DataFD_0_1_serialize_( + &obj->data_fd, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else if (2U == obj->_tag_) // uavcan.metatransport.can.DataClassic.0.1 data_classic + { + size_t _size_bytes2_ = 14UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_metatransport_can_DataClassic_0_1_serialize_( + &obj->data_classic, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + else if (3U == obj->_tag_) // uavcan.metatransport.can.RTR.0.1 remote_transmission_request + { + size_t _size_bytes3_ = 5UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_metatransport_can_RTR_0_1_serialize_( + &obj->remote_transmission_request, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Frame_0_2_deserialize_( + uavcan_metatransport_can_Frame_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // uavcan.metatransport.can.Error.0.1 error + { + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_metatransport_can_Error_0_1_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (1U == out_obj->_tag_) // uavcan.metatransport.can.DataFD.0.1 data_fd + { + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_metatransport_can_DataFD_0_1_deserialize_( + &out_obj->data_fd, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (2U == out_obj->_tag_) // uavcan.metatransport.can.DataClassic.0.1 data_classic + { + { + size_t _size_bytes6_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_metatransport_can_DataClassic_0_1_deserialize_( + &out_obj->data_classic, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (3U == out_obj->_tag_) // uavcan.metatransport.can.RTR.0.1 remote_transmission_request + { + { + size_t _size_bytes7_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_metatransport_can_RTR_0_1_deserialize_( + &out_obj->remote_transmission_request, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_Frame_0_2_initialize_(uavcan_metatransport_can_Frame_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_Frame_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "error" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Frame_0_2_select_error_(uavcan_metatransport_can_Frame_0_2* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "error" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Frame_0_2_is_error_(const uavcan_metatransport_can_Frame_0_2* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "data_fd" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Frame_0_2_select_data_fd_(uavcan_metatransport_can_Frame_0_2* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "data_fd" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Frame_0_2_is_data_fd_(const uavcan_metatransport_can_Frame_0_2* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +/// Mark option "data_classic" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Frame_0_2_select_data_classic_(uavcan_metatransport_can_Frame_0_2* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 2; + } +} + +/// Check if option "data_classic" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Frame_0_2_is_data_classic_(const uavcan_metatransport_can_Frame_0_2* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 2)); +} + +/// Mark option "remote_transmission_request" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Frame_0_2_select_remote_transmission_request_(uavcan_metatransport_can_Frame_0_2* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 3; + } +} + +/// Check if option "remote_transmission_request" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Frame_0_2_is_remote_transmission_request_(const uavcan_metatransport_can_Frame_0_2* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 3)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_FRAME_0_2_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/metatransport/can/Manifestation_0_1.h b/src/nunavut_out/uavcan/metatransport/can/Manifestation_0_1.h new file mode 100644 index 0000000..7a8cc9e --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/Manifestation_0_1.h @@ -0,0 +1,422 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.541236 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.Manifestation +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_METATRANSPORT_CAN_MANIFESTATION_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_MANIFESTATION_0_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/Manifestation.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_Manifestation_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_Manifestation_0_1_FULL_NAME_ "uavcan.metatransport.can.Manifestation" +#define uavcan_metatransport_can_Manifestation_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.Manifestation.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_Manifestation_0_1_EXTENT_BYTES_ 71UL +#define uavcan_metatransport_can_Manifestation_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 71UL +static_assert(uavcan_metatransport_can_Manifestation_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_Manifestation_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_metatransport_can_Manifestation_0_1_UNION_OPTION_COUNT_ 4U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// uavcan.metatransport.can.Error.0.1 error + uavcan_metatransport_can_Error_0_1 _error; + + /// uavcan.metatransport.can.DataFD.0.1 data_fd + uavcan_metatransport_can_DataFD_0_1 data_fd; + + /// uavcan.metatransport.can.DataClassic.0.1 data_classic + uavcan_metatransport_can_DataClassic_0_1 data_classic; + + /// uavcan.metatransport.can.RTR.0.1 remote_transmission_request + uavcan_metatransport_can_RTR_0_1 remote_transmission_request; + }; + uint8_t _tag_; +} uavcan_metatransport_can_Manifestation_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_Manifestation_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Manifestation_0_1_serialize_( + const uavcan_metatransport_can_Manifestation_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 568UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // uavcan.metatransport.can.Error.0.1 error + { + size_t _size_bytes0_ = 4UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_Error_0_1_serialize_( + &obj->_error, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + else if (1U == obj->_tag_) // uavcan.metatransport.can.DataFD.0.1 data_fd + { + size_t _size_bytes1_ = 70UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_metatransport_can_DataFD_0_1_serialize_( + &obj->data_fd, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else if (2U == obj->_tag_) // uavcan.metatransport.can.DataClassic.0.1 data_classic + { + size_t _size_bytes2_ = 14UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_metatransport_can_DataClassic_0_1_serialize_( + &obj->data_classic, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + else if (3U == obj->_tag_) // uavcan.metatransport.can.RTR.0.1 remote_transmission_request + { + size_t _size_bytes3_ = 5UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_metatransport_can_RTR_0_1_serialize_( + &obj->remote_transmission_request, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_Manifestation_0_1_deserialize_( + uavcan_metatransport_can_Manifestation_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // uavcan.metatransport.can.Error.0.1 error + { + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_metatransport_can_Error_0_1_deserialize_( + &out_obj->_error, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (1U == out_obj->_tag_) // uavcan.metatransport.can.DataFD.0.1 data_fd + { + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_metatransport_can_DataFD_0_1_deserialize_( + &out_obj->data_fd, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (2U == out_obj->_tag_) // uavcan.metatransport.can.DataClassic.0.1 data_classic + { + { + size_t _size_bytes6_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_metatransport_can_DataClassic_0_1_deserialize_( + &out_obj->data_classic, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes6_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (3U == out_obj->_tag_) // uavcan.metatransport.can.RTR.0.1 remote_transmission_request + { + { + size_t _size_bytes7_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_metatransport_can_RTR_0_1_deserialize_( + &out_obj->remote_transmission_request, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes7_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_Manifestation_0_1_initialize_(uavcan_metatransport_can_Manifestation_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_Manifestation_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "error" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Manifestation_0_1_select_error_(uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "error" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Manifestation_0_1_is_error_(const uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "data_fd" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Manifestation_0_1_select_data_fd_(uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "data_fd" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Manifestation_0_1_is_data_fd_(const uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +/// Mark option "data_classic" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Manifestation_0_1_select_data_classic_(uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 2; + } +} + +/// Check if option "data_classic" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Manifestation_0_1_is_data_classic_(const uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 2)); +} + +/// Mark option "remote_transmission_request" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_metatransport_can_Manifestation_0_1_select_remote_transmission_request_(uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 3; + } +} + +/// Check if option "remote_transmission_request" is active. Returns false if @param obj is NULL. +static inline bool uavcan_metatransport_can_Manifestation_0_1_is_remote_transmission_request_(const uavcan_metatransport_can_Manifestation_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 3)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_MANIFESTATION_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/metatransport/can/RTR_0_1.h b/src/nunavut_out/uavcan/metatransport/can/RTR_0_1.h new file mode 100644 index 0000000..0ec6500 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/can/RTR_0_1.h @@ -0,0 +1,239 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.544134 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.can.RTR +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_CAN_RTR_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_CAN_RTR_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/can/RTR.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_can_RTR_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_can_RTR_0_1_FULL_NAME_ "uavcan.metatransport.can.RTR" +#define uavcan_metatransport_can_RTR_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.can.RTR.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_can_RTR_0_1_EXTENT_BYTES_ 5UL +#define uavcan_metatransport_can_RTR_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 5UL +static_assert(uavcan_metatransport_can_RTR_0_1_EXTENT_BYTES_ >= uavcan_metatransport_can_RTR_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + uavcan_metatransport_can_ArbitrationID_0_1 arbitration_id; +} uavcan_metatransport_can_RTR_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_can_RTR_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_RTR_0_1_serialize_( + const uavcan_metatransport_can_RTR_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 40UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + size_t _size_bytes0_ = 5UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_metatransport_can_ArbitrationID_0_1_serialize_( + &obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_can_RTR_0_1_deserialize_( + uavcan_metatransport_can_RTR_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.metatransport.can.ArbitrationID.0.1 arbitration_id + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_metatransport_can_ArbitrationID_0_1_deserialize_( + &out_obj->arbitration_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_can_RTR_0_1_initialize_(uavcan_metatransport_can_RTR_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_can_RTR_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_CAN_RTR_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/ethernet/EtherType_0_1.h b/src/nunavut_out/uavcan/metatransport/ethernet/EtherType_0_1.h new file mode 100644 index 0000000..850eccd --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/ethernet/EtherType_0_1.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.519366 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.ethernet.EtherType +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_ETHERNET_ETHER_TYPE_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_ETHERNET_ETHER_TYPE_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/EtherType.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_ethernet_EtherType_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_ethernet_EtherType_0_1_FULL_NAME_ "uavcan.metatransport.ethernet.EtherType" +#define uavcan_metatransport_ethernet_EtherType_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.ethernet.EtherType.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_ethernet_EtherType_0_1_EXTENT_BYTES_ 2UL +#define uavcan_metatransport_ethernet_EtherType_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_metatransport_ethernet_EtherType_0_1_EXTENT_BYTES_ >= uavcan_metatransport_ethernet_EtherType_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 IP_V4 = 2048 +#define uavcan_metatransport_ethernet_EtherType_0_1_IP_V4 (2048U) +/// saturated uint16 ARP = 2054 +#define uavcan_metatransport_ethernet_EtherType_0_1_ARP (2054U) +/// saturated uint16 IP_V6 = 34525 +#define uavcan_metatransport_ethernet_EtherType_0_1_IP_V6 (34525U) + +typedef struct +{ + /// saturated uint16 value + uint16_t value; +} uavcan_metatransport_ethernet_EtherType_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_ethernet_EtherType_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_ethernet_EtherType_0_1_serialize_( + const uavcan_metatransport_ethernet_EtherType_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_ethernet_EtherType_0_1_deserialize_( + uavcan_metatransport_ethernet_EtherType_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_ethernet_EtherType_0_1_initialize_(uavcan_metatransport_ethernet_EtherType_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_ethernet_EtherType_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_ETHERNET_ETHER_TYPE_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/ethernet/Frame_0_1.h b/src/nunavut_out/uavcan/metatransport/ethernet/Frame_0_1.h new file mode 100644 index 0000000..efc376c --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/ethernet/Frame_0_1.h @@ -0,0 +1,336 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.521062 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.ethernet.Frame +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_ETHERNET_FRAME_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_ETHERNET_FRAME_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/ethernet/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_ethernet_Frame_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_ethernet_Frame_0_1_FULL_NAME_ "uavcan.metatransport.ethernet.Frame" +#define uavcan_metatransport_ethernet_Frame_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.ethernet.Frame.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_ethernet_Frame_0_1_EXTENT_BYTES_ 9232UL +#define uavcan_metatransport_ethernet_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 9232UL +static_assert(uavcan_metatransport_ethernet_Frame_0_1_EXTENT_BYTES_ >= uavcan_metatransport_ethernet_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[6] destination +#define uavcan_metatransport_ethernet_Frame_0_1_destination_ARRAY_CAPACITY_ 6U +#define uavcan_metatransport_ethernet_Frame_0_1_destination_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated uint8[6] source +#define uavcan_metatransport_ethernet_Frame_0_1_source_ARRAY_CAPACITY_ 6U +#define uavcan_metatransport_ethernet_Frame_0_1_source_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated uint8[<=9216] payload +#define uavcan_metatransport_ethernet_Frame_0_1_payload_ARRAY_CAPACITY_ 9216U +#define uavcan_metatransport_ethernet_Frame_0_1_payload_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[6] destination + uint8_t destination[6]; + + /// saturated uint8[6] source + uint8_t source[6]; + + /// uavcan.metatransport.ethernet.EtherType.0.1 ethertype + uavcan_metatransport_ethernet_EtherType_0_1 ethertype; + + /// saturated uint8[<=9216] payload + struct /// Array address equivalence guarantee: &elements[0] == &payload + { + uint8_t elements[uavcan_metatransport_ethernet_Frame_0_1_payload_ARRAY_CAPACITY_]; + size_t count; + } payload; +} uavcan_metatransport_ethernet_Frame_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_ethernet_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_ethernet_Frame_0_1_serialize_( + const uavcan_metatransport_ethernet_Frame_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 73856UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[6] destination + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 6UL * 8U, &obj->destination[0], 0U); + offset_bits += 6UL * 8U; + } + + + + + { // saturated uint8[6] source + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 6UL * 8U, &obj->source[0], 0U); + offset_bits += 6UL * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.metatransport.ethernet.EtherType.0.1 ethertype + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_metatransport_ethernet_EtherType_0_1_serialize_( + &obj->ethertype, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=9216] payload + if (obj->payload.count > 9216) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->payload.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->payload.count * 8U, &obj->payload.elements[0], 0U); + offset_bits += obj->payload.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_ethernet_Frame_0_1_deserialize_( + uavcan_metatransport_ethernet_Frame_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[6] destination + nunavutGetBits(&out_obj->destination[0], &buffer[0], capacity_bytes, offset_bits, 6UL * 8U); + offset_bits += 6UL * 8U; + + + + + // saturated uint8[6] source + nunavutGetBits(&out_obj->source[0], &buffer[0], capacity_bytes, offset_bits, 6UL * 8U); + offset_bits += 6UL * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.metatransport.ethernet.EtherType.0.1 ethertype + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_metatransport_ethernet_EtherType_0_1_deserialize_( + &out_obj->ethertype, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=9216] payload + // Array length prefix: truncated uint16 + out_obj->payload.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->payload.count > 9216U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->payload.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->payload.count * 8U); + offset_bits += out_obj->payload.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_ethernet_Frame_0_1_initialize_(uavcan_metatransport_ethernet_Frame_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_ethernet_Frame_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_ETHERNET_FRAME_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_1.h b/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_1.h new file mode 100644 index 0000000..a2b2074 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_1.h @@ -0,0 +1,294 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.547672 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.metatransport.serial.Fragment +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_serial_Fragment_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_serial_Fragment_0_1_FULL_NAME_ "uavcan.metatransport.serial.Fragment" +#define uavcan_metatransport_serial_Fragment_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.serial.Fragment.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_serial_Fragment_0_1_EXTENT_BYTES_ 265UL +#define uavcan_metatransport_serial_Fragment_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 265UL +static_assert(uavcan_metatransport_serial_Fragment_0_1_EXTENT_BYTES_ >= uavcan_metatransport_serial_Fragment_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint9 CAPACITY_BYTES = 256 +#define uavcan_metatransport_serial_Fragment_0_1_CAPACITY_BYTES (256U) + +/// Array metadata for: saturated uint8[<=256] data +#define uavcan_metatransport_serial_Fragment_0_1_data_ARRAY_CAPACITY_ 256U +#define uavcan_metatransport_serial_Fragment_0_1_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated uint8[<=256] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_metatransport_serial_Fragment_0_1_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_metatransport_serial_Fragment_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_serial_Fragment_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_serial_Fragment_0_1_serialize_( + const uavcan_metatransport_serial_Fragment_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=256] data + if (obj->data.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->data.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_serial_Fragment_0_1_deserialize_( + uavcan_metatransport_serial_Fragment_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=256] data + // Array length prefix: truncated uint16 + out_obj->data.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->data.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_serial_Fragment_0_1_initialize_(uavcan_metatransport_serial_Fragment_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_serial_Fragment_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_2.h b/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_2.h new file mode 100644 index 0000000..1e7b5c7 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/serial/Fragment_0_2.h @@ -0,0 +1,251 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl +// Generated at: 2024-11-23 10:35:29.545836 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.metatransport.serial.Fragment +// Version: 0.2 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_2_INCLUDED_ +#define UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_2_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/serial/Fragment.0.2.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_serial_Fragment_0_2_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_serial_Fragment_0_2_FULL_NAME_ "uavcan.metatransport.serial.Fragment" +#define uavcan_metatransport_serial_Fragment_0_2_FULL_NAME_AND_VERSION_ "uavcan.metatransport.serial.Fragment.0.2" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_serial_Fragment_0_2_EXTENT_BYTES_ 2050UL +#define uavcan_metatransport_serial_Fragment_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ 2050UL +static_assert(uavcan_metatransport_serial_Fragment_0_2_EXTENT_BYTES_ >= uavcan_metatransport_serial_Fragment_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint12 CAPACITY_BYTES = 2048 +#define uavcan_metatransport_serial_Fragment_0_2_CAPACITY_BYTES (2048U) + +/// Array metadata for: saturated uint8[<=2048] data +#define uavcan_metatransport_serial_Fragment_0_2_data_ARRAY_CAPACITY_ 2048U +#define uavcan_metatransport_serial_Fragment_0_2_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=2048] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_metatransport_serial_Fragment_0_2_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_metatransport_serial_Fragment_0_2; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_serial_Fragment_0_2_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_serial_Fragment_0_2_serialize_( + const uavcan_metatransport_serial_Fragment_0_2* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16400UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=2048] data + if (obj->data.count > 2048) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->data.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_serial_Fragment_0_2_deserialize_( + uavcan_metatransport_serial_Fragment_0_2* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=2048] data + // Array length prefix: truncated uint16 + out_obj->data.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->data.count > 2048U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_serial_Fragment_0_2_initialize_(uavcan_metatransport_serial_Fragment_0_2* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_serial_Fragment_0_2_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_SERIAL_FRAGMENT_0_2_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/udp/Endpoint_0_1.h b/src/nunavut_out/uavcan/metatransport/udp/Endpoint_0_1.h new file mode 100644 index 0000000..e475646 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/udp/Endpoint_0_1.h @@ -0,0 +1,294 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.549738 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.metatransport.udp.Endpoint +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_METATRANSPORT_UDP_ENDPOINT_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_UDP_ENDPOINT_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Endpoint.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_udp_Endpoint_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_udp_Endpoint_0_1_FULL_NAME_ "uavcan.metatransport.udp.Endpoint" +#define uavcan_metatransport_udp_Endpoint_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.udp.Endpoint.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_udp_Endpoint_0_1_EXTENT_BYTES_ 32UL +#define uavcan_metatransport_udp_Endpoint_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 32UL +static_assert(uavcan_metatransport_udp_Endpoint_0_1_EXTENT_BYTES_ >= uavcan_metatransport_udp_Endpoint_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[16] ip_address +#define uavcan_metatransport_udp_Endpoint_0_1_ip_address_ARRAY_CAPACITY_ 16U +#define uavcan_metatransport_udp_Endpoint_0_1_ip_address_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated uint8[6] mac_address +#define uavcan_metatransport_udp_Endpoint_0_1_mac_address_ARRAY_CAPACITY_ 6U +#define uavcan_metatransport_udp_Endpoint_0_1_mac_address_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated uint8[16] ip_address + uint8_t ip_address[16]; + + /// saturated uint8[6] mac_address + uint8_t mac_address[6]; + + /// saturated uint16 port + uint16_t port; +} uavcan_metatransport_udp_Endpoint_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_udp_Endpoint_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_udp_Endpoint_0_1_serialize_( + const uavcan_metatransport_udp_Endpoint_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 256UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[16] ip_address + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 16UL * 8U, &obj->ip_address[0], 0U); + offset_bits += 16UL * 8U; + } + + + + + { // saturated uint8[6] mac_address + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 6UL * 8U, &obj->mac_address[0], 0U); + offset_bits += 6UL * 8U; + } + + + + + { // saturated uint16 port + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->port, 2U); + offset_bits += 16U; + } + + + + + { // void64 + (void) memset(&buffer[offset_bits / 8U], 0, 8); + offset_bits += 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_udp_Endpoint_0_1_deserialize_( + uavcan_metatransport_udp_Endpoint_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[16] ip_address + nunavutGetBits(&out_obj->ip_address[0], &buffer[0], capacity_bytes, offset_bits, 16UL * 8U); + offset_bits += 16UL * 8U; + + + + + // saturated uint8[6] mac_address + nunavutGetBits(&out_obj->mac_address[0], &buffer[0], capacity_bytes, offset_bits, 6UL * 8U); + offset_bits += 6UL * 8U; + + + + + // saturated uint16 port + out_obj->port = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // void64 + offset_bits += 64; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_udp_Endpoint_0_1_initialize_(uavcan_metatransport_udp_Endpoint_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_udp_Endpoint_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_UDP_ENDPOINT_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/metatransport/udp/Frame_0_1.h b/src/nunavut_out/uavcan/metatransport/udp/Frame_0_1.h new file mode 100644 index 0000000..b1e06a0 --- /dev/null +++ b/src/nunavut_out/uavcan/metatransport/udp/Frame_0_1.h @@ -0,0 +1,394 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.552002 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.metatransport.udp.Frame +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_METATRANSPORT_UDP_FRAME_0_1_INCLUDED_ +#define UAVCAN_METATRANSPORT_UDP_FRAME_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/metatransport/udp/Frame.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_metatransport_udp_Frame_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_metatransport_udp_Frame_0_1_FULL_NAME_ "uavcan.metatransport.udp.Frame" +#define uavcan_metatransport_udp_Frame_0_1_FULL_NAME_AND_VERSION_ "uavcan.metatransport.udp.Frame.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_metatransport_udp_Frame_0_1_EXTENT_BYTES_ 10240UL +#define uavcan_metatransport_udp_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 9262UL +static_assert(uavcan_metatransport_udp_Frame_0_1_EXTENT_BYTES_ >= uavcan_metatransport_udp_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint14 MTU = 9188 +#define uavcan_metatransport_udp_Frame_0_1_MTU (9188U) + +/// Array metadata for: saturated uint8[<=9188] data +#define uavcan_metatransport_udp_Frame_0_1_data_ARRAY_CAPACITY_ 9188U +#define uavcan_metatransport_udp_Frame_0_1_data_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// uavcan.metatransport.udp.Endpoint.0.1 source + uavcan_metatransport_udp_Endpoint_0_1 source; + + /// uavcan.metatransport.udp.Endpoint.0.1 destination + uavcan_metatransport_udp_Endpoint_0_1 destination; + + /// saturated uint8[<=9188] data + struct /// Array address equivalence guarantee: &elements[0] == &data + { + uint8_t elements[uavcan_metatransport_udp_Frame_0_1_data_ARRAY_CAPACITY_]; + size_t count; + } data; +} uavcan_metatransport_udp_Frame_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_metatransport_udp_Frame_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_udp_Frame_0_1_serialize_( + const uavcan_metatransport_udp_Frame_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 74096UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // void8 + buffer[offset_bits / 8U] = 0U; + offset_bits += 8UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.metatransport.udp.Endpoint.0.1 source + size_t _size_bytes1_ = 32UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_metatransport_udp_Endpoint_0_1_serialize_( + &obj->source, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.metatransport.udp.Endpoint.0.1 destination + size_t _size_bytes2_ = 32UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_metatransport_udp_Endpoint_0_1_serialize_( + &obj->destination, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[<=9188] data + if (obj->data.count > 9188) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->data.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->data.count * 8U, &obj->data.elements[0], 0U); + offset_bits += obj->data.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_metatransport_udp_Frame_0_1_deserialize_( + uavcan_metatransport_udp_Frame_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // void8 + offset_bits += 8; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.metatransport.udp.Endpoint.0.1 source + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_metatransport_udp_Endpoint_0_1_deserialize_( + &out_obj->source, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.metatransport.udp.Endpoint.0.1 destination + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_metatransport_udp_Endpoint_0_1_deserialize_( + &out_obj->destination, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[<=9188] data + // Array length prefix: truncated uint16 + out_obj->data.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->data.count > 9188U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->data.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->data.count * 8U); + offset_bits += out_obj->data.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_metatransport_udp_Frame_0_1_initialize_(uavcan_metatransport_udp_Frame_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_metatransport_udp_Frame_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_METATRANSPORT_UDP_FRAME_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/ExecuteCommand_1_0.h b/src/nunavut_out/uavcan/node/ExecuteCommand_1_0.h new file mode 100644 index 0000000..d4d1fa7 --- /dev/null +++ b/src/nunavut_out/uavcan/node/ExecuteCommand_1_0.h @@ -0,0 +1,478 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.464726 UTC +// Is deprecated: yes +// Fixed port-ID: 435 +// Full name: uavcan.node.ExecuteCommand +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_NODE_EXECUTE_COMMAND_1_0_INCLUDED_ +#define UAVCAN_NODE_EXECUTE_COMMAND_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_ExecuteCommand_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_node_ExecuteCommand_1_0_FIXED_PORT_ID_ 435U + +#define uavcan_node_ExecuteCommand_1_0_FULL_NAME_ "uavcan.node.ExecuteCommand" +#define uavcan_node_ExecuteCommand_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.1.0" + +#define uavcan_node_ExecuteCommand_Request_1_0_FULL_NAME_ "uavcan.node.ExecuteCommand.Request" +#define uavcan_node_ExecuteCommand_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_ExecuteCommand_Request_1_0_EXTENT_BYTES_ 300UL +#define uavcan_node_ExecuteCommand_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 115UL +static_assert(uavcan_node_ExecuteCommand_Request_1_0_EXTENT_BYTES_ >= uavcan_node_ExecuteCommand_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 COMMAND_RESTART = 65535 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_RESTART (65535U) +/// saturated uint16 COMMAND_POWER_OFF = 65534 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_POWER_OFF (65534U) +/// saturated uint16 COMMAND_BEGIN_SOFTWARE_UPDATE = 65533 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_BEGIN_SOFTWARE_UPDATE (65533U) +/// saturated uint16 COMMAND_FACTORY_RESET = 65532 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_FACTORY_RESET (65532U) +/// saturated uint16 COMMAND_EMERGENCY_STOP = 65531 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_EMERGENCY_STOP (65531U) +/// saturated uint16 COMMAND_STORE_PERSISTENT_STATES = 65530 +#define uavcan_node_ExecuteCommand_Request_1_0_COMMAND_STORE_PERSISTENT_STATES (65530U) + +/// Array metadata for: saturated uint8[<=112] parameter +#define uavcan_node_ExecuteCommand_Request_1_0_parameter_ARRAY_CAPACITY_ 112U +#define uavcan_node_ExecuteCommand_Request_1_0_parameter_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 command + uint16_t command; + + /// saturated uint8[<=112] parameter + struct /// Array address equivalence guarantee: &elements[0] == ¶meter + { + uint8_t elements[uavcan_node_ExecuteCommand_Request_1_0_parameter_ARRAY_CAPACITY_]; + size_t count; + } parameter; +} uavcan_node_ExecuteCommand_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_ExecuteCommand_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Request_1_0_serialize_( + const uavcan_node_ExecuteCommand_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 920UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 command + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->command, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=112] parameter + if (obj->parameter.count > 112) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->parameter.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->parameter.count * 8U, &obj->parameter.elements[0], 0U); + offset_bits += obj->parameter.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Request_1_0_deserialize_( + uavcan_node_ExecuteCommand_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 command + out_obj->command = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=112] parameter + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->parameter.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->parameter.count = 0U; + } + offset_bits += 8U; + if (out_obj->parameter.count > 112U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->parameter.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->parameter.count * 8U); + offset_bits += out_obj->parameter.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_ExecuteCommand_Request_1_0_initialize_(uavcan_node_ExecuteCommand_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_ExecuteCommand_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_node_ExecuteCommand_Response_1_0_FULL_NAME_ "uavcan.node.ExecuteCommand.Response" +#define uavcan_node_ExecuteCommand_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_ExecuteCommand_Response_1_0_EXTENT_BYTES_ 48UL +#define uavcan_node_ExecuteCommand_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_node_ExecuteCommand_Response_1_0_EXTENT_BYTES_ >= uavcan_node_ExecuteCommand_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 STATUS_SUCCESS = 0 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_SUCCESS (0U) +/// saturated uint8 STATUS_FAILURE = 1 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_FAILURE (1U) +/// saturated uint8 STATUS_NOT_AUTHORIZED = 2 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_NOT_AUTHORIZED (2U) +/// saturated uint8 STATUS_BAD_COMMAND = 3 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_BAD_COMMAND (3U) +/// saturated uint8 STATUS_BAD_PARAMETER = 4 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_BAD_PARAMETER (4U) +/// saturated uint8 STATUS_BAD_STATE = 5 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_BAD_STATE (5U) +/// saturated uint8 STATUS_INTERNAL_ERROR = 6 +#define uavcan_node_ExecuteCommand_Response_1_0_STATUS_INTERNAL_ERROR (6U) + +typedef struct +{ + /// saturated uint8 status + uint8_t status; +} uavcan_node_ExecuteCommand_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_ExecuteCommand_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Response_1_0_serialize_( + const uavcan_node_ExecuteCommand_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 status + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->status); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Response_1_0_deserialize_( + uavcan_node_ExecuteCommand_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 status + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->status = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->status = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_ExecuteCommand_Response_1_0_initialize_(uavcan_node_ExecuteCommand_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_ExecuteCommand_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_EXECUTE_COMMAND_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/ExecuteCommand_1_1.h b/src/nunavut_out/uavcan/node/ExecuteCommand_1_1.h new file mode 100644 index 0000000..b6962c8 --- /dev/null +++ b/src/nunavut_out/uavcan/node/ExecuteCommand_1_1.h @@ -0,0 +1,469 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.461523 UTC +// Is deprecated: no +// Fixed port-ID: 435 +// Full name: uavcan.node.ExecuteCommand +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_EXECUTE_COMMAND_1_1_INCLUDED_ +#define UAVCAN_NODE_EXECUTE_COMMAND_1_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/435.ExecuteCommand.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_ExecuteCommand_1_1_HAS_FIXED_PORT_ID_ true +#define uavcan_node_ExecuteCommand_1_1_FIXED_PORT_ID_ 435U + +#define uavcan_node_ExecuteCommand_1_1_FULL_NAME_ "uavcan.node.ExecuteCommand" +#define uavcan_node_ExecuteCommand_1_1_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.1.1" + +#define uavcan_node_ExecuteCommand_Request_1_1_FULL_NAME_ "uavcan.node.ExecuteCommand.Request" +#define uavcan_node_ExecuteCommand_Request_1_1_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.Request.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_ExecuteCommand_Request_1_1_EXTENT_BYTES_ 300UL +#define uavcan_node_ExecuteCommand_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_node_ExecuteCommand_Request_1_1_EXTENT_BYTES_ >= uavcan_node_ExecuteCommand_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 COMMAND_RESTART = 65535 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_RESTART (65535U) +/// saturated uint16 COMMAND_POWER_OFF = 65534 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_POWER_OFF (65534U) +/// saturated uint16 COMMAND_BEGIN_SOFTWARE_UPDATE = 65533 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_BEGIN_SOFTWARE_UPDATE (65533U) +/// saturated uint16 COMMAND_FACTORY_RESET = 65532 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_FACTORY_RESET (65532U) +/// saturated uint16 COMMAND_EMERGENCY_STOP = 65531 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_EMERGENCY_STOP (65531U) +/// saturated uint16 COMMAND_STORE_PERSISTENT_STATES = 65530 +#define uavcan_node_ExecuteCommand_Request_1_1_COMMAND_STORE_PERSISTENT_STATES (65530U) + +/// Array metadata for: saturated uint8[<=255] parameter +#define uavcan_node_ExecuteCommand_Request_1_1_parameter_ARRAY_CAPACITY_ 255U +#define uavcan_node_ExecuteCommand_Request_1_1_parameter_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16 command + uint16_t command; + + /// saturated uint8[<=255] parameter + struct /// Array address equivalence guarantee: &elements[0] == ¶meter + { + uint8_t elements[uavcan_node_ExecuteCommand_Request_1_1_parameter_ARRAY_CAPACITY_]; + size_t count; + } parameter; +} uavcan_node_ExecuteCommand_Request_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_ExecuteCommand_Request_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Request_1_1_serialize_( + const uavcan_node_ExecuteCommand_Request_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 command + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->command, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint8[<=255] parameter + if (obj->parameter.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->parameter.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->parameter.count * 8U, &obj->parameter.elements[0], 0U); + offset_bits += obj->parameter.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Request_1_1_deserialize_( + uavcan_node_ExecuteCommand_Request_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 command + out_obj->command = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint8[<=255] parameter + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->parameter.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->parameter.count = 0U; + } + offset_bits += 8U; + if (out_obj->parameter.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->parameter.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->parameter.count * 8U); + offset_bits += out_obj->parameter.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_ExecuteCommand_Request_1_1_initialize_(uavcan_node_ExecuteCommand_Request_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_ExecuteCommand_Request_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_node_ExecuteCommand_Response_1_1_FULL_NAME_ "uavcan.node.ExecuteCommand.Response" +#define uavcan_node_ExecuteCommand_Response_1_1_FULL_NAME_AND_VERSION_ "uavcan.node.ExecuteCommand.Response.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_ExecuteCommand_Response_1_1_EXTENT_BYTES_ 48UL +#define uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_node_ExecuteCommand_Response_1_1_EXTENT_BYTES_ >= uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 STATUS_SUCCESS = 0 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_SUCCESS (0U) +/// saturated uint8 STATUS_FAILURE = 1 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_FAILURE (1U) +/// saturated uint8 STATUS_NOT_AUTHORIZED = 2 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_NOT_AUTHORIZED (2U) +/// saturated uint8 STATUS_BAD_COMMAND = 3 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_BAD_COMMAND (3U) +/// saturated uint8 STATUS_BAD_PARAMETER = 4 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_BAD_PARAMETER (4U) +/// saturated uint8 STATUS_BAD_STATE = 5 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_BAD_STATE (5U) +/// saturated uint8 STATUS_INTERNAL_ERROR = 6 +#define uavcan_node_ExecuteCommand_Response_1_1_STATUS_INTERNAL_ERROR (6U) + +typedef struct +{ + /// saturated uint8 status + uint8_t status; +} uavcan_node_ExecuteCommand_Response_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Response_1_1_serialize_( + const uavcan_node_ExecuteCommand_Response_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 status + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->status); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ExecuteCommand_Response_1_1_deserialize_( + uavcan_node_ExecuteCommand_Response_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 status + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->status = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->status = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_ExecuteCommand_Response_1_1_initialize_(uavcan_node_ExecuteCommand_Response_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_ExecuteCommand_Response_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_EXECUTE_COMMAND_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/GetInfo_1_0.h b/src/nunavut_out/uavcan/node/GetInfo_1_0.h new file mode 100644 index 0000000..c034e07 --- /dev/null +++ b/src/nunavut_out/uavcan/node/GetInfo_1_0.h @@ -0,0 +1,616 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.467759 UTC +// Is deprecated: no +// Fixed port-ID: 430 +// Full name: uavcan.node.GetInfo +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_GET_INFO_1_0_INCLUDED_ +#define UAVCAN_NODE_GET_INFO_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/430.GetInfo.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_GetInfo_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_node_GetInfo_1_0_FIXED_PORT_ID_ 430U + +#define uavcan_node_GetInfo_1_0_FULL_NAME_ "uavcan.node.GetInfo" +#define uavcan_node_GetInfo_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.GetInfo.1.0" + +#define uavcan_node_GetInfo_Request_1_0_FULL_NAME_ "uavcan.node.GetInfo.Request" +#define uavcan_node_GetInfo_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.GetInfo.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_GetInfo_Request_1_0_EXTENT_BYTES_ 0UL +#define uavcan_node_GetInfo_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_node_GetInfo_Request_1_0_EXTENT_BYTES_ >= uavcan_node_GetInfo_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_node_GetInfo_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_GetInfo_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetInfo_Request_1_0_serialize_( + const uavcan_node_GetInfo_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetInfo_Request_1_0_deserialize_( + uavcan_node_GetInfo_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_GetInfo_Request_1_0_initialize_(uavcan_node_GetInfo_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_GetInfo_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_node_GetInfo_Response_1_0_FULL_NAME_ "uavcan.node.GetInfo.Response" +#define uavcan_node_GetInfo_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.GetInfo.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_GetInfo_Response_1_0_EXTENT_BYTES_ 448UL +#define uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 313UL +static_assert(uavcan_node_GetInfo_Response_1_0_EXTENT_BYTES_ >= uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[16] unique_id +#define uavcan_node_GetInfo_Response_1_0_unique_id_ARRAY_CAPACITY_ 16U +#define uavcan_node_GetInfo_Response_1_0_unique_id_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: saturated uint8[<=50] name +#define uavcan_node_GetInfo_Response_1_0_name_ARRAY_CAPACITY_ 50U +#define uavcan_node_GetInfo_Response_1_0_name_ARRAY_IS_VARIABLE_LENGTH_ true +/// Array metadata for: saturated uint64[<=1] software_image_crc +#define uavcan_node_GetInfo_Response_1_0_software_image_crc_ARRAY_CAPACITY_ 1U +#define uavcan_node_GetInfo_Response_1_0_software_image_crc_ARRAY_IS_VARIABLE_LENGTH_ true +/// Array metadata for: saturated uint8[<=222] certificate_of_authenticity +#define uavcan_node_GetInfo_Response_1_0_certificate_of_authenticity_ARRAY_CAPACITY_ 222U +#define uavcan_node_GetInfo_Response_1_0_certificate_of_authenticity_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.node.Version.1.0 protocol_version + uavcan_node_Version_1_0 protocol_version; + + /// uavcan.node.Version.1.0 hardware_version + uavcan_node_Version_1_0 hardware_version; + + /// uavcan.node.Version.1.0 software_version + uavcan_node_Version_1_0 software_version; + + /// saturated uint64 software_vcs_revision_id + uint64_t software_vcs_revision_id; + + /// saturated uint8[16] unique_id + uint8_t unique_id[16]; + + /// saturated uint8[<=50] name + struct /// Array address equivalence guarantee: &elements[0] == &name + { + uint8_t elements[uavcan_node_GetInfo_Response_1_0_name_ARRAY_CAPACITY_]; + size_t count; + } name; + + /// saturated uint64[<=1] software_image_crc + struct /// Array address equivalence guarantee: &elements[0] == &software_image_crc + { + uint64_t elements[uavcan_node_GetInfo_Response_1_0_software_image_crc_ARRAY_CAPACITY_]; + size_t count; + } software_image_crc; + + /// saturated uint8[<=222] certificate_of_authenticity + struct /// Array address equivalence guarantee: &elements[0] == &certificate_of_authenticity + { + uint8_t elements[uavcan_node_GetInfo_Response_1_0_certificate_of_authenticity_ARRAY_CAPACITY_]; + size_t count; + } certificate_of_authenticity; +} uavcan_node_GetInfo_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetInfo_Response_1_0_serialize_( + const uavcan_node_GetInfo_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2504UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.node.Version.1.0 protocol_version + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_Version_1_0_serialize_( + &obj->protocol_version, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.Version.1.0 hardware_version + size_t _size_bytes1_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_node_Version_1_0_serialize_( + &obj->hardware_version, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.node.Version.1.0 software_version + size_t _size_bytes2_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err4_ = uavcan_node_Version_1_0_serialize_( + &obj->software_version, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint64 software_vcs_revision_id + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->software_vcs_revision_id, 8U); + offset_bits += 64U; + } + + + + + { // saturated uint8[16] unique_id + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 16UL * 8U, &obj->unique_id[0], 0U); + offset_bits += 16UL * 8U; + } + + + + + { // saturated uint8[<=50] name + if (obj->name.count > 50) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->name.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->name.count * 8U, &obj->name.elements[0], 0U); + offset_bits += obj->name.count * 8U; + } + + + + + { // saturated uint64[<=1] software_image_crc + if (obj->software_image_crc.count > 1) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->software_image_crc.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->software_image_crc.count * 64UL, &obj->software_image_crc.elements[0], 0U); + offset_bits += obj->software_image_crc.count * 64UL; + } + + + + + { // saturated uint8[<=222] certificate_of_authenticity + if (obj->certificate_of_authenticity.count > 222) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->certificate_of_authenticity.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->certificate_of_authenticity.count * 8U, &obj->certificate_of_authenticity.elements[0], 0U); + offset_bits += obj->certificate_of_authenticity.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetInfo_Response_1_0_deserialize_( + uavcan_node_GetInfo_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.node.Version.1.0 protocol_version + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_node_Version_1_0_deserialize_( + &out_obj->protocol_version, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.Version.1.0 hardware_version + { + size_t _size_bytes4_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err7_ = uavcan_node_Version_1_0_deserialize_( + &out_obj->hardware_version, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _size_bytes4_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.Version.1.0 software_version + { + size_t _size_bytes5_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err8_ = uavcan_node_Version_1_0_deserialize_( + &out_obj->software_version, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err8_ < 0) + { + return _err8_; + } + offset_bits += _size_bytes5_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint64 software_vcs_revision_id + out_obj->software_vcs_revision_id = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 64); + offset_bits += 64U; + + + + + // saturated uint8[16] unique_id + nunavutGetBits(&out_obj->unique_id[0], &buffer[0], capacity_bytes, offset_bits, 16UL * 8U); + offset_bits += 16UL * 8U; + + + + + // saturated uint8[<=50] name + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->name.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->name.count = 0U; + } + offset_bits += 8U; + if (out_obj->name.count > 50U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->name.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->name.count * 8U); + offset_bits += out_obj->name.count * 8U; + + + + + // saturated uint64[<=1] software_image_crc + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->software_image_crc.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->software_image_crc.count = 0U; + } + offset_bits += 8U; + if (out_obj->software_image_crc.count > 1U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->software_image_crc.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->software_image_crc.count * 64U); + offset_bits += out_obj->software_image_crc.count * 64U; + + + + + // saturated uint8[<=222] certificate_of_authenticity + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->certificate_of_authenticity.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->certificate_of_authenticity.count = 0U; + } + offset_bits += 8U; + if (out_obj->certificate_of_authenticity.count > 222U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->certificate_of_authenticity.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->certificate_of_authenticity.count * 8U); + offset_bits += out_obj->certificate_of_authenticity.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_GetInfo_Response_1_0_initialize_(uavcan_node_GetInfo_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_GetInfo_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_GET_INFO_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/GetTransportStatistics_0_1.h b/src/nunavut_out/uavcan/node/GetTransportStatistics_0_1.h new file mode 100644 index 0000000..34f7b43 --- /dev/null +++ b/src/nunavut_out/uavcan/node/GetTransportStatistics_0_1.h @@ -0,0 +1,427 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.472351 UTC +// Is deprecated: no +// Fixed port-ID: 434 +// Full name: uavcan.node.GetTransportStatistics +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_GET_TRANSPORT_STATISTICS_0_1_INCLUDED_ +#define UAVCAN_NODE_GET_TRANSPORT_STATISTICS_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/434.GetTransportStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_GetTransportStatistics_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_node_GetTransportStatistics_0_1_FIXED_PORT_ID_ 434U + +#define uavcan_node_GetTransportStatistics_0_1_FULL_NAME_ "uavcan.node.GetTransportStatistics" +#define uavcan_node_GetTransportStatistics_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.GetTransportStatistics.0.1" + +#define uavcan_node_GetTransportStatistics_Request_0_1_FULL_NAME_ "uavcan.node.GetTransportStatistics.Request" +#define uavcan_node_GetTransportStatistics_Request_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.GetTransportStatistics.Request.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_GetTransportStatistics_Request_0_1_EXTENT_BYTES_ 0UL +#define uavcan_node_GetTransportStatistics_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_node_GetTransportStatistics_Request_0_1_EXTENT_BYTES_ >= uavcan_node_GetTransportStatistics_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_node_GetTransportStatistics_Request_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_GetTransportStatistics_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetTransportStatistics_Request_0_1_serialize_( + const uavcan_node_GetTransportStatistics_Request_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetTransportStatistics_Request_0_1_deserialize_( + uavcan_node_GetTransportStatistics_Request_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_GetTransportStatistics_Request_0_1_initialize_(uavcan_node_GetTransportStatistics_Request_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_GetTransportStatistics_Request_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_node_GetTransportStatistics_Response_0_1_FULL_NAME_ "uavcan.node.GetTransportStatistics.Response" +#define uavcan_node_GetTransportStatistics_Response_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.GetTransportStatistics.Response.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_GetTransportStatistics_Response_0_1_EXTENT_BYTES_ 192UL +#define uavcan_node_GetTransportStatistics_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 61UL +static_assert(uavcan_node_GetTransportStatistics_Response_0_1_EXTENT_BYTES_ >= uavcan_node_GetTransportStatistics_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_NETWORK_INTERFACES = 3 +#define uavcan_node_GetTransportStatistics_Response_0_1_MAX_NETWORK_INTERFACES (3U) + +/// Array metadata for: uavcan.node.IOStatistics.0.1[<=3] network_interface_statistics +#define uavcan_node_GetTransportStatistics_Response_0_1_network_interface_statistics_ARRAY_CAPACITY_ 3U +#define uavcan_node_GetTransportStatistics_Response_0_1_network_interface_statistics_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// uavcan.node.IOStatistics.0.1 transfer_statistics + uavcan_node_IOStatistics_0_1 transfer_statistics; + + /// uavcan.node.IOStatistics.0.1[<=3] network_interface_statistics + struct /// Array address equivalence guarantee: &elements[0] == &network_interface_statistics + { + uavcan_node_IOStatistics_0_1 elements[uavcan_node_GetTransportStatistics_Response_0_1_network_interface_statistics_ARRAY_CAPACITY_]; + size_t count; + } network_interface_statistics; +} uavcan_node_GetTransportStatistics_Response_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_GetTransportStatistics_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetTransportStatistics_Response_0_1_serialize_( + const uavcan_node_GetTransportStatistics_Response_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 488UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.node.IOStatistics.0.1 transfer_statistics + size_t _size_bytes0_ = 15UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_IOStatistics_0_1_serialize_( + &obj->transfer_statistics, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.IOStatistics.0.1[<=3] network_interface_statistics + if (obj->network_interface_statistics.count > 3) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->network_interface_statistics.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->network_interface_statistics.count; ++_index0_) + { + size_t _size_bytes1_ = 15UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_node_IOStatistics_0_1_serialize_( + &obj->network_interface_statistics.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_GetTransportStatistics_Response_0_1_deserialize_( + uavcan_node_GetTransportStatistics_Response_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.node.IOStatistics.0.1 transfer_statistics + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_node_IOStatistics_0_1_deserialize_( + &out_obj->transfer_statistics, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.IOStatistics.0.1[<=3] network_interface_statistics + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->network_interface_statistics.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->network_interface_statistics.count = 0U; + } + offset_bits += 8U; + if (out_obj->network_interface_statistics.count > 3U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->network_interface_statistics.count; ++_index1_) + { + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_node_IOStatistics_0_1_deserialize_( + &out_obj->network_interface_statistics.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_GetTransportStatistics_Response_0_1_initialize_(uavcan_node_GetTransportStatistics_Response_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_GetTransportStatistics_Response_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_GET_TRANSPORT_STATISTICS_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/Health_1_0.h b/src/nunavut_out/uavcan/node/Health_1_0.h new file mode 100644 index 0000000..19ef213 --- /dev/null +++ b/src/nunavut_out/uavcan/node/Health_1_0.h @@ -0,0 +1,245 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.475419 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.Health +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_HEALTH_1_0_INCLUDED_ +#define UAVCAN_NODE_HEALTH_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Health.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_Health_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_Health_1_0_FULL_NAME_ "uavcan.node.Health" +#define uavcan_node_Health_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.Health.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_Health_1_0_EXTENT_BYTES_ 1UL +#define uavcan_node_Health_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_node_Health_1_0_EXTENT_BYTES_ >= uavcan_node_Health_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint2 NOMINAL = 0 +#define uavcan_node_Health_1_0_NOMINAL (0U) +/// saturated uint2 ADVISORY = 1 +#define uavcan_node_Health_1_0_ADVISORY (1U) +/// saturated uint2 CAUTION = 2 +#define uavcan_node_Health_1_0_CAUTION (2U) +/// saturated uint2 WARNING = 3 +#define uavcan_node_Health_1_0_WARNING (3U) + +typedef struct +{ + /// saturated uint2 value + uint8_t value; +} uavcan_node_Health_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_Health_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Health_1_0_serialize_( + const uavcan_node_Health_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint2 value + uint8_t _sat0_ = obj->value; + if (_sat0_ > 3U) + { + _sat0_ = 3U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 2U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Health_1_0_deserialize_( + uavcan_node_Health_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint2 value + if ((offset_bits + 2U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 3U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 2U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_Health_1_0_initialize_(uavcan_node_Health_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_Health_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_HEALTH_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/Heartbeat_1_0.h b/src/nunavut_out/uavcan/node/Heartbeat_1_0.h new file mode 100644 index 0000000..65b5301 --- /dev/null +++ b/src/nunavut_out/uavcan/node/Heartbeat_1_0.h @@ -0,0 +1,343 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.477099 UTC +// Is deprecated: no +// Fixed port-ID: 7509 +// Full name: uavcan.node.Heartbeat +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_HEARTBEAT_1_0_INCLUDED_ +#define UAVCAN_NODE_HEARTBEAT_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/7509.Heartbeat.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_Heartbeat_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_node_Heartbeat_1_0_FIXED_PORT_ID_ 7509U + +#define uavcan_node_Heartbeat_1_0_FULL_NAME_ "uavcan.node.Heartbeat" +#define uavcan_node_Heartbeat_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.Heartbeat.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_Heartbeat_1_0_EXTENT_BYTES_ 12UL +#define uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 7UL +static_assert(uavcan_node_Heartbeat_1_0_EXTENT_BYTES_ >= uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 MAX_PUBLICATION_PERIOD = 1 +#define uavcan_node_Heartbeat_1_0_MAX_PUBLICATION_PERIOD (1U) +/// saturated uint16 OFFLINE_TIMEOUT = 3 +#define uavcan_node_Heartbeat_1_0_OFFLINE_TIMEOUT (3U) + +typedef struct +{ + /// saturated uint32 uptime + uint32_t uptime; + + /// uavcan.node.Health.1.0 health + uavcan_node_Health_1_0 health; + + /// uavcan.node.Mode.1.0 mode + uavcan_node_Mode_1_0 mode; + + /// saturated uint8 vendor_specific_status_code + uint8_t vendor_specific_status_code; +} uavcan_node_Heartbeat_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Heartbeat_1_0_serialize_( + const uavcan_node_Heartbeat_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 56UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 uptime + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->uptime, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.Health.1.0 health + size_t _size_bytes0_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_node_Health_1_0_serialize_( + &obj->health, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + + { // uavcan.node.Mode.1.0 mode + size_t _size_bytes1_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_node_Mode_1_0_serialize_( + &obj->mode, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8 vendor_specific_status_code + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->vendor_specific_status_code); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Heartbeat_1_0_deserialize_( + uavcan_node_Heartbeat_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 uptime + out_obj->uptime = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.Health.1.0 health + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_node_Health_1_0_deserialize_( + &out_obj->health, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.Mode.1.0 mode + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_node_Mode_1_0_deserialize_( + &out_obj->mode, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8 vendor_specific_status_code + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->vendor_specific_status_code = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->vendor_specific_status_code = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_Heartbeat_1_0_initialize_(uavcan_node_Heartbeat_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_Heartbeat_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_HEARTBEAT_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/ID_1_0.h b/src/nunavut_out/uavcan/node/ID_1_0.h new file mode 100644 index 0000000..a2ae828 --- /dev/null +++ b/src/nunavut_out/uavcan/node/ID_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.479737 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.ID +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_ID_1_0_INCLUDED_ +#define UAVCAN_NODE_ID_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_ID_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_ID_1_0_FULL_NAME_ "uavcan.node.ID" +#define uavcan_node_ID_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.ID.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_ID_1_0_EXTENT_BYTES_ 2UL +#define uavcan_node_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_node_ID_1_0_EXTENT_BYTES_ >= uavcan_node_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint16 value + uint16_t value; +} uavcan_node_ID_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ID_1_0_serialize_( + const uavcan_node_ID_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_ID_1_0_deserialize_( + uavcan_node_ID_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_ID_1_0_initialize_(uavcan_node_ID_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_ID_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_ID_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/IOStatistics_0_1.h b/src/nunavut_out/uavcan/node/IOStatistics_0_1.h new file mode 100644 index 0000000..f7484c0 --- /dev/null +++ b/src/nunavut_out/uavcan/node/IOStatistics_0_1.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.481282 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.IOStatistics +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_IO_STATISTICS_0_1_INCLUDED_ +#define UAVCAN_NODE_IO_STATISTICS_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/IOStatistics.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_IOStatistics_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_IOStatistics_0_1_FULL_NAME_ "uavcan.node.IOStatistics" +#define uavcan_node_IOStatistics_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.IOStatistics.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_IOStatistics_0_1_EXTENT_BYTES_ 15UL +#define uavcan_node_IOStatistics_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 15UL +static_assert(uavcan_node_IOStatistics_0_1_EXTENT_BYTES_ >= uavcan_node_IOStatistics_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// truncated uint40 num_emitted + uint64_t num_emitted; + + /// truncated uint40 num_received + uint64_t num_received; + + /// truncated uint40 num_errored + uint64_t num_errored; +} uavcan_node_IOStatistics_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_IOStatistics_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_IOStatistics_0_1_serialize_( + const uavcan_node_IOStatistics_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint40 num_emitted + (void) memmove(&buffer[offset_bits / 8U], &obj->num_emitted, 5U); + offset_bits += 40U; + } + + + + + { // truncated uint40 num_received + (void) memmove(&buffer[offset_bits / 8U], &obj->num_received, 5U); + offset_bits += 40U; + } + + + + + { // truncated uint40 num_errored + (void) memmove(&buffer[offset_bits / 8U], &obj->num_errored, 5U); + offset_bits += 40U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_IOStatistics_0_1_deserialize_( + uavcan_node_IOStatistics_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint40 num_emitted + out_obj->num_emitted = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // truncated uint40 num_received + out_obj->num_received = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + + + // truncated uint40 num_errored + out_obj->num_errored = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 40); + offset_bits += 40U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_IOStatistics_0_1_initialize_(uavcan_node_IOStatistics_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_IOStatistics_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_IO_STATISTICS_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/Mode_1_0.h b/src/nunavut_out/uavcan/node/Mode_1_0.h new file mode 100644 index 0000000..48d347b --- /dev/null +++ b/src/nunavut_out/uavcan/node/Mode_1_0.h @@ -0,0 +1,245 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.483260 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.Mode +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_MODE_1_0_INCLUDED_ +#define UAVCAN_NODE_MODE_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Mode.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_Mode_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_Mode_1_0_FULL_NAME_ "uavcan.node.Mode" +#define uavcan_node_Mode_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.Mode.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_Mode_1_0_EXTENT_BYTES_ 1UL +#define uavcan_node_Mode_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_node_Mode_1_0_EXTENT_BYTES_ >= uavcan_node_Mode_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint3 OPERATIONAL = 0 +#define uavcan_node_Mode_1_0_OPERATIONAL (0U) +/// saturated uint3 INITIALIZATION = 1 +#define uavcan_node_Mode_1_0_INITIALIZATION (1U) +/// saturated uint3 MAINTENANCE = 2 +#define uavcan_node_Mode_1_0_MAINTENANCE (2U) +/// saturated uint3 SOFTWARE_UPDATE = 3 +#define uavcan_node_Mode_1_0_SOFTWARE_UPDATE (3U) + +typedef struct +{ + /// saturated uint3 value + uint8_t value; +} uavcan_node_Mode_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_Mode_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Mode_1_0_serialize_( + const uavcan_node_Mode_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint3 value + uint8_t _sat0_ = obj->value; + if (_sat0_ > 7U) + { + _sat0_ = 7U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 3U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Mode_1_0_deserialize_( + uavcan_node_Mode_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint3 value + if ((offset_bits + 3U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 7U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 3U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_Mode_1_0_initialize_(uavcan_node_Mode_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_Mode_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_MODE_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/Version_1_0.h b/src/nunavut_out/uavcan/node/Version_1_0.h new file mode 100644 index 0000000..1c397aa --- /dev/null +++ b/src/nunavut_out/uavcan/node/Version_1_0.h @@ -0,0 +1,258 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.484928 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.Version +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_VERSION_1_0_INCLUDED_ +#define UAVCAN_NODE_VERSION_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/Version.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_Version_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_Version_1_0_FULL_NAME_ "uavcan.node.Version" +#define uavcan_node_Version_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.Version.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_Version_1_0_EXTENT_BYTES_ 2UL +#define uavcan_node_Version_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_node_Version_1_0_EXTENT_BYTES_ >= uavcan_node_Version_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint8 major + uint8_t major; + + /// saturated uint8 minor + uint8_t minor; +} uavcan_node_Version_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_Version_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Version_1_0_serialize_( + const uavcan_node_Version_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 major + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->major); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + + + { // saturated uint8 minor + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->minor); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_Version_1_0_deserialize_( + uavcan_node_Version_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 major + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->major = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->major = 0U; + } + offset_bits += 8U; + + + + + // saturated uint8 minor + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->minor = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->minor = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_Version_1_0_initialize_(uavcan_node_Version_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_Version_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_VERSION_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/port/ID_1_0.h b/src/nunavut_out/uavcan/node/port/ID_1_0.h new file mode 100644 index 0000000..e4f70f5 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/ID_1_0.h @@ -0,0 +1,324 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.486774 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.port.ID +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_ID_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_ID_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_ID_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_ID_1_0_FULL_NAME_ "uavcan.node.port.ID" +#define uavcan_node_port_ID_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.ID.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_ID_1_0_EXTENT_BYTES_ 3UL +#define uavcan_node_port_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 3UL +static_assert(uavcan_node_port_ID_1_0_EXTENT_BYTES_ >= uavcan_node_port_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_node_port_ID_1_0_UNION_OPTION_COUNT_ 2U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// uavcan.node.port.SubjectID.1.0 subject_id + uavcan_node_port_SubjectID_1_0 subject_id; + + /// uavcan.node.port.ServiceID.1.0 service_id + uavcan_node_port_ServiceID_1_0 service_id; + }; + uint8_t _tag_; +} uavcan_node_port_ID_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_ID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ID_1_0_serialize_( + const uavcan_node_port_ID_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 24UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // uavcan.node.port.SubjectID.1.0 subject_id + { + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_port_SubjectID_1_0_serialize_( + &obj->subject_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + else if (1U == obj->_tag_) // uavcan.node.port.ServiceID.1.0 service_id + { + size_t _size_bytes1_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_node_port_ServiceID_1_0_serialize_( + &obj->service_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ID_1_0_deserialize_( + uavcan_node_port_ID_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // uavcan.node.port.SubjectID.1.0 subject_id + { + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_node_port_SubjectID_1_0_deserialize_( + &out_obj->subject_id, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else if (1U == out_obj->_tag_) // uavcan.node.port.ServiceID.1.0 service_id + { + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_node_port_ServiceID_1_0_deserialize_( + &out_obj->service_id, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_ID_1_0_initialize_(uavcan_node_port_ID_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_ID_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "subject_id" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_ID_1_0_select_subject_id_(uavcan_node_port_ID_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "subject_id" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_ID_1_0_is_subject_id_(const uavcan_node_port_ID_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "service_id" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_ID_1_0_select_service_id_(uavcan_node_port_ID_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "service_id" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_ID_1_0_is_service_id_(const uavcan_node_port_ID_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_ID_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/port/List_0_1.h b/src/nunavut_out/uavcan/node/port/List_0_1.h new file mode 100644 index 0000000..1c80aaa --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/List_0_1.h @@ -0,0 +1,432 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.492219 UTC +// Is deprecated: yes +// Fixed port-ID: 7510 +// Full name: uavcan.node.port.List +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_NODE_PORT_LIST_0_1_INCLUDED_ +#define UAVCAN_NODE_PORT_LIST_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_port_List_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_node_port_List_0_1_FIXED_PORT_ID_ 7510U + +#define uavcan_node_port_List_0_1_FULL_NAME_ "uavcan.node.port.List" +#define uavcan_node_port_List_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.port.List.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_List_0_1_EXTENT_BYTES_ 8466UL +#define uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 8466UL +static_assert(uavcan_node_port_List_0_1_EXTENT_BYTES_ >= uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_PUBLICATION_PERIOD = 10 +#define uavcan_node_port_List_0_1_MAX_PUBLICATION_PERIOD (10U) + +typedef struct +{ + /// uavcan.node.port.SubjectIDList.0.1 publishers + uavcan_node_port_SubjectIDList_0_1 publishers; + + /// uavcan.node.port.SubjectIDList.0.1 subscribers + uavcan_node_port_SubjectIDList_0_1 subscribers; + + /// uavcan.node.port.ServiceIDList.0.1 clients + uavcan_node_port_ServiceIDList_0_1 clients; + + /// uavcan.node.port.ServiceIDList.0.1 servers + uavcan_node_port_ServiceIDList_0_1 servers; +} uavcan_node_port_List_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_List_0_1_serialize_( + const uavcan_node_port_List_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 67728UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.node.port.SubjectIDList.0.1 publishers + size_t _size_bytes0_ = 1025UL; // Nested object (max) size, in bytes. + offset_bits += 32U; // Reserve space for the delimiter header. + int8_t _err0_ = uavcan_node_port_SubjectIDList_0_1_serialize_( + &obj->publishers, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + // Jump back to write the delimiter header after the nested object is serialized and its length is known. + (void) memmove(&buffer[(offset_bits - 32) / 8U], &_size_bytes0_, 4U); + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.port.SubjectIDList.0.1 subscribers + size_t _size_bytes1_ = 1025UL; // Nested object (max) size, in bytes. + offset_bits += 32U; // Reserve space for the delimiter header. + int8_t _err2_ = uavcan_node_port_SubjectIDList_0_1_serialize_( + &obj->subscribers, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + // Jump back to write the delimiter header after the nested object is serialized and its length is known. + (void) memmove(&buffer[(offset_bits - 32) / 8U], &_size_bytes1_, 4U); + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.node.port.ServiceIDList.0.1 clients + size_t _size_bytes2_ = 64UL; // Nested object (max) size, in bytes. + // Constant delimiter header can be written ahead of the nested object. + (void) memmove(&buffer[offset_bits / 8U], &_size_bytes2_, 4U); + offset_bits += 32U; + int8_t _err4_ = uavcan_node_port_ServiceIDList_0_1_serialize_( + &obj->clients, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + + { // uavcan.node.port.ServiceIDList.0.1 servers + size_t _size_bytes3_ = 64UL; // Nested object (max) size, in bytes. + // Constant delimiter header can be written ahead of the nested object. + (void) memmove(&buffer[offset_bits / 8U], &_size_bytes3_, 4U); + offset_bits += 32U; + int8_t _err6_ = uavcan_node_port_ServiceIDList_0_1_serialize_( + &obj->servers, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_List_0_1_deserialize_( + uavcan_node_port_List_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.node.port.SubjectIDList.0.1 publishers + { + // Delimiter header: truncated uint32 + size_t _size_bytes4_ = 0U; + _size_bytes4_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes4_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh0_ = _size_bytes4_; // Store the original delimiter header value. + const int8_t _err8_ = uavcan_node_port_SubjectIDList_0_1_deserialize_( + &out_obj->publishers, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh0_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.SubjectIDList.0.1 subscribers + { + // Delimiter header: truncated uint32 + size_t _size_bytes5_ = 0U; + _size_bytes5_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes5_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh1_ = _size_bytes5_; // Store the original delimiter header value. + const int8_t _err9_ = uavcan_node_port_SubjectIDList_0_1_deserialize_( + &out_obj->subscribers, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh1_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.ServiceIDList.0.1 clients + { + // Delimiter header: truncated uint32 + size_t _size_bytes6_ = 0U; + _size_bytes6_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes6_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh2_ = _size_bytes6_; // Store the original delimiter header value. + const int8_t _err10_ = uavcan_node_port_ServiceIDList_0_1_deserialize_( + &out_obj->clients, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err10_ < 0) + { + return _err10_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh2_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.ServiceIDList.0.1 servers + { + // Delimiter header: truncated uint32 + size_t _size_bytes7_ = 0U; + _size_bytes7_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes7_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh3_ = _size_bytes7_; // Store the original delimiter header value. + const int8_t _err11_ = uavcan_node_port_ServiceIDList_0_1_deserialize_( + &out_obj->servers, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err11_ < 0) + { + return _err11_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh3_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_List_0_1_initialize_(uavcan_node_port_List_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_List_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_LIST_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/port/List_1_0.h b/src/nunavut_out/uavcan/node/port/List_1_0.h new file mode 100644 index 0000000..784bac8 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/List_1_0.h @@ -0,0 +1,423 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.489059 UTC +// Is deprecated: no +// Fixed port-ID: 7510 +// Full name: uavcan.node.port.List +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_LIST_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_LIST_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/7510.List.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_node_port_List_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_node_port_List_1_0_FIXED_PORT_ID_ 7510U + +#define uavcan_node_port_List_1_0_FULL_NAME_ "uavcan.node.port.List" +#define uavcan_node_port_List_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.List.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_List_1_0_EXTENT_BYTES_ 8466UL +#define uavcan_node_port_List_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8466UL +static_assert(uavcan_node_port_List_1_0_EXTENT_BYTES_ >= uavcan_node_port_List_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_PUBLICATION_PERIOD = 10 +#define uavcan_node_port_List_1_0_MAX_PUBLICATION_PERIOD (10U) + +typedef struct +{ + /// uavcan.node.port.SubjectIDList.1.0 publishers + uavcan_node_port_SubjectIDList_1_0 publishers; + + /// uavcan.node.port.SubjectIDList.1.0 subscribers + uavcan_node_port_SubjectIDList_1_0 subscribers; + + /// uavcan.node.port.ServiceIDList.1.0 clients + uavcan_node_port_ServiceIDList_1_0 clients; + + /// uavcan.node.port.ServiceIDList.1.0 servers + uavcan_node_port_ServiceIDList_1_0 servers; +} uavcan_node_port_List_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_List_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_List_1_0_serialize_( + const uavcan_node_port_List_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 67728UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.node.port.SubjectIDList.1.0 publishers + size_t _size_bytes0_ = 1025UL; // Nested object (max) size, in bytes. + offset_bits += 32U; // Reserve space for the delimiter header. + int8_t _err0_ = uavcan_node_port_SubjectIDList_1_0_serialize_( + &obj->publishers, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + // Jump back to write the delimiter header after the nested object is serialized and its length is known. + (void) memmove(&buffer[(offset_bits - 32) / 8U], &_size_bytes0_, 4U); + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.port.SubjectIDList.1.0 subscribers + size_t _size_bytes1_ = 1025UL; // Nested object (max) size, in bytes. + offset_bits += 32U; // Reserve space for the delimiter header. + int8_t _err2_ = uavcan_node_port_SubjectIDList_1_0_serialize_( + &obj->subscribers, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + // Jump back to write the delimiter header after the nested object is serialized and its length is known. + (void) memmove(&buffer[(offset_bits - 32) / 8U], &_size_bytes1_, 4U); + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + + { // uavcan.node.port.ServiceIDList.1.0 clients + size_t _size_bytes2_ = 64UL; // Nested object (max) size, in bytes. + // Constant delimiter header can be written ahead of the nested object. + (void) memmove(&buffer[offset_bits / 8U], &_size_bytes2_, 4U); + offset_bits += 32U; + int8_t _err4_ = uavcan_node_port_ServiceIDList_1_0_serialize_( + &obj->clients, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err4_ < 0) + { + return _err4_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err5_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _pad2_; + } + + { // uavcan.node.port.ServiceIDList.1.0 servers + size_t _size_bytes3_ = 64UL; // Nested object (max) size, in bytes. + // Constant delimiter header can be written ahead of the nested object. + (void) memmove(&buffer[offset_bits / 8U], &_size_bytes3_, 4U); + offset_bits += 32U; + int8_t _err6_ = uavcan_node_port_ServiceIDList_1_0_serialize_( + &obj->servers, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad3_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err7_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad3_); // Optimize? + if (_err7_ < 0) + { + return _err7_; + } + offset_bits += _pad3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_List_1_0_deserialize_( + uavcan_node_port_List_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.node.port.SubjectIDList.1.0 publishers + { + // Delimiter header: truncated uint32 + size_t _size_bytes4_ = 0U; + _size_bytes4_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes4_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh0_ = _size_bytes4_; // Store the original delimiter header value. + const int8_t _err8_ = uavcan_node_port_SubjectIDList_1_0_deserialize_( + &out_obj->publishers, &buffer[offset_bits / 8U], &_size_bytes4_); + if (_err8_ < 0) + { + return _err8_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh0_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.SubjectIDList.1.0 subscribers + { + // Delimiter header: truncated uint32 + size_t _size_bytes5_ = 0U; + _size_bytes5_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes5_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh1_ = _size_bytes5_; // Store the original delimiter header value. + const int8_t _err9_ = uavcan_node_port_SubjectIDList_1_0_deserialize_( + &out_obj->subscribers, &buffer[offset_bits / 8U], &_size_bytes5_); + if (_err9_ < 0) + { + return _err9_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh1_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.ServiceIDList.1.0 clients + { + // Delimiter header: truncated uint32 + size_t _size_bytes6_ = 0U; + _size_bytes6_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes6_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh2_ = _size_bytes6_; // Store the original delimiter header value. + const int8_t _err10_ = uavcan_node_port_ServiceIDList_1_0_deserialize_( + &out_obj->clients, &buffer[offset_bits / 8U], &_size_bytes6_); + if (_err10_ < 0) + { + return _err10_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh2_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.port.ServiceIDList.1.0 servers + { + // Delimiter header: truncated uint32 + size_t _size_bytes7_ = 0U; + _size_bytes7_ = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + if (_size_bytes7_ > (capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes))) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER; + } + const size_t _dh3_ = _size_bytes7_; // Store the original delimiter header value. + const int8_t _err11_ = uavcan_node_port_ServiceIDList_1_0_deserialize_( + &out_obj->servers, &buffer[offset_bits / 8U], &_size_bytes7_); + if (_err11_ < 0) + { + return _err11_; + } + // Advance the offset by the size of the delimiter header, even if the nested deserialization routine + // consumed fewer bytes of data. This behavior implements the implicit truncation rule for nested objects. + offset_bits += _dh3_ * 8U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_List_1_0_initialize_(uavcan_node_port_List_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_List_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_LIST_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/port/ServiceIDList_0_1.h b/src/nunavut_out/uavcan/node/port/ServiceIDList_0_1.h new file mode 100644 index 0000000..2789589 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/ServiceIDList_0_1.h @@ -0,0 +1,245 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.498998 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.node.port.ServiceIDList +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_NODE_PORT_SERVICE_ID_LIST_0_1_INCLUDED_ +#define UAVCAN_NODE_PORT_SERVICE_ID_LIST_0_1_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_ServiceIDList_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_ServiceIDList_0_1_FULL_NAME_ "uavcan.node.port.ServiceIDList" +#define uavcan_node_port_ServiceIDList_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.port.ServiceIDList.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_ServiceIDList_0_1_EXTENT_BYTES_ 128UL +#define uavcan_node_port_ServiceIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 64UL +static_assert(uavcan_node_port_ServiceIDList_0_1_EXTENT_BYTES_ >= uavcan_node_port_ServiceIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 CAPACITY = 512 +#define uavcan_node_port_ServiceIDList_0_1_CAPACITY (512U) + +/// Array metadata for: saturated bool[512] mask +#define uavcan_node_port_ServiceIDList_0_1_mask_ARRAY_CAPACITY_ 512U +#define uavcan_node_port_ServiceIDList_0_1_mask_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated bool[512] mask + /// Bitpacked array, capacity 512 bits. Access via @ref nunavutSetBit(), @ref nunavutGetBit(). + uint8_t mask_bitpacked_[64]; +} uavcan_node_port_ServiceIDList_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_ServiceIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceIDList_0_1_serialize_( + const uavcan_node_port_ServiceIDList_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 512UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool[512] mask + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 512UL, &obj->mask_bitpacked_[0], 0U); + offset_bits += 512UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceIDList_0_1_deserialize_( + uavcan_node_port_ServiceIDList_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool[512] mask + nunavutGetBits(&out_obj->mask_bitpacked_[0], &buffer[0], capacity_bytes, offset_bits, 512UL); + offset_bits += 512UL; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_ServiceIDList_0_1_initialize_(uavcan_node_port_ServiceIDList_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_ServiceIDList_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SERVICE_ID_LIST_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/port/ServiceIDList_1_0.h b/src/nunavut_out/uavcan/node/port/ServiceIDList_1_0.h new file mode 100644 index 0000000..6484f54 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/ServiceIDList_1_0.h @@ -0,0 +1,236 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.496912 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.port.ServiceIDList +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_SERVICE_ID_LIST_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_SERVICE_ID_LIST_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_ServiceIDList_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_ServiceIDList_1_0_FULL_NAME_ "uavcan.node.port.ServiceIDList" +#define uavcan_node_port_ServiceIDList_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.ServiceIDList.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_ServiceIDList_1_0_EXTENT_BYTES_ 128UL +#define uavcan_node_port_ServiceIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 64UL +static_assert(uavcan_node_port_ServiceIDList_1_0_EXTENT_BYTES_ >= uavcan_node_port_ServiceIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 CAPACITY = 512 +#define uavcan_node_port_ServiceIDList_1_0_CAPACITY (512U) + +/// Array metadata for: saturated bool[512] mask +#define uavcan_node_port_ServiceIDList_1_0_mask_ARRAY_CAPACITY_ 512U +#define uavcan_node_port_ServiceIDList_1_0_mask_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated bool[512] mask + /// Bitpacked array, capacity 512 bits. Access via @ref nunavutSetBit(), @ref nunavutGetBit(). + uint8_t mask_bitpacked_[64]; +} uavcan_node_port_ServiceIDList_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_ServiceIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceIDList_1_0_serialize_( + const uavcan_node_port_ServiceIDList_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 512UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool[512] mask + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 512UL, &obj->mask_bitpacked_[0], 0U); + offset_bits += 512UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceIDList_1_0_deserialize_( + uavcan_node_port_ServiceIDList_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool[512] mask + nunavutGetBits(&out_obj->mask_bitpacked_[0], &buffer[0], capacity_bytes, offset_bits, 512UL); + offset_bits += 512UL; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_ServiceIDList_1_0_initialize_(uavcan_node_port_ServiceIDList_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_ServiceIDList_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SERVICE_ID_LIST_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/port/ServiceID_1_0.h b/src/nunavut_out/uavcan/node/port/ServiceID_1_0.h new file mode 100644 index 0000000..b318d4c --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/ServiceID_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.495260 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.port.ServiceID +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_SERVICE_ID_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_SERVICE_ID_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/ServiceID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_ServiceID_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_ServiceID_1_0_FULL_NAME_ "uavcan.node.port.ServiceID" +#define uavcan_node_port_ServiceID_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.ServiceID.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_ServiceID_1_0_EXTENT_BYTES_ 2UL +#define uavcan_node_port_ServiceID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_node_port_ServiceID_1_0_EXTENT_BYTES_ >= uavcan_node_port_ServiceID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint9 MAX = 511 +#define uavcan_node_port_ServiceID_1_0_MAX (511U) + +typedef struct +{ + /// saturated uint9 value + uint16_t value; +} uavcan_node_port_ServiceID_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_ServiceID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceID_1_0_serialize_( + const uavcan_node_port_ServiceID_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint9 value + uint16_t _sat0_ = obj->value; + if (_sat0_ > 511U) + { + _sat0_ = 511U; + } + (void) memmove(&buffer[offset_bits / 8U], &_sat0_, 2U); + offset_bits += 9U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_ServiceID_1_0_deserialize_( + uavcan_node_port_ServiceID_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint9 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 9); + offset_bits += 9U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_ServiceID_1_0_initialize_(uavcan_node_port_ServiceID_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_ServiceID_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SERVICE_ID_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/node/port/SubjectIDList_0_1.h b/src/nunavut_out/uavcan/node/port/SubjectIDList_0_1.h new file mode 100644 index 0000000..cde3918 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/SubjectIDList_0_1.h @@ -0,0 +1,407 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.505341 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.node.port.SubjectIDList +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_NODE_PORT_SUBJECT_ID_LIST_0_1_INCLUDED_ +#define UAVCAN_NODE_PORT_SUBJECT_ID_LIST_0_1_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_SubjectIDList_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_SubjectIDList_0_1_FULL_NAME_ "uavcan.node.port.SubjectIDList" +#define uavcan_node_port_SubjectIDList_0_1_FULL_NAME_AND_VERSION_ "uavcan.node.port.SubjectIDList.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_SubjectIDList_0_1_EXTENT_BYTES_ 4097UL +#define uavcan_node_port_SubjectIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1025UL +static_assert(uavcan_node_port_SubjectIDList_0_1_EXTENT_BYTES_ >= uavcan_node_port_SubjectIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 CAPACITY = 8192 +#define uavcan_node_port_SubjectIDList_0_1_CAPACITY (8192U) + +/// Array metadata for: saturated bool[8192] mask +#define uavcan_node_port_SubjectIDList_0_1_mask_ARRAY_CAPACITY_ 8192U +#define uavcan_node_port_SubjectIDList_0_1_mask_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: uavcan.node.port.SubjectID.1.0[<=255] sparse_list +#define uavcan_node_port_SubjectIDList_0_1_sparse_list_ARRAY_CAPACITY_ 255U +#define uavcan_node_port_SubjectIDList_0_1_sparse_list_ARRAY_IS_VARIABLE_LENGTH_ true + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_node_port_SubjectIDList_0_1_UNION_OPTION_COUNT_ 3U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// saturated bool[8192] mask + /// Bitpacked array, capacity 8192 bits. Access via @ref nunavutSetBit(), @ref nunavutGetBit(). + uint8_t mask_bitpacked_[1024]; + + /// uavcan.node.port.SubjectID.1.0[<=255] sparse_list + struct /// Array address equivalence guarantee: &elements[0] == &sparse_list + { + uavcan_node_port_SubjectID_1_0 elements[uavcan_node_port_SubjectIDList_0_1_sparse_list_ARRAY_CAPACITY_]; + size_t count; + } sparse_list; + + /// uavcan.primitive.Empty.1.0 total + uavcan_primitive_Empty_1_0 _total; + }; + uint8_t _tag_; +} uavcan_node_port_SubjectIDList_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_SubjectIDList_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectIDList_0_1_serialize_( + const uavcan_node_port_SubjectIDList_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8200UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // saturated bool[8192] mask + { + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 8192UL, &obj->mask_bitpacked_[0], 0U); + offset_bits += 8192UL; + } + else if (1U == obj->_tag_) // uavcan.node.port.SubjectID.1.0[<=255] sparse_list + { + if (obj->sparse_list.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->sparse_list.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->sparse_list.count; ++_index0_) + { + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_port_SubjectID_1_0_serialize_( + &obj->sparse_list.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + } + else if (2U == obj->_tag_) // uavcan.primitive.Empty.1.0 total + { + size_t _size_bytes1_ = 0UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_primitive_Empty_1_0_serialize_( + &obj->_total, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectIDList_0_1_deserialize_( + uavcan_node_port_SubjectIDList_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // saturated bool[8192] mask + { + nunavutGetBits(&out_obj->mask_bitpacked_[0], &buffer[0], capacity_bytes, offset_bits, 8192UL); + offset_bits += 8192UL; + } + else if (1U == out_obj->_tag_) // uavcan.node.port.SubjectID.1.0[<=255] sparse_list + { + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->sparse_list.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->sparse_list.count = 0U; + } + offset_bits += 8U; + if (out_obj->sparse_list.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->sparse_list.count; ++_index1_) + { + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_node_port_SubjectID_1_0_deserialize_( + &out_obj->sparse_list.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + } + } + else if (2U == out_obj->_tag_) // uavcan.primitive.Empty.1.0 total + { + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_primitive_Empty_1_0_deserialize_( + &out_obj->_total, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_SubjectIDList_0_1_initialize_(uavcan_node_port_SubjectIDList_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_SubjectIDList_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "mask" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_0_1_select_mask_(uavcan_node_port_SubjectIDList_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "mask" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_0_1_is_mask_(const uavcan_node_port_SubjectIDList_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "sparse_list" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_0_1_select_sparse_list_(uavcan_node_port_SubjectIDList_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "sparse_list" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_0_1_is_sparse_list_(const uavcan_node_port_SubjectIDList_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +/// Mark option "total" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_0_1_select_total_(uavcan_node_port_SubjectIDList_0_1* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 2; + } +} + +/// Check if option "total" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_0_1_is_total_(const uavcan_node_port_SubjectIDList_0_1* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 2)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SUBJECT_ID_LIST_0_1_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/port/SubjectIDList_1_0.h b/src/nunavut_out/uavcan/node/port/SubjectIDList_1_0.h new file mode 100644 index 0000000..c297702 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/SubjectIDList_1_0.h @@ -0,0 +1,398 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.502564 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.port.SubjectIDList +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_SUBJECT_ID_LIST_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_SUBJECT_ID_LIST_1_0_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectIDList.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_SubjectIDList_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_SubjectIDList_1_0_FULL_NAME_ "uavcan.node.port.SubjectIDList" +#define uavcan_node_port_SubjectIDList_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.SubjectIDList.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_SubjectIDList_1_0_EXTENT_BYTES_ 4097UL +#define uavcan_node_port_SubjectIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1025UL +static_assert(uavcan_node_port_SubjectIDList_1_0_EXTENT_BYTES_ >= uavcan_node_port_SubjectIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint16 CAPACITY = 8192 +#define uavcan_node_port_SubjectIDList_1_0_CAPACITY (8192U) + +/// Array metadata for: saturated bool[8192] mask +#define uavcan_node_port_SubjectIDList_1_0_mask_ARRAY_CAPACITY_ 8192U +#define uavcan_node_port_SubjectIDList_1_0_mask_ARRAY_IS_VARIABLE_LENGTH_ false +/// Array metadata for: uavcan.node.port.SubjectID.1.0[<=255] sparse_list +#define uavcan_node_port_SubjectIDList_1_0_sparse_list_ARRAY_CAPACITY_ 255U +#define uavcan_node_port_SubjectIDList_1_0_sparse_list_ARRAY_IS_VARIABLE_LENGTH_ true + +/// The number of fields in the union. Valid tag values range from zero to this value minus one, inclusive. +#define uavcan_node_port_SubjectIDList_1_0_UNION_OPTION_COUNT_ 3U + +typedef struct +{ + union /// The union is placed first to ensure that the active element address equals the struct address. + { + /// saturated bool[8192] mask + /// Bitpacked array, capacity 8192 bits. Access via @ref nunavutSetBit(), @ref nunavutGetBit(). + uint8_t mask_bitpacked_[1024]; + + /// uavcan.node.port.SubjectID.1.0[<=255] sparse_list + struct /// Array address equivalence guarantee: &elements[0] == &sparse_list + { + uavcan_node_port_SubjectID_1_0 elements[uavcan_node_port_SubjectIDList_1_0_sparse_list_ARRAY_CAPACITY_]; + size_t count; + } sparse_list; + + /// uavcan.primitive.Empty.1.0 total + uavcan_primitive_Empty_1_0 _total; + }; + uint8_t _tag_; +} uavcan_node_port_SubjectIDList_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_SubjectIDList_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectIDList_1_0_serialize_( + const uavcan_node_port_SubjectIDList_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8200UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + { // Union tag field: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->_tag_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + if (0U == obj->_tag_) // saturated bool[8192] mask + { + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 8192UL, &obj->mask_bitpacked_[0], 0U); + offset_bits += 8192UL; + } + else if (1U == obj->_tag_) // uavcan.node.port.SubjectID.1.0[<=255] sparse_list + { + if (obj->sparse_list.count > 255) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->sparse_list.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->sparse_list.count; ++_index0_) + { + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_port_SubjectID_1_0_serialize_( + &obj->sparse_list.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + } + else if (2U == obj->_tag_) // uavcan.primitive.Empty.1.0 total + { + size_t _size_bytes1_ = 0UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_primitive_Empty_1_0_serialize_( + &obj->_total, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectIDList_1_0_deserialize_( + uavcan_node_port_SubjectIDList_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + // Union tag field: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->_tag_ = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->_tag_ = 0U; + } + offset_bits += 8U; + + if (0U == out_obj->_tag_) // saturated bool[8192] mask + { + nunavutGetBits(&out_obj->mask_bitpacked_[0], &buffer[0], capacity_bytes, offset_bits, 8192UL); + offset_bits += 8192UL; + } + else if (1U == out_obj->_tag_) // uavcan.node.port.SubjectID.1.0[<=255] sparse_list + { + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->sparse_list.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->sparse_list.count = 0U; + } + offset_bits += 8U; + if (out_obj->sparse_list.count > 255U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->sparse_list.count; ++_index1_) + { + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_node_port_SubjectID_1_0_deserialize_( + &out_obj->sparse_list.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + } + } + else if (2U == out_obj->_tag_) // uavcan.primitive.Empty.1.0 total + { + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_primitive_Empty_1_0_deserialize_( + &out_obj->_total, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + } + else + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG; + } + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_SubjectIDList_1_0_initialize_(uavcan_node_port_SubjectIDList_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_SubjectIDList_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +/// Mark option "mask" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_1_0_select_mask_(uavcan_node_port_SubjectIDList_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 0; + } +} + +/// Check if option "mask" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_1_0_is_mask_(const uavcan_node_port_SubjectIDList_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 0)); +} + +/// Mark option "sparse_list" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_1_0_select_sparse_list_(uavcan_node_port_SubjectIDList_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 1; + } +} + +/// Check if option "sparse_list" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_1_0_is_sparse_list_(const uavcan_node_port_SubjectIDList_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 1)); +} + +/// Mark option "total" active without initializing it. Does nothing if @param obj is NULL. +static inline void uavcan_node_port_SubjectIDList_1_0_select_total_(uavcan_node_port_SubjectIDList_1_0* const obj) +{ + if (obj != NULL) + { + obj->_tag_ = 2; + } +} + +/// Check if option "total" is active. Returns false if @param obj is NULL. +static inline bool uavcan_node_port_SubjectIDList_1_0_is_total_(const uavcan_node_port_SubjectIDList_1_0* const obj) +{ + return ((obj != NULL) && (obj->_tag_ == 2)); +} + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SUBJECT_ID_LIST_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/node/port/SubjectID_1_0.h b/src/nunavut_out/uavcan/node/port/SubjectID_1_0.h new file mode 100644 index 0000000..bf26a50 --- /dev/null +++ b/src/nunavut_out/uavcan/node/port/SubjectID_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.500967 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.node.port.SubjectID +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_NODE_PORT_SUBJECT_ID_1_0_INCLUDED_ +#define UAVCAN_NODE_PORT_SUBJECT_ID_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/node/port/SubjectID.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_node_port_SubjectID_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_node_port_SubjectID_1_0_FULL_NAME_ "uavcan.node.port.SubjectID" +#define uavcan_node_port_SubjectID_1_0_FULL_NAME_AND_VERSION_ "uavcan.node.port.SubjectID.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_node_port_SubjectID_1_0_EXTENT_BYTES_ 2UL +#define uavcan_node_port_SubjectID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_node_port_SubjectID_1_0_EXTENT_BYTES_ >= uavcan_node_port_SubjectID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint13 MAX = 8191 +#define uavcan_node_port_SubjectID_1_0_MAX (8191U) + +typedef struct +{ + /// saturated uint13 value + uint16_t value; +} uavcan_node_port_SubjectID_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_node_port_SubjectID_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectID_1_0_serialize_( + const uavcan_node_port_SubjectID_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint13 value + uint16_t _sat0_ = obj->value; + if (_sat0_ > 8191U) + { + _sat0_ = 8191U; + } + (void) memmove(&buffer[offset_bits / 8U], &_sat0_, 2U); + offset_bits += 13U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_node_port_SubjectID_1_0_deserialize_( + uavcan_node_port_SubjectID_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint13 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 13); + offset_bits += 13U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_node_port_SubjectID_1_0_initialize_(uavcan_node_port_SubjectID_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_node_port_SubjectID_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_NODE_PORT_SUBJECT_ID_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_1_0.h b/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_1_0.h new file mode 100644 index 0000000..ebe54b3 --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_1_0.h @@ -0,0 +1,303 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.447404 UTC +// Is deprecated: no +// Fixed port-ID: 8166 +// Full name: uavcan.pnp.NodeIDAllocationData +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_1_0_INCLUDED_ +#define UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8166.NodeIDAllocationData.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_pnp_NodeIDAllocationData_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_pnp_NodeIDAllocationData_1_0_FIXED_PORT_ID_ 8166U + +#define uavcan_pnp_NodeIDAllocationData_1_0_FULL_NAME_ "uavcan.pnp.NodeIDAllocationData" +#define uavcan_pnp_NodeIDAllocationData_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.NodeIDAllocationData.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_NodeIDAllocationData_1_0_EXTENT_BYTES_ 9UL +#define uavcan_pnp_NodeIDAllocationData_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 9UL +static_assert(uavcan_pnp_NodeIDAllocationData_1_0_EXTENT_BYTES_ >= uavcan_pnp_NodeIDAllocationData_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: uavcan.node.ID.1.0[<=1] allocated_node_id +#define uavcan_pnp_NodeIDAllocationData_1_0_allocated_node_id_ARRAY_CAPACITY_ 1U +#define uavcan_pnp_NodeIDAllocationData_1_0_allocated_node_id_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// truncated uint48 unique_id_hash + uint64_t unique_id_hash; + + /// uavcan.node.ID.1.0[<=1] allocated_node_id + struct /// Array address equivalence guarantee: &elements[0] == &allocated_node_id + { + uavcan_node_ID_1_0 elements[uavcan_pnp_NodeIDAllocationData_1_0_allocated_node_id_ARRAY_CAPACITY_]; + size_t count; + } allocated_node_id; +} uavcan_pnp_NodeIDAllocationData_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_NodeIDAllocationData_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_NodeIDAllocationData_1_0_serialize_( + const uavcan_pnp_NodeIDAllocationData_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 72UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint48 unique_id_hash + (void) memmove(&buffer[offset_bits / 8U], &obj->unique_id_hash, 6U); + offset_bits += 48U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.ID.1.0[<=1] allocated_node_id + if (obj->allocated_node_id.count > 1) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->allocated_node_id.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->allocated_node_id.count; ++_index0_) + { + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_node_ID_1_0_serialize_( + &obj->allocated_node_id.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_NodeIDAllocationData_1_0_deserialize_( + uavcan_pnp_NodeIDAllocationData_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint48 unique_id_hash + out_obj->unique_id_hash = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 48); + offset_bits += 48U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.ID.1.0[<=1] allocated_node_id + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->allocated_node_id.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->allocated_node_id.count = 0U; + } + offset_bits += 8U; + if (out_obj->allocated_node_id.count > 1U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->allocated_node_id.count; ++_index1_) + { + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_node_ID_1_0_deserialize_( + &out_obj->allocated_node_id.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_NodeIDAllocationData_1_0_initialize_(uavcan_pnp_NodeIDAllocationData_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_NodeIDAllocationData_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_2_0.h b/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_2_0.h new file mode 100644 index 0000000..12974ee --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/NodeIDAllocationData_2_0.h @@ -0,0 +1,265 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl +// Generated at: 2024-11-23 10:35:29.445242 UTC +// Is deprecated: no +// Fixed port-ID: 8165 +// Full name: uavcan.pnp.NodeIDAllocationData +// Version: 2.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_2_0_INCLUDED_ +#define UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_2_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_pnp_NodeIDAllocationData_2_0_HAS_FIXED_PORT_ID_ true +#define uavcan_pnp_NodeIDAllocationData_2_0_FIXED_PORT_ID_ 8165U + +#define uavcan_pnp_NodeIDAllocationData_2_0_FULL_NAME_ "uavcan.pnp.NodeIDAllocationData" +#define uavcan_pnp_NodeIDAllocationData_2_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.NodeIDAllocationData.2.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_NodeIDAllocationData_2_0_EXTENT_BYTES_ 48UL +#define uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 18UL +static_assert(uavcan_pnp_NodeIDAllocationData_2_0_EXTENT_BYTES_ >= uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[16] unique_id +#define uavcan_pnp_NodeIDAllocationData_2_0_unique_id_ARRAY_CAPACITY_ 16U +#define uavcan_pnp_NodeIDAllocationData_2_0_unique_id_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.node.ID.1.0 node_id + uavcan_node_ID_1_0 node_id; + + /// saturated uint8[16] unique_id + uint8_t unique_id[16]; +} uavcan_pnp_NodeIDAllocationData_2_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_NodeIDAllocationData_2_0_serialize_( + const uavcan_pnp_NodeIDAllocationData_2_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 144UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.node.ID.1.0 node_id + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_node_ID_1_0_serialize_( + &obj->node_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated uint8[16] unique_id + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 16UL * 8U, &obj->unique_id[0], 0U); + offset_bits += 16UL * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_NodeIDAllocationData_2_0_deserialize_( + uavcan_pnp_NodeIDAllocationData_2_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.node.ID.1.0 node_id + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_node_ID_1_0_deserialize_( + &out_obj->node_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated uint8[16] unique_id + nunavutGetBits(&out_obj->unique_id[0], &buffer[0], capacity_bytes, offset_bits, 16UL * 8U); + offset_bits += 16UL * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_NodeIDAllocationData_2_0_initialize_(uavcan_pnp_NodeIDAllocationData_2_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_NodeIDAllocationData_2_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_NODE_ID_ALLOCATION_DATA_2_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/pnp/cluster/AppendEntries_1_0.h b/src/nunavut_out/uavcan/pnp/cluster/AppendEntries_1_0.h new file mode 100644 index 0000000..f0b1dc3 --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/cluster/AppendEntries_1_0.h @@ -0,0 +1,552 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.449708 UTC +// Is deprecated: no +// Fixed port-ID: 390 +// Full name: uavcan.pnp.cluster.AppendEntries +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_CLUSTER_APPEND_ENTRIES_1_0_INCLUDED_ +#define UAVCAN_PNP_CLUSTER_APPEND_ENTRIES_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/390.AppendEntries.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_pnp_cluster_AppendEntries_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_pnp_cluster_AppendEntries_1_0_FIXED_PORT_ID_ 390U + +#define uavcan_pnp_cluster_AppendEntries_1_0_FULL_NAME_ "uavcan.pnp.cluster.AppendEntries" +#define uavcan_pnp_cluster_AppendEntries_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.AppendEntries.1.0" + +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_FULL_NAME_ "uavcan.pnp.cluster.AppendEntries.Request" +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.AppendEntries.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_EXTENT_BYTES_ 96UL +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 35UL +static_assert(uavcan_pnp_cluster_AppendEntries_Request_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_AppendEntries_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 DEFAULT_MIN_ELECTION_TIMEOUT = 2 +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_DEFAULT_MIN_ELECTION_TIMEOUT (2U) +/// saturated uint8 DEFAULT_MAX_ELECTION_TIMEOUT = 4 +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_DEFAULT_MAX_ELECTION_TIMEOUT (4U) + +/// Array metadata for: uavcan.pnp.cluster.Entry.1.0[<=1] entries +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_entries_ARRAY_CAPACITY_ 1U +#define uavcan_pnp_cluster_AppendEntries_Request_1_0_entries_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint32 term + uint32_t term; + + /// saturated uint32 prev_log_term + uint32_t prev_log_term; + + /// saturated uint16 prev_log_index + uint16_t prev_log_index; + + /// saturated uint16 leader_commit + uint16_t leader_commit; + + /// uavcan.pnp.cluster.Entry.1.0[<=1] entries + struct /// Array address equivalence guarantee: &elements[0] == &entries + { + uavcan_pnp_cluster_Entry_1_0 elements[uavcan_pnp_cluster_AppendEntries_Request_1_0_entries_ARRAY_CAPACITY_]; + size_t count; + } entries; +} uavcan_pnp_cluster_AppendEntries_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_AppendEntries_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_AppendEntries_Request_1_0_serialize_( + const uavcan_pnp_cluster_AppendEntries_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 280UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->term, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint32 prev_log_term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->prev_log_term, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint16 prev_log_index + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->prev_log_index, 2U); + offset_bits += 16U; + } + + + + + { // saturated uint16 leader_commit + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->leader_commit, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.pnp.cluster.Entry.1.0[<=1] entries + if (obj->entries.count > 1) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->entries.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->entries.count; ++_index0_) + { + size_t _size_bytes0_ = 22UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_pnp_cluster_Entry_1_0_serialize_( + &obj->entries.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_AppendEntries_Request_1_0_deserialize_( + uavcan_pnp_cluster_AppendEntries_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 term + out_obj->term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint32 prev_log_term + out_obj->prev_log_term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint16 prev_log_index + out_obj->prev_log_index = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + + + // saturated uint16 leader_commit + out_obj->leader_commit = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.pnp.cluster.Entry.1.0[<=1] entries + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->entries.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->entries.count = 0U; + } + offset_bits += 8U; + if (out_obj->entries.count > 1U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->entries.count; ++_index1_) + { + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_pnp_cluster_Entry_1_0_deserialize_( + &out_obj->entries.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_AppendEntries_Request_1_0_initialize_(uavcan_pnp_cluster_AppendEntries_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_AppendEntries_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_pnp_cluster_AppendEntries_Response_1_0_FULL_NAME_ "uavcan.pnp.cluster.AppendEntries.Response" +#define uavcan_pnp_cluster_AppendEntries_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.AppendEntries.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_AppendEntries_Response_1_0_EXTENT_BYTES_ 48UL +#define uavcan_pnp_cluster_AppendEntries_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 5UL +static_assert(uavcan_pnp_cluster_AppendEntries_Response_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_AppendEntries_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 term + uint32_t term; + + /// saturated bool success + bool success; +} uavcan_pnp_cluster_AppendEntries_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_AppendEntries_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_AppendEntries_Response_1_0_serialize_( + const uavcan_pnp_cluster_AppendEntries_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 40UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->term, 4U); + offset_bits += 32U; + } + + + + + { // saturated bool success + buffer[offset_bits / 8U] = obj->success ? 1U : 0U; + offset_bits += 1U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_AppendEntries_Response_1_0_deserialize_( + uavcan_pnp_cluster_AppendEntries_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 term + out_obj->term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated bool success + if (offset_bits < capacity_bits) + { + out_obj->success = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->success = false; + } + offset_bits += 1U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_AppendEntries_Response_1_0_initialize_(uavcan_pnp_cluster_AppendEntries_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_AppendEntries_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_CLUSTER_APPEND_ENTRIES_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/pnp/cluster/Discovery_1_0.h b/src/nunavut_out/uavcan/pnp/cluster/Discovery_1_0.h new file mode 100644 index 0000000..e7b8bb9 --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/cluster/Discovery_1_0.h @@ -0,0 +1,339 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.453908 UTC +// Is deprecated: no +// Fixed port-ID: 8164 +// Full name: uavcan.pnp.cluster.Discovery +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_CLUSTER_DISCOVERY_1_0_INCLUDED_ +#define UAVCAN_PNP_CLUSTER_DISCOVERY_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/8164.Discovery.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_pnp_cluster_Discovery_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_pnp_cluster_Discovery_1_0_FIXED_PORT_ID_ 8164U + +#define uavcan_pnp_cluster_Discovery_1_0_FULL_NAME_ "uavcan.pnp.cluster.Discovery" +#define uavcan_pnp_cluster_Discovery_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.Discovery.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_Discovery_1_0_EXTENT_BYTES_ 96UL +#define uavcan_pnp_cluster_Discovery_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_pnp_cluster_Discovery_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_Discovery_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 BROADCASTING_PERIOD = 1 +#define uavcan_pnp_cluster_Discovery_1_0_BROADCASTING_PERIOD (1U) +/// saturated uint3 MAX_CLUSTER_SIZE = 5 +#define uavcan_pnp_cluster_Discovery_1_0_MAX_CLUSTER_SIZE (5U) + +/// Array metadata for: uavcan.node.ID.1.0[<=5] known_nodes +#define uavcan_pnp_cluster_Discovery_1_0_known_nodes_ARRAY_CAPACITY_ 5U +#define uavcan_pnp_cluster_Discovery_1_0_known_nodes_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint3 configured_cluster_size + uint8_t configured_cluster_size; + + /// uavcan.node.ID.1.0[<=5] known_nodes + struct /// Array address equivalence guarantee: &elements[0] == &known_nodes + { + uavcan_node_ID_1_0 elements[uavcan_pnp_cluster_Discovery_1_0_known_nodes_ARRAY_CAPACITY_]; + size_t count; + } known_nodes; +} uavcan_pnp_cluster_Discovery_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_Discovery_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_Discovery_1_0_serialize_( + const uavcan_pnp_cluster_Discovery_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint3 configured_cluster_size + uint8_t _sat0_ = obj->configured_cluster_size; + if (_sat0_ > 7U) + { + _sat0_ = 7U; + } + buffer[offset_bits / 8U] = (uint8_t)(_sat0_); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 3U; + } + + + + + { // void5 + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, 5U); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += 5UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.ID.1.0[<=5] known_nodes + if (obj->known_nodes.count > 5) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->known_nodes.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->known_nodes.count; ++_index0_) + { + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err2_ = uavcan_node_ID_1_0_serialize_( + &obj->known_nodes.elements[_index0_], &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err2_ < 0) + { + return _err2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err3_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_Discovery_1_0_deserialize_( + uavcan_pnp_cluster_Discovery_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint3 configured_cluster_size + if ((offset_bits + 3U) <= capacity_bits) + { + out_obj->configured_cluster_size = buffer[offset_bits / 8U] & 7U; + } + else + { + out_obj->configured_cluster_size = 0U; + } + offset_bits += 3U; + + + + + // void5 + offset_bits += 5; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.ID.1.0[<=5] known_nodes + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->known_nodes.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->known_nodes.count = 0U; + } + offset_bits += 8U; + if (out_obj->known_nodes.count > 5U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->known_nodes.count; ++_index1_) + { + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err4_ = uavcan_node_ID_1_0_deserialize_( + &out_obj->known_nodes.elements[_index1_], &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_Discovery_1_0_initialize_(uavcan_pnp_cluster_Discovery_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_Discovery_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_CLUSTER_DISCOVERY_1_0_INCLUDED_ + diff --git a/src/nunavut_out/uavcan/pnp/cluster/Entry_1_0.h b/src/nunavut_out/uavcan/pnp/cluster/Entry_1_0.h new file mode 100644 index 0000000..58a5a45 --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/cluster/Entry_1_0.h @@ -0,0 +1,292 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.456457 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.pnp.cluster.Entry +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_CLUSTER_ENTRY_1_0_INCLUDED_ +#define UAVCAN_PNP_CLUSTER_ENTRY_1_0_INCLUDED_ + +#include +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/Entry.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_pnp_cluster_Entry_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_pnp_cluster_Entry_1_0_FULL_NAME_ "uavcan.pnp.cluster.Entry" +#define uavcan_pnp_cluster_Entry_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.Entry.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_Entry_1_0_EXTENT_BYTES_ 22UL +#define uavcan_pnp_cluster_Entry_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 22UL +static_assert(uavcan_pnp_cluster_Entry_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_Entry_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[16] unique_id +#define uavcan_pnp_cluster_Entry_1_0_unique_id_ARRAY_CAPACITY_ 16U +#define uavcan_pnp_cluster_Entry_1_0_unique_id_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated uint32 term + uint32_t term; + + /// saturated uint8[16] unique_id + uint8_t unique_id[16]; + + /// uavcan.node.ID.1.0 node_id + uavcan_node_ID_1_0 node_id; +} uavcan_pnp_cluster_Entry_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_Entry_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_Entry_1_0_serialize_( + const uavcan_pnp_cluster_Entry_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 176UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->term, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint8[16] unique_id + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 16UL * 8U, &obj->unique_id[0], 0U); + offset_bits += 16UL * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.node.ID.1.0 node_id + size_t _size_bytes0_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_node_ID_1_0_serialize_( + &obj->node_id, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_Entry_1_0_deserialize_( + uavcan_pnp_cluster_Entry_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 term + out_obj->term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint8[16] unique_id + nunavutGetBits(&out_obj->unique_id[0], &buffer[0], capacity_bytes, offset_bits, 16UL * 8U); + offset_bits += 16UL * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.node.ID.1.0 node_id + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err3_ = uavcan_node_ID_1_0_deserialize_( + &out_obj->node_id, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_Entry_1_0_initialize_(uavcan_pnp_cluster_Entry_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_Entry_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_CLUSTER_ENTRY_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/pnp/cluster/RequestVote_1_0.h b/src/nunavut_out/uavcan/pnp/cluster/RequestVote_1_0.h new file mode 100644 index 0000000..eae779c --- /dev/null +++ b/src/nunavut_out/uavcan/pnp/cluster/RequestVote_1_0.h @@ -0,0 +1,449 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.458485 UTC +// Is deprecated: no +// Fixed port-ID: 391 +// Full name: uavcan.pnp.cluster.RequestVote +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PNP_CLUSTER_REQUEST_VOTE_1_0_INCLUDED_ +#define UAVCAN_PNP_CLUSTER_REQUEST_VOTE_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/pnp/cluster/391.RequestVote.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_pnp_cluster_RequestVote_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_pnp_cluster_RequestVote_1_0_FIXED_PORT_ID_ 391U + +#define uavcan_pnp_cluster_RequestVote_1_0_FULL_NAME_ "uavcan.pnp.cluster.RequestVote" +#define uavcan_pnp_cluster_RequestVote_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.RequestVote.1.0" + +#define uavcan_pnp_cluster_RequestVote_Request_1_0_FULL_NAME_ "uavcan.pnp.cluster.RequestVote.Request" +#define uavcan_pnp_cluster_RequestVote_Request_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.RequestVote.Request.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_RequestVote_Request_1_0_EXTENT_BYTES_ 48UL +#define uavcan_pnp_cluster_RequestVote_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 10UL +static_assert(uavcan_pnp_cluster_RequestVote_Request_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_RequestVote_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 term + uint32_t term; + + /// saturated uint32 last_log_term + uint32_t last_log_term; + + /// saturated uint16 last_log_index + uint16_t last_log_index; +} uavcan_pnp_cluster_RequestVote_Request_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_RequestVote_Request_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_RequestVote_Request_1_0_serialize_( + const uavcan_pnp_cluster_RequestVote_Request_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 80UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->term, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint32 last_log_term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->last_log_term, 4U); + offset_bits += 32U; + } + + + + + { // saturated uint16 last_log_index + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->last_log_index, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_RequestVote_Request_1_0_deserialize_( + uavcan_pnp_cluster_RequestVote_Request_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 term + out_obj->term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint32 last_log_term + out_obj->last_log_term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated uint16 last_log_index + out_obj->last_log_index = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_RequestVote_Request_1_0_initialize_(uavcan_pnp_cluster_RequestVote_Request_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_RequestVote_Request_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_pnp_cluster_RequestVote_Response_1_0_FULL_NAME_ "uavcan.pnp.cluster.RequestVote.Response" +#define uavcan_pnp_cluster_RequestVote_Response_1_0_FULL_NAME_AND_VERSION_ "uavcan.pnp.cluster.RequestVote.Response.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_pnp_cluster_RequestVote_Response_1_0_EXTENT_BYTES_ 48UL +#define uavcan_pnp_cluster_RequestVote_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 5UL +static_assert(uavcan_pnp_cluster_RequestVote_Response_1_0_EXTENT_BYTES_ >= uavcan_pnp_cluster_RequestVote_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 term + uint32_t term; + + /// saturated bool vote_granted + bool vote_granted; +} uavcan_pnp_cluster_RequestVote_Response_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_pnp_cluster_RequestVote_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_RequestVote_Response_1_0_serialize_( + const uavcan_pnp_cluster_RequestVote_Response_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 40UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 term + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->term, 4U); + offset_bits += 32U; + } + + + + + { // saturated bool vote_granted + buffer[offset_bits / 8U] = obj->vote_granted ? 1U : 0U; + offset_bits += 1U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_pnp_cluster_RequestVote_Response_1_0_deserialize_( + uavcan_pnp_cluster_RequestVote_Response_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 term + out_obj->term = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + + + // saturated bool vote_granted + if (offset_bits < capacity_bits) + { + out_obj->vote_granted = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->vote_granted = false; + } + offset_bits += 1U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_pnp_cluster_RequestVote_Response_1_0_initialize_(uavcan_pnp_cluster_RequestVote_Response_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_pnp_cluster_RequestVote_Response_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PNP_CLUSTER_REQUEST_VOTE_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/Empty_1_0.h b/src/nunavut_out/uavcan/primitive/Empty_1_0.h new file mode 100644 index 0000000..ba64156 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/Empty_1_0.h @@ -0,0 +1,170 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.382231 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.Empty +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_EMPTY_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_EMPTY_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Empty.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_Empty_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_Empty_1_0_FULL_NAME_ "uavcan.primitive.Empty" +#define uavcan_primitive_Empty_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.Empty.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_Empty_1_0_EXTENT_BYTES_ 0UL +#define uavcan_primitive_Empty_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_primitive_Empty_1_0_EXTENT_BYTES_ >= uavcan_primitive_Empty_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_primitive_Empty_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_Empty_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_Empty_1_0_serialize_( + const uavcan_primitive_Empty_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_Empty_1_0_deserialize_( + uavcan_primitive_Empty_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_Empty_1_0_initialize_(uavcan_primitive_Empty_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_Empty_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_EMPTY_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/String_1_0.h b/src/nunavut_out/uavcan/primitive/String_1_0.h new file mode 100644 index 0000000..d06d1dd --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/String_1_0.h @@ -0,0 +1,248 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.383488 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.String +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_STRING_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_STRING_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/String.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_String_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_String_1_0_FULL_NAME_ "uavcan.primitive.String" +#define uavcan_primitive_String_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.String.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_String_1_0_EXTENT_BYTES_ 258UL +#define uavcan_primitive_String_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_primitive_String_1_0_EXTENT_BYTES_ >= uavcan_primitive_String_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=256] value +#define uavcan_primitive_String_1_0_value_ARRAY_CAPACITY_ 256U +#define uavcan_primitive_String_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=256] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint8_t elements[uavcan_primitive_String_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_String_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_String_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_String_1_0_serialize_( + const uavcan_primitive_String_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=256] value + if (obj->value.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->value.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 8U, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_String_1_0_deserialize_( + uavcan_primitive_String_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=256] value + // Array length prefix: truncated uint16 + out_obj->value.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->value.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 8U); + offset_bits += out_obj->value.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_String_1_0_initialize_(uavcan_primitive_String_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_String_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_STRING_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/Unstructured_1_0.h b/src/nunavut_out/uavcan/primitive/Unstructured_1_0.h new file mode 100644 index 0000000..616f7ad --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/Unstructured_1_0.h @@ -0,0 +1,248 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.385316 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.Unstructured +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_UNSTRUCTURED_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_UNSTRUCTURED_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/Unstructured.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_Unstructured_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_Unstructured_1_0_FULL_NAME_ "uavcan.primitive.Unstructured" +#define uavcan_primitive_Unstructured_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.Unstructured.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_Unstructured_1_0_EXTENT_BYTES_ 258UL +#define uavcan_primitive_Unstructured_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_primitive_Unstructured_1_0_EXTENT_BYTES_ >= uavcan_primitive_Unstructured_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=256] value +#define uavcan_primitive_Unstructured_1_0_value_ARRAY_CAPACITY_ 256U +#define uavcan_primitive_Unstructured_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=256] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint8_t elements[uavcan_primitive_Unstructured_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_Unstructured_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_Unstructured_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_Unstructured_1_0_serialize_( + const uavcan_primitive_Unstructured_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=256] value + if (obj->value.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->value.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 8U, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_Unstructured_1_0_deserialize_( + uavcan_primitive_Unstructured_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=256] value + // Array length prefix: truncated uint16 + out_obj->value.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->value.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 8U); + offset_bits += out_obj->value.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_Unstructured_1_0_initialize_(uavcan_primitive_Unstructured_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_Unstructured_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_UNSTRUCTURED_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Bit_1_0.h b/src/nunavut_out/uavcan/primitive/array/Bit_1_0.h new file mode 100644 index 0000000..95bbee8 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Bit_1_0.h @@ -0,0 +1,249 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.406322 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Bit +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_BIT_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_BIT_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Bit_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Bit_1_0_FULL_NAME_ "uavcan.primitive.array.Bit" +#define uavcan_primitive_array_Bit_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Bit.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Bit_1_0_EXTENT_BYTES_ 258UL +#define uavcan_primitive_array_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_primitive_array_Bit_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated bool[<=2048] value +#define uavcan_primitive_array_Bit_1_0_value_ARRAY_CAPACITY_ 2048U +#define uavcan_primitive_array_Bit_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated bool[<=2048] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + /// Bitpacked array, capacity 2048 bits. Access via @ref nunavutSetBit(), @ref nunavutGetBit(). + uint8_t bitpacked[256]; + size_t count; + } value; +} uavcan_primitive_array_Bit_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Bit_1_0_serialize_( + const uavcan_primitive_array_Bit_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool[<=2048] value + if (obj->value.count > 2048) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->value.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count, &obj->value.bitpacked[0], 0U); + offset_bits += obj->value.count; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Bit_1_0_deserialize_( + uavcan_primitive_array_Bit_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool[<=2048] value + // Array length prefix: truncated uint16 + out_obj->value.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->value.count > 2048U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.bitpacked[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count); + offset_bits += out_obj->value.count; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Bit_1_0_initialize_(uavcan_primitive_array_Bit_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Bit_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_BIT_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Integer16_1_0.h b/src/nunavut_out/uavcan/primitive/array/Integer16_1_0.h new file mode 100644 index 0000000..5ecf4e6 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Integer16_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.408178 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Integer16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_INTEGER16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_INTEGER16_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Integer16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Integer16_1_0_FULL_NAME_ "uavcan.primitive.array.Integer16" +#define uavcan_primitive_array_Integer16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Integer16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Integer16_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Integer16_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated int16[<=128] value +#define uavcan_primitive_array_Integer16_1_0_value_ARRAY_CAPACITY_ 128U +#define uavcan_primitive_array_Integer16_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated int16[<=128] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + int16_t elements[uavcan_primitive_array_Integer16_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Integer16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer16_1_0_serialize_( + const uavcan_primitive_array_Integer16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int16[<=128] value + if (obj->value.count > 128) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 16UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 16UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer16_1_0_deserialize_( + uavcan_primitive_array_Integer16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int16[<=128] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 128U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 16U); + offset_bits += out_obj->value.count * 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Integer16_1_0_initialize_(uavcan_primitive_array_Integer16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Integer16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_INTEGER16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Integer32_1_0.h b/src/nunavut_out/uavcan/primitive/array/Integer32_1_0.h new file mode 100644 index 0000000..16fb044 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Integer32_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.409987 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Integer32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_INTEGER32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_INTEGER32_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Integer32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Integer32_1_0_FULL_NAME_ "uavcan.primitive.array.Integer32" +#define uavcan_primitive_array_Integer32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Integer32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Integer32_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Integer32_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated int32[<=64] value +#define uavcan_primitive_array_Integer32_1_0_value_ARRAY_CAPACITY_ 64U +#define uavcan_primitive_array_Integer32_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated int32[<=64] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + int32_t elements[uavcan_primitive_array_Integer32_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Integer32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer32_1_0_serialize_( + const uavcan_primitive_array_Integer32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int32[<=64] value + if (obj->value.count > 64) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 32UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer32_1_0_deserialize_( + uavcan_primitive_array_Integer32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int32[<=64] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 64U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 32U); + offset_bits += out_obj->value.count * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Integer32_1_0_initialize_(uavcan_primitive_array_Integer32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Integer32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_INTEGER32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Integer64_1_0.h b/src/nunavut_out/uavcan/primitive/array/Integer64_1_0.h new file mode 100644 index 0000000..21f5534 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Integer64_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.411787 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Integer64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_INTEGER64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_INTEGER64_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Integer64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Integer64_1_0_FULL_NAME_ "uavcan.primitive.array.Integer64" +#define uavcan_primitive_array_Integer64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Integer64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Integer64_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Integer64_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated int64[<=32] value +#define uavcan_primitive_array_Integer64_1_0_value_ARRAY_CAPACITY_ 32U +#define uavcan_primitive_array_Integer64_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated int64[<=32] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + int64_t elements[uavcan_primitive_array_Integer64_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Integer64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer64_1_0_serialize_( + const uavcan_primitive_array_Integer64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int64[<=32] value + if (obj->value.count > 32) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 64UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer64_1_0_deserialize_( + uavcan_primitive_array_Integer64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int64[<=32] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 32U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 64U); + offset_bits += out_obj->value.count * 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Integer64_1_0_initialize_(uavcan_primitive_array_Integer64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Integer64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_INTEGER64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Integer8_1_0.h b/src/nunavut_out/uavcan/primitive/array/Integer8_1_0.h new file mode 100644 index 0000000..e668e93 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Integer8_1_0.h @@ -0,0 +1,248 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.413565 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Integer8 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_INTEGER8_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_INTEGER8_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Integer8_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Integer8_1_0_FULL_NAME_ "uavcan.primitive.array.Integer8" +#define uavcan_primitive_array_Integer8_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Integer8.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Integer8_1_0_EXTENT_BYTES_ 258UL +#define uavcan_primitive_array_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_primitive_array_Integer8_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated int8[<=256] value +#define uavcan_primitive_array_Integer8_1_0_value_ARRAY_CAPACITY_ 256U +#define uavcan_primitive_array_Integer8_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated int8[<=256] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + int8_t elements[uavcan_primitive_array_Integer8_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Integer8_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer8_1_0_serialize_( + const uavcan_primitive_array_Integer8_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int8[<=256] value + if (obj->value.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->value.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 8U, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Integer8_1_0_deserialize_( + uavcan_primitive_array_Integer8_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int8[<=256] value + // Array length prefix: truncated uint16 + out_obj->value.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->value.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 8U); + offset_bits += out_obj->value.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Integer8_1_0_initialize_(uavcan_primitive_array_Integer8_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Integer8_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_INTEGER8_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Natural16_1_0.h b/src/nunavut_out/uavcan/primitive/array/Natural16_1_0.h new file mode 100644 index 0000000..3cef07b --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Natural16_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.415322 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Natural16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_NATURAL16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_NATURAL16_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Natural16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Natural16_1_0_FULL_NAME_ "uavcan.primitive.array.Natural16" +#define uavcan_primitive_array_Natural16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Natural16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Natural16_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Natural16_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint16[<=128] value +#define uavcan_primitive_array_Natural16_1_0_value_ARRAY_CAPACITY_ 128U +#define uavcan_primitive_array_Natural16_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint16[<=128] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint16_t elements[uavcan_primitive_array_Natural16_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Natural16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural16_1_0_serialize_( + const uavcan_primitive_array_Natural16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16[<=128] value + if (obj->value.count > 128) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 16UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 16UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural16_1_0_deserialize_( + uavcan_primitive_array_Natural16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16[<=128] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 128U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 16U); + offset_bits += out_obj->value.count * 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Natural16_1_0_initialize_(uavcan_primitive_array_Natural16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Natural16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_NATURAL16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Natural32_1_0.h b/src/nunavut_out/uavcan/primitive/array/Natural32_1_0.h new file mode 100644 index 0000000..f7ab730 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Natural32_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.417121 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Natural32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_NATURAL32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_NATURAL32_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Natural32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Natural32_1_0_FULL_NAME_ "uavcan.primitive.array.Natural32" +#define uavcan_primitive_array_Natural32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Natural32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Natural32_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Natural32_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint32[<=64] value +#define uavcan_primitive_array_Natural32_1_0_value_ARRAY_CAPACITY_ 64U +#define uavcan_primitive_array_Natural32_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint32[<=64] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint32_t elements[uavcan_primitive_array_Natural32_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Natural32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural32_1_0_serialize_( + const uavcan_primitive_array_Natural32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32[<=64] value + if (obj->value.count > 64) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 32UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural32_1_0_deserialize_( + uavcan_primitive_array_Natural32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32[<=64] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 64U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 32U); + offset_bits += out_obj->value.count * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Natural32_1_0_initialize_(uavcan_primitive_array_Natural32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Natural32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_NATURAL32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Natural64_1_0.h b/src/nunavut_out/uavcan/primitive/array/Natural64_1_0.h new file mode 100644 index 0000000..f7dd652 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Natural64_1_0.h @@ -0,0 +1,256 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.418897 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Natural64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_NATURAL64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_NATURAL64_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Natural64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Natural64_1_0_FULL_NAME_ "uavcan.primitive.array.Natural64" +#define uavcan_primitive_array_Natural64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Natural64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Natural64_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Natural64_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint64[<=32] value +#define uavcan_primitive_array_Natural64_1_0_value_ARRAY_CAPACITY_ 32U +#define uavcan_primitive_array_Natural64_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint64[<=32] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint64_t elements[uavcan_primitive_array_Natural64_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Natural64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural64_1_0_serialize_( + const uavcan_primitive_array_Natural64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint64[<=32] value + if (obj->value.count > 32) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 64UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural64_1_0_deserialize_( + uavcan_primitive_array_Natural64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint64[<=32] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 32U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 64U); + offset_bits += out_obj->value.count * 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Natural64_1_0_initialize_(uavcan_primitive_array_Natural64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Natural64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_NATURAL64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Natural8_1_0.h b/src/nunavut_out/uavcan/primitive/array/Natural8_1_0.h new file mode 100644 index 0000000..a52ed20 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Natural8_1_0.h @@ -0,0 +1,248 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.420667 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Natural8 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_NATURAL8_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_NATURAL8_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Natural8_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Natural8_1_0_FULL_NAME_ "uavcan.primitive.array.Natural8" +#define uavcan_primitive_array_Natural8_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Natural8.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Natural8_1_0_EXTENT_BYTES_ 258UL +#define uavcan_primitive_array_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 258UL +static_assert(uavcan_primitive_array_Natural8_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated uint8[<=256] value +#define uavcan_primitive_array_Natural8_1_0_value_ARRAY_CAPACITY_ 256U +#define uavcan_primitive_array_Natural8_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated uint8[<=256] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + uint8_t elements[uavcan_primitive_array_Natural8_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Natural8_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural8_1_0_serialize_( + const uavcan_primitive_array_Natural8_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2064UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8[<=256] value + if (obj->value.count > 256) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint16 + (void) memmove(&buffer[offset_bits / 8U], &obj->value.count, 2U); + offset_bits += 16U; + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 8U, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Natural8_1_0_deserialize_( + uavcan_primitive_array_Natural8_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8[<=256] value + // Array length prefix: truncated uint16 + out_obj->value.count = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + if (out_obj->value.count > 256U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 8U); + offset_bits += out_obj->value.count * 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Natural8_1_0_initialize_(uavcan_primitive_array_Natural8_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Natural8_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_NATURAL8_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Real16_1_0.h b/src/nunavut_out/uavcan/primitive/array/Real16_1_0.h new file mode 100644 index 0000000..71994e6 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Real16_1_0.h @@ -0,0 +1,272 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.422455 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Real16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_REAL16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_REAL16_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Real16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Real16_1_0_FULL_NAME_ "uavcan.primitive.array.Real16" +#define uavcan_primitive_array_Real16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Real16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Real16_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Real16_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float16[<=128] value +#define uavcan_primitive_array_Real16_1_0_value_ARRAY_CAPACITY_ 128U +#define uavcan_primitive_array_Real16_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated float16[<=128] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + float elements[uavcan_primitive_array_Real16_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Real16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real16_1_0_serialize_( + const uavcan_primitive_array_Real16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16[<=128] value + if (obj->value.count > 128) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + for (size_t _index0_ = 0U; _index0_ < obj->value.count; ++_index0_) + { + float _sat0_ = obj->value.elements[_index0_]; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real16_1_0_deserialize_( + uavcan_primitive_array_Real16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16[<=128] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 128U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + for (size_t _index1_ = 0U; _index1_ < out_obj->value.count; ++_index1_) + { + out_obj->value.elements[_index1_] = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Real16_1_0_initialize_(uavcan_primitive_array_Real16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Real16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_REAL16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Real32_1_0.h b/src/nunavut_out/uavcan/primitive/array/Real32_1_0.h new file mode 100644 index 0000000..4f4823e --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Real32_1_0.h @@ -0,0 +1,257 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.424398 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Real32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_REAL32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_REAL32_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Real32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Real32_1_0_FULL_NAME_ "uavcan.primitive.array.Real32" +#define uavcan_primitive_array_Real32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Real32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Real32_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Real32_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[<=64] value +#define uavcan_primitive_array_Real32_1_0_value_ARRAY_CAPACITY_ 64U +#define uavcan_primitive_array_Real32_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated float32[<=64] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + float elements[uavcan_primitive_array_Real32_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Real32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real32_1_0_serialize_( + const uavcan_primitive_array_Real32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[<=64] value + if (obj->value.count > 64) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 32UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real32_1_0_deserialize_( + uavcan_primitive_array_Real32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[<=64] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 64U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 32U); + offset_bits += out_obj->value.count * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Real32_1_0_initialize_(uavcan_primitive_array_Real32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Real32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_REAL32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/array/Real64_1_0.h b/src/nunavut_out/uavcan/primitive/array/Real64_1_0.h new file mode 100644 index 0000000..a601dfa --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/array/Real64_1_0.h @@ -0,0 +1,259 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.426223 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.array.Real64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_ARRAY_REAL64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_ARRAY_REAL64_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/array/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_array_Real64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_array_Real64_1_0_FULL_NAME_ "uavcan.primitive.array.Real64" +#define uavcan_primitive_array_Real64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.array.Real64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_array_Real64_1_0_EXTENT_BYTES_ 257UL +#define uavcan_primitive_array_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 257UL +static_assert(uavcan_primitive_array_Real64_1_0_EXTENT_BYTES_ >= uavcan_primitive_array_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float64[<=32] value +#define uavcan_primitive_array_Real64_1_0_value_ARRAY_CAPACITY_ 32U +#define uavcan_primitive_array_Real64_1_0_value_ARRAY_IS_VARIABLE_LENGTH_ true + +typedef struct +{ + /// saturated float64[<=32] value + struct /// Array address equivalence guarantee: &elements[0] == &value + { + double elements[uavcan_primitive_array_Real64_1_0_value_ARRAY_CAPACITY_]; + size_t count; + } value; +} uavcan_primitive_array_Real64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_array_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real64_1_0_serialize_( + const uavcan_primitive_array_Real64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 2056UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64[<=32] value + if (obj->value.count > 32) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + // Array length prefix: truncated uint8 + buffer[offset_bits / 8U] = (uint8_t)(obj->value.count); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, obj->value.count * 64UL, &obj->value.elements[0], 0U); + offset_bits += obj->value.count * 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_array_Real64_1_0_deserialize_( + uavcan_primitive_array_Real64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64[<=32] value + // Array length prefix: truncated uint8 + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value.count = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value.count = 0U; + } + offset_bits += 8U; + if (out_obj->value.count > 32U) + { + return -NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH; + } + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->value.elements[0], &buffer[0], capacity_bytes, offset_bits, out_obj->value.count * 64U); + offset_bits += out_obj->value.count * 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_array_Real64_1_0_initialize_(uavcan_primitive_array_Real64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_array_Real64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_ARRAY_REAL64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Bit_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Bit_1_0.h new file mode 100644 index 0000000..de62982 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Bit_1_0.h @@ -0,0 +1,231 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.387100 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Bit +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_BIT_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_BIT_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Bit.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Bit_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Bit_1_0_FULL_NAME_ "uavcan.primitive.scalar.Bit" +#define uavcan_primitive_scalar_Bit_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Bit.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Bit_1_0_EXTENT_BYTES_ 1UL +#define uavcan_primitive_scalar_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_primitive_scalar_Bit_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated bool value + bool value; +} uavcan_primitive_scalar_Bit_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Bit_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Bit_1_0_serialize_( + const uavcan_primitive_scalar_Bit_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated bool value + buffer[offset_bits / 8U] = obj->value ? 1U : 0U; + offset_bits += 1U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Bit_1_0_deserialize_( + uavcan_primitive_scalar_Bit_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated bool value + if (offset_bits < capacity_bits) + { + out_obj->value = (buffer[offset_bits / 8U] & 1U) != 0U; + } + else + { + out_obj->value = false; + } + offset_bits += 1U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Bit_1_0_initialize_(uavcan_primitive_scalar_Bit_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Bit_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_BIT_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Integer16_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Integer16_1_0.h new file mode 100644 index 0000000..86f2913 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Integer16_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.388756 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Integer16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_INTEGER16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_INTEGER16_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Integer16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Integer16_1_0_FULL_NAME_ "uavcan.primitive.scalar.Integer16" +#define uavcan_primitive_scalar_Integer16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Integer16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Integer16_1_0_EXTENT_BYTES_ 2UL +#define uavcan_primitive_scalar_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_primitive_scalar_Integer16_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated int16 value + int16_t value; +} uavcan_primitive_scalar_Integer16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Integer16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer16_1_0_serialize_( + const uavcan_primitive_scalar_Integer16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int16 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer16_1_0_deserialize_( + uavcan_primitive_scalar_Integer16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int16 value + out_obj->value = nunavutGetI16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Integer16_1_0_initialize_(uavcan_primitive_scalar_Integer16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Integer16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_INTEGER16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Integer32_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Integer32_1_0.h new file mode 100644 index 0000000..1c44387 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Integer32_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.390377 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Integer32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_INTEGER32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_INTEGER32_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Integer32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Integer32_1_0_FULL_NAME_ "uavcan.primitive.scalar.Integer32" +#define uavcan_primitive_scalar_Integer32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Integer32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Integer32_1_0_EXTENT_BYTES_ 4UL +#define uavcan_primitive_scalar_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_primitive_scalar_Integer32_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated int32 value + int32_t value; +} uavcan_primitive_scalar_Integer32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Integer32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer32_1_0_serialize_( + const uavcan_primitive_scalar_Integer32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int32 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer32_1_0_deserialize_( + uavcan_primitive_scalar_Integer32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int32 value + out_obj->value = nunavutGetI32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Integer32_1_0_initialize_(uavcan_primitive_scalar_Integer32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Integer32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_INTEGER32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Integer64_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Integer64_1_0.h new file mode 100644 index 0000000..fe879d2 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Integer64_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.392080 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Integer64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_INTEGER64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_INTEGER64_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Integer64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Integer64_1_0_FULL_NAME_ "uavcan.primitive.scalar.Integer64" +#define uavcan_primitive_scalar_Integer64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Integer64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Integer64_1_0_EXTENT_BYTES_ 8UL +#define uavcan_primitive_scalar_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(uavcan_primitive_scalar_Integer64_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated int64 value + int64_t value; +} uavcan_primitive_scalar_Integer64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Integer64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer64_1_0_serialize_( + const uavcan_primitive_scalar_Integer64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int64 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer64_1_0_deserialize_( + uavcan_primitive_scalar_Integer64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int64 value + out_obj->value = nunavutGetI64(&buffer[0], capacity_bytes, offset_bits, 64); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Integer64_1_0_initialize_(uavcan_primitive_scalar_Integer64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Integer64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_INTEGER64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Integer8_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Integer8_1_0.h new file mode 100644 index 0000000..a482a16 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Integer8_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.393681 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Integer8 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_INTEGER8_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_INTEGER8_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Integer8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Integer8_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Integer8_1_0_FULL_NAME_ "uavcan.primitive.scalar.Integer8" +#define uavcan_primitive_scalar_Integer8_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Integer8.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Integer8_1_0_EXTENT_BYTES_ 1UL +#define uavcan_primitive_scalar_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_primitive_scalar_Integer8_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated int8 value + int8_t value; +} uavcan_primitive_scalar_Integer8_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Integer8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer8_1_0_serialize_( + const uavcan_primitive_scalar_Integer8_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated int8 value + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Integer8_1_0_deserialize_( + uavcan_primitive_scalar_Integer8_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated int8 value + out_obj->value = nunavutGetI8(&buffer[0], capacity_bytes, offset_bits, 8); + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Integer8_1_0_initialize_(uavcan_primitive_scalar_Integer8_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Integer8_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_INTEGER8_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Natural16_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Natural16_1_0.h new file mode 100644 index 0000000..0325a5e --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Natural16_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.395231 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Natural16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_NATURAL16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_NATURAL16_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Natural16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Natural16_1_0_FULL_NAME_ "uavcan.primitive.scalar.Natural16" +#define uavcan_primitive_scalar_Natural16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Natural16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Natural16_1_0_EXTENT_BYTES_ 2UL +#define uavcan_primitive_scalar_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_primitive_scalar_Natural16_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint16 value + uint16_t value; +} uavcan_primitive_scalar_Natural16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Natural16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural16_1_0_serialize_( + const uavcan_primitive_scalar_Natural16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint16 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural16_1_0_deserialize_( + uavcan_primitive_scalar_Natural16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint16 value + out_obj->value = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 16); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Natural16_1_0_initialize_(uavcan_primitive_scalar_Natural16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Natural16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_NATURAL16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Natural32_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Natural32_1_0.h new file mode 100644 index 0000000..6611c26 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Natural32_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.396779 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Natural32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_NATURAL32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_NATURAL32_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Natural32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Natural32_1_0_FULL_NAME_ "uavcan.primitive.scalar.Natural32" +#define uavcan_primitive_scalar_Natural32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Natural32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Natural32_1_0_EXTENT_BYTES_ 4UL +#define uavcan_primitive_scalar_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_primitive_scalar_Natural32_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint32 value + uint32_t value; +} uavcan_primitive_scalar_Natural32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Natural32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural32_1_0_serialize_( + const uavcan_primitive_scalar_Natural32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint32 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural32_1_0_deserialize_( + uavcan_primitive_scalar_Natural32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint32 value + out_obj->value = nunavutGetU32(&buffer[0], capacity_bytes, offset_bits, 32); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Natural32_1_0_initialize_(uavcan_primitive_scalar_Natural32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Natural32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_NATURAL32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Natural64_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Natural64_1_0.h new file mode 100644 index 0000000..7b621e9 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Natural64_1_0.h @@ -0,0 +1,225 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.398325 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Natural64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_NATURAL64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_NATURAL64_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Natural64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Natural64_1_0_FULL_NAME_ "uavcan.primitive.scalar.Natural64" +#define uavcan_primitive_scalar_Natural64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Natural64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Natural64_1_0_EXTENT_BYTES_ 8UL +#define uavcan_primitive_scalar_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(uavcan_primitive_scalar_Natural64_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint64 value + uint64_t value; +} uavcan_primitive_scalar_Natural64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Natural64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural64_1_0_serialize_( + const uavcan_primitive_scalar_Natural64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint64 value + // Saturation code not emitted -- native representation matches the serialized representation. + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural64_1_0_deserialize_( + uavcan_primitive_scalar_Natural64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint64 value + out_obj->value = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 64); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Natural64_1_0_initialize_(uavcan_primitive_scalar_Natural64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Natural64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_NATURAL64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Natural8_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Natural8_1_0.h new file mode 100644 index 0000000..f719876 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Natural8_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.399869 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Natural8 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_NATURAL8_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_NATURAL8_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Natural8.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Natural8_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Natural8_1_0_FULL_NAME_ "uavcan.primitive.scalar.Natural8" +#define uavcan_primitive_scalar_Natural8_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Natural8.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Natural8_1_0_EXTENT_BYTES_ 1UL +#define uavcan_primitive_scalar_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_primitive_scalar_Natural8_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated uint8 value + uint8_t value; +} uavcan_primitive_scalar_Natural8_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Natural8_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural8_1_0_serialize_( + const uavcan_primitive_scalar_Natural8_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint8 value + // Saturation code not emitted -- native representation matches the serialized representation. + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 8U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Natural8_1_0_deserialize_( + uavcan_primitive_scalar_Natural8_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint8 value + if ((offset_bits + 8U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 255U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 8U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Natural8_1_0_initialize_(uavcan_primitive_scalar_Natural8_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Natural8_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_NATURAL8_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Real16_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Real16_1_0.h new file mode 100644 index 0000000..579fe33 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Real16_1_0.h @@ -0,0 +1,236 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.401502 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Real16 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_REAL16_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_REAL16_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real16.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Real16_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Real16_1_0_FULL_NAME_ "uavcan.primitive.scalar.Real16" +#define uavcan_primitive_scalar_Real16_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Real16.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Real16_1_0_EXTENT_BYTES_ 2UL +#define uavcan_primitive_scalar_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_primitive_scalar_Real16_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float16 value + float value; +} uavcan_primitive_scalar_Real16_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Real16_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real16_1_0_serialize_( + const uavcan_primitive_scalar_Real16_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float16 value + float _sat0_ = obj->value; + if (isfinite(_sat0_)) + { + if (_sat0_ < ((float) -65504.0)) + { + _sat0_ = ((float) -65504.0); + } + if (_sat0_ > ((float) 65504.0)) + { + _sat0_ = ((float) 65504.0); + } + } + const uint16_t _half0_ = nunavutFloat16Pack(_sat0_); + (void) memmove(&buffer[offset_bits / 8U], &_half0_, 2U); + offset_bits += 16U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real16_1_0_deserialize_( + uavcan_primitive_scalar_Real16_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float16 value + out_obj->value = nunavutGetF16(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 16U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Real16_1_0_initialize_(uavcan_primitive_scalar_Real16_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Real16_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_REAL16_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Real32_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Real32_1_0.h new file mode 100644 index 0000000..31ccc44 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Real32_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.403189 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Real32 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_REAL32_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_REAL32_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real32.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Real32_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Real32_1_0_FULL_NAME_ "uavcan.primitive.scalar.Real32" +#define uavcan_primitive_scalar_Real32_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Real32.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Real32_1_0_EXTENT_BYTES_ 4UL +#define uavcan_primitive_scalar_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_primitive_scalar_Real32_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 value + float value; +} uavcan_primitive_scalar_Real32_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real32_1_0_serialize_( + const uavcan_primitive_scalar_Real32_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 value + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real32_1_0_deserialize_( + uavcan_primitive_scalar_Real32_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 value + out_obj->value = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Real32_1_0_initialize_(uavcan_primitive_scalar_Real32_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Real32_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_REAL32_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/primitive/scalar/Real64_1_0.h b/src/nunavut_out/uavcan/primitive/scalar/Real64_1_0.h new file mode 100644 index 0000000..8b4c288 --- /dev/null +++ b/src/nunavut_out/uavcan/primitive/scalar/Real64_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.404763 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.primitive.scalar.Real64 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_PRIMITIVE_SCALAR_REAL64_1_0_INCLUDED_ +#define UAVCAN_PRIMITIVE_SCALAR_REAL64_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/primitive/scalar/Real64.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_primitive_scalar_Real64_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_primitive_scalar_Real64_1_0_FULL_NAME_ "uavcan.primitive.scalar.Real64" +#define uavcan_primitive_scalar_Real64_1_0_FULL_NAME_AND_VERSION_ "uavcan.primitive.scalar.Real64.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_primitive_scalar_Real64_1_0_EXTENT_BYTES_ 8UL +#define uavcan_primitive_scalar_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(uavcan_primitive_scalar_Real64_1_0_EXTENT_BYTES_ >= uavcan_primitive_scalar_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float64 value + double value; +} uavcan_primitive_scalar_Real64_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_primitive_scalar_Real64_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real64_1_0_serialize_( + const uavcan_primitive_scalar_Real64_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64 value + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->value, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_primitive_scalar_Real64_1_0_deserialize_( + uavcan_primitive_scalar_Real64_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64 value + out_obj->value = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_primitive_scalar_Real64_1_0_initialize_(uavcan_primitive_scalar_Real64_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_primitive_scalar_Real64_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_PRIMITIVE_SCALAR_REAL64_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/acceleration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/acceleration/Scalar_1_0.h new file mode 100644 index 0000000..1ca25cd --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/acceleration/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.619828 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.acceleration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ACCELERATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ACCELERATION_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_acceleration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_acceleration_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.acceleration.Scalar" +#define uavcan_si_sample_acceleration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.acceleration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_acceleration_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_acceleration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 meter_per_second_per_second + float meter_per_second_per_second; +} uavcan_si_sample_acceleration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_acceleration_Scalar_1_0_serialize_( + const uavcan_si_sample_acceleration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 meter_per_second_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter_per_second_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_acceleration_Scalar_1_0_deserialize_( + uavcan_si_sample_acceleration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 meter_per_second_per_second + out_obj->meter_per_second_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_acceleration_Scalar_1_0_initialize_(uavcan_si_sample_acceleration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_acceleration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ACCELERATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/acceleration/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/acceleration/Vector3_1_0.h new file mode 100644 index 0000000..5558e04 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/acceleration/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.621691 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.acceleration.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ACCELERATION_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ACCELERATION_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_acceleration_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_acceleration_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.acceleration.Vector3" +#define uavcan_si_sample_acceleration_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.acceleration.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_acceleration_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_acceleration_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter_per_second_per_second +#define uavcan_si_sample_acceleration_Vector3_1_0_meter_per_second_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_acceleration_Vector3_1_0_meter_per_second_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] meter_per_second_per_second + float meter_per_second_per_second[3]; +} uavcan_si_sample_acceleration_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_acceleration_Vector3_1_0_serialize_( + const uavcan_si_sample_acceleration_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] meter_per_second_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter_per_second_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_acceleration_Vector3_1_0_deserialize_( + uavcan_si_sample_acceleration_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] meter_per_second_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter_per_second_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_acceleration_Vector3_1_0_initialize_(uavcan_si_sample_acceleration_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_acceleration_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ACCELERATION_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angle/Quaternion_1_0.h b/src/nunavut_out/uavcan/si/sample/angle/Quaternion_1_0.h new file mode 100644 index 0000000..83ab357 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angle/Quaternion_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.640754 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angle.Quaternion +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGLE_QUATERNION_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGLE_QUATERNION_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angle_Quaternion_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angle_Quaternion_1_0_FULL_NAME_ "uavcan.si.sample.angle.Quaternion" +#define uavcan_si_sample_angle_Quaternion_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angle.Quaternion.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angle_Quaternion_1_0_EXTENT_BYTES_ 23UL +#define uavcan_si_sample_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 23UL +static_assert(uavcan_si_sample_angle_Quaternion_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[4] wxyz +#define uavcan_si_sample_angle_Quaternion_1_0_wxyz_ARRAY_CAPACITY_ 4U +#define uavcan_si_sample_angle_Quaternion_1_0_wxyz_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[4] wxyz + float wxyz[4]; +} uavcan_si_sample_angle_Quaternion_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angle_Quaternion_1_0_serialize_( + const uavcan_si_sample_angle_Quaternion_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 184UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[4] wxyz + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 4UL * 32UL, &obj->wxyz[0], 0U); + offset_bits += 4UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angle_Quaternion_1_0_deserialize_( + uavcan_si_sample_angle_Quaternion_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[4] wxyz + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->wxyz[0], &buffer[0], capacity_bytes, offset_bits, 4UL * 32U); + offset_bits += 4UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angle_Quaternion_1_0_initialize_(uavcan_si_sample_angle_Quaternion_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angle_Quaternion_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGLE_QUATERNION_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angle/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/angle/Scalar_1_0.h new file mode 100644 index 0000000..62f019e --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angle/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.642654 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angle.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGLE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGLE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angle_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angle_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.angle.Scalar" +#define uavcan_si_sample_angle_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angle.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angle_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_angle_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 radian + float radian; +} uavcan_si_sample_angle_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angle_Scalar_1_0_serialize_( + const uavcan_si_sample_angle_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 radian + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angle_Scalar_1_0_deserialize_( + uavcan_si_sample_angle_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 radian + out_obj->radian = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angle_Scalar_1_0_initialize_(uavcan_si_sample_angle_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angle_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGLE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angular_acceleration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/angular_acceleration/Scalar_1_0.h new file mode 100644 index 0000000..c0ce5e6 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angular_acceleration/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.623680 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angular_acceleration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angular_acceleration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angular_acceleration_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.angular_acceleration.Scalar" +#define uavcan_si_sample_angular_acceleration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angular_acceleration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angular_acceleration_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_angular_acceleration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 radian_per_second_per_second + float radian_per_second_per_second; +} uavcan_si_sample_angular_acceleration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_acceleration_Scalar_1_0_serialize_( + const uavcan_si_sample_angular_acceleration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 radian_per_second_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian_per_second_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_acceleration_Scalar_1_0_deserialize_( + uavcan_si_sample_angular_acceleration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 radian_per_second_per_second + out_obj->radian_per_second_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angular_acceleration_Scalar_1_0_initialize_(uavcan_si_sample_angular_acceleration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angular_acceleration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angular_acceleration/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/angular_acceleration/Vector3_1_0.h new file mode 100644 index 0000000..92f5771 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angular_acceleration/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.625641 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angular_acceleration.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.angular_acceleration.Vector3" +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angular_acceleration.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_angular_acceleration_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] radian_per_second_per_second +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_radian_per_second_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_angular_acceleration_Vector3_1_0_radian_per_second_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] radian_per_second_per_second + float radian_per_second_per_second[3]; +} uavcan_si_sample_angular_acceleration_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_acceleration_Vector3_1_0_serialize_( + const uavcan_si_sample_angular_acceleration_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] radian_per_second_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->radian_per_second_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_acceleration_Vector3_1_0_deserialize_( + uavcan_si_sample_angular_acceleration_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] radian_per_second_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->radian_per_second_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angular_acceleration_Vector3_1_0_initialize_(uavcan_si_sample_angular_acceleration_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angular_acceleration_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angular_velocity/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/angular_velocity/Scalar_1_0.h new file mode 100644 index 0000000..6ef8b5b --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angular_velocity/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.646388 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angular_velocity.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angular_velocity_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angular_velocity_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.angular_velocity.Scalar" +#define uavcan_si_sample_angular_velocity_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angular_velocity.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angular_velocity_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_angular_velocity_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 radian_per_second + float radian_per_second; +} uavcan_si_sample_angular_velocity_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_velocity_Scalar_1_0_serialize_( + const uavcan_si_sample_angular_velocity_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 radian_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_velocity_Scalar_1_0_deserialize_( + uavcan_si_sample_angular_velocity_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 radian_per_second + out_obj->radian_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angular_velocity_Scalar_1_0_initialize_(uavcan_si_sample_angular_velocity_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angular_velocity_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/angular_velocity/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/angular_velocity/Vector3_1_0.h new file mode 100644 index 0000000..ee4df73 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/angular_velocity/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.648227 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.angular_velocity.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_angular_velocity_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_angular_velocity_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.angular_velocity.Vector3" +#define uavcan_si_sample_angular_velocity_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.angular_velocity.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_angular_velocity_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_angular_velocity_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] radian_per_second +#define uavcan_si_sample_angular_velocity_Vector3_1_0_radian_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_angular_velocity_Vector3_1_0_radian_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] radian_per_second + float radian_per_second[3]; +} uavcan_si_sample_angular_velocity_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_velocity_Vector3_1_0_serialize_( + const uavcan_si_sample_angular_velocity_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] radian_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->radian_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_angular_velocity_Vector3_1_0_deserialize_( + uavcan_si_sample_angular_velocity_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] radian_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->radian_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_angular_velocity_Vector3_1_0_initialize_(uavcan_si_sample_angular_velocity_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_angular_velocity_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/duration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/duration/Scalar_1_0.h new file mode 100644 index 0000000..74b5dba --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/duration/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.627591 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.duration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_DURATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_DURATION_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_duration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_duration_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.duration.Scalar" +#define uavcan_si_sample_duration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.duration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_duration_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_duration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 second + float second; +} uavcan_si_sample_duration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_duration_Scalar_1_0_serialize_( + const uavcan_si_sample_duration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_duration_Scalar_1_0_deserialize_( + uavcan_si_sample_duration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 second + out_obj->second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_duration_Scalar_1_0_initialize_(uavcan_si_sample_duration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_duration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_DURATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/duration/WideScalar_1_0.h b/src/nunavut_out/uavcan/si/sample/duration/WideScalar_1_0.h new file mode 100644 index 0000000..5ae0ff6 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/duration/WideScalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.629473 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.duration.WideScalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_DURATION_WIDE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_DURATION_WIDE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_duration_WideScalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_duration_WideScalar_1_0_FULL_NAME_ "uavcan.si.sample.duration.WideScalar" +#define uavcan_si_sample_duration_WideScalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.duration.WideScalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_duration_WideScalar_1_0_EXTENT_BYTES_ 15UL +#define uavcan_si_sample_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 15UL +static_assert(uavcan_si_sample_duration_WideScalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float64 second + double second; +} uavcan_si_sample_duration_WideScalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_duration_WideScalar_1_0_serialize_( + const uavcan_si_sample_duration_WideScalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float64 second + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->second, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_duration_WideScalar_1_0_deserialize_( + uavcan_si_sample_duration_WideScalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float64 second + out_obj->second = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_duration_WideScalar_1_0_initialize_(uavcan_si_sample_duration_WideScalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_duration_WideScalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_DURATION_WIDE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/electric_charge/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/electric_charge/Scalar_1_0.h new file mode 100644 index 0000000..74f0422 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/electric_charge/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.674865 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.electric_charge.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_electric_charge_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_electric_charge_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.electric_charge.Scalar" +#define uavcan_si_sample_electric_charge_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.electric_charge.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_electric_charge_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_electric_charge_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 coulomb + float coulomb; +} uavcan_si_sample_electric_charge_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_electric_charge_Scalar_1_0_serialize_( + const uavcan_si_sample_electric_charge_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 coulomb + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->coulomb, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_electric_charge_Scalar_1_0_deserialize_( + uavcan_si_sample_electric_charge_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 coulomb + out_obj->coulomb = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_electric_charge_Scalar_1_0_initialize_(uavcan_si_sample_electric_charge_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_electric_charge_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/electric_current/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/electric_current/Scalar_1_0.h new file mode 100644 index 0000000..e7251b3 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/electric_current/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.682558 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.electric_current.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_electric_current_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_electric_current_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.electric_current.Scalar" +#define uavcan_si_sample_electric_current_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.electric_current.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_electric_current_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_electric_current_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 ampere + float ampere; +} uavcan_si_sample_electric_current_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_electric_current_Scalar_1_0_serialize_( + const uavcan_si_sample_electric_current_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 ampere + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->ampere, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_electric_current_Scalar_1_0_deserialize_( + uavcan_si_sample_electric_current_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 ampere + out_obj->ampere = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_electric_current_Scalar_1_0_initialize_(uavcan_si_sample_electric_current_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_electric_current_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/energy/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/energy/Scalar_1_0.h new file mode 100644 index 0000000..9ca174e --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/energy/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.671162 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.energy.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_ENERGY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_ENERGY_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_energy_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_energy_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.energy.Scalar" +#define uavcan_si_sample_energy_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.energy.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_energy_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_energy_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 joule + float joule; +} uavcan_si_sample_energy_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_energy_Scalar_1_0_serialize_( + const uavcan_si_sample_energy_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 joule + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->joule, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_energy_Scalar_1_0_deserialize_( + uavcan_si_sample_energy_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 joule + out_obj->joule = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_energy_Scalar_1_0_initialize_(uavcan_si_sample_energy_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_energy_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_ENERGY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/force/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/force/Scalar_1_0.h new file mode 100644 index 0000000..8fb7272 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/force/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.653793 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.force.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_FORCE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_FORCE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_force_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_force_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.force.Scalar" +#define uavcan_si_sample_force_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.force.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_force_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_force_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 newton + float newton; +} uavcan_si_sample_force_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_force_Scalar_1_0_serialize_( + const uavcan_si_sample_force_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 newton + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->newton, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_force_Scalar_1_0_deserialize_( + uavcan_si_sample_force_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 newton + out_obj->newton = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_force_Scalar_1_0_initialize_(uavcan_si_sample_force_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_force_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_FORCE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/force/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/force/Vector3_1_0.h new file mode 100644 index 0000000..4e81b9a --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/force/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.655711 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.force.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_FORCE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_FORCE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_force_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_force_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.force.Vector3" +#define uavcan_si_sample_force_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.force.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_force_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_force_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] newton +#define uavcan_si_sample_force_Vector3_1_0_newton_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_force_Vector3_1_0_newton_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] newton + float newton[3]; +} uavcan_si_sample_force_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_force_Vector3_1_0_serialize_( + const uavcan_si_sample_force_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] newton + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->newton[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_force_Vector3_1_0_deserialize_( + uavcan_si_sample_force_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] newton + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->newton[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_force_Vector3_1_0_initialize_(uavcan_si_sample_force_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_force_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_FORCE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/frequency/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/frequency/Scalar_1_0.h new file mode 100644 index 0000000..fa90829 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/frequency/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.680629 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.frequency.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_FREQUENCY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_FREQUENCY_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_frequency_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_frequency_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.frequency.Scalar" +#define uavcan_si_sample_frequency_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.frequency.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_frequency_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_frequency_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 hertz + float hertz; +} uavcan_si_sample_frequency_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_frequency_Scalar_1_0_serialize_( + const uavcan_si_sample_frequency_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 hertz + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->hertz, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_frequency_Scalar_1_0_deserialize_( + uavcan_si_sample_frequency_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 hertz + out_obj->hertz = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_frequency_Scalar_1_0_initialize_(uavcan_si_sample_frequency_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_frequency_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_FREQUENCY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/length/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/length/Scalar_1_0.h new file mode 100644 index 0000000..ff286fa --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/length/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.657672 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.length.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_LENGTH_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_LENGTH_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_length_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_length_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.length.Scalar" +#define uavcan_si_sample_length_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.length.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_length_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_length_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 meter + float meter; +} uavcan_si_sample_length_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_Scalar_1_0_serialize_( + const uavcan_si_sample_length_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_Scalar_1_0_deserialize_( + uavcan_si_sample_length_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 meter + out_obj->meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_length_Scalar_1_0_initialize_(uavcan_si_sample_length_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_length_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_LENGTH_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/length/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/length/Vector3_1_0.h new file mode 100644 index 0000000..a7f83b3 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/length/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.659560 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.length.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_LENGTH_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_LENGTH_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_length_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_length_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.length.Vector3" +#define uavcan_si_sample_length_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.length.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_length_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_length_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter +#define uavcan_si_sample_length_Vector3_1_0_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_length_Vector3_1_0_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] meter + float meter[3]; +} uavcan_si_sample_length_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_Vector3_1_0_serialize_( + const uavcan_si_sample_length_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_Vector3_1_0_deserialize_( + uavcan_si_sample_length_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_length_Vector3_1_0_initialize_(uavcan_si_sample_length_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_length_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_LENGTH_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/length/WideScalar_1_0.h b/src/nunavut_out/uavcan/si/sample/length/WideScalar_1_0.h new file mode 100644 index 0000000..0a782ab --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/length/WideScalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.661475 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.length.WideScalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_length_WideScalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_length_WideScalar_1_0_FULL_NAME_ "uavcan.si.sample.length.WideScalar" +#define uavcan_si_sample_length_WideScalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.length.WideScalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_length_WideScalar_1_0_EXTENT_BYTES_ 15UL +#define uavcan_si_sample_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 15UL +static_assert(uavcan_si_sample_length_WideScalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float64 meter + double meter; +} uavcan_si_sample_length_WideScalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_WideScalar_1_0_serialize_( + const uavcan_si_sample_length_WideScalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 120UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float64 meter + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_WideScalar_1_0_deserialize_( + uavcan_si_sample_length_WideScalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float64 meter + out_obj->meter = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_length_WideScalar_1_0_initialize_(uavcan_si_sample_length_WideScalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_length_WideScalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/length/WideVector3_1_0.h b/src/nunavut_out/uavcan/si/sample/length/WideVector3_1_0.h new file mode 100644 index 0000000..86fd304 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/length/WideVector3_1_0.h @@ -0,0 +1,268 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.663305 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.length.WideVector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_length_WideVector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_length_WideVector3_1_0_FULL_NAME_ "uavcan.si.sample.length.WideVector3" +#define uavcan_si_sample_length_WideVector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.length.WideVector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_length_WideVector3_1_0_EXTENT_BYTES_ 31UL +#define uavcan_si_sample_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 31UL +static_assert(uavcan_si_sample_length_WideVector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float64[3] meter +#define uavcan_si_sample_length_WideVector3_1_0_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_length_WideVector3_1_0_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float64[3] meter + double meter[3]; +} uavcan_si_sample_length_WideVector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_WideVector3_1_0_serialize_( + const uavcan_si_sample_length_WideVector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 248UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float64[3] meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 64UL, &obj->meter[0], 0U); + offset_bits += 3UL * 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_length_WideVector3_1_0_deserialize_( + uavcan_si_sample_length_WideVector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float64[3] meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 64U); + offset_bits += 3UL * 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_length_WideVector3_1_0_initialize_(uavcan_si_sample_length_WideVector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_length_WideVector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/luminance/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/luminance/Scalar_1_0.h new file mode 100644 index 0000000..0bfee82 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/luminance/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.644495 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.luminance.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_LUMINANCE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_LUMINANCE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_luminance_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_luminance_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.luminance.Scalar" +#define uavcan_si_sample_luminance_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.luminance.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_luminance_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_luminance_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 candela_per_square_meter + float candela_per_square_meter; +} uavcan_si_sample_luminance_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_luminance_Scalar_1_0_serialize_( + const uavcan_si_sample_luminance_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 candela_per_square_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->candela_per_square_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_luminance_Scalar_1_0_deserialize_( + uavcan_si_sample_luminance_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 candela_per_square_meter + out_obj->candela_per_square_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_luminance_Scalar_1_0_initialize_(uavcan_si_sample_luminance_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_luminance_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_LUMINANCE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_0.h new file mode 100644 index 0000000..a2a9e09 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_0.h @@ -0,0 +1,269 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.635022 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_field_strength.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.magnetic_field_strength.Scalar" +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_field_strength.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_magnetic_field_strength_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 tesla + float tesla; +} uavcan_si_sample_magnetic_field_strength_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Scalar_1_0_serialize_( + const uavcan_si_sample_magnetic_field_strength_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 tesla + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->tesla, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Scalar_1_0_deserialize_( + uavcan_si_sample_magnetic_field_strength_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 tesla + out_obj->tesla = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_field_strength_Scalar_1_0_initialize_(uavcan_si_sample_magnetic_field_strength_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_field_strength_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_1.h b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_1.h new file mode 100644 index 0000000..be20df0 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Scalar_1_1.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.633178 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_field_strength.Scalar +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_1_FULL_NAME_ "uavcan.si.sample.magnetic_field_strength.Scalar" +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_1_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_field_strength.Scalar.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_1_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_magnetic_field_strength_Scalar_1_1_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 ampere_per_meter + float ampere_per_meter; +} uavcan_si_sample_magnetic_field_strength_Scalar_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Scalar_1_1_serialize_( + const uavcan_si_sample_magnetic_field_strength_Scalar_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 ampere_per_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->ampere_per_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Scalar_1_1_deserialize_( + uavcan_si_sample_magnetic_field_strength_Scalar_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 ampere_per_meter + out_obj->ampere_per_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_field_strength_Scalar_1_1_initialize_(uavcan_si_sample_magnetic_field_strength_Scalar_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_field_strength_Scalar_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_0.h new file mode 100644 index 0000000..d4fb392 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_0.h @@ -0,0 +1,275 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.638852 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_field_strength.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.magnetic_field_strength.Vector3" +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_field_strength.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_magnetic_field_strength_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] tesla +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_tesla_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_0_tesla_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] tesla + float tesla[3]; +} uavcan_si_sample_magnetic_field_strength_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Vector3_1_0_serialize_( + const uavcan_si_sample_magnetic_field_strength_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] tesla + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->tesla[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Vector3_1_0_deserialize_( + uavcan_si_sample_magnetic_field_strength_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] tesla + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->tesla[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_field_strength_Vector3_1_0_initialize_(uavcan_si_sample_magnetic_field_strength_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_field_strength_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_1.h b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_1.h new file mode 100644 index 0000000..df43f87 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_field_strength/Vector3_1_1.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.636937 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_field_strength.Vector3 +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_FULL_NAME_ "uavcan.si.sample.magnetic_field_strength.Vector3" +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_field_strength.Vector3.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_magnetic_field_strength_Vector3_1_1_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] ampere_per_meter +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_ampere_per_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_magnetic_field_strength_Vector3_1_1_ampere_per_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] ampere_per_meter + float ampere_per_meter[3]; +} uavcan_si_sample_magnetic_field_strength_Vector3_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Vector3_1_1_serialize_( + const uavcan_si_sample_magnetic_field_strength_Vector3_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] ampere_per_meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->ampere_per_meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_field_strength_Vector3_1_1_deserialize_( + uavcan_si_sample_magnetic_field_strength_Vector3_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] ampere_per_meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->ampere_per_meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_field_strength_Vector3_1_1_initialize_(uavcan_si_sample_magnetic_field_strength_Vector3_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_field_strength_Vector3_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Scalar_1_0.h new file mode 100644 index 0000000..55ea6a2 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.685175 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_flux_density.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_flux_density_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_flux_density_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.magnetic_flux_density.Scalar" +#define uavcan_si_sample_magnetic_flux_density_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_flux_density.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_flux_density_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_magnetic_flux_density_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 tesla + float tesla; +} uavcan_si_sample_magnetic_flux_density_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_flux_density_Scalar_1_0_serialize_( + const uavcan_si_sample_magnetic_flux_density_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 tesla + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->tesla, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_flux_density_Scalar_1_0_deserialize_( + uavcan_si_sample_magnetic_flux_density_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 tesla + out_obj->tesla = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_flux_density_Scalar_1_0_initialize_(uavcan_si_sample_magnetic_flux_density_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_flux_density_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Vector3_1_0.h new file mode 100644 index 0000000..21be1cc --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/magnetic_flux_density/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.687441 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.magnetic_flux_density.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.magnetic_flux_density.Vector3" +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.magnetic_flux_density.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_magnetic_flux_density_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] tesla +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_tesla_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_magnetic_flux_density_Vector3_1_0_tesla_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] tesla + float tesla[3]; +} uavcan_si_sample_magnetic_flux_density_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_flux_density_Vector3_1_0_serialize_( + const uavcan_si_sample_magnetic_flux_density_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] tesla + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->tesla[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_magnetic_flux_density_Vector3_1_0_deserialize_( + uavcan_si_sample_magnetic_flux_density_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] tesla + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->tesla[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_magnetic_flux_density_Vector3_1_0_initialize_(uavcan_si_sample_magnetic_flux_density_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_magnetic_flux_density_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/mass/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/mass/Scalar_1_0.h new file mode 100644 index 0000000..b8c4780 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/mass/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.617976 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.mass.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_MASS_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_MASS_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_mass_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_mass_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.mass.Scalar" +#define uavcan_si_sample_mass_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.mass.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_mass_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_mass_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 kilogram + float kilogram; +} uavcan_si_sample_mass_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_mass_Scalar_1_0_serialize_( + const uavcan_si_sample_mass_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 kilogram + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->kilogram, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_mass_Scalar_1_0_deserialize_( + uavcan_si_sample_mass_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 kilogram + out_obj->kilogram = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_mass_Scalar_1_0_initialize_(uavcan_si_sample_mass_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_mass_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_MASS_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/power/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/power/Scalar_1_0.h new file mode 100644 index 0000000..7c2680a --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/power/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.669241 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.power.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_POWER_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_POWER_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_power_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_power_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.power.Scalar" +#define uavcan_si_sample_power_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.power.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_power_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_power_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 watt + float watt; +} uavcan_si_sample_power_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_power_Scalar_1_0_serialize_( + const uavcan_si_sample_power_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 watt + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->watt, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_power_Scalar_1_0_deserialize_( + uavcan_si_sample_power_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 watt + out_obj->watt = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_power_Scalar_1_0_initialize_(uavcan_si_sample_power_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_power_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_POWER_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/pressure/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/pressure/Scalar_1_0.h new file mode 100644 index 0000000..718f2d7 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/pressure/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.631341 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.pressure.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_PRESSURE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_PRESSURE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_pressure_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_pressure_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.pressure.Scalar" +#define uavcan_si_sample_pressure_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.pressure.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_pressure_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_pressure_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 pascal + float pascal; +} uavcan_si_sample_pressure_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_pressure_Scalar_1_0_serialize_( + const uavcan_si_sample_pressure_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 pascal + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->pascal, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_pressure_Scalar_1_0_deserialize_( + uavcan_si_sample_pressure_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 pascal + out_obj->pascal = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_pressure_Scalar_1_0_initialize_(uavcan_si_sample_pressure_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_pressure_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_PRESSURE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/temperature/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/temperature/Scalar_1_0.h new file mode 100644 index 0000000..e567c05 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/temperature/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.616094 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.temperature.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_TEMPERATURE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_TEMPERATURE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_temperature_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_temperature_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.temperature.Scalar" +#define uavcan_si_sample_temperature_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.temperature.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_temperature_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_temperature_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 kelvin + float kelvin; +} uavcan_si_sample_temperature_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_temperature_Scalar_1_0_serialize_( + const uavcan_si_sample_temperature_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 kelvin + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->kelvin, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_temperature_Scalar_1_0_deserialize_( + uavcan_si_sample_temperature_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 kelvin + out_obj->kelvin = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_temperature_Scalar_1_0_initialize_(uavcan_si_sample_temperature_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_temperature_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_TEMPERATURE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/torque/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/torque/Scalar_1_0.h new file mode 100644 index 0000000..ce960b8 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/torque/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.676768 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.torque.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_TORQUE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_TORQUE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_torque_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_torque_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.torque.Scalar" +#define uavcan_si_sample_torque_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.torque.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_torque_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_torque_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 newton_meter + float newton_meter; +} uavcan_si_sample_torque_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_torque_Scalar_1_0_serialize_( + const uavcan_si_sample_torque_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 newton_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->newton_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_torque_Scalar_1_0_deserialize_( + uavcan_si_sample_torque_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 newton_meter + out_obj->newton_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_torque_Scalar_1_0_initialize_(uavcan_si_sample_torque_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_torque_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_TORQUE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/torque/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/torque/Vector3_1_0.h new file mode 100644 index 0000000..d9feefc --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/torque/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.678691 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.torque.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_TORQUE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_TORQUE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_torque_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_torque_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.torque.Vector3" +#define uavcan_si_sample_torque_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.torque.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_torque_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_torque_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] newton_meter +#define uavcan_si_sample_torque_Vector3_1_0_newton_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_torque_Vector3_1_0_newton_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] newton_meter + float newton_meter[3]; +} uavcan_si_sample_torque_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_torque_Vector3_1_0_serialize_( + const uavcan_si_sample_torque_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] newton_meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->newton_meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_torque_Vector3_1_0_deserialize_( + uavcan_si_sample_torque_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] newton_meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->newton_meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_torque_Vector3_1_0_initialize_(uavcan_si_sample_torque_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_torque_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_TORQUE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/velocity/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/velocity/Scalar_1_0.h new file mode 100644 index 0000000..4937746 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/velocity/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.665179 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.velocity.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_VELOCITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_VELOCITY_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_velocity_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_velocity_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.velocity.Scalar" +#define uavcan_si_sample_velocity_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.velocity.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_velocity_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_velocity_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 meter_per_second + float meter_per_second; +} uavcan_si_sample_velocity_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_velocity_Scalar_1_0_serialize_( + const uavcan_si_sample_velocity_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 meter_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_velocity_Scalar_1_0_deserialize_( + uavcan_si_sample_velocity_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 meter_per_second + out_obj->meter_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_velocity_Scalar_1_0_initialize_(uavcan_si_sample_velocity_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_velocity_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_VELOCITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/velocity/Vector3_1_0.h b/src/nunavut_out/uavcan/si/sample/velocity/Vector3_1_0.h new file mode 100644 index 0000000..bf3179b --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/velocity/Vector3_1_0.h @@ -0,0 +1,266 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.667078 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.velocity.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_VELOCITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_VELOCITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_velocity_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_velocity_Vector3_1_0_FULL_NAME_ "uavcan.si.sample.velocity.Vector3" +#define uavcan_si_sample_velocity_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.velocity.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_velocity_Vector3_1_0_EXTENT_BYTES_ 19UL +#define uavcan_si_sample_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 19UL +static_assert(uavcan_si_sample_velocity_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_sample_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter_per_second +#define uavcan_si_sample_velocity_Vector3_1_0_meter_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_sample_velocity_Vector3_1_0_meter_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32[3] meter_per_second + float meter_per_second[3]; +} uavcan_si_sample_velocity_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_velocity_Vector3_1_0_serialize_( + const uavcan_si_sample_velocity_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 152UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32[3] meter_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_velocity_Vector3_1_0_deserialize_( + uavcan_si_sample_velocity_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32[3] meter_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_velocity_Vector3_1_0_initialize_(uavcan_si_sample_velocity_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_velocity_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_VELOCITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/voltage/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/voltage/Scalar_1_0.h new file mode 100644 index 0000000..706b6f8 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/voltage/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.650096 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.voltage.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_VOLTAGE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_VOLTAGE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_voltage_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_voltage_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.voltage.Scalar" +#define uavcan_si_sample_voltage_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.voltage.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_voltage_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_voltage_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 volt + float volt; +} uavcan_si_sample_voltage_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_voltage_Scalar_1_0_serialize_( + const uavcan_si_sample_voltage_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 volt + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->volt, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_voltage_Scalar_1_0_deserialize_( + uavcan_si_sample_voltage_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 volt + out_obj->volt = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_voltage_Scalar_1_0_initialize_(uavcan_si_sample_voltage_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_voltage_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_VOLTAGE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/volume/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/volume/Scalar_1_0.h new file mode 100644 index 0000000..88328d6 --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/volume/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.673034 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.volume.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_VOLUME_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_VOLUME_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_volume_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_volume_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.volume.Scalar" +#define uavcan_si_sample_volume_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.volume.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_volume_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_volume_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 cubic_meter + float cubic_meter; +} uavcan_si_sample_volume_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_volume_Scalar_1_0_serialize_( + const uavcan_si_sample_volume_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 cubic_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->cubic_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_volume_Scalar_1_0_deserialize_( + uavcan_si_sample_volume_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 cubic_meter + out_obj->cubic_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_volume_Scalar_1_0_initialize_(uavcan_si_sample_volume_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_volume_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_VOLUME_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/sample/volumetric_flow_rate/Scalar_1_0.h b/src/nunavut_out/uavcan/si/sample/volumetric_flow_rate/Scalar_1_0.h new file mode 100644 index 0000000..87768ef --- /dev/null +++ b/src/nunavut_out/uavcan/si/sample/volumetric_flow_rate/Scalar_1_0.h @@ -0,0 +1,260 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.651912 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.sample.volumetric_flow_rate.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_SAMPLE_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_SAMPLE_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/sample/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_FULL_NAME_ "uavcan.si.sample.volumetric_flow_rate.Scalar" +#define uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.sample.volumetric_flow_rate.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_EXTENT_BYTES_ 11UL +#define uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 11UL +static_assert(uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// uavcan.time.SynchronizedTimestamp.1.0 timestamp + uavcan_time_SynchronizedTimestamp_1_0 timestamp; + + /// saturated float32 cubic_meter_per_second + float cubic_meter_per_second; +} uavcan_si_sample_volumetric_flow_rate_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_serialize_( + const uavcan_si_sample_volumetric_flow_rate_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 88UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // uavcan.time.SynchronizedTimestamp.1.0 timestamp + size_t _size_bytes0_ = 7UL; // Nested object (max) size, in bytes. + int8_t _err0_ = uavcan_time_SynchronizedTimestamp_1_0_serialize_( + &obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err0_ < 0) + { + return _err0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + + + { // saturated float32 cubic_meter_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->cubic_meter_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err1_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err1_ < 0) + { + return _err1_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_deserialize_( + uavcan_si_sample_volumetric_flow_rate_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // uavcan.time.SynchronizedTimestamp.1.0 timestamp + { + size_t _size_bytes1_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err2_ = uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + &out_obj->timestamp, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested serialized representation. + } + + + + + // saturated float32 cubic_meter_per_second + out_obj->cubic_meter_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_initialize_(uavcan_si_sample_volumetric_flow_rate_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_sample_volumetric_flow_rate_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_SAMPLE_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/acceleration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/acceleration/Scalar_1_0.h new file mode 100644 index 0000000..ecc2d29 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/acceleration/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.592081 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.acceleration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ACCELERATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ACCELERATION_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_acceleration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_acceleration_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.acceleration.Scalar" +#define uavcan_si_unit_acceleration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.acceleration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_acceleration_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_acceleration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 meter_per_second_per_second + float meter_per_second_per_second; +} uavcan_si_unit_acceleration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_acceleration_Scalar_1_0_serialize_( + const uavcan_si_unit_acceleration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 meter_per_second_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter_per_second_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_acceleration_Scalar_1_0_deserialize_( + uavcan_si_unit_acceleration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 meter_per_second_per_second + out_obj->meter_per_second_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_acceleration_Scalar_1_0_initialize_(uavcan_si_unit_acceleration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_acceleration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ACCELERATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/acceleration/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/acceleration/Vector3_1_0.h new file mode 100644 index 0000000..076f085 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/acceleration/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.593886 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.acceleration.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ACCELERATION_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ACCELERATION_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_acceleration_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_acceleration_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.acceleration.Vector3" +#define uavcan_si_unit_acceleration_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.acceleration.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_acceleration_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_acceleration_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter_per_second_per_second +#define uavcan_si_unit_acceleration_Vector3_1_0_meter_per_second_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_acceleration_Vector3_1_0_meter_per_second_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] meter_per_second_per_second + float meter_per_second_per_second[3]; +} uavcan_si_unit_acceleration_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_acceleration_Vector3_1_0_serialize_( + const uavcan_si_unit_acceleration_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] meter_per_second_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter_per_second_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_acceleration_Vector3_1_0_deserialize_( + uavcan_si_unit_acceleration_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] meter_per_second_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter_per_second_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_acceleration_Vector3_1_0_initialize_(uavcan_si_unit_acceleration_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_acceleration_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ACCELERATION_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angle/Quaternion_1_0.h b/src/nunavut_out/uavcan/si/unit/angle/Quaternion_1_0.h new file mode 100644 index 0000000..4a6f382 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angle/Quaternion_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.571344 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angle.Quaternion +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGLE_QUATERNION_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGLE_QUATERNION_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Quaternion.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angle_Quaternion_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angle_Quaternion_1_0_FULL_NAME_ "uavcan.si.unit.angle.Quaternion" +#define uavcan_si_unit_angle_Quaternion_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angle.Quaternion.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angle_Quaternion_1_0_EXTENT_BYTES_ 16UL +#define uavcan_si_unit_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 16UL +static_assert(uavcan_si_unit_angle_Quaternion_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[4] wxyz +#define uavcan_si_unit_angle_Quaternion_1_0_wxyz_ARRAY_CAPACITY_ 4U +#define uavcan_si_unit_angle_Quaternion_1_0_wxyz_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[4] wxyz + float wxyz[4]; +} uavcan_si_unit_angle_Quaternion_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angle_Quaternion_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angle_Quaternion_1_0_serialize_( + const uavcan_si_unit_angle_Quaternion_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 128UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[4] wxyz + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 4UL * 32UL, &obj->wxyz[0], 0U); + offset_bits += 4UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angle_Quaternion_1_0_deserialize_( + uavcan_si_unit_angle_Quaternion_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[4] wxyz + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->wxyz[0], &buffer[0], capacity_bytes, offset_bits, 4UL * 32U); + offset_bits += 4UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angle_Quaternion_1_0_initialize_(uavcan_si_unit_angle_Quaternion_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angle_Quaternion_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGLE_QUATERNION_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angle/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/angle/Scalar_1_0.h new file mode 100644 index 0000000..0773b65 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angle/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.572990 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angle.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGLE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGLE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angle/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angle_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angle_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.angle.Scalar" +#define uavcan_si_unit_angle_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angle.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angle_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_angle_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 radian + float radian; +} uavcan_si_unit_angle_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angle_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angle_Scalar_1_0_serialize_( + const uavcan_si_unit_angle_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 radian + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angle_Scalar_1_0_deserialize_( + uavcan_si_unit_angle_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 radian + out_obj->radian = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angle_Scalar_1_0_initialize_(uavcan_si_unit_angle_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angle_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGLE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angular_acceleration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/angular_acceleration/Scalar_1_0.h new file mode 100644 index 0000000..d0fd8a1 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angular_acceleration/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.606501 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angular_acceleration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angular_acceleration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angular_acceleration_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.angular_acceleration.Scalar" +#define uavcan_si_unit_angular_acceleration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angular_acceleration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angular_acceleration_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_angular_acceleration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 radian_per_second_per_second + float radian_per_second_per_second; +} uavcan_si_unit_angular_acceleration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angular_acceleration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_acceleration_Scalar_1_0_serialize_( + const uavcan_si_unit_angular_acceleration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 radian_per_second_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian_per_second_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_acceleration_Scalar_1_0_deserialize_( + uavcan_si_unit_angular_acceleration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 radian_per_second_per_second + out_obj->radian_per_second_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angular_acceleration_Scalar_1_0_initialize_(uavcan_si_unit_angular_acceleration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angular_acceleration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angular_acceleration/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/angular_acceleration/Vector3_1_0.h new file mode 100644 index 0000000..bb57d9a --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angular_acceleration/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.608112 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angular_acceleration.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_acceleration/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.angular_acceleration.Vector3" +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angular_acceleration.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_angular_acceleration_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] radian_per_second_per_second +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_radian_per_second_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_angular_acceleration_Vector3_1_0_radian_per_second_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] radian_per_second_per_second + float radian_per_second_per_second[3]; +} uavcan_si_unit_angular_acceleration_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angular_acceleration_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_acceleration_Vector3_1_0_serialize_( + const uavcan_si_unit_angular_acceleration_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] radian_per_second_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->radian_per_second_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_acceleration_Vector3_1_0_deserialize_( + uavcan_si_unit_angular_acceleration_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] radian_per_second_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->radian_per_second_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angular_acceleration_Vector3_1_0_initialize_(uavcan_si_unit_angular_acceleration_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angular_acceleration_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGULAR_ACCELERATION_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angular_velocity/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/angular_velocity/Scalar_1_0.h new file mode 100644 index 0000000..98bc075 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angular_velocity/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.563375 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angular_velocity.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angular_velocity_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angular_velocity_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.angular_velocity.Scalar" +#define uavcan_si_unit_angular_velocity_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angular_velocity.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angular_velocity_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_angular_velocity_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 radian_per_second + float radian_per_second; +} uavcan_si_unit_angular_velocity_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angular_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_velocity_Scalar_1_0_serialize_( + const uavcan_si_unit_angular_velocity_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 radian_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->radian_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_velocity_Scalar_1_0_deserialize_( + uavcan_si_unit_angular_velocity_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 radian_per_second + out_obj->radian_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angular_velocity_Scalar_1_0_initialize_(uavcan_si_unit_angular_velocity_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angular_velocity_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGULAR_VELOCITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/angular_velocity/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/angular_velocity/Vector3_1_0.h new file mode 100644 index 0000000..1f1cfcb --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/angular_velocity/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.565006 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.angular_velocity.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/angular_velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_angular_velocity_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_angular_velocity_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.angular_velocity.Vector3" +#define uavcan_si_unit_angular_velocity_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.angular_velocity.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_angular_velocity_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_angular_velocity_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] radian_per_second +#define uavcan_si_unit_angular_velocity_Vector3_1_0_radian_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_angular_velocity_Vector3_1_0_radian_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] radian_per_second + float radian_per_second[3]; +} uavcan_si_unit_angular_velocity_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_angular_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_velocity_Vector3_1_0_serialize_( + const uavcan_si_unit_angular_velocity_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] radian_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->radian_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_angular_velocity_Vector3_1_0_deserialize_( + uavcan_si_unit_angular_velocity_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] radian_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->radian_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_angular_velocity_Vector3_1_0_initialize_(uavcan_si_unit_angular_velocity_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_angular_velocity_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ANGULAR_VELOCITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/duration/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/duration/Scalar_1_0.h new file mode 100644 index 0000000..1991273 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/duration/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.611378 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.duration.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_DURATION_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_DURATION_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_duration_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_duration_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.duration.Scalar" +#define uavcan_si_unit_duration_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.duration.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_duration_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_duration_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 second + float second; +} uavcan_si_unit_duration_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_duration_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_duration_Scalar_1_0_serialize_( + const uavcan_si_unit_duration_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_duration_Scalar_1_0_deserialize_( + uavcan_si_unit_duration_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 second + out_obj->second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_duration_Scalar_1_0_initialize_(uavcan_si_unit_duration_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_duration_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_DURATION_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/duration/WideScalar_1_0.h b/src/nunavut_out/uavcan/si/unit/duration/WideScalar_1_0.h new file mode 100644 index 0000000..78a04fa --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/duration/WideScalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.612951 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.duration.WideScalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_DURATION_WIDE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_DURATION_WIDE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/duration/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_duration_WideScalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_duration_WideScalar_1_0_FULL_NAME_ "uavcan.si.unit.duration.WideScalar" +#define uavcan_si_unit_duration_WideScalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.duration.WideScalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_duration_WideScalar_1_0_EXTENT_BYTES_ 8UL +#define uavcan_si_unit_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(uavcan_si_unit_duration_WideScalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float64 second + double second; +} uavcan_si_unit_duration_WideScalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_duration_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_duration_WideScalar_1_0_serialize_( + const uavcan_si_unit_duration_WideScalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64 second + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->second, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_duration_WideScalar_1_0_deserialize_( + uavcan_si_unit_duration_WideScalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64 second + out_obj->second = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_duration_WideScalar_1_0_initialize_(uavcan_si_unit_duration_WideScalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_duration_WideScalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_DURATION_WIDE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/electric_charge/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/electric_charge/Scalar_1_0.h new file mode 100644 index 0000000..bc08f6b --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/electric_charge/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.614523 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.electric_charge.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_charge/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_electric_charge_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_electric_charge_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.electric_charge.Scalar" +#define uavcan_si_unit_electric_charge_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.electric_charge.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_electric_charge_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_electric_charge_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 coulomb + float coulomb; +} uavcan_si_unit_electric_charge_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_electric_charge_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_electric_charge_Scalar_1_0_serialize_( + const uavcan_si_unit_electric_charge_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 coulomb + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->coulomb, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_electric_charge_Scalar_1_0_deserialize_( + uavcan_si_unit_electric_charge_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 coulomb + out_obj->coulomb = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_electric_charge_Scalar_1_0_initialize_(uavcan_si_unit_electric_charge_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_electric_charge_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ELECTRIC_CHARGE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/electric_current/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/electric_current/Scalar_1_0.h new file mode 100644 index 0000000..8cef7ea --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/electric_current/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.566613 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.electric_current.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/electric_current/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_electric_current_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_electric_current_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.electric_current.Scalar" +#define uavcan_si_unit_electric_current_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.electric_current.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_electric_current_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_electric_current_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 ampere + float ampere; +} uavcan_si_unit_electric_current_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_electric_current_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_electric_current_Scalar_1_0_serialize_( + const uavcan_si_unit_electric_current_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 ampere + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->ampere, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_electric_current_Scalar_1_0_deserialize_( + uavcan_si_unit_electric_current_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 ampere + out_obj->ampere = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_electric_current_Scalar_1_0_initialize_(uavcan_si_unit_electric_current_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_electric_current_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ELECTRIC_CURRENT_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/energy/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/energy/Scalar_1_0.h new file mode 100644 index 0000000..5860b12 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/energy/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.556664 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.energy.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_ENERGY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_ENERGY_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/energy/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_energy_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_energy_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.energy.Scalar" +#define uavcan_si_unit_energy_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.energy.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_energy_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_energy_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 joule + float joule; +} uavcan_si_unit_energy_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_energy_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_energy_Scalar_1_0_serialize_( + const uavcan_si_unit_energy_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 joule + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->joule, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_energy_Scalar_1_0_deserialize_( + uavcan_si_unit_energy_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 joule + out_obj->joule = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_energy_Scalar_1_0_initialize_(uavcan_si_unit_energy_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_energy_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_ENERGY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/force/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/force/Scalar_1_0.h new file mode 100644 index 0000000..b584473 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/force/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.588836 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.force.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_FORCE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_FORCE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_force_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_force_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.force.Scalar" +#define uavcan_si_unit_force_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.force.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_force_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_force_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 newton + float newton; +} uavcan_si_unit_force_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_force_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_force_Scalar_1_0_serialize_( + const uavcan_si_unit_force_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 newton + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->newton, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_force_Scalar_1_0_deserialize_( + uavcan_si_unit_force_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 newton + out_obj->newton = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_force_Scalar_1_0_initialize_(uavcan_si_unit_force_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_force_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_FORCE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/force/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/force/Vector3_1_0.h new file mode 100644 index 0000000..f2a0215 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/force/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.590448 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.force.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_FORCE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_FORCE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/force/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_force_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_force_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.force.Vector3" +#define uavcan_si_unit_force_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.force.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_force_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_force_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] newton +#define uavcan_si_unit_force_Vector3_1_0_newton_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_force_Vector3_1_0_newton_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] newton + float newton[3]; +} uavcan_si_unit_force_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_force_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_force_Vector3_1_0_serialize_( + const uavcan_si_unit_force_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] newton + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->newton[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_force_Vector3_1_0_deserialize_( + uavcan_si_unit_force_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] newton + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->newton[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_force_Vector3_1_0_initialize_(uavcan_si_unit_force_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_force_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_FORCE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/frequency/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/frequency/Scalar_1_0.h new file mode 100644 index 0000000..e4127ab --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/frequency/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.582430 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.frequency.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_FREQUENCY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_FREQUENCY_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/frequency/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_frequency_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_frequency_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.frequency.Scalar" +#define uavcan_si_unit_frequency_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.frequency.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_frequency_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_frequency_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 hertz + float hertz; +} uavcan_si_unit_frequency_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_frequency_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_frequency_Scalar_1_0_serialize_( + const uavcan_si_unit_frequency_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 hertz + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->hertz, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_frequency_Scalar_1_0_deserialize_( + uavcan_si_unit_frequency_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 hertz + out_obj->hertz = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_frequency_Scalar_1_0_initialize_(uavcan_si_unit_frequency_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_frequency_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_FREQUENCY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/length/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/length/Scalar_1_0.h new file mode 100644 index 0000000..889fddc --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/length/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.600232 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.length.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_LENGTH_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_LENGTH_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_length_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_length_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.length.Scalar" +#define uavcan_si_unit_length_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.length.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_length_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_length_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 meter + float meter; +} uavcan_si_unit_length_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_length_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_Scalar_1_0_serialize_( + const uavcan_si_unit_length_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_Scalar_1_0_deserialize_( + uavcan_si_unit_length_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 meter + out_obj->meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_length_Scalar_1_0_initialize_(uavcan_si_unit_length_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_length_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_LENGTH_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/length/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/length/Vector3_1_0.h new file mode 100644 index 0000000..ceebd74 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/length/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.601810 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.length.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_LENGTH_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_LENGTH_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_length_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_length_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.length.Vector3" +#define uavcan_si_unit_length_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.length.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_length_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_length_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter +#define uavcan_si_unit_length_Vector3_1_0_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_length_Vector3_1_0_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] meter + float meter[3]; +} uavcan_si_unit_length_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_length_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_Vector3_1_0_serialize_( + const uavcan_si_unit_length_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_Vector3_1_0_deserialize_( + uavcan_si_unit_length_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_length_Vector3_1_0_initialize_(uavcan_si_unit_length_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_length_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_LENGTH_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/length/WideScalar_1_0.h b/src/nunavut_out/uavcan/si/unit/length/WideScalar_1_0.h new file mode 100644 index 0000000..0e2f659 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/length/WideScalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.603381 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.length.WideScalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideScalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_length_WideScalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_length_WideScalar_1_0_FULL_NAME_ "uavcan.si.unit.length.WideScalar" +#define uavcan_si_unit_length_WideScalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.length.WideScalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_length_WideScalar_1_0_EXTENT_BYTES_ 8UL +#define uavcan_si_unit_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 8UL +static_assert(uavcan_si_unit_length_WideScalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float64 meter + double meter; +} uavcan_si_unit_length_WideScalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_length_WideScalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_WideScalar_1_0_serialize_( + const uavcan_si_unit_length_WideScalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 64UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64 meter + // Saturation code not emitted -- assume the native representation of float64 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter, 8U); + offset_bits += 64U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_WideScalar_1_0_deserialize_( + uavcan_si_unit_length_WideScalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64 meter + out_obj->meter = nunavutGetF64(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_length_WideScalar_1_0_initialize_(uavcan_si_unit_length_WideScalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_length_WideScalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_LENGTH_WIDE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/length/WideVector3_1_0.h b/src/nunavut_out/uavcan/si/unit/length/WideVector3_1_0.h new file mode 100644 index 0000000..626ac19 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/length/WideVector3_1_0.h @@ -0,0 +1,234 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.604914 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.length.WideVector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/length/WideVector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_length_WideVector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_length_WideVector3_1_0_FULL_NAME_ "uavcan.si.unit.length.WideVector3" +#define uavcan_si_unit_length_WideVector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.length.WideVector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_length_WideVector3_1_0_EXTENT_BYTES_ 24UL +#define uavcan_si_unit_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 24UL +static_assert(uavcan_si_unit_length_WideVector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float64[3] meter +#define uavcan_si_unit_length_WideVector3_1_0_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_length_WideVector3_1_0_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float64[3] meter + double meter[3]; +} uavcan_si_unit_length_WideVector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_length_WideVector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_WideVector3_1_0_serialize_( + const uavcan_si_unit_length_WideVector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 192UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float64[3] meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 64UL, &obj->meter[0], 0U); + offset_bits += 3UL * 64UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_length_WideVector3_1_0_deserialize_( + uavcan_si_unit_length_WideVector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float64[3] meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_DOUBLE, "Native IEEE754 binary64 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 64U); + offset_bits += 3UL * 64U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_length_WideVector3_1_0_initialize_(uavcan_si_unit_length_WideVector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_length_WideVector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_LENGTH_WIDE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/luminance/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/luminance/Scalar_1_0.h new file mode 100644 index 0000000..7f4a5eb --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/luminance/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.598661 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.luminance.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_LUMINANCE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_LUMINANCE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/luminance/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_luminance_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_luminance_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.luminance.Scalar" +#define uavcan_si_unit_luminance_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.luminance.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_luminance_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_luminance_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 candela_per_square_meter + float candela_per_square_meter; +} uavcan_si_unit_luminance_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_luminance_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_luminance_Scalar_1_0_serialize_( + const uavcan_si_unit_luminance_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 candela_per_square_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->candela_per_square_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_luminance_Scalar_1_0_deserialize_( + uavcan_si_unit_luminance_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 candela_per_square_meter + out_obj->candela_per_square_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_luminance_Scalar_1_0_initialize_(uavcan_si_unit_luminance_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_luminance_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_LUMINANCE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_0.h new file mode 100644 index 0000000..ac0920b --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_0.h @@ -0,0 +1,235 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.576107 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_field_strength.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.magnetic_field_strength.Scalar" +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_field_strength.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_magnetic_field_strength_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 tesla + float tesla; +} uavcan_si_unit_magnetic_field_strength_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_field_strength_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Scalar_1_0_serialize_( + const uavcan_si_unit_magnetic_field_strength_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 tesla + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->tesla, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Scalar_1_0_deserialize_( + uavcan_si_unit_magnetic_field_strength_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 tesla + out_obj->tesla = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_field_strength_Scalar_1_0_initialize_(uavcan_si_unit_magnetic_field_strength_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_field_strength_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_1.h b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_1.h new file mode 100644 index 0000000..90c1b23 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Scalar_1_1.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.574553 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_field_strength.Scalar +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Scalar.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_1_FULL_NAME_ "uavcan.si.unit.magnetic_field_strength.Scalar" +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_1_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_field_strength.Scalar.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_1_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_magnetic_field_strength_Scalar_1_1_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 ampere_per_meter + float ampere_per_meter; +} uavcan_si_unit_magnetic_field_strength_Scalar_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_field_strength_Scalar_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Scalar_1_1_serialize_( + const uavcan_si_unit_magnetic_field_strength_Scalar_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 ampere_per_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->ampere_per_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Scalar_1_1_deserialize_( + uavcan_si_unit_magnetic_field_strength_Scalar_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 ampere_per_meter + out_obj->ampere_per_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_field_strength_Scalar_1_1_initialize_(uavcan_si_unit_magnetic_field_strength_Scalar_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_field_strength_Scalar_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_SCALAR_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_0.h new file mode 100644 index 0000000..03c2840 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_0.h @@ -0,0 +1,241 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.579210 UTC +// Is deprecated: yes +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_field_strength.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +// _____ ______ _____ _____ ______ _____ _______ ______ _____ +// | __ `| ____| __ `| __ `| ____/ ____| /`|__ __| ____| __ ` +// | | | | |__ | |__) | |__) | |__ | | / ` | | | |__ | | | | +// | | | | __| | ___/| _ /| __|| | / /` ` | | | __| | | | | +// | |__| | |____| | | | ` `| |___| |____ / ____ `| | | |____| |__| | +// |_____/|______|_| |_| `_`______`_____/_/ `_`_| |______|_____/ +// +// WARNING: this data type is deprecated and is nearing the end of its life cycle. Seek replacement. + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.magnetic_field_strength.Vector3" +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_field_strength.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_magnetic_field_strength_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] tesla +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_tesla_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_0_tesla_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] tesla + float tesla[3]; +} uavcan_si_unit_magnetic_field_strength_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_field_strength_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Vector3_1_0_serialize_( + const uavcan_si_unit_magnetic_field_strength_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] tesla + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->tesla[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Vector3_1_0_deserialize_( + uavcan_si_unit_magnetic_field_strength_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] tesla + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->tesla[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_field_strength_Vector3_1_0_initialize_(uavcan_si_unit_magnetic_field_strength_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_field_strength_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_1.h b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_1.h new file mode 100644 index 0000000..66fc780 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_field_strength/Vector3_1_1.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl +// Generated at: 2024-11-23 10:35:29.577610 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_field_strength.Vector3 +// Version: 1.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_field_strength/Vector3.1.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_FULL_NAME_ "uavcan.si.unit.magnetic_field_strength.Vector3" +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_field_strength.Vector3.1.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_magnetic_field_strength_Vector3_1_1_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] ampere_per_meter +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_ampere_per_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_magnetic_field_strength_Vector3_1_1_ampere_per_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] ampere_per_meter + float ampere_per_meter[3]; +} uavcan_si_unit_magnetic_field_strength_Vector3_1_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_field_strength_Vector3_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Vector3_1_1_serialize_( + const uavcan_si_unit_magnetic_field_strength_Vector3_1_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] ampere_per_meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->ampere_per_meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_field_strength_Vector3_1_1_deserialize_( + uavcan_si_unit_magnetic_field_strength_Vector3_1_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] ampere_per_meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->ampere_per_meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_field_strength_Vector3_1_1_initialize_(uavcan_si_unit_magnetic_field_strength_Vector3_1_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_field_strength_Vector3_1_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FIELD_STRENGTH_VECTOR3_1_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Scalar_1_0.h new file mode 100644 index 0000000..1fb3f32 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.558265 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_flux_density.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_flux_density_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_flux_density_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.magnetic_flux_density.Scalar" +#define uavcan_si_unit_magnetic_flux_density_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_flux_density.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_flux_density_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_magnetic_flux_density_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 tesla + float tesla; +} uavcan_si_unit_magnetic_flux_density_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_flux_density_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_flux_density_Scalar_1_0_serialize_( + const uavcan_si_unit_magnetic_flux_density_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 tesla + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->tesla, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_flux_density_Scalar_1_0_deserialize_( + uavcan_si_unit_magnetic_flux_density_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 tesla + out_obj->tesla = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_flux_density_Scalar_1_0_initialize_(uavcan_si_unit_magnetic_flux_density_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_flux_density_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Vector3_1_0.h new file mode 100644 index 0000000..5a1ac49 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/magnetic_flux_density/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.559923 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.magnetic_flux_density.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/magnetic_flux_density/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.magnetic_flux_density.Vector3" +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.magnetic_flux_density.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_magnetic_flux_density_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] tesla +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_tesla_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_magnetic_flux_density_Vector3_1_0_tesla_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] tesla + float tesla[3]; +} uavcan_si_unit_magnetic_flux_density_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_magnetic_flux_density_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_flux_density_Vector3_1_0_serialize_( + const uavcan_si_unit_magnetic_flux_density_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] tesla + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->tesla[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_magnetic_flux_density_Vector3_1_0_deserialize_( + uavcan_si_unit_magnetic_flux_density_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] tesla + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->tesla[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_magnetic_flux_density_Vector3_1_0_initialize_(uavcan_si_unit_magnetic_flux_density_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_magnetic_flux_density_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MAGNETIC_FLUX_DENSITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/mass/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/mass/Scalar_1_0.h new file mode 100644 index 0000000..13923ee --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/mass/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.595495 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.mass.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_MASS_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_MASS_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/mass/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_mass_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_mass_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.mass.Scalar" +#define uavcan_si_unit_mass_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.mass.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_mass_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_mass_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 kilogram + float kilogram; +} uavcan_si_unit_mass_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_mass_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_mass_Scalar_1_0_serialize_( + const uavcan_si_unit_mass_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 kilogram + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->kilogram, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_mass_Scalar_1_0_deserialize_( + uavcan_si_unit_mass_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 kilogram + out_obj->kilogram = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_mass_Scalar_1_0_initialize_(uavcan_si_unit_mass_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_mass_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_MASS_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/power/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/power/Scalar_1_0.h new file mode 100644 index 0000000..54d003b --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/power/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.580804 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.power.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_POWER_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_POWER_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/power/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_power_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_power_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.power.Scalar" +#define uavcan_si_unit_power_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.power.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_power_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_power_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 watt + float watt; +} uavcan_si_unit_power_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_power_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_power_Scalar_1_0_serialize_( + const uavcan_si_unit_power_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 watt + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->watt, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_power_Scalar_1_0_deserialize_( + uavcan_si_unit_power_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 watt + out_obj->watt = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_power_Scalar_1_0_initialize_(uavcan_si_unit_power_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_power_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_POWER_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/pressure/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/pressure/Scalar_1_0.h new file mode 100644 index 0000000..025e14e --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/pressure/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.555008 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.pressure.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_PRESSURE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_PRESSURE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/pressure/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_pressure_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_pressure_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.pressure.Scalar" +#define uavcan_si_unit_pressure_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.pressure.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_pressure_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_pressure_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 pascal + float pascal; +} uavcan_si_unit_pressure_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_pressure_Scalar_1_0_serialize_( + const uavcan_si_unit_pressure_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 pascal + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->pascal, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_pressure_Scalar_1_0_deserialize_( + uavcan_si_unit_pressure_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 pascal + out_obj->pascal = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_pressure_Scalar_1_0_initialize_(uavcan_si_unit_pressure_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_pressure_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_PRESSURE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/temperature/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/temperature/Scalar_1_0.h new file mode 100644 index 0000000..6732e65 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/temperature/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.597067 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.temperature.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_TEMPERATURE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_TEMPERATURE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/temperature/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_temperature_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_temperature_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.temperature.Scalar" +#define uavcan_si_unit_temperature_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.temperature.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_temperature_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_temperature_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 kelvin + float kelvin; +} uavcan_si_unit_temperature_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_temperature_Scalar_1_0_serialize_( + const uavcan_si_unit_temperature_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 kelvin + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->kelvin, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_temperature_Scalar_1_0_deserialize_( + uavcan_si_unit_temperature_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 kelvin + out_obj->kelvin = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_temperature_Scalar_1_0_initialize_(uavcan_si_unit_temperature_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_temperature_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_TEMPERATURE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/torque/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/torque/Scalar_1_0.h new file mode 100644 index 0000000..b5db069 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/torque/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.568178 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.torque.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_TORQUE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_TORQUE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_torque_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_torque_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.torque.Scalar" +#define uavcan_si_unit_torque_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.torque.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_torque_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_torque_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 newton_meter + float newton_meter; +} uavcan_si_unit_torque_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_torque_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_torque_Scalar_1_0_serialize_( + const uavcan_si_unit_torque_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 newton_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->newton_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_torque_Scalar_1_0_deserialize_( + uavcan_si_unit_torque_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 newton_meter + out_obj->newton_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_torque_Scalar_1_0_initialize_(uavcan_si_unit_torque_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_torque_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_TORQUE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/torque/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/torque/Vector3_1_0.h new file mode 100644 index 0000000..6edfb4b --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/torque/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.569729 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.torque.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_TORQUE_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_TORQUE_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/torque/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_torque_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_torque_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.torque.Vector3" +#define uavcan_si_unit_torque_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.torque.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_torque_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_torque_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] newton_meter +#define uavcan_si_unit_torque_Vector3_1_0_newton_meter_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_torque_Vector3_1_0_newton_meter_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] newton_meter + float newton_meter[3]; +} uavcan_si_unit_torque_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_torque_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_torque_Vector3_1_0_serialize_( + const uavcan_si_unit_torque_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] newton_meter + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->newton_meter[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_torque_Vector3_1_0_deserialize_( + uavcan_si_unit_torque_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] newton_meter + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->newton_meter[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_torque_Vector3_1_0_initialize_(uavcan_si_unit_torque_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_torque_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_TORQUE_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/velocity/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/velocity/Scalar_1_0.h new file mode 100644 index 0000000..f277580 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/velocity/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.585692 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.velocity.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_VELOCITY_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_VELOCITY_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_velocity_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_velocity_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.velocity.Scalar" +#define uavcan_si_unit_velocity_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.velocity.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_velocity_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_velocity_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 meter_per_second + float meter_per_second; +} uavcan_si_unit_velocity_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_velocity_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_velocity_Scalar_1_0_serialize_( + const uavcan_si_unit_velocity_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 meter_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->meter_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_velocity_Scalar_1_0_deserialize_( + uavcan_si_unit_velocity_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 meter_per_second + out_obj->meter_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_velocity_Scalar_1_0_initialize_(uavcan_si_unit_velocity_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_velocity_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_VELOCITY_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/velocity/Vector3_1_0.h b/src/nunavut_out/uavcan/si/unit/velocity/Vector3_1_0.h new file mode 100644 index 0000000..0b01285 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/velocity/Vector3_1_0.h @@ -0,0 +1,232 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.587258 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.velocity.Vector3 +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_VELOCITY_VECTOR3_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_VELOCITY_VECTOR3_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/velocity/Vector3.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_velocity_Vector3_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_velocity_Vector3_1_0_FULL_NAME_ "uavcan.si.unit.velocity.Vector3" +#define uavcan_si_unit_velocity_Vector3_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.velocity.Vector3.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_velocity_Vector3_1_0_EXTENT_BYTES_ 12UL +#define uavcan_si_unit_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 12UL +static_assert(uavcan_si_unit_velocity_Vector3_1_0_EXTENT_BYTES_ >= uavcan_si_unit_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// Array metadata for: saturated float32[3] meter_per_second +#define uavcan_si_unit_velocity_Vector3_1_0_meter_per_second_ARRAY_CAPACITY_ 3U +#define uavcan_si_unit_velocity_Vector3_1_0_meter_per_second_ARRAY_IS_VARIABLE_LENGTH_ false + +typedef struct +{ + /// saturated float32[3] meter_per_second + float meter_per_second[3]; +} uavcan_si_unit_velocity_Vector3_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_velocity_Vector3_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_velocity_Vector3_1_0_serialize_( + const uavcan_si_unit_velocity_Vector3_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 96UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32[3] meter_per_second + // Saturation code not emitted -- assume the native representation is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + // Optimization prospect: this item is aligned at the byte boundary, so it is possible to use memmove(). + nunavutCopyBits(&buffer[0], offset_bits, 3UL * 32UL, &obj->meter_per_second[0], 0U); + offset_bits += 3UL * 32UL; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_velocity_Vector3_1_0_deserialize_( + uavcan_si_unit_velocity_Vector3_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32[3] meter_per_second + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + nunavutGetBits(&out_obj->meter_per_second[0], &buffer[0], capacity_bytes, offset_bits, 3UL * 32U); + offset_bits += 3UL * 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_velocity_Vector3_1_0_initialize_(uavcan_si_unit_velocity_Vector3_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_velocity_Vector3_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_VELOCITY_VECTOR3_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/voltage/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/voltage/Scalar_1_0.h new file mode 100644 index 0000000..82082be --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/voltage/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.561795 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.voltage.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_VOLTAGE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_VOLTAGE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/voltage/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_voltage_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_voltage_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.voltage.Scalar" +#define uavcan_si_unit_voltage_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.voltage.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_voltage_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_voltage_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 volt + float volt; +} uavcan_si_unit_voltage_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_voltage_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_voltage_Scalar_1_0_serialize_( + const uavcan_si_unit_voltage_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 volt + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->volt, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_voltage_Scalar_1_0_deserialize_( + uavcan_si_unit_voltage_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 volt + out_obj->volt = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_voltage_Scalar_1_0_initialize_(uavcan_si_unit_voltage_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_voltage_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_VOLTAGE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/volume/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/volume/Scalar_1_0.h new file mode 100644 index 0000000..ebd553a --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/volume/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.584068 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.volume.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_VOLUME_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_VOLUME_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volume/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_volume_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_volume_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.volume.Scalar" +#define uavcan_si_unit_volume_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.volume.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_volume_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_volume_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 cubic_meter + float cubic_meter; +} uavcan_si_unit_volume_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_volume_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_volume_Scalar_1_0_serialize_( + const uavcan_si_unit_volume_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 cubic_meter + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->cubic_meter, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_volume_Scalar_1_0_deserialize_( + uavcan_si_unit_volume_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 cubic_meter + out_obj->cubic_meter = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_volume_Scalar_1_0_initialize_(uavcan_si_unit_volume_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_volume_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_VOLUME_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/si/unit/volumetric_flow_rate/Scalar_1_0.h b/src/nunavut_out/uavcan/si/unit/volumetric_flow_rate/Scalar_1_0.h new file mode 100644 index 0000000..0515a79 --- /dev/null +++ b/src/nunavut_out/uavcan/si/unit/volumetric_flow_rate/Scalar_1_0.h @@ -0,0 +1,226 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.609743 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.si.unit.volumetric_flow_rate.Scalar +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_SI_UNIT_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ +#define UAVCAN_SI_UNIT_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ + +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/si/unit/volumetric_flow_rate/Scalar.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_FULL_NAME_ "uavcan.si.unit.volumetric_flow_rate.Scalar" +#define uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_FULL_NAME_AND_VERSION_ "uavcan.si.unit.volumetric_flow_rate.Scalar.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_EXTENT_BYTES_ 4UL +#define uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 4UL +static_assert(uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_EXTENT_BYTES_ >= uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 cubic_meter_per_second + float cubic_meter_per_second; +} uavcan_si_unit_volumetric_flow_rate_Scalar_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_serialize_( + const uavcan_si_unit_volumetric_flow_rate_Scalar_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 32UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 cubic_meter_per_second + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->cubic_meter_per_second, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_deserialize_( + uavcan_si_unit_volumetric_flow_rate_Scalar_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 cubic_meter_per_second + out_obj->cubic_meter_per_second = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_initialize_(uavcan_si_unit_volumetric_flow_rate_Scalar_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_si_unit_volumetric_flow_rate_Scalar_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_SI_UNIT_VOLUMETRIC_FLOW_RATE_SCALAR_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/time/GetSynchronizationMasterInfo_0_1.h b/src/nunavut_out/uavcan/time/GetSynchronizationMasterInfo_0_1.h new file mode 100644 index 0000000..46396a4 --- /dev/null +++ b/src/nunavut_out/uavcan/time/GetSynchronizationMasterInfo_0_1.h @@ -0,0 +1,418 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.689537 UTC +// Is deprecated: no +// Fixed port-ID: 510 +// Full name: uavcan.time.GetSynchronizationMasterInfo +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_TIME_GET_SYNCHRONIZATION_MASTER_INFO_0_1_INCLUDED_ +#define UAVCAN_TIME_GET_SYNCHRONIZATION_MASTER_INFO_0_1_INCLUDED_ + +#include +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/510.GetSynchronizationMasterInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_time_GetSynchronizationMasterInfo_0_1_HAS_FIXED_PORT_ID_ true +#define uavcan_time_GetSynchronizationMasterInfo_0_1_FIXED_PORT_ID_ 510U + +#define uavcan_time_GetSynchronizationMasterInfo_0_1_FULL_NAME_ "uavcan.time.GetSynchronizationMasterInfo" +#define uavcan_time_GetSynchronizationMasterInfo_0_1_FULL_NAME_AND_VERSION_ "uavcan.time.GetSynchronizationMasterInfo.0.1" + +#define uavcan_time_GetSynchronizationMasterInfo_Request_0_1_FULL_NAME_ "uavcan.time.GetSynchronizationMasterInfo.Request" +#define uavcan_time_GetSynchronizationMasterInfo_Request_0_1_FULL_NAME_AND_VERSION_ "uavcan.time.GetSynchronizationMasterInfo.Request.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_GetSynchronizationMasterInfo_Request_0_1_EXTENT_BYTES_ 48UL +#define uavcan_time_GetSynchronizationMasterInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 0UL +static_assert(uavcan_time_GetSynchronizationMasterInfo_Request_0_1_EXTENT_BYTES_ >= uavcan_time_GetSynchronizationMasterInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + uint8_t _dummy_; +} uavcan_time_GetSynchronizationMasterInfo_Request_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_GetSynchronizationMasterInfo_Request_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_GetSynchronizationMasterInfo_Request_0_1_serialize_( + const uavcan_time_GetSynchronizationMasterInfo_Request_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_GetSynchronizationMasterInfo_Request_0_1_deserialize_( + uavcan_time_GetSynchronizationMasterInfo_Request_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + *inout_buffer_size_bytes = 0U; + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_GetSynchronizationMasterInfo_Request_0_1_initialize_(uavcan_time_GetSynchronizationMasterInfo_Request_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_GetSynchronizationMasterInfo_Request_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#define uavcan_time_GetSynchronizationMasterInfo_Response_0_1_FULL_NAME_ "uavcan.time.GetSynchronizationMasterInfo.Response" +#define uavcan_time_GetSynchronizationMasterInfo_Response_0_1_FULL_NAME_AND_VERSION_ "uavcan.time.GetSynchronizationMasterInfo.Response.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_GetSynchronizationMasterInfo_Response_0_1_EXTENT_BYTES_ 192UL +#define uavcan_time_GetSynchronizationMasterInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 7UL +static_assert(uavcan_time_GetSynchronizationMasterInfo_Response_0_1_EXTENT_BYTES_ >= uavcan_time_GetSynchronizationMasterInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +typedef struct +{ + /// saturated float32 error_variance + float error_variance; + + /// uavcan.time.TimeSystem.0.1 time_system + uavcan_time_TimeSystem_0_1 time_system; + + /// uavcan.time.TAIInfo.0.1 tai_info + uavcan_time_TAIInfo_0_1 tai_info; +} uavcan_time_GetSynchronizationMasterInfo_Response_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_GetSynchronizationMasterInfo_Response_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_GetSynchronizationMasterInfo_Response_0_1_serialize_( + const uavcan_time_GetSynchronizationMasterInfo_Response_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 56UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated float32 error_variance + // Saturation code not emitted -- assume the native representation of float32 is conformant. + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + static_assert(NUNAVUT_PLATFORM_IEEE754_FLOAT, "Native IEEE754 binary32 required. TODO: relax constraint"); + (void) memmove(&buffer[offset_bits / 8U], &obj->error_variance, 4U); + offset_bits += 32U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + + { // uavcan.time.TimeSystem.0.1 time_system + size_t _size_bytes0_ = 1UL; // Nested object (max) size, in bytes. + int8_t _err1_ = uavcan_time_TimeSystem_0_1_serialize_( + &obj->time_system, &buffer[offset_bits / 8U], &_size_bytes0_); + if (_err1_ < 0) + { + return _err1_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes0_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad1_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err2_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad1_); // Optimize? + if (_err2_ < 0) + { + return _err2_; + } + offset_bits += _pad1_; + } + + { // uavcan.time.TAIInfo.0.1 tai_info + size_t _size_bytes1_ = 2UL; // Nested object (max) size, in bytes. + int8_t _err3_ = uavcan_time_TAIInfo_0_1_serialize_( + &obj->tai_info, &buffer[offset_bits / 8U], &_size_bytes1_); + if (_err3_ < 0) + { + return _err3_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + offset_bits += _size_bytes1_ * 8U; // Advance by the size of the nested object. + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad2_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err4_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad2_); // Optimize? + if (_err4_ < 0) + { + return _err4_; + } + offset_bits += _pad2_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_GetSynchronizationMasterInfo_Response_0_1_deserialize_( + uavcan_time_GetSynchronizationMasterInfo_Response_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated float32 error_variance + out_obj->error_variance = nunavutGetF32(&buffer[0], capacity_bytes, offset_bits); + offset_bits += 32U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.time.TimeSystem.0.1 time_system + { + size_t _size_bytes2_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err5_ = uavcan_time_TimeSystem_0_1_deserialize_( + &out_obj->time_system, &buffer[offset_bits / 8U], &_size_bytes2_); + if (_err5_ < 0) + { + return _err5_; + } + offset_bits += _size_bytes2_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + // uavcan.time.TAIInfo.0.1 tai_info + { + size_t _size_bytes3_ = (size_t)(capacity_bytes - nunavutChooseMin((offset_bits / 8U), capacity_bytes)); + const int8_t _err6_ = uavcan_time_TAIInfo_0_1_deserialize_( + &out_obj->tai_info, &buffer[offset_bits / 8U], &_size_bytes3_); + if (_err6_ < 0) + { + return _err6_; + } + offset_bits += _size_bytes3_ * 8U; // Advance by the size of the nested serialized representation. + } + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_GetSynchronizationMasterInfo_Response_0_1_initialize_(uavcan_time_GetSynchronizationMasterInfo_Response_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_GetSynchronizationMasterInfo_Response_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_TIME_GET_SYNCHRONIZATION_MASTER_INFO_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/time/Synchronization_1_0.h b/src/nunavut_out/uavcan/time/Synchronization_1_0.h new file mode 100644 index 0000000..acfebeb --- /dev/null +++ b/src/nunavut_out/uavcan/time/Synchronization_1_0.h @@ -0,0 +1,229 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.692547 UTC +// Is deprecated: no +// Fixed port-ID: 7168 +// Full name: uavcan.time.Synchronization +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_TIME_SYNCHRONIZATION_1_0_INCLUDED_ +#define UAVCAN_TIME_SYNCHRONIZATION_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/7168.Synchronization.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +#define uavcan_time_Synchronization_1_0_HAS_FIXED_PORT_ID_ true +#define uavcan_time_Synchronization_1_0_FIXED_PORT_ID_ 7168U + +#define uavcan_time_Synchronization_1_0_FULL_NAME_ "uavcan.time.Synchronization" +#define uavcan_time_Synchronization_1_0_FULL_NAME_AND_VERSION_ "uavcan.time.Synchronization.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_Synchronization_1_0_EXTENT_BYTES_ 7UL +#define uavcan_time_Synchronization_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 7UL +static_assert(uavcan_time_Synchronization_1_0_EXTENT_BYTES_ >= uavcan_time_Synchronization_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 MAX_PUBLICATION_PERIOD = 1 +#define uavcan_time_Synchronization_1_0_MAX_PUBLICATION_PERIOD (1U) +/// saturated uint8 PUBLISHER_TIMEOUT_PERIOD_MULTIPLIER = 3 +#define uavcan_time_Synchronization_1_0_PUBLISHER_TIMEOUT_PERIOD_MULTIPLIER (3U) + +typedef struct +{ + /// truncated uint56 previous_transmission_timestamp_microsecond + uint64_t previous_transmission_timestamp_microsecond; +} uavcan_time_Synchronization_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_Synchronization_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_Synchronization_1_0_serialize_( + const uavcan_time_Synchronization_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 56UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint56 previous_transmission_timestamp_microsecond + (void) memmove(&buffer[offset_bits / 8U], &obj->previous_transmission_timestamp_microsecond, 7U); + offset_bits += 56U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_Synchronization_1_0_deserialize_( + uavcan_time_Synchronization_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint56 previous_transmission_timestamp_microsecond + out_obj->previous_transmission_timestamp_microsecond = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 56); + offset_bits += 56U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_Synchronization_1_0_initialize_(uavcan_time_Synchronization_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_Synchronization_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_TIME_SYNCHRONIZATION_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/time/SynchronizedTimestamp_1_0.h b/src/nunavut_out/uavcan/time/SynchronizedTimestamp_1_0.h new file mode 100644 index 0000000..408d59c --- /dev/null +++ b/src/nunavut_out/uavcan/time/SynchronizedTimestamp_1_0.h @@ -0,0 +1,227 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl +// Generated at: 2024-11-23 10:35:29.694189 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.time.SynchronizedTimestamp +// Version: 1.0 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_TIME_SYNCHRONIZED_TIMESTAMP_1_0_INCLUDED_ +#define UAVCAN_TIME_SYNCHRONIZED_TIMESTAMP_1_0_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/SynchronizedTimestamp.1.0.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_time_SynchronizedTimestamp_1_0_HAS_FIXED_PORT_ID_ false + +#define uavcan_time_SynchronizedTimestamp_1_0_FULL_NAME_ "uavcan.time.SynchronizedTimestamp" +#define uavcan_time_SynchronizedTimestamp_1_0_FULL_NAME_AND_VERSION_ "uavcan.time.SynchronizedTimestamp.1.0" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_SynchronizedTimestamp_1_0_EXTENT_BYTES_ 7UL +#define uavcan_time_SynchronizedTimestamp_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ 7UL +static_assert(uavcan_time_SynchronizedTimestamp_1_0_EXTENT_BYTES_ >= uavcan_time_SynchronizedTimestamp_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint56 UNKNOWN = 0 +#define uavcan_time_SynchronizedTimestamp_1_0_UNKNOWN (0ULL) + +typedef struct +{ + /// truncated uint56 microsecond + uint64_t microsecond; +} uavcan_time_SynchronizedTimestamp_1_0; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_SynchronizedTimestamp_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_SynchronizedTimestamp_1_0_serialize_( + const uavcan_time_SynchronizedTimestamp_1_0* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 56UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint56 microsecond + (void) memmove(&buffer[offset_bits / 8U], &obj->microsecond, 7U); + offset_bits += 56U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_SynchronizedTimestamp_1_0_deserialize_( + uavcan_time_SynchronizedTimestamp_1_0* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint56 microsecond + out_obj->microsecond = nunavutGetU64(&buffer[0], capacity_bytes, offset_bits, 56); + offset_bits += 56U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_SynchronizedTimestamp_1_0_initialize_(uavcan_time_SynchronizedTimestamp_1_0* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_SynchronizedTimestamp_1_0_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_TIME_SYNCHRONIZED_TIMESTAMP_1_0_INCLUDED_ diff --git a/src/nunavut_out/uavcan/time/TAIInfo_0_1.h b/src/nunavut_out/uavcan/time/TAIInfo_0_1.h new file mode 100644 index 0000000..7b9e7aa --- /dev/null +++ b/src/nunavut_out/uavcan/time/TAIInfo_0_1.h @@ -0,0 +1,234 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.695800 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.time.TAIInfo +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_TIME_TAI_INFO_0_1_INCLUDED_ +#define UAVCAN_TIME_TAI_INFO_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TAIInfo.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_time_TAIInfo_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_time_TAIInfo_0_1_FULL_NAME_ "uavcan.time.TAIInfo" +#define uavcan_time_TAIInfo_0_1_FULL_NAME_AND_VERSION_ "uavcan.time.TAIInfo.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_TAIInfo_0_1_EXTENT_BYTES_ 2UL +#define uavcan_time_TAIInfo_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 2UL +static_assert(uavcan_time_TAIInfo_0_1_EXTENT_BYTES_ >= uavcan_time_TAIInfo_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint8 DIFFERENCE_TAI_MINUS_GPS = 19 +#define uavcan_time_TAIInfo_0_1_DIFFERENCE_TAI_MINUS_GPS (19U) +/// saturated uint10 DIFFERENCE_TAI_MINUS_UTC_UNKNOWN = 0 +#define uavcan_time_TAIInfo_0_1_DIFFERENCE_TAI_MINUS_UTC_UNKNOWN (0U) + +typedef struct +{ + /// saturated uint10 difference_tai_minus_utc + uint16_t difference_tai_minus_utc; +} uavcan_time_TAIInfo_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_TAIInfo_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_TAIInfo_0_1_serialize_( + const uavcan_time_TAIInfo_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 16UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // saturated uint10 difference_tai_minus_utc + uint16_t _sat0_ = obj->difference_tai_minus_utc; + if (_sat0_ > 1023U) + { + _sat0_ = 1023U; + } + (void) memmove(&buffer[offset_bits / 8U], &_sat0_, 2U); + offset_bits += 10U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_TAIInfo_0_1_deserialize_( + uavcan_time_TAIInfo_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // saturated uint10 difference_tai_minus_utc + out_obj->difference_tai_minus_utc = nunavutGetU16(&buffer[0], capacity_bytes, offset_bits, 10); + offset_bits += 10U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_TAIInfo_0_1_initialize_(uavcan_time_TAIInfo_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_TAIInfo_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_TIME_TAI_INFO_0_1_INCLUDED_ diff --git a/src/nunavut_out/uavcan/time/TimeSystem_0_1.h b/src/nunavut_out/uavcan/time/TimeSystem_0_1.h new file mode 100644 index 0000000..7784e3a --- /dev/null +++ b/src/nunavut_out/uavcan/time/TimeSystem_0_1.h @@ -0,0 +1,238 @@ +// This is an AUTO-GENERATED UAVCAN DSDL data type implementation. Curious? See https://opencyphal.org. +// You shouldn't attempt to edit this file. +// +// Checking this file under version control is not recommended unless it is used as part of a high-SIL +// safety-critical codebase. The typical usage scenario is to generate it as part of the build process. +// +// To avoid conflicts with definitions given in the source DSDL file, all entities created by the code generator +// are named with an underscore at the end, like foo_bar_(). +// +// Generator: nunavut-1.8.0 (serialization was enabled) +// Source file: /home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl +// Generated at: 2024-11-23 10:35:29.697513 UTC +// Is deprecated: no +// Fixed port-ID: None +// Full name: uavcan.time.TimeSystem +// Version: 0.1 +// +// Platform +// python_implementation: CPython +// python_version: 3.10.12 +// python_release_level: final +// python_build: ('main', 'Nov 6 2024 20:22:13') +// python_compiler: GCC 11.4.0 +// python_revision: +// python_xoptions: {} +// runtime_platform: Linux-6.8.0-49-generic-x86_64-with-glibc2.35 +// +// Language Options +// target_endianness: little +// omit_float_serialization_support: False +// enable_serialization_asserts: False +// enable_override_variable_array_capacity: False +// cast_format: (({type}) {value}) + +#ifndef UAVCAN_TIME_TIME_SYSTEM_0_1_INCLUDED_ +#define UAVCAN_TIME_TIME_SYSTEM_0_1_INCLUDED_ + +#include +#include +#include + +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS == 434322821, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 0, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); +static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_CAST_FORMAT == 2368206204, + "/home/nex/zilant/uav_hitl_sim/communicators/cyphal_communicator/Libs/cyphal_application/Libs/public_regulated_data_types/uavcan/time/TimeSystem.0.1.dsdl is trying to use a serialization library that was compiled with " + "different language options. This is dangerous and therefore not allowed." ); + +#ifdef __cplusplus +extern "C" { +#endif + +/// This type does not have a fixed port-ID. See https://forum.opencyphal.org/t/choosing-message-and-service-ids/889 +#define uavcan_time_TimeSystem_0_1_HAS_FIXED_PORT_ID_ false + +#define uavcan_time_TimeSystem_0_1_FULL_NAME_ "uavcan.time.TimeSystem" +#define uavcan_time_TimeSystem_0_1_FULL_NAME_AND_VERSION_ "uavcan.time.TimeSystem.0.1" + +/// Extent is the minimum amount of memory required to hold any serialized representation of any compatible +/// version of the data type; or, on other words, it is the the maximum possible size of received objects of this type. +/// The size is specified in bytes (rather than bits) because by definition, extent is an integer number of bytes long. +/// When allocating a deserialization (RX) buffer for this data type, it should be at least extent bytes large. +/// When allocating a serialization (TX) buffer, it is safe to use the size of the largest serialized representation +/// instead of the extent because it provides a tighter bound of the object size; it is safe because the concrete type +/// is always known during serialization (unlike deserialization). If not sure, use extent everywhere. +#define uavcan_time_TimeSystem_0_1_EXTENT_BYTES_ 1UL +#define uavcan_time_TimeSystem_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ 1UL +static_assert(uavcan_time_TimeSystem_0_1_EXTENT_BYTES_ >= uavcan_time_TimeSystem_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_, + "Internal constraint violation"); + +/// saturated uint4 MONOTONIC_SINCE_BOOT = 0 +#define uavcan_time_TimeSystem_0_1_MONOTONIC_SINCE_BOOT (0U) +/// saturated uint4 TAI = 1 +#define uavcan_time_TimeSystem_0_1_TAI (1U) +/// saturated uint4 APPLICATION_SPECIFIC = 15 +#define uavcan_time_TimeSystem_0_1_APPLICATION_SPECIFIC (15U) + +typedef struct +{ + /// truncated uint4 value + uint8_t value; +} uavcan_time_TimeSystem_0_1; + +/// Serialize an instance into the provided buffer. +/// The lifetime of the resulting serialized representation is independent of the original instance. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original object where possible. +/// +/// @param obj The object to serialize. +/// +/// @param buffer The destination buffer. There are no alignment requirements. +/// @see uavcan_time_TimeSystem_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the buffer in bytes. +/// Upon return this value will be updated with the size of the constructed serialized +/// representation (in bytes); this value is then to be passed over to the transport +/// layer. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_TimeSystem_0_1_serialize_( + const uavcan_time_TimeSystem_0_1* const obj, uint8_t* const buffer, size_t* const inout_buffer_size_bytes) +{ + if ((obj == NULL) || (buffer == NULL) || (inout_buffer_size_bytes == NULL)) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + if ((8U * (size_t) capacity_bytes) < 8UL) + { + return -NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL; + } + // Notice that fields that are not an integer number of bytes long may overrun the space allocated for them + // in the serialization buffer up to the next byte boundary. This is by design and is guaranteed to be safe. + size_t offset_bits = 0U; + + + + + + { // truncated uint4 value + buffer[offset_bits / 8U] = (uint8_t)(obj->value); // C std, 6.3.1.3 Signed and unsigned integers + offset_bits += 4U; + } + + + if (offset_bits % 8U != 0U) // Pad to 8 bits. TODO: Eliminate redundant padding checks. + { + const uint8_t _pad0_ = (uint8_t)(8U - offset_bits % 8U); + const int8_t _err0_ = nunavutSetUxx(&buffer[0], capacity_bytes, offset_bits, 0U, _pad0_); // Optimize? + if (_err0_ < 0) + { + return _err0_; + } + offset_bits += _pad0_; + } + // It is assumed that we know the exact type of the serialized entity, hence we expect the size to match. + + + + + *inout_buffer_size_bytes = (size_t) (offset_bits / 8U); + + return NUNAVUT_SUCCESS; +} + +/// Deserialize an instance from the provided buffer. +/// The lifetime of the resulting object is independent of the original buffer. +/// This method may be slow for large objects (e.g., images, point clouds, radar samples), so in a later revision +/// we may define a zero-copy alternative that keeps references to the original buffer where possible. +/// +/// @param obj The object to update from the provided serialized representation. +/// +/// @param buffer The source buffer containing the serialized representation. There are no alignment requirements. +/// If the buffer is shorter or longer than expected, it will be implicitly zero-extended or truncated, +/// respectively; see Specification for "implicit zero extension" and "implicit truncation" rules. +/// +/// @param inout_buffer_size_bytes When calling, this is a pointer to the size of the supplied serialized +/// representation, in bytes. Upon return this value will be updated with the +/// size of the consumed fragment of the serialized representation (in bytes), +/// which may be smaller due to the implicit truncation rule, but it is guaranteed +/// to never exceed the original buffer size even if the implicit zero extension rule +/// was activated. In case of error this value is undefined. +/// +/// @returns Negative on error, zero on success. +static inline int8_t uavcan_time_TimeSystem_0_1_deserialize_( + uavcan_time_TimeSystem_0_1* const out_obj, const uint8_t* buffer, size_t* const inout_buffer_size_bytes) +{ + if ((out_obj == NULL) || (inout_buffer_size_bytes == NULL) || ((buffer == NULL) && (0 != *inout_buffer_size_bytes))) + { + return -NUNAVUT_ERROR_INVALID_ARGUMENT; + } + if (buffer == NULL) + { + buffer = (const uint8_t*)""; + } + + + const size_t capacity_bytes = *inout_buffer_size_bytes; + const size_t capacity_bits = capacity_bytes * (size_t) 8U; + size_t offset_bits = 0U; + + + + + + // truncated uint4 value + if ((offset_bits + 4U) <= capacity_bits) + { + out_obj->value = buffer[offset_bits / 8U] & 15U; + } + else + { + out_obj->value = 0U; + } + offset_bits += 4U; + + + offset_bits = (offset_bits + 7U) & ~(size_t) 7U; // Align on 8 bits. + + *inout_buffer_size_bytes = (size_t) (nunavutChooseMin(offset_bits, capacity_bits) / 8U); + + + return NUNAVUT_SUCCESS; +} + +/// Initialize an instance to default values. Does nothing if @param out_obj is NULL. +/// This function intentionally leaves inactive elements uninitialized; for example, members of a variable-length +/// array beyond its length are left uninitialized; aliased union memory that is not used by the first union field +/// is left uninitialized, etc. If full zero-initialization is desired, just use memset(&obj, 0, sizeof(obj)). +static inline void uavcan_time_TimeSystem_0_1_initialize_(uavcan_time_TimeSystem_0_1* const out_obj) +{ + if (out_obj != NULL) + { + size_t size_bytes = 0; + const uint8_t buf = 0; + const int8_t err = uavcan_time_TimeSystem_0_1_deserialize_(out_obj, &buf, &size_bytes); + + (void) err; + } +} + + + +#ifdef __cplusplus +} +#endif +#endif // UAVCAN_TIME_TIME_SYSTEM_0_1_INCLUDED_