al422b

Dependencies:   BufferedSerial

Committer:
kangmingyo
Date:
Fri Sep 06 02:09:38 2019 +0000
Revision:
8:221b2fc093e4
Parent:
3:2a3664dc6634
final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeonghoon 3:2a3664dc6634 1 #ifndef _ROS_sensor_msgs_BatteryState_h
Jeonghoon 3:2a3664dc6634 2 #define _ROS_sensor_msgs_BatteryState_h
Jeonghoon 3:2a3664dc6634 3
Jeonghoon 3:2a3664dc6634 4 #include <stdint.h>
Jeonghoon 3:2a3664dc6634 5 #include <string.h>
Jeonghoon 3:2a3664dc6634 6 #include <stdlib.h>
Jeonghoon 3:2a3664dc6634 7 #include "ros/msg.h"
Jeonghoon 3:2a3664dc6634 8 #include "std_msgs/Header.h"
Jeonghoon 3:2a3664dc6634 9
Jeonghoon 3:2a3664dc6634 10 namespace sensor_msgs
Jeonghoon 3:2a3664dc6634 11 {
Jeonghoon 3:2a3664dc6634 12
Jeonghoon 3:2a3664dc6634 13 class BatteryState : public ros::Msg
Jeonghoon 3:2a3664dc6634 14 {
Jeonghoon 3:2a3664dc6634 15 public:
Jeonghoon 3:2a3664dc6634 16 typedef std_msgs::Header _header_type;
Jeonghoon 3:2a3664dc6634 17 _header_type header;
Jeonghoon 3:2a3664dc6634 18 typedef float _voltage_type;
Jeonghoon 3:2a3664dc6634 19 _voltage_type voltage;
Jeonghoon 3:2a3664dc6634 20 typedef float _current_type;
Jeonghoon 3:2a3664dc6634 21 _current_type current;
Jeonghoon 3:2a3664dc6634 22 typedef float _charge_type;
Jeonghoon 3:2a3664dc6634 23 _charge_type charge;
Jeonghoon 3:2a3664dc6634 24 typedef float _capacity_type;
Jeonghoon 3:2a3664dc6634 25 _capacity_type capacity;
Jeonghoon 3:2a3664dc6634 26 typedef float _design_capacity_type;
Jeonghoon 3:2a3664dc6634 27 _design_capacity_type design_capacity;
Jeonghoon 3:2a3664dc6634 28 typedef float _percentage_type;
Jeonghoon 3:2a3664dc6634 29 _percentage_type percentage;
Jeonghoon 3:2a3664dc6634 30 typedef uint8_t _power_supply_status_type;
Jeonghoon 3:2a3664dc6634 31 _power_supply_status_type power_supply_status;
Jeonghoon 3:2a3664dc6634 32 typedef uint8_t _power_supply_health_type;
Jeonghoon 3:2a3664dc6634 33 _power_supply_health_type power_supply_health;
Jeonghoon 3:2a3664dc6634 34 typedef uint8_t _power_supply_technology_type;
Jeonghoon 3:2a3664dc6634 35 _power_supply_technology_type power_supply_technology;
Jeonghoon 3:2a3664dc6634 36 typedef bool _present_type;
Jeonghoon 3:2a3664dc6634 37 _present_type present;
Jeonghoon 3:2a3664dc6634 38 uint32_t cell_voltage_length;
Jeonghoon 3:2a3664dc6634 39 typedef float _cell_voltage_type;
Jeonghoon 3:2a3664dc6634 40 _cell_voltage_type st_cell_voltage;
Jeonghoon 3:2a3664dc6634 41 _cell_voltage_type * cell_voltage;
Jeonghoon 3:2a3664dc6634 42 typedef const char* _location_type;
Jeonghoon 3:2a3664dc6634 43 _location_type location;
Jeonghoon 3:2a3664dc6634 44 typedef const char* _serial_number_type;
Jeonghoon 3:2a3664dc6634 45 _serial_number_type serial_number;
Jeonghoon 3:2a3664dc6634 46 enum { POWER_SUPPLY_STATUS_UNKNOWN = 0 };
Jeonghoon 3:2a3664dc6634 47 enum { POWER_SUPPLY_STATUS_CHARGING = 1 };
Jeonghoon 3:2a3664dc6634 48 enum { POWER_SUPPLY_STATUS_DISCHARGING = 2 };
Jeonghoon 3:2a3664dc6634 49 enum { POWER_SUPPLY_STATUS_NOT_CHARGING = 3 };
Jeonghoon 3:2a3664dc6634 50 enum { POWER_SUPPLY_STATUS_FULL = 4 };
Jeonghoon 3:2a3664dc6634 51 enum { POWER_SUPPLY_HEALTH_UNKNOWN = 0 };
Jeonghoon 3:2a3664dc6634 52 enum { POWER_SUPPLY_HEALTH_GOOD = 1 };
Jeonghoon 3:2a3664dc6634 53 enum { POWER_SUPPLY_HEALTH_OVERHEAT = 2 };
Jeonghoon 3:2a3664dc6634 54 enum { POWER_SUPPLY_HEALTH_DEAD = 3 };
Jeonghoon 3:2a3664dc6634 55 enum { POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4 };
Jeonghoon 3:2a3664dc6634 56 enum { POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5 };
Jeonghoon 3:2a3664dc6634 57 enum { POWER_SUPPLY_HEALTH_COLD = 6 };
Jeonghoon 3:2a3664dc6634 58 enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7 };
Jeonghoon 3:2a3664dc6634 59 enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8 };
Jeonghoon 3:2a3664dc6634 60 enum { POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0 };
Jeonghoon 3:2a3664dc6634 61 enum { POWER_SUPPLY_TECHNOLOGY_NIMH = 1 };
Jeonghoon 3:2a3664dc6634 62 enum { POWER_SUPPLY_TECHNOLOGY_LION = 2 };
Jeonghoon 3:2a3664dc6634 63 enum { POWER_SUPPLY_TECHNOLOGY_LIPO = 3 };
Jeonghoon 3:2a3664dc6634 64 enum { POWER_SUPPLY_TECHNOLOGY_LIFE = 4 };
Jeonghoon 3:2a3664dc6634 65 enum { POWER_SUPPLY_TECHNOLOGY_NICD = 5 };
Jeonghoon 3:2a3664dc6634 66 enum { POWER_SUPPLY_TECHNOLOGY_LIMN = 6 };
Jeonghoon 3:2a3664dc6634 67
Jeonghoon 3:2a3664dc6634 68 BatteryState():
Jeonghoon 3:2a3664dc6634 69 header(),
Jeonghoon 3:2a3664dc6634 70 voltage(0),
Jeonghoon 3:2a3664dc6634 71 current(0),
Jeonghoon 3:2a3664dc6634 72 charge(0),
Jeonghoon 3:2a3664dc6634 73 capacity(0),
Jeonghoon 3:2a3664dc6634 74 design_capacity(0),
Jeonghoon 3:2a3664dc6634 75 percentage(0),
Jeonghoon 3:2a3664dc6634 76 power_supply_status(0),
Jeonghoon 3:2a3664dc6634 77 power_supply_health(0),
Jeonghoon 3:2a3664dc6634 78 power_supply_technology(0),
Jeonghoon 3:2a3664dc6634 79 present(0),
Jeonghoon 3:2a3664dc6634 80 cell_voltage_length(0), cell_voltage(NULL),
Jeonghoon 3:2a3664dc6634 81 location(""),
Jeonghoon 3:2a3664dc6634 82 serial_number("")
Jeonghoon 3:2a3664dc6634 83 {
Jeonghoon 3:2a3664dc6634 84 }
Jeonghoon 3:2a3664dc6634 85
Jeonghoon 3:2a3664dc6634 86 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 3:2a3664dc6634 87 {
Jeonghoon 3:2a3664dc6634 88 int offset = 0;
Jeonghoon 3:2a3664dc6634 89 offset += this->header.serialize(outbuffer + offset);
Jeonghoon 3:2a3664dc6634 90 union {
Jeonghoon 3:2a3664dc6634 91 float real;
Jeonghoon 3:2a3664dc6634 92 uint32_t base;
Jeonghoon 3:2a3664dc6634 93 } u_voltage;
Jeonghoon 3:2a3664dc6634 94 u_voltage.real = this->voltage;
Jeonghoon 3:2a3664dc6634 95 *(outbuffer + offset + 0) = (u_voltage.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 96 *(outbuffer + offset + 1) = (u_voltage.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 97 *(outbuffer + offset + 2) = (u_voltage.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 98 *(outbuffer + offset + 3) = (u_voltage.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 99 offset += sizeof(this->voltage);
Jeonghoon 3:2a3664dc6634 100 union {
Jeonghoon 3:2a3664dc6634 101 float real;
Jeonghoon 3:2a3664dc6634 102 uint32_t base;
Jeonghoon 3:2a3664dc6634 103 } u_current;
Jeonghoon 3:2a3664dc6634 104 u_current.real = this->current;
Jeonghoon 3:2a3664dc6634 105 *(outbuffer + offset + 0) = (u_current.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 106 *(outbuffer + offset + 1) = (u_current.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 107 *(outbuffer + offset + 2) = (u_current.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 108 *(outbuffer + offset + 3) = (u_current.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 109 offset += sizeof(this->current);
Jeonghoon 3:2a3664dc6634 110 union {
Jeonghoon 3:2a3664dc6634 111 float real;
Jeonghoon 3:2a3664dc6634 112 uint32_t base;
Jeonghoon 3:2a3664dc6634 113 } u_charge;
Jeonghoon 3:2a3664dc6634 114 u_charge.real = this->charge;
Jeonghoon 3:2a3664dc6634 115 *(outbuffer + offset + 0) = (u_charge.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 116 *(outbuffer + offset + 1) = (u_charge.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 117 *(outbuffer + offset + 2) = (u_charge.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 118 *(outbuffer + offset + 3) = (u_charge.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 119 offset += sizeof(this->charge);
Jeonghoon 3:2a3664dc6634 120 union {
Jeonghoon 3:2a3664dc6634 121 float real;
Jeonghoon 3:2a3664dc6634 122 uint32_t base;
Jeonghoon 3:2a3664dc6634 123 } u_capacity;
Jeonghoon 3:2a3664dc6634 124 u_capacity.real = this->capacity;
Jeonghoon 3:2a3664dc6634 125 *(outbuffer + offset + 0) = (u_capacity.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 126 *(outbuffer + offset + 1) = (u_capacity.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 127 *(outbuffer + offset + 2) = (u_capacity.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 128 *(outbuffer + offset + 3) = (u_capacity.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 129 offset += sizeof(this->capacity);
Jeonghoon 3:2a3664dc6634 130 union {
Jeonghoon 3:2a3664dc6634 131 float real;
Jeonghoon 3:2a3664dc6634 132 uint32_t base;
Jeonghoon 3:2a3664dc6634 133 } u_design_capacity;
Jeonghoon 3:2a3664dc6634 134 u_design_capacity.real = this->design_capacity;
Jeonghoon 3:2a3664dc6634 135 *(outbuffer + offset + 0) = (u_design_capacity.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 136 *(outbuffer + offset + 1) = (u_design_capacity.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 137 *(outbuffer + offset + 2) = (u_design_capacity.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 138 *(outbuffer + offset + 3) = (u_design_capacity.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 139 offset += sizeof(this->design_capacity);
Jeonghoon 3:2a3664dc6634 140 union {
Jeonghoon 3:2a3664dc6634 141 float real;
Jeonghoon 3:2a3664dc6634 142 uint32_t base;
Jeonghoon 3:2a3664dc6634 143 } u_percentage;
Jeonghoon 3:2a3664dc6634 144 u_percentage.real = this->percentage;
Jeonghoon 3:2a3664dc6634 145 *(outbuffer + offset + 0) = (u_percentage.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 146 *(outbuffer + offset + 1) = (u_percentage.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 147 *(outbuffer + offset + 2) = (u_percentage.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 148 *(outbuffer + offset + 3) = (u_percentage.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 149 offset += sizeof(this->percentage);
Jeonghoon 3:2a3664dc6634 150 *(outbuffer + offset + 0) = (this->power_supply_status >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 151 offset += sizeof(this->power_supply_status);
Jeonghoon 3:2a3664dc6634 152 *(outbuffer + offset + 0) = (this->power_supply_health >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 153 offset += sizeof(this->power_supply_health);
Jeonghoon 3:2a3664dc6634 154 *(outbuffer + offset + 0) = (this->power_supply_technology >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 155 offset += sizeof(this->power_supply_technology);
Jeonghoon 3:2a3664dc6634 156 union {
Jeonghoon 3:2a3664dc6634 157 bool real;
Jeonghoon 3:2a3664dc6634 158 uint8_t base;
Jeonghoon 3:2a3664dc6634 159 } u_present;
Jeonghoon 3:2a3664dc6634 160 u_present.real = this->present;
Jeonghoon 3:2a3664dc6634 161 *(outbuffer + offset + 0) = (u_present.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 162 offset += sizeof(this->present);
Jeonghoon 3:2a3664dc6634 163 *(outbuffer + offset + 0) = (this->cell_voltage_length >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 164 *(outbuffer + offset + 1) = (this->cell_voltage_length >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 165 *(outbuffer + offset + 2) = (this->cell_voltage_length >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 166 *(outbuffer + offset + 3) = (this->cell_voltage_length >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 167 offset += sizeof(this->cell_voltage_length);
Jeonghoon 3:2a3664dc6634 168 for( uint32_t i = 0; i < cell_voltage_length; i++){
Jeonghoon 3:2a3664dc6634 169 union {
Jeonghoon 3:2a3664dc6634 170 float real;
Jeonghoon 3:2a3664dc6634 171 uint32_t base;
Jeonghoon 3:2a3664dc6634 172 } u_cell_voltagei;
Jeonghoon 3:2a3664dc6634 173 u_cell_voltagei.real = this->cell_voltage[i];
Jeonghoon 3:2a3664dc6634 174 *(outbuffer + offset + 0) = (u_cell_voltagei.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 175 *(outbuffer + offset + 1) = (u_cell_voltagei.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 176 *(outbuffer + offset + 2) = (u_cell_voltagei.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 177 *(outbuffer + offset + 3) = (u_cell_voltagei.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 178 offset += sizeof(this->cell_voltage[i]);
Jeonghoon 3:2a3664dc6634 179 }
Jeonghoon 3:2a3664dc6634 180 uint32_t length_location = strlen(this->location);
Jeonghoon 3:2a3664dc6634 181 varToArr(outbuffer + offset, length_location);
Jeonghoon 3:2a3664dc6634 182 offset += 4;
Jeonghoon 3:2a3664dc6634 183 memcpy(outbuffer + offset, this->location, length_location);
Jeonghoon 3:2a3664dc6634 184 offset += length_location;
Jeonghoon 3:2a3664dc6634 185 uint32_t length_serial_number = strlen(this->serial_number);
Jeonghoon 3:2a3664dc6634 186 varToArr(outbuffer + offset, length_serial_number);
Jeonghoon 3:2a3664dc6634 187 offset += 4;
Jeonghoon 3:2a3664dc6634 188 memcpy(outbuffer + offset, this->serial_number, length_serial_number);
Jeonghoon 3:2a3664dc6634 189 offset += length_serial_number;
Jeonghoon 3:2a3664dc6634 190 return offset;
Jeonghoon 3:2a3664dc6634 191 }
Jeonghoon 3:2a3664dc6634 192
Jeonghoon 3:2a3664dc6634 193 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 3:2a3664dc6634 194 {
Jeonghoon 3:2a3664dc6634 195 int offset = 0;
Jeonghoon 3:2a3664dc6634 196 offset += this->header.deserialize(inbuffer + offset);
Jeonghoon 3:2a3664dc6634 197 union {
Jeonghoon 3:2a3664dc6634 198 float real;
Jeonghoon 3:2a3664dc6634 199 uint32_t base;
Jeonghoon 3:2a3664dc6634 200 } u_voltage;
Jeonghoon 3:2a3664dc6634 201 u_voltage.base = 0;
Jeonghoon 3:2a3664dc6634 202 u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 203 u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 204 u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 205 u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 206 this->voltage = u_voltage.real;
Jeonghoon 3:2a3664dc6634 207 offset += sizeof(this->voltage);
Jeonghoon 3:2a3664dc6634 208 union {
Jeonghoon 3:2a3664dc6634 209 float real;
Jeonghoon 3:2a3664dc6634 210 uint32_t base;
Jeonghoon 3:2a3664dc6634 211 } u_current;
Jeonghoon 3:2a3664dc6634 212 u_current.base = 0;
Jeonghoon 3:2a3664dc6634 213 u_current.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 214 u_current.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 215 u_current.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 216 u_current.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 217 this->current = u_current.real;
Jeonghoon 3:2a3664dc6634 218 offset += sizeof(this->current);
Jeonghoon 3:2a3664dc6634 219 union {
Jeonghoon 3:2a3664dc6634 220 float real;
Jeonghoon 3:2a3664dc6634 221 uint32_t base;
Jeonghoon 3:2a3664dc6634 222 } u_charge;
Jeonghoon 3:2a3664dc6634 223 u_charge.base = 0;
Jeonghoon 3:2a3664dc6634 224 u_charge.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 225 u_charge.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 226 u_charge.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 227 u_charge.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 228 this->charge = u_charge.real;
Jeonghoon 3:2a3664dc6634 229 offset += sizeof(this->charge);
Jeonghoon 3:2a3664dc6634 230 union {
Jeonghoon 3:2a3664dc6634 231 float real;
Jeonghoon 3:2a3664dc6634 232 uint32_t base;
Jeonghoon 3:2a3664dc6634 233 } u_capacity;
Jeonghoon 3:2a3664dc6634 234 u_capacity.base = 0;
Jeonghoon 3:2a3664dc6634 235 u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 236 u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 237 u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 238 u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 239 this->capacity = u_capacity.real;
Jeonghoon 3:2a3664dc6634 240 offset += sizeof(this->capacity);
Jeonghoon 3:2a3664dc6634 241 union {
Jeonghoon 3:2a3664dc6634 242 float real;
Jeonghoon 3:2a3664dc6634 243 uint32_t base;
Jeonghoon 3:2a3664dc6634 244 } u_design_capacity;
Jeonghoon 3:2a3664dc6634 245 u_design_capacity.base = 0;
Jeonghoon 3:2a3664dc6634 246 u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 247 u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 248 u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 249 u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 250 this->design_capacity = u_design_capacity.real;
Jeonghoon 3:2a3664dc6634 251 offset += sizeof(this->design_capacity);
Jeonghoon 3:2a3664dc6634 252 union {
Jeonghoon 3:2a3664dc6634 253 float real;
Jeonghoon 3:2a3664dc6634 254 uint32_t base;
Jeonghoon 3:2a3664dc6634 255 } u_percentage;
Jeonghoon 3:2a3664dc6634 256 u_percentage.base = 0;
Jeonghoon 3:2a3664dc6634 257 u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 258 u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 259 u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 260 u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 261 this->percentage = u_percentage.real;
Jeonghoon 3:2a3664dc6634 262 offset += sizeof(this->percentage);
Jeonghoon 3:2a3664dc6634 263 this->power_supply_status = ((uint8_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 264 offset += sizeof(this->power_supply_status);
Jeonghoon 3:2a3664dc6634 265 this->power_supply_health = ((uint8_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 266 offset += sizeof(this->power_supply_health);
Jeonghoon 3:2a3664dc6634 267 this->power_supply_technology = ((uint8_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 268 offset += sizeof(this->power_supply_technology);
Jeonghoon 3:2a3664dc6634 269 union {
Jeonghoon 3:2a3664dc6634 270 bool real;
Jeonghoon 3:2a3664dc6634 271 uint8_t base;
Jeonghoon 3:2a3664dc6634 272 } u_present;
Jeonghoon 3:2a3664dc6634 273 u_present.base = 0;
Jeonghoon 3:2a3664dc6634 274 u_present.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 275 this->present = u_present.real;
Jeonghoon 3:2a3664dc6634 276 offset += sizeof(this->present);
Jeonghoon 3:2a3664dc6634 277 uint32_t cell_voltage_lengthT = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 278 cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 279 cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 280 cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 281 offset += sizeof(this->cell_voltage_length);
Jeonghoon 3:2a3664dc6634 282 if(cell_voltage_lengthT > cell_voltage_length)
Jeonghoon 3:2a3664dc6634 283 this->cell_voltage = (float*)realloc(this->cell_voltage, cell_voltage_lengthT * sizeof(float));
Jeonghoon 3:2a3664dc6634 284 cell_voltage_length = cell_voltage_lengthT;
Jeonghoon 3:2a3664dc6634 285 for( uint32_t i = 0; i < cell_voltage_length; i++){
Jeonghoon 3:2a3664dc6634 286 union {
Jeonghoon 3:2a3664dc6634 287 float real;
Jeonghoon 3:2a3664dc6634 288 uint32_t base;
Jeonghoon 3:2a3664dc6634 289 } u_st_cell_voltage;
Jeonghoon 3:2a3664dc6634 290 u_st_cell_voltage.base = 0;
Jeonghoon 3:2a3664dc6634 291 u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 292 u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 293 u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 294 u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 295 this->st_cell_voltage = u_st_cell_voltage.real;
Jeonghoon 3:2a3664dc6634 296 offset += sizeof(this->st_cell_voltage);
Jeonghoon 3:2a3664dc6634 297 memcpy( &(this->cell_voltage[i]), &(this->st_cell_voltage), sizeof(float));
Jeonghoon 3:2a3664dc6634 298 }
Jeonghoon 3:2a3664dc6634 299 uint32_t length_location;
Jeonghoon 3:2a3664dc6634 300 arrToVar(length_location, (inbuffer + offset));
Jeonghoon 3:2a3664dc6634 301 offset += 4;
Jeonghoon 3:2a3664dc6634 302 for(unsigned int k= offset; k< offset+length_location; ++k){
Jeonghoon 3:2a3664dc6634 303 inbuffer[k-1]=inbuffer[k];
Jeonghoon 3:2a3664dc6634 304 }
Jeonghoon 3:2a3664dc6634 305 inbuffer[offset+length_location-1]=0;
Jeonghoon 3:2a3664dc6634 306 this->location = (char *)(inbuffer + offset-1);
Jeonghoon 3:2a3664dc6634 307 offset += length_location;
Jeonghoon 3:2a3664dc6634 308 uint32_t length_serial_number;
Jeonghoon 3:2a3664dc6634 309 arrToVar(length_serial_number, (inbuffer + offset));
Jeonghoon 3:2a3664dc6634 310 offset += 4;
Jeonghoon 3:2a3664dc6634 311 for(unsigned int k= offset; k< offset+length_serial_number; ++k){
Jeonghoon 3:2a3664dc6634 312 inbuffer[k-1]=inbuffer[k];
Jeonghoon 3:2a3664dc6634 313 }
Jeonghoon 3:2a3664dc6634 314 inbuffer[offset+length_serial_number-1]=0;
Jeonghoon 3:2a3664dc6634 315 this->serial_number = (char *)(inbuffer + offset-1);
Jeonghoon 3:2a3664dc6634 316 offset += length_serial_number;
Jeonghoon 3:2a3664dc6634 317 return offset;
Jeonghoon 3:2a3664dc6634 318 }
Jeonghoon 3:2a3664dc6634 319
Jeonghoon 3:2a3664dc6634 320 const char * getType(){ return "sensor_msgs/BatteryState"; };
Jeonghoon 3:2a3664dc6634 321 const char * getMD5(){ return "476f837fa6771f6e16e3bf4ef96f8770"; };
Jeonghoon 3:2a3664dc6634 322
Jeonghoon 3:2a3664dc6634 323 };
Jeonghoon 3:2a3664dc6634 324
Jeonghoon 3:2a3664dc6634 325 }
Jeonghoon 3:2a3664dc6634 326 #endif