Skip to content

Commit

Permalink
Add status and maps for handling status strings (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
valegagge authored Sep 8, 2023
2 parents 055a13f + 363069a commit 7e078b6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.12)

project(icub_firmware_shared
VERSION 1.35.1)
VERSION 1.35.2)

find_package(YCM 0.11.0 REQUIRED)

Expand Down
48 changes: 25 additions & 23 deletions can/canProtocolLib/iCubCanProto_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,31 @@ extern "C" {
#define ICUBCANPROTO_PER_MC_STATUS_FLAG_CANRECHWOVERRUN 0x40 //in data[4]

// definition of board types.
#define ICUBCANPROTO_BOARDTYPE__DSP 0
#define ICUBCANPROTO_BOARDTYPE__PIC 1
#define ICUBCANPROTO_BOARDTYPE__2DC 2
#define ICUBCANPROTO_BOARDTYPE__4DC 3
#define ICUBCANPROTO_BOARDTYPE__BLL 4
#define ICUBCANPROTO_BOARDTYPE__SKIN 5
#define ICUBCANPROTO_BOARDTYPE__STRAIN 6
#define ICUBCANPROTO_BOARDTYPE__MAIS 7
#define ICUBCANPROTO_BOARDTYPE__2FOC 8
#define ICUBCANPROTO_BOARDTYPE__6SG 9
#define ICUBCANPROTO_BOARDTYPE__JOG 10
#define ICUBCANPROTO_BOARDTYPE__MTB4 11
#define ICUBCANPROTO_BOARDTYPE__STRAIN2 12
#define ICUBCANPROTO_BOARDTYPE__RFE 13
#define ICUBCANPROTO_BOARDTYPE__SG3 14
#define ICUBCANPROTO_BOARDTYPE__PSC 15
#define ICUBCANPROTO_BOARDTYPE__MTB4W 16
#define ICUBCANPROTO_BOARDTYPE__PMC 17
#define ICUBCANPROTO_BOARDTYPE__AMCBLDC 18
#define ICUBCANPROTO_BOARDTYPE__BMS 19
#define ICUBCANPROTO_BOARDTYPE__MTB4C 20
#define ICUBCANPROTO_BOARDTYPE__FFU 21
#define ICUBCANPROTO_BOARDTYPE__DSP 0
#define ICUBCANPROTO_BOARDTYPE__PIC 1
#define ICUBCANPROTO_BOARDTYPE__2DC 2
#define ICUBCANPROTO_BOARDTYPE__4DC 3
#define ICUBCANPROTO_BOARDTYPE__BLL 4
#define ICUBCANPROTO_BOARDTYPE__SKIN 5
#define ICUBCANPROTO_BOARDTYPE__STRAIN 6
#define ICUBCANPROTO_BOARDTYPE__MAIS 7
#define ICUBCANPROTO_BOARDTYPE__2FOC 8
#define ICUBCANPROTO_BOARDTYPE__6SG 9
#define ICUBCANPROTO_BOARDTYPE__JOG 10
#define ICUBCANPROTO_BOARDTYPE__MTB4 11
#define ICUBCANPROTO_BOARDTYPE__STRAIN2 12
#define ICUBCANPROTO_BOARDTYPE__RFE 13
#define ICUBCANPROTO_BOARDTYPE__SG3 14
#define ICUBCANPROTO_BOARDTYPE__PSC 15
#define ICUBCANPROTO_BOARDTYPE__MTB4W 16
#define ICUBCANPROTO_BOARDTYPE__PMC 17
#define ICUBCANPROTO_BOARDTYPE__AMCBLDC 18
#define ICUBCANPROTO_BOARDTYPE__BMS 19
#define ICUBCANPROTO_BOARDTYPE__MTB4C 20
#define ICUBCANPROTO_BOARDTYPE__FFU 21
#define ICUBCANPROTO_BOARDTYPE__STRAIN2C 22
#define ICUBCANPROTO_BOARDTYPE__UNKNOWN 255
#define ICUBCANPROTO_BOARDTYPE__BAT 23
#define ICUBCANPROTO_BOARDTYPE__UNKNOWN 255

// skin types
#define ICUBCANPROTO_SKINTYPE__WITHTEMPCOMP 0
Expand Down Expand Up @@ -118,6 +119,7 @@ typedef enum
icubCanProto_boardType__bms = ICUBCANPROTO_BOARDTYPE__BMS,
icubCanProto_boardType__mtb4c = ICUBCANPROTO_BOARDTYPE__MTB4C,
icubCanProto_boardType__strain2c = ICUBCANPROTO_BOARDTYPE__STRAIN2C,
icubCanProto_boardType__bat = ICUBCANPROTO_BOARDTYPE__BAT,
icubCanProto_boardType__unknown = ICUBCANPROTO_BOARDTYPE__UNKNOWN
} icubCanProto_boardType_t;

Expand Down
5 changes: 3 additions & 2 deletions eth/embobj/plus/comm-v2/icub/EoAnalogSensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
// --------------------------------------------------------------------------------------------------------------------

#include "EoAnalogSensors.h"
#include "EOtheErrorManager.h"
#include "EoError.h"


// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -222,7 +224,6 @@ extern eoas_pos_ROT_t eoas_string2posrot(const char * string, eObool_t usecompac
return((eoas_pos_ROT_t)eo_common_map_str_str_u08__string2value(map, size, string, usecompactstring, defvalue));
}


enum { in3_mtb_pos = 0, in3_mtb4_pos = 1, in3_strain2_pos = 2, in3_rfe_pos = 3, in3_mtb4c_pos = 4, in3_strain2c_pos = 5 };

static const eObrd_cantype_t s_eoas_inertial3_supportedboards_types[] = { eobrd_cantype_mtb, eobrd_cantype_mtb4, eobrd_cantype_strain2, eobrd_cantype_rfe, eobrd_cantype_mtb4c, eobrd_cantype_strain2c };
Expand Down Expand Up @@ -553,7 +554,7 @@ extern const eObrd_info_t * eoas_temperature_setof_boardinfos_find(const eOas_te
//

static const eObrd_cantype_t s_eoas_ft_supportedboards_types[] = { eobrd_cantype_strain, eobrd_cantype_strain2, eobrd_cantype_strain2c };
static const eObrd_cantype_t s_eoas_bms_supportedboards_types[] = { eobrd_cantype_bms };
static const eObrd_cantype_t s_eoas_bms_supportedboards_types[] = { eobrd_cantype_bms, eobrd_cantype_bat };


extern uint8_t eoas_battery_supportedboards_numberof(void)
Expand Down
56 changes: 45 additions & 11 deletions eth/embobj/plus/comm-v2/icub/EoAnalogSensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,41 @@ typedef struct
eOas_ft_status_t status;
} eOas_ft_t; EO_VERIFYsizeof(eOas_ft_t, 64)

typedef enum
{
//shold I define a value to the first element of bat, such as 16,
//thus to give to bms a certain amount of int for the statuses thinking about a future expantion
// so that number from 0 to 15 are restricted to bms and the other to bat
//an then add null values in the map for the empty spaces
eoas_bms_general_alarm_lowvoltage = 1,
eoas_bms_general_alarm_highvoltage = 2,
eoas_bms_general_alarm_overcurrent_discharge = 3,
eoas_bms_general_alarm_overcurrent_charge = 4,
eoas_bms_general_alarm_lowSOC = 5,
eoas_bms_general_alarm_lowtemperature = 6,
eoas_bms_general_alarm_hightemperature = 7,
eoas_bat_status_hsm_mosfet_broken = 16,
eoas_bat_status_hsm_mosfet_normal = 116, //(x-1)+100
eoas_bat_status_hsm_overcurrent_overvoltage = 17,
eoas_bat_status_hsm_normal = 117,
eoas_bat_status_hsm_voltage_power_good = 18,
eoas_bat_status_hsm_voltage_not_guaranteed = 118,
eoas_bat_status_hsm_status_on = 19,
eoas_bat_status_hsm_status_off = 119,
eoas_bat_status_motor_regulator_overcurrent = 20,
eoas_bat_status_motor_regulator_normal = 120,
eoas_bat_status_motor_on = 21,
eoas_bat_status_motor_off = 121,
eoas_bat_status_board_regulator_overcurrent = 22,
eoas_bat_status_board_regulator_normal = 122,
eoas_bat_status_board_on = 23,
eoas_bat_status_board_off = 123,
eoas_bat_status_btn_2_start_up_phase = 24,
eoas_bat_status_btn_2_stable_op = 124,
eoas_bat_status_btn_1_start_up_phase = 25,
eoas_bat_status_btn_1_stable_op = 125
} eOas_battery_alarm_status_t;
enum { eoas_bms_alarm_numberof = 8, eoas_battery_alarm_status_numberof = 27 };


typedef struct
Expand All @@ -808,33 +843,33 @@ typedef struct
uint8_t filler[3];
} eOas_battery_commands_t; EO_VERIFYsizeof(eOas_battery_commands_t, 4)


typedef struct
{
eOabstime_t age; // timeoflife in usec. better using this because yarp may ask the board to have its time
int16_t temperature; // in steps of 0.1 celsius degree (pos and neg).
int8_t status;
uint8_t filler;
eOabstime_t age; // timeoflife in usec. better using this because yarp may ask the board to have its time
int16_t temperature; // in steps of 0.1 celsius degree (pos and neg).
int16_t filler16; // filler to cover the remaining 16bits considired that we are working efficiently in memory packs of 32bits
uint32_t status; // status used on both BAT(10 bits - primary in 0x00000000ffffffff - secondary in 0x000000ff00000000) and BMS(8 MSB)
float32_t voltage;
float32_t current;
float32_t charge;
float32_t charge;
uint32_t filler32; // to keep struct with an even number of memory chunks

} eOas_battery_timedvalue_t; EO_VERIFYsizeof(eOas_battery_timedvalue_t, 24)
} eOas_battery_timedvalue_t; EO_VERIFYsizeof(eOas_battery_timedvalue_t, 32)
//char (*luca)[sizeof( eOas_battery_timedvalue_t )] = 1;

typedef struct
{ // 40 + 12 + 4 = 56
eOas_battery_timedvalue_t timedvalue;
} eOas_battery_status_t; EO_VERIFYsizeof(eOas_battery_status_t, 24)
} eOas_battery_status_t; EO_VERIFYsizeof(eOas_battery_status_t, 32)


typedef struct
{
// size is: 4 + 4 + 56 = 64
// size is: 4 + 4 + 32 = 40
eOas_battery_config_t config;
eOas_battery_commands_t cmmnds;
eOas_battery_status_t status;
} eOas_battery_t; EO_VERIFYsizeof(eOas_battery_t, 32)
} eOas_battery_t; EO_VERIFYsizeof(eOas_battery_t, 40)

// - declaration of extern public variables, ... but better using use _get/_set instead -------------------------------
// empty-section
Expand Down Expand Up @@ -877,7 +912,6 @@ extern eoas_pos_TYPE_t eoas_string2postype(const char * string, eObool_t usecomp
extern const char * eoas_posrot2string(eoas_pos_ROT_t posrot, eObool_t usecompactstring);
extern eoas_pos_ROT_t eoas_string2posrot(const char * string, eObool_t usecompactstring);


/** @}
end of group eo_cevcwervcrev5555
**/
Expand Down
4 changes: 3 additions & 1 deletion eth/embobj/plus/comm-v2/icub/EoBoards.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ static const uint64_t s_eoboards_is_can_mask = (0x1LL << eobrd_mc4) |
(0x1LL << eobrd_amcbldc)|
(0x1LL << eobrd_bms)|
(0x1LL << eobrd_mtb4c) |
(0x1LL << eobrd_strain2c);
(0x1LL << eobrd_strain2c) |
(0x1LL << eobrd_bat);


static const eOmap_str_str_u08_t s_eoboards_map_of_boards[] =
Expand Down Expand Up @@ -127,6 +128,7 @@ static const eOmap_str_str_u08_t s_eoboards_map_of_boards[] =
{"bms", "eobrd_bms", eobrd_bms},
{"mtb4c", "eobrd_mtb4c", eobrd_mtb4c},
{"strain2c", "eobrd_strain2c", eobrd_strain2c},
{"bat", "eobrd_bat", eobrd_bat},

{"none", "eobrd_none", eobrd_none},
{"unknown", "eobrd_unknown", eobrd_unknown}
Expand Down
10 changes: 6 additions & 4 deletions eth/embobj/plus/comm-v2/icub/EoBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
typedef enum
{
eobrd_cantype_dsp = ICUBCANPROTO_BOARDTYPE__DSP, // 0, not used
eobrd_cantype_pic = ICUBCANPROTO_BOARDTYPE__PIC, // 2, not used
eobrd_cantype_pic = ICUBCANPROTO_BOARDTYPE__PIC, // 1, not used
eobrd_cantype_2dc = ICUBCANPROTO_BOARDTYPE__2DC, // 2, not used
eobrd_cantype_mc4 = ICUBCANPROTO_BOARDTYPE__4DC, // 3
eobrd_cantype_bll = ICUBCANPROTO_BOARDTYPE__BLL, // 4, not used
Expand All @@ -78,12 +78,13 @@ typedef enum
eobrd_cantype_amcbldc = ICUBCANPROTO_BOARDTYPE__AMCBLDC, // 18 (amcbldc)
eobrd_cantype_bms = ICUBCANPROTO_BOARDTYPE__BMS, // 19 (bms)
eobrd_cantype_mtb4c = ICUBCANPROTO_BOARDTYPE__MTB4C, // 20 (mtb4c)
eobrd_cantype_strain2c = ICUBCANPROTO_BOARDTYPE__STRAIN2C, // 22 (strain2c)
eobrd_cantype_strain2c = ICUBCANPROTO_BOARDTYPE__STRAIN2C, // 22 (strain2c)
eobrd_cantype_bat = ICUBCANPROTO_BOARDTYPE__BAT, // 23 (bat)
eobrd_cantype_none = 254,
eobrd_cantype_unknown = ICUBCANPROTO_BOARDTYPE__UNKNOWN // 255
} eObrd_cantype_t;

enum { eobrd_cantype_numberof = 21 };
enum { eobrd_cantype_numberof = 23 };


typedef enum
Expand Down Expand Up @@ -134,12 +135,13 @@ typedef enum
eobrd_bms = eobrd_cantype_bms,
eobrd_mtb4c = eobrd_cantype_mtb4c,
eobrd_strain2c = eobrd_cantype_strain2c,
eobrd_bat = eobrd_cantype_bat,

eobrd_none = 254,
eobrd_unknown = 255 // = ICUBCANPROTO_BOARDTYPE__UNKNOWN
} eObrd_type_t;

enum { eobrd_type_numberof = 26 };
enum { eobrd_type_numberof = 27 };


typedef struct
Expand Down

0 comments on commit 7e078b6

Please sign in to comment.