35 #include "FeatureInterface.h"
42 #include "EoProtocolMN.h"
79 static void s_process_CANPRINT(eOmn_info_basic_t* infobasic, uint8_t * extra,
const EOnv* nv,
const eOropdescriptor_t* rd);
81 static void s_process_category_Default(eOmn_info_basic_t* infobasic, uint8_t * extra,
const EOnv* nv,
const eOropdescriptor_t* rd);
83 static void s_process_category_Config(eOmn_info_basic_t* infobasic, uint8_t * extra,
const EOnv* nv,
const eOropdescriptor_t* rd);
114 if(eo_ropcode_sig == rd->ropcode)
116 eOmn_info_status_t* infostatus = (eOmn_info_status_t*) rd->data;
124 if(eo_ropcode_sig == rd->ropcode)
126 eOmn_info_basic_t* infostatusbasic = (eOmn_info_basic_t*) rd->data;
134 if(eo_ropcode_sig == rd->ropcode)
138 feat_PrintError(
"eoprot_fun_UPDT_mn_comm_cmmnds_command_replynumof() has received an unexpected message");
144 feat_PrintError(
"eoprot_fun_UPDT_mn_comm_cmmnds_command_replynumof() has received an unexpected opcode");
151 if(eo_ropcode_sig == rd->ropcode)
155 feat_PrintError(
"eoprot_fun_UPDT_mn_comm_cmmnds_command_replyarray() has received an unexpected message");
161 feat_PrintError(
"eoprot_fun_UPDT_mn_comm_cmmnds_command_replyarray() has received an unexpected opcode");
167 if(eo_ropcode_sig == rd->ropcode)
171 feat_PrintError(
"eoprot_fun_UPDT_mn_service_status_commandresult() has received an unexpected message");
177 feat_PrintError(
"eoprot_fun_UPDT_mn_service_status_commandresult() has received an unexpected opcode");
196 #undef DROPCODES_FROM_LIST
197 #define CAN_PRINT_FULL_PARSING
199 static const eOerror_code_t codecanprint = EOERRORCODE(eoerror_category_System, eoerror_value_SYS_canservices_canprint);
200 eOerror_category_t category = eoerror_code2category(infobasic->properties.code);
202 #if defined(DROPCODES_FROM_LIST)
203 static const eOerror_code_t codes2drop_value[] =
205 EOERRORCODE(eoerror_category_System, eoerror_value_SYS_canservices_parsingfailure),
206 EOERRORCODE(eoerror_category_System, eoerror_value_SYS_canservices_rxmaisbug),
207 EOERRORCODE(eoerror_category_System, eoerror_value_SYS_canservices_rxfromwrongboard),
208 EOERRORCODE(eoerror_category_System, eoerror_value_SYS_transceiver_rxseqnumber_error)
211 static const int codes2drop_number =
sizeof(codes2drop_value) /
sizeof(eOerror_code_t);
215 for(i=0; i<codes2drop_number; i++)
217 if(codes2drop_value[i] == infobasic->properties.code)
224 if(codecanprint == infobasic->properties.code)
239 eOmn_info_type_t type;
241 eOmn_info_extraformat_t extraf;
242 const char * str_source = NULL;
243 const char * str_code = NULL;
244 const char * str_extra = NULL;
246 char ipinfo[20] = {0};
249 static const char nullverbalextra[] =
"no extra info despite we are in verbal mode";
250 static const char emptyextra[] =
".";
255 type = EOMN_INFO_PROPERTIES_FLAGS_get_type(infobasic->properties.flags);
256 extraf = EOMN_INFO_PROPERTIES_FLAGS_get_extraformat(infobasic->properties.flags);
260 str_code = eoerror_code2string(infobasic->properties.code);
263 if(eomn_info_extraformat_verbal == extraf)
265 str_extra = (NULL == extra) ? (nullverbalextra) : ((
const char *)extra);
269 str_extra = emptyextra;
272 p64 = (uint8_t*)&(infobasic->properties.par64);
275 eo_common_ipv4addr_to_string(eo_nv_GetIP(nv), ipinfo,
sizeof(ipinfo));
278 snprintf(str,
sizeof(str),
" from BOARD %s (%s), src %s, adr %d, time %ds %dm %du: (code 0x%.8x, par16 0x%.4x par64 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x) -> %s + %s",
284 infobasic->properties.code,
285 infobasic->properties.par16,
286 p64[7], p64[6], p64[5], p64[4], p64[3], p64[2], p64[1], p64[0],
299 case eomn_info_type_info:
304 case eomn_info_type_debug:
309 case eomn_info_type_warning:
314 case eomn_info_type_error:
319 case eomn_info_type_fatal:
334 static void s_process_CANPRINT(eOmn_info_basic_t* infobasic, uint8_t * extra,
const EOnv* nv,
const eOropdescriptor_t* rd)
343 eOmn_info_type_t type;
344 char ipinfo[20] = {0};
347 eOerror_value_t value;
353 type = EOMN_INFO_PROPERTIES_FLAGS_get_type(infobasic->properties.flags);
355 eo_common_ipv4addr_to_string(eo_nv_GetIP(nv), ipinfo,
sizeof(ipinfo));
358 value = eoerror_code2value(infobasic->properties.code);
363 case eoerror_value_CFG_candiscovery_started:
365 uint16_t maskcan2 = infobasic->properties.par16;
366 uint64_t brdnum = (infobasic->properties.par64 & 0x0000ff0000000000) >> 40;
367 const char *canboardname = eoboards_type2string(brdnum);
368 uint16_t maskcan1 = (infobasic->properties.par64 & 0xffff000000000000) >> 48;
369 eObrd_protocolversion_t prot = {0};
370 eObrd_firmwareversion_t appl = {0};
371 uint64_t reqpr = (infobasic->properties.par64 & 0x000000ffff000000) >> 24;
372 uint64_t reqfw = (infobasic->properties.par64 & 0x0000000000ffffff);
374 prot.major = reqpr >> 8;
375 prot.minor = reqpr & 0xff;
376 appl.major = (reqfw >> 16) & 0xff;
377 appl.minor = (reqfw >> 8) & 0xff;
378 appl.build = reqfw & 0xff;
379 num = eo_common_hlfword_bitsetcount(maskcan1)+eo_common_hlfword_bitsetcount(maskcan2);
381 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: CAN discovery has started for %d %s boards on (can1map, can2map) = (0x%.4x, 0x%.4x) with target can protocol ver %d.%d and application ver %d.%d.%d.",
388 prot.major, prot.minor,
389 appl.major, appl.minor, appl.build
396 case eoerror_value_CFG_candiscovery_ok:
398 uint8_t num = infobasic->properties.par16 & 0x00ff;
399 eObool_t fakesearch = (0x0000 == (infobasic->properties.par16 & 0xf000)) ? (eobool_false) : (eobool_true);
400 uint64_t brdnum = (infobasic->properties.par64 & 0x0000ff0000000000) >> 40;
401 const char *canboardname = eoboards_type2string(brdnum);
402 uint64_t searchtime = (infobasic->properties.par64 & 0xffff000000000000) >> 48;
403 eObrd_protocolversion_t prot = {0};
404 eObrd_firmwareversion_t appl = {0};
405 uint64_t reqpr = (infobasic->properties.par64 & 0x000000ffff000000) >> 24;
406 uint64_t reqfw = (infobasic->properties.par64 & 0x0000000000ffffff);
407 char strOK[80] =
"OK";
409 prot.major = reqpr >> 8;
410 prot.minor = reqpr & 0xff;
411 appl.major = (reqfw >> 16) & 0xff;
412 appl.minor = (reqfw >> 8) & 0xff;
413 appl.build = reqfw & 0xff;
416 if(eobool_true == fakesearch)
418 snprintf(strOK,
sizeof(strOK),
"OK but FAKE (without any control on CAN w/ get-fw-version<> message)");
421 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: CAN discovery is %s for %d %s boards with target can protocol ver %d.%d and application ver %d.%d.%d. Search time was %d ms",
427 prot.major, prot.minor,
428 appl.major, appl.minor, appl.build,
436 case eoerror_value_CFG_candiscovery_detectedboard:
438 uint64_t brdnum = (infobasic->properties.par64 & 0x0000ff0000000000) >> 40;
439 const char *canboardname = eoboards_type2string(brdnum);
440 uint64_t searchtime = (infobasic->properties.par64 & 0xffff000000000000) >> 48;
441 eObrd_protocolversion_t prot = {0};
442 eObrd_firmwareversion_t appl = {0};
443 uint64_t reqpr = (infobasic->properties.par64 & 0x000000ffff000000) >> 24;
444 uint64_t reqfw = (infobasic->properties.par64 & 0x0000000000ffffff);
447 prot.major = reqpr >> 8;
448 prot.minor = reqpr & 0xff;
449 appl.major = (reqfw >> 16) & 0xff;
450 appl.minor = (reqfw >> 8) & 0xff;
451 appl.build = reqfw & 0xff;
452 address = infobasic->properties.par16 & 0x000f;
455 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: CAN discovery has detected a %s board in %s addr %d with can protocol ver %d.%d and application ver %d.%d.%d Search time was %d ms",
462 prot.major, prot.minor,
463 appl.major, appl.minor, appl.build,
470 case eoerror_value_CFG_candiscovery_boardsmissing:
472 uint8_t numofmissing = infobasic->properties.par16 & 0x00ff;
473 const char *canboardname = eoboards_type2string(infobasic->properties.par16 >> 8);
474 uint64_t searchtime = (infobasic->properties.par64 & 0xffff000000000000) >> 48;
475 uint16_t maskofmissing = infobasic->properties.par64 & 0x000000000000ffff;
480 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: CAN discovery after %d ms has detected %d missing %s boards in %s:",
494 if(eobool_true == eo_common_hlfword_bitcheck(maskofmissing, i))
496 snprintf(str,
sizeof(str),
"%d of %d: missing %s BOARD %s:%s:%d",
497 n, numofmissing, canboardname,
508 case eoerror_value_CFG_candiscovery_boardsinvalid:
510 uint8_t numofinvalid = infobasic->properties.par16 & 0x00ff;
511 const char *canboardname = eoboards_type2string(infobasic->properties.par16 >> 8);
512 uint64_t invalidmask = infobasic->properties.par64;
516 const char *empty =
"";
517 const char *wrongtype =
"WRONG BOARD TYPE";
518 const char *wrongprot =
"WRONG PROTOCOL VERSION";
519 const char *wrongappl =
"WRONG APPLICATION VERSION";
521 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: CAN discovery has detected %d invalid %s boards in %s:",
536 uint64_t val = (invalidmask >> (4*i)) & 0x0f;
539 snprintf(str,
sizeof(str),
"%d of %d: wrong %s BOARD %s:%s:%d because it has: %s %s %s",
540 n, numofinvalid, canboardname,
542 ((val & 0x1) == 0x1) ? (wrongtype) : (empty),
543 ((val & 0x2) == 0x2) ? (wrongappl) : (empty),
544 ((val & 0x4) == 0x4) ? (wrongprot) : (empty)
560 case EOERROR_VALUE_DUMMY:
562 snprintf(str,
sizeof(str),
" from BOARD %s (%s) @ %ds %dm %du: unrecognised eoerror_category_Config error value:",
578 t->
sec = infobasic->timestamp / 1000000;
579 t->
msec = (infobasic->timestamp % 1000000) / 1000;
580 t->
usec = infobasic->timestamp % 1000;
586 static const char *
const sourcenames[] =
594 eOmn_info_source_t source = EOMN_INFO_PROPERTIES_FLAGS_get_source(infobasic->properties.flags);
598 *address = EOMN_INFO_PROPERTIES_FLAGS_get_address(infobasic->properties.flags);
601 return((source > eomn_info_source_can2) ? (sourcenames[3]) : (sourcenames[source]));
static void s_print_string(char *str, eOmn_info_type_t errortype)
void eoprot_fun_ONSAY_mn(const EOnv *nv, const eOropdescriptor_t *rd)
void eoprot_fun_UPDT_mn_comm_cmmnds_command_replynumof(const EOnv *nv, const eOropdescriptor_t *rd)
static void s_process_category_Default(eOmn_info_basic_t *infobasic, uint8_t *extra, const EOnv *nv, const eOropdescriptor_t *rd)
static void s_eoprot_print_mninfo_status(eOmn_info_basic_t *infobasic, uint8_t *extra, const EOnv *nv, const eOropdescriptor_t *rd)
static void s_get_timeofmessage(eOmn_info_basic_t *infobasic, timeofmessage_t *t)
void eoprot_fun_UPDT_mn_info_status_basic(const EOnv *nv, const eOropdescriptor_t *rd)
static const char * s_get_sourceofmessage(eOmn_info_basic_t *infobasic, uint8_t *address)
void eoprot_fun_UPDT_mn_comm_cmmnds_command_replyarray(const EOnv *nv, const eOropdescriptor_t *rd)
void eoprot_fun_UPDT_mn_service_status_commandresult(const EOnv *nv, const eOropdescriptor_t *rd)
static void s_process_CANPRINT(eOmn_info_basic_t *infobasic, uint8_t *extra, const EOnv *nv, const eOropdescriptor_t *rd)
void eoprot_fun_UPDT_mn_info_status(const EOnv *nv, const eOropdescriptor_t *rd)
static void s_process_category_Config(eOmn_info_basic_t *infobasic, uint8_t *extra, const EOnv *nv, const eOropdescriptor_t *rd)
eObool_t feat_signal_network_onsay(eOipv4addr_t ipv4, eOprotID32_t id32, uint32_t signature)
void feat_PrintFatal(char *string)
eObool_t feat_CANprint(eOipv4addr_t ipv4, eOmn_info_basic_t *infobasic)
void feat_manage_diagnostic(eOmn_info_basic_t *infobasic, uint8_t *extra, const EOnv *nv, const eOropdescriptor_t *rd)
void feat_PrintDebug(char *string)
const char * feat_GetBoardName(eOipv4addr_t ipv4)
void feat_PrintInfo(char *string)
void feat_PrintError(char *string)
eObool_t feat_signal_network_onsig(eOipv4addr_t ipv4, eOprotID32_t id32, uint32_t signature)
void feat_PrintWarning(char *string)