Skip to content

Commit

Permalink
Update diagnostic for aksim2 sending all specific errors per jomo eac…
Browse files Browse the repository at this point in the history
…h 10 sec to not overflood eth bus
  • Loading branch information
MSECode committed Jun 10, 2024
1 parent a268118 commit a51d54c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern "C" {
#define EOMTHEEMSAPPLCFG_VERSION_MAJOR (VERSION_MAJOR_OFFSET+3)
// <o> minor <0-255>
// <o> minor <0-255>
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 90
#define EOMTHEEMSAPPLCFG_VERSION_MINOR 91

// </h>version

Expand Down
75 changes: 56 additions & 19 deletions emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ static EOappEncReader s_eo_theappencreader =
EO_INIT(.cnts) { 0, 0},
EO_INIT(.one) { 0, 0, 0, 0, 0 },
EO_INIT(.two) { 0, 0, 0, 0, 0 }
},
EO_INIT(.aksim2DiagnerrorCounters )
{
EO_INIT(.encoder_error_crc_counter ) {0, 0, 0, 0},
EO_INIT(.encoder_error_invalid_data_counter ) {0, 0, 0, 0},
EO_INIT(.encoder_error_close_to_limit_counter ) {0, 0, 0, 0},
EO_INIT(.encoder_error_hal_counter ) {0, 0, 0, 0},
EO_INIT(.encoder_error_total_timer_counter ) {0, 0, 0, 0}
}
};

Expand Down Expand Up @@ -698,18 +706,57 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen
}
else
{ // we dont even have a valid reading from hal or the encoder is not properly connected to the board
++s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_hal_counter[jomo];

prop.valueinfo->errortype = encreader_err_AKSIM2_GENERIC ;
errorparam = 0;

// notify the error (check and re-check)
}

if(++s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_total_timer_counter[jomo] > 10000)
{
// preperare data for diagnostics
eOerrmanDescriptor_t errdes = {0};
errdes.sourcedevice = eo_errman_sourcedevice_localboard;
errdes.sourceaddress = 0;
errdes.par16 = 0;
errdes.par16 = jomo;
errdes.par64 = (uint64_t) (diagn.info.aksim2_status_crc) << 32;
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_not_connected);
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);

if(s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_hal_counter[jomo] > 0)
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_not_connected);
errdes.par64 |= s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_hal_counter[jomo];
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);

s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_hal_counter[jomo] = 0;
}
if(s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_invalid_data_counter[jomo] > 0)
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_invalid_value);
errdes.par64 |= s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_invalid_data_counter[jomo];
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);

s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_invalid_data_counter[jomo] = 0;
}
if(s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_close_to_limit_counter[jomo] > 0)
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_close_to_limits);
errdes.par64 |= s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_close_to_limit_counter[jomo];
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);

s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_close_to_limit_counter[jomo] = 0;
}
if(s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_crc_counter[jomo] > 0)
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_crc);
errdes.par64 |= s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_crc_counter[jomo];
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);

s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_crc_counter[jomo] = 0;
}

s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_total_timer_counter[jomo] = 0;
}

#if defined(DEBUG_encoder_AKSIM)
sev->off();
#endif
Expand Down Expand Up @@ -1398,36 +1445,26 @@ static eObool_t s_eo_appEncReader_IsValidValue_AKSIM2(uint8_t jomo, hal_spiencod
{
// in case of errors we return false. Initially we assume no errors
eObool_t ret = eobool_true;

// preperare data for diagnostics
eOerrmanDescriptor_t errdes = {0};
errdes.sourcedevice = eo_errman_sourcedevice_localboard;
errdes.sourceaddress = 0;
errdes.par16 = jomo;
errdes.par64 = (uint64_t) (diag->info.aksim2_status_crc) << 32;

// In case of errors we send human readable diagnostics messages
if(0x04 == (0x04 & diag->info.aksim2_status_crc))
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_invalid_value);
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);
++s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_invalid_data_counter[jomo];
ret = eobool_false;
}

if(0x02 == (0x02 & diag->info.aksim2_status_crc))
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_close_to_limits);
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);
++s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_close_to_limit_counter[jomo];
ret = eobool_false;
}

if(0x01 == (0x01 & diag->info.aksim2_status_crc))
{
errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_crc);
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes);
++s_eo_theappencreader.aksim2DiagnerrorCounters.encoder_error_crc_counter[jomo];
ret = eobool_false;
}


return ret;
}

Expand Down
12 changes: 12 additions & 0 deletions emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ typedef struct
} eo_appEncReader_amodiag_t;


// structure defined for counting the errors related to aksim2 encoder
typedef struct
{
uint16_t encoder_error_crc_counter[eOappEncReader_jomos_maxnumberof];
uint16_t encoder_error_invalid_data_counter[eOappEncReader_jomos_maxnumberof];
uint16_t encoder_error_close_to_limit_counter[eOappEncReader_jomos_maxnumberof];
uint16_t encoder_error_hal_counter[eOappEncReader_jomos_maxnumberof];
uint16_t encoder_error_total_timer_counter[eOappEncReader_jomos_maxnumberof];

} eOappEncReader_Aksim2_DiagnosticError_Counters_t;

struct EOappEncReader_hid
{
eObool_t initted;
Expand All @@ -127,6 +138,7 @@ struct EOappEncReader_hid
float maisConversionFactors[eOappEncReader_jomos_maxnumberof];
eOappEncReader_hallAdc_conversionData_t hallAdcConversionData;
eo_appEncReader_amodiag_t amodiag;
eOappEncReader_Aksim2_DiagnosticError_Counters_t aksim2DiagnerrorCounters;
};


Expand Down

0 comments on commit a51d54c

Please sign in to comment.