/* * UAVCAN data structure definition for libcanard. * * Autogenerated, do not edit. * * Source file: D:\data\libcanard-master\dsdl_compiler\dsdl_define\uavcan\equipment\actuator\1999.ArrayStatus.uavcan */ #ifndef __UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS #define __UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS #include #include "canard.h" #ifdef __cplusplus extern "C" { #endif #include /******************************* Source text ********************************** # # Actuator status. # The system supports up to 6 actuators; up to 6 of them can be recriveded with one message. # Statusinfo[<=6] status ******************************************************************************/ /********************* DSDL signature source definition *********************** uavcan.equipment.actuator.ArrayStatus uavcan.equipment.actuator.Statusinfo[<=6] status ******************************************************************************/ #define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_ID 1999 #define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_NAME "uavcan.equipment.actuator.ArrayStatus" #define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_SIGNATURE (0xB4274B775EE28B6FULL) #define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_MAX_SIZE ((387 + 7)/8) // Constants #define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_STATUS_MAX_LENGTH 6 typedef struct { // FieldTypes struct { uint8_t len; // Dynamic array length uavcan_equipment_actuator_Statusinfo* data; // Dynamic Array 64bit[6] max items } status; } uavcan_equipment_actuator_ArrayStatus; static inline uint32_t uavcan_equipment_actuator_ArrayStatus_encode(uavcan_equipment_actuator_ArrayStatus* source, void* msg_buf, bool tao_enabled); static inline int32_t uavcan_equipment_actuator_ArrayStatus_decode(const CanardRxTransfer* transfer, uint16_t payload_len, uavcan_equipment_actuator_ArrayStatus* dest, uint8_t** dyn_arr_buf, bool tao_enabled); static inline uint32_t uavcan_equipment_actuator_ArrayStatus_encode_internal(uavcan_equipment_actuator_ArrayStatus* source, void* msg_buf, uint32_t offset, uint8_t root_item, bool tao_enabled); static inline int32_t uavcan_equipment_actuator_ArrayStatus_decode_internal(const CanardRxTransfer* transfer, uint16_t payload_len, uavcan_equipment_actuator_ArrayStatus* dest, uint8_t** dyn_arr_buf, int32_t offset, bool tao_enabled); /* * UAVCAN data structure definition for libcanard. * * Autogenerated, do not edit. * * Source file: D:\data\libcanard-master\dsdl_compiler\dsdl_define\uavcan\equipment\actuator\1999.ArrayStatus.uavcan */ #ifndef CANARD_INTERNAL_SATURATE #define CANARD_INTERNAL_SATURATE(x, max) ( ((x) > max) ? max : ( (-(x) > max) ? (-max) : (x) ) ); #endif #ifndef CANARD_INTERNAL_SATURATE_UNSIGNED #define CANARD_INTERNAL_SATURATE_UNSIGNED(x, max) ( ((x) >= max) ? max : (x) ); #endif #if defined(__GNUC__) # define CANARD_MAYBE_UNUSED(x) x __attribute__((unused)) #else # define CANARD_MAYBE_UNUSED(x) x #endif /** * @brief uavcan_equipment_actuator_ArrayStatus_encode_internal * @param source : pointer to source data struct * @param msg_buf: pointer to msg storage * @param offset: bit offset to msg storage * @param root_item: for detecting if TAO should be used * @retval returns offset */ uint32_t uavcan_equipment_actuator_ArrayStatus_encode_internal(uavcan_equipment_actuator_ArrayStatus* source, void* msg_buf, uint32_t offset, uint8_t CANARD_MAYBE_UNUSED(root_item), bool tao_enabled) { uint32_t c = 0; // Dynamic Array (status) if (! root_item || ! tao_enabled) { // - Add array length canardEncodeScalar(msg_buf, offset, 3, (void*)&source->status.len); offset += 3; } // - Add array items for (c = 0; c < source->status.len; c++) { offset += uavcan_equipment_actuator_Statusinfo_encode_internal(&source->status.data[c], msg_buf, offset, 0, tao_enabled); } return offset; } /** * @brief uavcan_equipment_actuator_ArrayStatus_encode * @param source : Pointer to source data struct * @param msg_buf: Pointer to msg storage * @retval returns message length as bytes */ uint32_t uavcan_equipment_actuator_ArrayStatus_encode(uavcan_equipment_actuator_ArrayStatus* source, void* msg_buf, bool tao_enabled) { uint32_t offset = 0; offset = uavcan_equipment_actuator_ArrayStatus_encode_internal(source, msg_buf, offset, 1, tao_enabled); return (offset + 7 ) / 8; } /** * @brief uavcan_equipment_actuator_ArrayStatus_decode_internal * @param transfer: Pointer to CanardRxTransfer transfer * @param payload_len: Payload message length * @param dest: Pointer to destination struct * @param dyn_arr_buf: NULL or Pointer to memory storage to be used for dynamic arrays * uavcan_equipment_actuator_ArrayStatus dyn memory will point to dyn_arr_buf memory. * NULL will ignore dynamic arrays decoding. * @param offset: Call with 0, bit offset to msg storage * @retval offset or ERROR value if < 0 */ int32_t uavcan_equipment_actuator_ArrayStatus_decode_internal( const CanardRxTransfer* transfer, uint16_t CANARD_MAYBE_UNUSED(payload_len), uavcan_equipment_actuator_ArrayStatus* dest, uint8_t** CANARD_MAYBE_UNUSED(dyn_arr_buf), int32_t offset, bool tao_enabled) { int32_t ret = 0; uint32_t c = 0; // Dynamic Array (status) // - Last item in struct & Root item & (Array Size > 8 bit), tail array optimization if (payload_len && tao_enabled) { // - Calculate Array length from MSG length dest->status.len = ((payload_len * 8) - offset ) / 64; // 64 bit array item size } else { // - Array length 3 bits ret = canardDecodeScalar(transfer, (uint32_t)offset, 3, false, (void*)&dest->status.len); // 0 if (ret != 3) { goto uavcan_equipment_actuator_ArrayStatus_error_exit; } offset += 3; } // - Get Array if (dyn_arr_buf) { dest->status.data = (uavcan_equipment_actuator_Statusinfo*)*dyn_arr_buf; } for (c = 0; c < dest->status.len; c++) { offset += uavcan_equipment_actuator_Statusinfo_decode_internal(transfer, 0, &dest->status.data[c], dyn_arr_buf, offset, tao_enabled); } return offset; uavcan_equipment_actuator_ArrayStatus_error_exit: if (ret < 0) { return ret; } else { return -CANARD_ERROR_INTERNAL; } } /** * @brief uavcan_equipment_actuator_ArrayStatus_decode * @param transfer: Pointer to CanardRxTransfer transfer * @param payload_len: Payload message length * @param dest: Pointer to destination struct * @param dyn_arr_buf: NULL or Pointer to memory storage to be used for dynamic arrays * uavcan_equipment_actuator_ArrayStatus dyn memory will point to dyn_arr_buf memory. * NULL will ignore dynamic arrays decoding. * @retval offset or ERROR value if < 0 */ int32_t uavcan_equipment_actuator_ArrayStatus_decode(const CanardRxTransfer* transfer, uint16_t payload_len, uavcan_equipment_actuator_ArrayStatus* dest, uint8_t** dyn_arr_buf, bool tao_enabled) { const int32_t offset = 0; int32_t ret = 0; // Clear the destination struct for (uint32_t c = 0; c < sizeof(uavcan_equipment_actuator_ArrayStatus); c++) { ((uint8_t*)dest)[c] = 0x00; } ret = uavcan_equipment_actuator_ArrayStatus_decode_internal(transfer, payload_len, dest, dyn_arr_buf, offset, tao_enabled); return ret; } #ifdef __cplusplus } // extern "C" #endif #endif // __UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS