28#include "EoDiagnostics.h" 
   29#include "OPCprotocolManager.h" 
   30#include "OPCprotocolManager_Cfg.h" 
   72static void on_rec_emsperiph(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata);
 
   79static void on_rec_emsapplmc(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata);
 
   82static void on_rec_motorstflags(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata);
 
   83static void on_rec_errorLog(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata);
 
  144    opcprotman_res_t res = opcprotman_OK;
 
  147    res = opcprotman_personalize_var(   
p,
 
  148                                        eodgn_nvidbdoor_cmds,
 
  152    if(opcprotman_OK != res)
 
  157    res = opcprotman_personalize_var(   
p,
 
  158                                        eodgn_nvidbdoor_errorlog,
 
  163    if(opcprotman_OK != res)
 
  168    res = opcprotman_personalize_var(   
p,
 
  169                                        eodgn_nvidbdoor_emsperiph,
 
  174    if(opcprotman_OK != res)
 
  181    res = opcprotman_personalize_var(   
p,
 
  182                                        eodgn_nvidbdoor_emsapplcommon,
 
  187    if(opcprotman_OK != res)
 
  194    res = opcprotman_personalize_var(   
p,
 
  195                                        eodgn_nvidbdoor_emsapplmc,
 
  199    if(opcprotman_OK != res)
 
  206    res = opcprotman_personalize_var(   
p,
 
  207                                        eodgn_nvidbdoor_motorstatus,
 
  212    if(opcprotman_OK != res)
 
  218        res = opcprotman_personalize_var(   
p,
 
  219                                            eodgn_nvidbdoor_canQueueStatistics,
 
  223        if(opcprotman_OK != res)
 
  228        res = opcprotman_personalize_var(   
p,
 
  229                                            eodgn_nvidbdoor_rxcheckSetpoints,
 
  233        if(opcprotman_OK != res)
 
 
  260    printf(
"\t\twarning=%d passive=%d busoff=%d\n", canst_ptr->hw.warning, canst_ptr->hw.passive, canst_ptr->hw.busoff);  
 
  261    printf(
"\t\thw_rx_queue_is_full=%d\n", canst_ptr->hw.rxqueueisfull);
 
  262    printf(
"\t\tsw_rx_queue_is_full=%d sw_tx_queue_is_full=%d dummy=0x%x\n", canst_ptr->sw.rxqueueisfull, canst_ptr->sw.txqueueisfull, canst_ptr->sw.dummy);
 
 
  265static void on_rec_emsperiph(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata)
 
  267    eOdgn_emsperipheralstatus_t* 
data = (eOdgn_emsperipheralstatus_t*)recdata;
 
  275        case opcprotman_opc_set:
 
  280        case opcprotman_opc_say:    
 
  281        case opcprotman_opc_sig:    
 
  284            printf(
"-----EMS periph data---\n");
 
  285            printf(
"\t CAN 1:\n");
 
  287            printf(
"\t CAN 2:\n");
 
  289            printf(
"\t ETH MASK: 0x%x\n", 
data->eth_dev.linksmask);
 
  292                if(((
data->eth_dev.crcErrorCnt_validVal & (1<<i)) == (1<<i)))
 
  295                    if(((
data->eth_dev.crcErrorCnt_overflow & (1<<i)) == (1<<i)))
 
  299                    printf(
"\t CRC_error phy-port %d: %d overflow=%d", i, 
data->eth_dev.crcErrorCnt[i], overflow);
 
  314                    printf(
"\t CRC_error phy-port %d: INVALID VALUE", i);
 
  321                printf(
"\t i2cError %d on phy-port %d", 
data->eth_dev.i2c_error[i], i);
 
 
  335    eOdgn_emsapplication_common_t* 
data = (eOdgn_emsapplication_common_t*)recdata;
 
  341        case opcprotman_opc_set:
 
  346        case opcprotman_opc_say:    
 
  347        case opcprotman_opc_sig:    
 
  350            printf(
"-----EMS appl common---\n");
 
 
  363    printf(
"\tRUNNING ST\n");
 
  364        printf(
"\t\tnumberofperiods=%ld\n ", appcore_ptr->runst.numberofperiods);
 
  365        printf(
"\t\tcumulativeabsoluteerrorinperiod=%ld\n ", appcore_ptr->runst.cumulativeabsoluteerrorinperiod);
 
  366        printf(
"\t\tmeanofabsoluteerrorinperiod=%d\n ", appcore_ptr->runst.meanofabsoluteerrorinperiod);
 
  368        printf(
"\t\tmovingmeanofabsoluteerrorinperiod=%d\n ", appcore_ptr->runst.movingmeanofabsoluteerrorinperiod);
 
  369        printf(
"\t\tmaxabsoluteerrorinperiod=%d\n ", appcore_ptr->runst.maxabsoluteerrorinperiod);
 
  370        printf(
"\t\tminabsoluteerrorinperiod=%d\n ", appcore_ptr->runst.minabsoluteerrorinperiod);
 
  372        printf(
"\t\texecutionoverflows[0]=%d\n ", appcore_ptr->runst.executionoverflows[0]);
 
  373        printf(
"\t\texecutionoverflows[1]=%d\n ", appcore_ptr->runst.executionoverflows[1]);
 
  374        printf(
"\t\texecutionoverflows[2]=%d\n ", appcore_ptr->runst.executionoverflows[2]);
 
  375        printf(
"\t\tdatagrams_failed_to_go_in_txsocket=%d\n ", appcore_ptr->runst.datagrams_failed_to_go_in_txsocket);
 
  376        printf(
"\t\tcantxfailuretimeoutsemaphore=%d\n ", appcore_ptr->runst.cantxfailuretimeoutsemaphore);
 
  378    printf(
"\tCONFIG ST\n");
 
  379        printf(
"\t\tcantxfailuretimeoutsemaphore=%d\n ", appcore_ptr->cfgst.cantxfailuretimeoutsemaphore);
 
 
  383    printf(
"\tIPNET INFO\n");
 
  384        printf(
"\t\tdatagrams_failed_to_go_in_rxfifo=%d\n ", appipnet_ptr->datagrams_failed_to_go_in_rxfifo);
 
  385        printf(
"\t\tdatagrams_failed_to_go_in_txosalqueue=%d\n ", appipnet_ptr->datagrams_failed_to_go_in_txosalqueue);
 
  386        printf(
"\t\tdatagrams_failed_to_be_retrieved_from_txfifo=%d\n ", appipnet_ptr->datagrams_failed_to_be_retrieved_from_txfifo);
 
  387        printf(
"\t\tdatagrams_failed_to_be_sent_by_ipal=%d\n ", appipnet_ptr->datagrams_failed_to_be_sent_by_ipal);
 
 
  392    printf(
"\tTRANSCEIVER INFO\n");
 
  393        printf(
"\t\trxinvalidropframes=%d\n ", apptrans_ptr->rxinvalidropframes);
 
  394        printf(
"\t\trxseqnumwrong=%d\n ", apptrans_ptr->rxseqnumwrong);
 
  395        printf(
"\t\tlostreplies=%d\n ", apptrans_ptr->lostreplies);
 
  396        printf(
"\t\tfailuresinloadofreplyropframe=%d\n ", apptrans_ptr->failuresinloadofreplyropframe);
 
  397        printf(
"\t\ttxropframeistoobigforthepacket=%d\n ", apptrans_ptr->txropframeistoobigforthepacket);
 
  398        printf(
"\t\tcannotloadropinregulars=%d\n ", apptrans_ptr->cannotloadropinregulars);
 
  399        printf(
"\t\tcannotloadropinoccasionals=%d\n ", apptrans_ptr->cannotloadropinoccasionals);
 
 
  405static void on_rec_emsapplmc(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata)
 
  408    eOdgn_emsapplication_emswithmc_t* 
data = (eOdgn_emsapplication_emswithmc_t*)recdata;
 
  414        case opcprotman_opc_set:
 
  419        case opcprotman_opc_say:    
 
  420        case opcprotman_opc_sig:    
 
  423            printf(
"-----EMS appl mc---\n");
 
  436            if(memcmp(&
data->encreads.encList[0], &
s_emswithmc_data.encreads.encList[0], eOdgn_emsmaxnumofencoders*
sizeof(eOappEncReader_error_t)) != 0)
 
 
  454        printf(
"Encoder num %d\t", i);
 
  455        printf(
"\t err_onReadFromSpi=%d   ", encreads->encList[i].err_onReadFromSpi);  
 
  456        printf(
"err_onParityError=%d  ", encreads->encList[i].err_onParityError);  
 
  457        printf(
"err_onInvalidValue=%d  \n", encreads->encList[i].err_onInvalidValue);
 
  459    printf(
"\tcount=%d\n", encreads->count);
 
 
  464    eOdgn_motorstatusflags_t* 
data = (eOdgn_motorstatusflags_t*)recdata;
 
  472        case opcprotman_opc_set:
 
  477        case opcprotman_opc_say:    
 
  478        case opcprotman_opc_sig:    
 
  481            printf(
"-----motor status flag---\n");
 
  485                if(
data->motorlist[i] != 0)
 
  487                    sprintf(stroutput, 
"motor %d with err flags=0x%x: ", i, 
data->motorlist[i]);
 
  488                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_UNDERVOLTAGE) == DGN_MOTOR_FAULT_UNDERVOLTAGE)
 
  489                        strcat(stroutput, 
"UNDERVOLTAGE, ");
 
  490                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_OVERVOLTAGE) == DGN_MOTOR_FAULT_OVERVOLTAGE)
 
  491                        strcat(stroutput, 
"OVERVOLTAGE, ");
 
  492                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_EXTERNAL) == DGN_MOTOR_FAULT_EXTERNAL)
 
  493                        strcat(stroutput, 
"EXTERNAL, ");
 
  494                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_OVERCURRENT) == DGN_MOTOR_FAULT_OVERCURRENT)
 
  495                        strcat(stroutput, 
"OVERCURRENT, ");
 
  496                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_I2TFAILURE) == DGN_MOTOR_FAULT_I2TFAILURE)
 
  497                        strcat(stroutput, 
"I2TFAILURE, ");
 
  498                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_CANRECWARNING) == DGN_MOTOR_FAULT_CANRECWARNING)
 
  499                        strcat(stroutput, 
"CANRECWARNING, ");
 
  500                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_CANRECERROR) == DGN_MOTOR_FAULT_CANRECERROR)
 
  501                        strcat(stroutput, 
"CANRECERROR, ");
 
  502                    if((
data->motorlist[i] & DGN_MOTOR_FAULT_CANRECHWOVERRUN) == DGN_MOTOR_FAULT_CANRECHWOVERRUN)
 
  503                        strcat(stroutput, 
"CANRECHWOVERRUN ");
 
  504                    printf(
"%s\n", stroutput);
 
 
  516static void on_rec_errorLog(opcprotman_opc_t opc, opcprotman_var_map_t* map, 
void* recdata)
 
  518    eOdgn_errorlog_t *
data = (eOdgn_errorlog_t *)recdata;
 
  520    printf(
"----- switch to error state because... \n");
 
  521    printf(
"\t%s\n", 
data->errorstate_str);
 
 
  526    eOdgn_can_statistics_t* 
data = (eOdgn_can_statistics_t*)recdata;
 
  533        case opcprotman_opc_set:
 
  538        case opcprotman_opc_say:    
 
  539        case opcprotman_opc_sig:    
 
  542            printf(
"-----can queue statistics ---\n");
 
  544            printf(
"Config_mode: ");
 
  547                printf(
"\t port %d ==> rx.min=%d, rx.max=%d, tx.min=%d, tx.max=%d\n\t",i, 
data->config_mode.stat[i].info_rx.min, 
data->config_mode.stat[i].info_rx.max,
 
  548                                                                                        data->config_mode.stat[i].info_tx.min, 
data->config_mode.stat[i].info_tx.max);
 
  550            printf(
"\nRun_mode: ");
 
  553                printf(
"\t port %d ==> rx.min=%d, rx.max=%d, tx.min=%d, tx.max=%d\n\t",i, 
data->run_mode.stat[i].info_rx.min, 
data->run_mode.stat[i].info_rx.max,
 
  554                                                                                        data->run_mode.stat[i].info_tx.min, 
data->run_mode.stat[i].info_tx.max);
 
 
  601    eOdgn_rxCheckSetpoints_t* 
data = (eOdgn_rxCheckSetpoints_t*)recdata;
 
  614        case opcprotman_opc_set:
 
  619        case opcprotman_opc_say:    
 
  620        case opcprotman_opc_sig:    
 
  623            printf(
"\n\n-----rx check setpoints---\n");
 
  628                printf(
"\tj %d: pos-deltaprognum =", i );
 
  629                if(
data->position[i].deltaprognumber == INT32_MAX)
 
  635                    printf(
" %d ", 
data->position[i].deltaprognumber);
 
  638                printf(
"    pos-deltarxtime =");
 
  639                if(
data->position[i].deltarxtime == UINT32_MAX)
 
  645                    printf(
" %d ", 
data->position[i].deltarxtime);
 
  648                    printf(
"    imp-deltaprognum =");
 
  650                if(
data->impedence[i].deltaprognumber == INT32_MAX)
 
  656                    printf(
" %d ", 
data->impedence[i].deltaprognumber);
 
  660                printf(
"    imp-deltarxtime=");
 
  662                if(
data->impedence[i].deltarxtime == UINT32_MAX)
 
  668                    printf(
" %d \n", 
data->impedence[i].deltarxtime);
 
 
opcprotman_res_t opcprotman_personalize_database(OPCprotocolManager *p)
 
static void on_rec_emsapplcommon(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void on_rec_emsperiph(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void on_rec_rxcheckSetpoints(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static eOdgn_emsapplication_emswithmc_t s_emswithmc_data
 
static void on_rec_canQueueStatistics(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void on_rec_emsapplmc(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void on_rec_errorLog(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void on_rec_motorstflags(opcprotman_opc_t opc, opcprotman_var_map_t *map, void *recdata)
 
static void s_print_emsapplcomm_ipnet(eOdgn_ipnet_t *appipnet_ptr)
 
eOdgn_commands_t dgnCommands
 
static void s_print_emsperiph_candata(eOdgn_canstatus_t *canst_ptr)
 
static ethCounters_total ethCounterBoards[9][3]
 
static void s_print_emsapplmc_encoderserror(eOdgn_encoderreads_t *encreads)
 
static void s_print_emsapplcomm_core(eOdgn_coreapplication_t *appcore_ptr)
 
uint32_t cmdena_rxsetPointCheck
 
static void s_print_emsapplcomm_transceiver(eOdgn_embObjtransceiver_t *apptrans_ptr)