static char *ConvSJIStoEUCkanaProc(CODECONVINFO *cInfo, char Dt, char *Put) { int Kcode; int Daku; if(cInfo->KanaCnv == NO) { if(Dt != 0) { Kcode = 0x8E00 + (uchar)Dt; *Put++ = HIGH8(Kcode) | 0x80; *Put++ = LOW8(Kcode) | 0x80; } } else { if(cInfo->KanaPrev != 0) { Daku = AskDakuon(cInfo->KanaPrev, Dt); Kcode = HanKataToZen(cInfo->KanaPrev) + Daku; *Put++ = HIGH8(Kcode) | 0x80; *Put++ = LOW8(Kcode) | 0x80; if(Daku == 0) cInfo->KanaPrev = Dt; else cInfo->KanaPrev = 0; } else cInfo->KanaPrev = Dt; } return(Put); }
void timer_hw_init(void) { outb(PIT_CONTROL, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); outb(PIT_CHANNEL0, LOW8(LATCH)); outb(PIT_CHANNEL0, HIGH8(LATCH)); }
static char *ConvJIStoSJISkanaProc(CODECONVINFO *cInfo, char Dt, char *Put) { int Kcode; int Daku; Dt = (uchar)Dt + (uchar)0x80; if(cInfo->KanaCnv == NO) { if((uchar)Dt != (uchar)0x80) *Put++ = Dt; } else { if(cInfo->KanaPrev != 0) { Daku = AskDakuon(cInfo->KanaPrev, Dt); Kcode = _mbcjistojms(HanKataToZen(cInfo->KanaPrev)) + Daku; *Put++ = HIGH8(Kcode); *Put++ = LOW8(Kcode); if((Daku == 0) && ((uchar)Dt != (uchar)0x80)) cInfo->KanaPrev = Dt; else cInfo->KanaPrev = 0; } else if((uchar)Dt != (uchar)0x80) cInfo->KanaPrev = Dt; } return(Put); }
static char *ConvSJIStoJISkanaProc(CODECONVINFO *cInfo, char Dt, char *Put) { int Kcode; int Daku; if(cInfo->KanaCnv == NO) { if(Dt != 0) { if(cInfo->KanjiMode != CONV_KANA) { *Put++ = 0x1B; *Put++ = '('; *Put++ = 'I'; cInfo->KanjiMode = CONV_KANA; } *Put++ = (uchar)Dt - (uchar)0x80; } } else { if(cInfo->KanaPrev != 0) { if(cInfo->KanjiMode != CONV_KANJI) { *Put++ = 0x1B; *Put++ = '$'; *Put++ = 'B'; cInfo->KanjiMode = CONV_KANJI; } Daku = AskDakuon(cInfo->KanaPrev, Dt); Kcode = HanKataToZen(cInfo->KanaPrev) + Daku; *Put++ = HIGH8(Kcode); *Put++ = LOW8(Kcode); if(Daku == 0) cInfo->KanaPrev = Dt; else cInfo->KanaPrev = 0; } else cInfo->KanaPrev = Dt; } return(Put); }
/** * @brief This function returns a description of every available errors of the assigned unit. * * @param w_errorCode error number * * @param dw_addInfo additional error information * * @retval pac_str empty buffer to build the error string */ void SNMTS_GetErrorStr(UINT16 w_errorCode, UINT32 dw_addInfo, CHAR *pac_str) { UINT16 w_expErr; UINT16 w_recErr; /* choose the matching error string */ switch(w_errorCode) { /** SNMTSmain.c **/ case SNMTS_k_ERR_TIMER_CHK_INST_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_TIMER_CHK_INST_INV: SNMTS_TimerCheck():\n" "The provided instance number (%02lu) is bigger than the " "maximum value.\n", SNMTS_k_ERR_TIMER_CHK_INST_INV, dw_addInfo); break; } case SNMTS_k_ERR_REF_MNGT_FRMS_TC_INV: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_REF_MNGT_FRMS_TC_INV: SNMTS_TimerCheck():\n" "NULL pointer passed instead of reference to " "<number of free management frames>.\n", SNMTS_k_ERR_REF_MNGT_FRMS_TC_INV); break; } case SNMTS_k_ERR_NO_MNGT_FRMS_AVAIL: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_NO_MNGT_FRMS_AVAIL: SNMTS_TimerCheck():\n" "NO management frames available to build and transmit.\n", SNMTS_k_ERR_NO_MNGT_FRMS_AVAIL); break; } case SNMTS_k_ERR_PASS_PARAM_INST_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_PASS_PARAM_INST_INV: SNMTS_PassParamChkSumValid():\n" "The provided instance number (%02lu) is bigger than the " "maximum value.\n", SNMTS_k_ERR_PASS_PARAM_INST_INV, dw_addInfo); break; } case SNMTS_k_ERR_ENTER_OP_INST_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_ENTER_OP_INST_INV: SNMTS_EnterOpState():\n" "The provided instance number (%02lu) is bigger than the " "maximum value.\n", SNMTS_k_ERR_ENTER_OP_INST_INV, dw_addInfo); break; } case SNMTS_k_ERR_ERR_GRP_INV: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_ERR_GRP_INV: SNMTS_EnterOpState():\n" "Error group 4 was passed by the application." "(Reserved for EPLS Stack internal errors).\n", SNMTS_k_ERR_ERR_GRP_INV); break; } case SNMTS_k_ERR_PERF_TRANS_PREOP_INST_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_PERF_TRANS_PREOP_INST_INV: " "SNMTS_PerformTransPreOp():\n" "The provided instance number (%02lu) is bigger than the " "maximum value.\n", SNMTS_k_ERR_PERF_TRANS_PREOP_INST_INV, dw_addInfo); break; } /** SNMTSprocess.c **/ case SNMTS_k_ERR_LE_UDID_REQ_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_UDID_REQ_INV: processRequest():\n" "The value in LE field (%02lu) of the received Service " "<UDID Request> is NOT valid.\n", SNMTS_k_ERR_LE_UDID_REQ_INV, dw_addInfo); break; } case SNMTS_k_ERR_EXT_REQ_LEN: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EXT_REQ_LEN: processRequest():\n" "Payload length of the extended SNMT service request is 0.\n", SNMTS_k_ERR_EXT_REQ_LEN); break; } case SNMTS_k_ERR_RX_FRMID_REQ_PROC_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_RX_FRMID_REQ_PROC_INV: processRequest():\n" "The frame ID (%02lu) of the received SNMT Service is NOT defined.\n", SNMTS_k_ERR_RX_FRMID_REQ_PROC_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_SET_TO_PREOP_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_SET_TO_PREOP_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<SN set to PRE-OP> is NOT valid.\n", SNMTS_k_ERR_LE_SET_TO_PREOP_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_SET_TO_OP_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_SET_TO_OP_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<SN set to OP> is NOT valid.\n", SNMTS_k_ERR_LE_SET_TO_OP_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_SCM_SET_TO_STOP_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_SCM_SET_TO_STOP_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<SCM set to STOP> is NOT valid.\n", SNMTS_k_ERR_LE_SCM_SET_TO_STOP_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_SCM_SET_TO_OP_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_SCM_SET_TO_OP_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<SCM set to OP> is NOT valid.\n", SNMTS_k_ERR_LE_SCM_SET_TO_OP_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_GUARD_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_GUARD_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<Node Guarding> is NOT valid.\n", SNMTS_k_ERR_LE_GUARD_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_ADD_SADR_ASS_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_ADD_SADR_ASS_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<Add. SADR Assignment> is NOT valid.\n", SNMTS_k_ERR_LE_ADD_SADR_ASS_INV, dw_addInfo); break; } case SNMTS_k_ERR_ADD_SADR_NOT_SUPPO: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_ADD_SADR_NOT_SUPPO: processRequestExt():\n" "It is only one transmit SPDO configurable. Assignment of the " "additional SADR can not be accomplished\n", SNMTS_k_ERR_ADD_SADR_NOT_SUPPO); break; } case SNMTS_k_ERR_LE_ERR_ACK_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_ERR_ACK_INV: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<Error Acknowledge> is NOT valid.\n", SNMTS_k_ERR_LE_ERR_ACK_INV, dw_addInfo); break; } case SNMTS_k_ERR_LE_UDID_SCM: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_UDID_SCM: processRequestExt():\n" "The value in LE field (%02lu) of the received Service " "<UDID of SCM assignment> is NOT valid.\n", SNMTS_k_ERR_LE_UDID_SCM, dw_addInfo); break; } case SNMTS_k_ERR_REQ_EXT_FRMTYP_INV1: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_REQ_EXT_FRMTYP_INV1: processRequest():\n" "The extended service type (%02lu) of the received SNMT Service " "is NOT defined.\n", SNMTS_k_ERR_REQ_EXT_FRMTYP_INV1, dw_addInfo); break; } case SNMTS_k_ERR_CT_FIELD_NOT_UNUSED: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_CT_FIELD_NOT_UNUSED: checkRequest():\n" "The value in CT field (%04lu) of the received frame is NOT zero.\n", SNMTS_k_ERR_CT_FIELD_NOT_UNUSED, dw_addInfo); break; } case SNMTS_k_ERR_TR_FIELD_NOT_UNUSED: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_TR_FIELD_NOT_UNUSED: checkRequest():\n" "The value in TR field (%02lu) of the received frame is NOT zero.\n", SNMTS_k_ERR_TR_FIELD_NOT_UNUSED, dw_addInfo); break; } case SNMTS_k_ERR_REQ_REJ_INV_DSADR: { SPRINTF3(pac_str, "%#x - SNMTS_k_ERR_REQ_REJ_INV_DSADR: " "filterServReq():\n" "The received SNMT Service was rejected by SNMTS filter - " "target address: %#x " "safety domain number: %#x\n", SNMTS_k_ERR_REQ_REJ_INV_DSADR, HIGH16(dw_addInfo),(UINT16)dw_addInfo); break; } case SNMTS_k_ERR_LE_SADR_ASS_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_LE_SADR_ASS_INV: checkRxUdid():\n" "The value in LE field (%02lu) of the received Service " "<SADR Assignment> is NOT valid.\n", SNMTS_k_ERR_LE_SADR_ASS_INV, dw_addInfo); break; } case SNMTS_k_ERR_RX_UDID_UNEVEN: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_RX_UDID_UNEVEN: checkRxUdid():\n" "Received UDID is NOT equal to the UDID of this SN.\n", SNMTS_k_ERR_RX_UDID_UNEVEN); break; } /** SNMTSsnstate.c **/ case SNMTS_k_ERR_GET_SN_STATE_INST_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_GET_SN_STATE_INST_INV: SNMTS_GetSnState():\n" "The provided instance number (%02lu) is bigger than the " "maximum value.\n", SNMTS_k_ERR_GET_SN_STATE_INST_INV, dw_addInfo); break; } case SNMTS_k_ERR_PTR_INV: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_PTR_INV: SNMTS_GetSnState():\n" "The provided state pointer is NULL.\n", SNMTS_k_ERR_PTR_INV); break; } case SNMTS_k_ERR_SN_STATE_MAIN_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_SN_STATE_MAIN_INV: SNMTS_SnStateFsm():\n" "Undefined FSM state (%02lu) occurred.\n", SNMTS_k_ERR_SN_STATE_MAIN_INV, dw_addInfo); break; } case SNMTS_k_ERR_EVENT_UNDEF1: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF1: InitializationState():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF1, dw_addInfo); break; } case SNMTS_k_ERR_EVENT1: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT1: WfSadrAssStep1State():\n" "k_EVT_RX_SET_TO_OP event is unexpected.\n", SNMTS_k_ERR_EVENT1); break; } case SNMTS_k_ERR_EVENT15: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT15: WfSadrAssStep1State():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT15); break; } case SNMTS_k_ERR_EVENT2: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT2: WfSadrAssStep1State():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT2); break; } case SNMTS_k_ERR_EVENT14: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT14: WfSadrAssStep1State():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT14); break; } case SNMTS_k_ERR_EVENT13: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT13: WfSadrAssStep1State():\n" "k_EVT_SN_ACK event is unexpected.\n", SNMTS_k_ERR_EVENT13); break; } case SNMTS_k_ERR_EVENT_UNDEF2: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF2: WfSadrAssStep1State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF2, dw_addInfo); break; } case SNMTS_k_ERR_EVENT_UNDEF3: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF3: WfSadrAssStep2State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF3, dw_addInfo); break; } case SNMTS_k_ERR_EVENT16: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT16: WfUdidScmAssState():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT16); break; } case SNMTS_k_ERR_EVENT17: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT17: WfUdidScmAssState():\n" "k_EVT_SN_ACK event is unexpected.\n", SNMTS_k_ERR_EVENT17); break; } case SNMTS_k_ERR_EVENT18: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT18: WfUdidScmAssState():\n" "k_EVT_RX_SET_TO_OP event is unexpected.\n", SNMTS_k_ERR_EVENT18); break; } case SNMTS_k_ERR_EVENT19: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT19: WfUdidScmAssState():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT19); break; } case SNMTS_k_ERR_EVENT_UNDEF12: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF12: WfUdidScmAssState():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF12, dw_addInfo); break; } case SNMTS_k_ERR_EVENT20: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT20: WfSetToOp1Step1State():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT20); break; } case SNMTS_k_ERR_EVENT_UNDEF4: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF4: WfSetToOp1Step1State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF4, dw_addInfo); break; } case SNMTS_k_ERR_EVENT27: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT27: WfSetToOp1Step2State():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT27); break; } case SNMTS_k_ERR_EVENT21: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT21: WfSetToOp1Step2State():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT21); break; } case SNMTS_k_ERR_EVENT_UNDEF5: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF5: WfSetToOp1Step2State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF5, dw_addInfo); break; } case SNMTS_k_ERR_EVENT3: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT3: WfApiChksumState():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT3); break; } case SNMTS_k_ERR_EVENT9: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT9: WfApiChksumState():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT9); break; } case SNMTS_k_ERR_EVENT22: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT22: WfApiChksumState():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT22); break; } case SNMTS_k_ERR_EVENT_UNDEF6: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF6: WfApiChksumState():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF6, dw_addInfo); break; } case SNMTS_k_ERR_EVENT4: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT4: WfSetToOp2State():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT4); break; } case SNMTS_k_ERR_EVENT10: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT10: WfSetToOp2State():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT10); break; } case SNMTS_k_ERR_EVENT23: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT23: WfSetToOp2State():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT23); break; } case SNMTS_k_ERR_EVENT_UNDEF7: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF7: WfSetToOp2State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF7, dw_addInfo); break; } case SNMTS_k_ERR_EVENT5: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT5: WfApiConfState():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT5); break; } case SNMTS_k_ERR_EVENT11: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT11: WfApiConfState():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT11); break; } case SNMTS_k_ERR_EVENT24: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT24: WfApiConfState():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT24); break; } case SNMTS_k_ERR_EVENT_UNDEF8: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF8: WfApiConfState():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF8, dw_addInfo); break; } case SNMTS_k_ERR_EVENT6: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT6: WfSetToOp3State():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT6); break; } case SNMTS_k_ERR_EVENT12: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT12: WfSetToOp3State():\n" "k_EVT_RX_SET_TO_PREOP event is unexpected.\n", SNMTS_k_ERR_EVENT12); break; } case SNMTS_k_ERR_EVENT25: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT25: WfSetToOp3State():\n" "k_EVT_RX_UDID_SCM event is unexpected.\n", SNMTS_k_ERR_EVENT25); break; } case SNMTS_k_ERR_EVENT_UNDEF9: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF9: WfSetToOp3State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF9, dw_addInfo); break; } case SNMTS_k_ERR_EVENT7: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT7: OperationStep1State():\n" "k_EVT_RX_SADR_ADD event is unexpected.\n", SNMTS_k_ERR_EVENT7); break; } case SNMTS_k_ERR_EVENT8: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_EVENT8: OperationStep1State():\n" "k_EVT_SN_ACK event is unexpected.\n", SNMTS_k_ERR_EVENT8); break; } case SNMTS_k_ERR_EVENT_UNDEF10: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF10: OperationStep1State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF10, dw_addInfo); break; } case SNMTS_k_ERR_EVENT_UNDEF11: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_EVENT_UNDEF11: OperationStep2State():\n" "Unexpected FSM event (%02lu) occurred.\n", SNMTS_k_ERR_EVENT_UNDEF11, dw_addInfo); break; } case SNMTS_k_ERR_RX_TX_BUFF_NULL: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_RX_TX_BUFF_NULL: checkParam():\n" "The rx and the tx buffer pointer must not be NULL with " "the (%02lu) calling event.\n", SNMTS_k_ERR_RX_TX_BUFF_NULL, dw_addInfo); break; } case SNMTS_k_ERR_TXSPDO_NUM_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_TXSPDO_NUM_INV: enterAddSadr():\n" "The received SPDO number (%02lu) is NOT in valid range.\n", SNMTS_k_ERR_TXSPDO_NUM_INV, dw_addInfo); break; } case SNMTS_k_ERR_SPDO_NUM: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_SPDO_NUM: enterAddSadr():\n" "No SOD index can be found for the SPDO number (%02lu).\n", SNMTS_k_ERR_SPDO_NUM, dw_addInfo); break; } /** SNMTSappInfo.c **/ case SNMTS_k_ERR_PARAM_CHKSUM_INV: { SPRINTF3(pac_str, "%#x - SNMTS_k_ERR_PARAM_CHKSUM_INV: SNMTS_AppChkSumComp():\n" "The received checksum (%04u) is NOT equal to calculated " "checksum (%04u).\n", SNMTS_k_ERR_PARAM_CHKSUM_INV, HIGH16(dw_addInfo), LOW16(dw_addInfo)); break; } case SNMTS_k_ERR_PARAM_TIMESTAMP_INV: { SPRINTF2(pac_str, "%#x - SNMTS_k_ERR_PARAM_TIMESTAMP_INV: SNMTS_AppChkSumComp():\n" "The received parameter timestamp (%08lu) is wrong.\n", SNMTS_k_ERR_PARAM_TIMESTAMP_INV, dw_addInfo); break; } /** SNMTSlifetime.c **/ case SNMTS_k_ERR_LIFE_TIME_ELAPSED: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_LIFE_TIME_ELAPSED: SNMTS_LifeTimeCheck():\n" "The lifetime elapsed.\n", SNMTS_k_ERR_LIFE_TIME_ELAPSED); break; } case SNMTS_k_ERR_TIMER: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_TIMER: SNMTS_LifeTimeCheck():\n" "The guard timer was not started but checked.\n", SNMTS_k_ERR_TIMER); break; } /** SNMTSrefresh.c **/ case SNMTS_k_ERR_REFR_TIME_ELAPSED: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_REFR_TIME_ELAPSED: SNMTS_RefreshTimeCheck():\n" "The refresh time elapsed.\n", SNMTS_k_ERR_REFR_TIME_ELAPSED); break; } /** SNMTSresponse.c **/ case SNMTS_k_ERR_SN_ACK1: { w_expErr = HIGH16(dw_addInfo); w_recErr = LOW16(dw_addInfo); SPRINTF5(pac_str, "%#x - SNMTS_k_ERR_SN_ACK1: SNMTS_SnAckRespCheck():\n" "Unexpected error group and/or error code were received. " "Exp. error group : (%02u) error code : (%02u) " "Rec. error group : (%02u) error code : (%02u)\n", SNMTS_k_ERR_SN_ACK1, HIGH8(w_expErr), LOW8(w_expErr), HIGH8(w_recErr), LOW8(w_recErr)); break; } case SNMTS_k_ERR_SN_ACK2: { SPRINTF1(pac_str, "%#x - SNMTS_k_ERR_SN_ACK2: SNMTS_SnAckRespCheck():\n" "Unexpected SN ack received (no SN FAIL was sent).\n", SNMTS_k_ERR_SN_ACK2); break; } default: { SPRINTF(pac_str, "Unknown error code was generated by the SNMTS\n"); } } SCFM_TACK_PATH(); return; /* RSM_IGNORE_QUALITY_BEGIN Notice #28 - Cyclomatic complexity > 15 Notice #18 - Function eLOC > maximum 200 eLOC Notice #17 - Function comment content less than 10.0% */ }
int ConvSJIStoJIS(CODECONVINFO *cInfo) { int Kcode; char *Str; char *Put; char *Limit; int Continue; cInfo->KanaProc = &ConvSJIStoJISkanaProc; Continue = NO; Str = cInfo->Str; Put = cInfo->Buf; Limit = cInfo->Buf + cInfo->BufSize - 5; for(; cInfo->StrLen > 0; cInfo->StrLen--) { if(Put >= Limit) { Continue = YES; break; } if(cInfo->KanjiFst == 0) { if((((uchar)*Str >= (uchar)0x81) && ((uchar)*Str <= (uchar)0x9F)) || ((uchar)*Str >= (uchar)0xE0)) { Put = ConvSJIStoJISkanaProc(cInfo, 0, Put); cInfo->KanjiFst = *Str++; } else if(((uchar)*Str >= (uchar)0xA0) && ((uchar)*Str <= (uchar)0xDF)) { Put = ConvSJIStoJISkanaProc(cInfo, *Str++, Put); } else { Put = ConvSJIStoJISkanaProc(cInfo, 0, Put); if(cInfo->KanjiMode != CONV_ASCII) { *Put++ = 0x1B; *Put++ = '('; *Put++ = 'B'; cInfo->KanjiMode = CONV_ASCII; } *Put++ = *Str++; } } else { Put = ConvSJIStoJISkanaProc(cInfo, 0, Put); if((uchar)*Str >= (uchar)0x40) { if(cInfo->KanjiMode != CONV_KANJI) { *Put++ = 0x1B; *Put++ = '$'; *Put++ = 'B'; cInfo->KanjiMode = CONV_KANJI; } Kcode = ConvertIBMExtendedChar(((uchar)cInfo->KanjiFst * 0x100) + (uchar)*Str++); Kcode = _mbcjmstojis(Kcode); *Put++ = HIGH8(Kcode); *Put++ = LOW8(Kcode); } else { if(cInfo->KanjiMode != CONV_ASCII) { *Put++ = 0x1B; *Put++ = '('; *Put++ = 'B'; cInfo->KanjiMode = CONV_ASCII; } *Put++ = cInfo->KanjiFst; *Put++ = *Str++; } cInfo->KanjiFst = 0; } } cInfo->Str = Str; cInfo->OutLen = Put - cInfo->Buf; return(Continue); }
int ConvJIStoSJIS(CODECONVINFO *cInfo) { int Kcode; char *Str; char *Put; char *Limit; int Continue; cInfo->KanaProc = &ConvJIStoSJISkanaProc; Continue = NO; Str = cInfo->Str; Put = cInfo->Buf; Limit = cInfo->Buf + cInfo->BufSize - 3; for(; cInfo->StrLen > 0; cInfo->StrLen--) { if(Put >= Limit) { Continue = YES; break; } if(cInfo->EscProc == 0) { if(*Str == 0x1B) { if(cInfo->KanjiFst != 0) { *Put++ = cInfo->KanjiFst; cInfo->KanjiFst = 0; } Put = ConvJIStoSJISkanaProc(cInfo, 0, Put); cInfo->EscCode[cInfo->EscProc] = *Str++; cInfo->EscProc++; } else { if(cInfo->KanjiMode == CONV_KANA) { if(cInfo->KanjiFst != 0) { *Put++ = cInfo->KanjiFst; cInfo->KanjiFst = 0; } if((*Str >= 0x21) && (*Str <= 0x5F)) { Put = ConvJIStoSJISkanaProc(cInfo, *Str++, Put); } else { Put = ConvJIStoSJISkanaProc(cInfo, 0, Put); *Put++ = *Str++; } } else if(cInfo->KanjiMode == CONV_KANJI) { Put = ConvJIStoSJISkanaProc(cInfo, 0, Put); if((*Str >= 0x21) && (*Str <= 0x7E)) { if(cInfo->KanjiFst == 0) cInfo->KanjiFst = *Str++; else { Kcode = _mbcjistojms((cInfo->KanjiFst * 0x100) + *Str++); *Put++ = HIGH8(Kcode); *Put++ = LOW8(Kcode); cInfo->KanjiFst = 0; } } else { if(cInfo->KanjiFst == 0) *Put++ = *Str++; else { *Put++ = cInfo->KanjiFst; *Put++ = *Str++; cInfo->KanjiFst = 0; } } } else { Put = ConvJIStoSJISkanaProc(cInfo, 0, Put); *Put++ = *Str++; } } } else if(cInfo->EscProc == 1) { if((*Str == '$') || (*Str == '(')) { cInfo->EscCode[cInfo->EscProc] = *Str++; cInfo->EscProc++; } else { *Put++ = cInfo->EscCode[0]; *Put++ = *Str++; cInfo->EscProc = 0; } } else if(cInfo->EscProc == 2) { if((cInfo->EscCode[1] == '$') && ((*Str == 'B') || (*Str == '@'))) cInfo->KanjiMode = CONV_KANJI; else if((cInfo->EscCode[1] == '(') && (*Str == 'I')) cInfo->KanjiMode = CONV_KANA; else if((cInfo->EscCode[1] == '(') && ((*Str == 'B') || (*Str == 'J') || (*Str == 'H'))) cInfo->KanjiMode = CONV_ASCII; else { *Put++ = cInfo->EscCode[0]; *Put++ = cInfo->EscCode[1]; if((cInfo->KanjiMode == CONV_KANJI) && ((*Str >= 0x21) && (*Str <= 0x7E))) cInfo->KanjiFst = *Str; else *Put++ = *Str; } Str++; cInfo->EscProc = 0; } } cInfo->Str = Str; cInfo->OutLen = Put - cInfo->Buf; return(Continue); }
int ConvEUCtoSJIS(CODECONVINFO *cInfo) { int Kcode; char *Str; char *Put; char *Limit; int Continue; cInfo->KanaProc = &ConvEUCtoSJISkanaProc; Continue = NO; Str = cInfo->Str; Put = cInfo->Buf; Limit = cInfo->Buf + cInfo->BufSize - 2; for(; cInfo->StrLen > 0; cInfo->StrLen--) { if(Put >= Limit) { Continue = YES; break; } if((*Str & 0x80) != 0) { if(cInfo->KanjiFst == 0) cInfo->KanjiFst = *Str++; else { if((uchar)cInfo->KanjiFst == (uchar)0x8E) /* 半角カタカナ */ { Put = ConvEUCtoSJISkanaProc(cInfo, *Str++, Put); } else { Put = ConvEUCtoSJISkanaProc(cInfo, 0, Put); Kcode = _mbcjistojms(((cInfo->KanjiFst & 0x7F) * 0x100) + (*Str++ & 0x7F)); *Put++ = HIGH8(Kcode); *Put++ = LOW8(Kcode); } cInfo->KanjiFst = 0; } } else { Put = ConvEUCtoSJISkanaProc(cInfo, 0, Put); if(cInfo->KanjiFst != 0) { *Put++ = cInfo->KanjiFst; cInfo->KanjiFst = 0; } *Put++ = *Str++; } } cInfo->Str = Str; cInfo->OutLen = Put - cInfo->Buf; return(Continue); }
/** * @brief This function builds an openSAFETY frame and provides it to the HNF, which is in charge of transmission. * * The calling function has to request the memory block by using {SFS_GetMemBlock()}. The memory block has * to be of size of the complete openSAFETY frame and data to be transmitted is stored at the place inside the * memory block where payload data of sub frame one is located. The memory block is provided by reference * to this function. The calling function also has to provide the header info by reference. The data structure * must be of type EPLS_t_FRM_HDR and assembles all necessary header info to build the openSAFETY frame. * All frame header info is checked before is is put into the right order and stored into sub frame one and two. * Frame data, already stored in sub frame one, is copied into sub frame two. To pass the openSAFETY frame to the * SHNF and so transmitting it the function SHNF_MarkTxMemBlock() is used. * * @see EPLS_t_FRM_HDR * * @param b_instNum instance number (not checked, called with EPLS_k_SCM_INST_NUM or checked in * SSC_ProcessSNMTSSDOFrame() or SPDO_BuildTxSpdo())) valid range: 0 .. <EPLS_cfg_MAX_INSTANCES> - 1 * * @param ps_hdrInfo reference to header info, stored into an internal data structure (not checked, * only called with reference to struct), valid range: <> NULL * * @param pb_frame reference to an openSAFETY frame (payload data is already stored in sub frame ONE). * Reference is provided by function SFS_GetMemBlock() (not checked, checked in transmitRequest() * or SNMTM_SnErrorAck() or SNMTS_TxRespRstGuardScm() or SendTxSpdo() processStateSer() or * reqBufferSend()), valid range: <> NULL * * @return * - TRUE - openSAFETY frame serialized and passed to the SHNF successfully * - FALSE - error during marking the memory block openSAFETY frame passing failed */ BOOLEAN SFS_FrmSerialize(BYTE_B_INSTNUM_ const EPLS_t_FRM_HDR *ps_hdrInfo, UINT8 *pb_frame) { BOOLEAN o_return = FALSE; /* predefined return value */ UINT8 b_subFrm1Id = 0u; /* variable to build the value of the ID field in sub frame 1 */ UINT8 b_subFrm2Id = 0u; /* variable to build the value of the ID field in sub frame 2 */ UINT8 b_subFrm2Adr = 0u; /* variable to build the value of ADR field */ UINT8 b_subFrm2Tr = 0u; /* variable to build the value of TR field */ UINT8 b_calcCrc1Short = 0u; /* calculated 8 bit CRC, provided by SHNF */ UINT8 b_calcCrc2Short = 0u; /* calculated 8 bit CRC, provided by SHNF */ UINT16 w_calcCrc1Long = 0u; /* calculated 16 bit CRC, provided by SHNF */ UINT16 w_calcCrc2Long = 0u; /* calculated 16 bit CRC, provided by SHNF */ UINT16 w_subFrm1Len = 0u; /* number of bytes of sub frame ONE */ UINT16 w_subFrm2Len = 0u; /* number of bytes of sub frame ONE */ UINT8 *pb_subFrm1Crc = 0u; /* pointer to CRC in sub frame ONE */ UINT8 *pb_subFrm2Crc = 0u; /* pointer to CRC in sub frame TWO */ /* reference to sub frame ONE within received openSAFETY frame NOTE: sub frame ONE and TWO are twisted within the openSAFETY frame in tx dir. !!! */ UINT8 *pb_subFrm1 = (UINT8 *)NULL; /* if the header info provided by the calling function is correct */ if(checkTxFrameHeader(B_INSTNUM_ ps_hdrInfo)) { /* Build 8 bit value of openSAFETY frame ID field in sub frame ONE */ b_subFrm1Id = ps_hdrInfo->b_id; /* 00XX|XXXX */ b_subFrm1Id = (UINT8)(b_subFrm1Id << 2u); /* XXXX|XX00 */ b_subFrm1Id = (UINT8)(b_subFrm1Id | (HIGH8(ps_hdrInfo->w_adr) & k_ADR_MASK_AND)); /* XXXX|XXYY */ /* Build 8 bit value of openSAFETY frame ADR field in sub frame TWO */ b_subFrm2Adr = LOW8(ps_hdrInfo->w_adr); b_subFrm2Adr = (UINT8)(b_subFrm2Adr ^ LOW8(ps_hdrInfo->w_sdn)); /* Build 8 bit value of openSAFETY frame ID field in sub frame TWO, * ID field = 6bit frame ID, ((2bit sadr) XOR (2bit domain number)) * * HIGH8(w_sdn) : SSSS|SSZZ * AND k_ID_MASK_AND : 0000|0011 * -------------------> 0000|00ZZ * XOR b_subFrm1Id : XXXX|XXYY * -------------------> XXXX|XXQQ ( Q = Y xor Z ) */ b_subFrm2Id = (UINT8)(b_subFrm1Id ^ (HIGH8(ps_hdrInfo->w_sdn) & k_SDN_HB_MASK_AND)); /* Build 8 bit value of openSAFETY frame TR field in sub frame TWO */ b_subFrm2Tr = ps_hdrInfo->b_tr; /* 00XX|XXXX */ b_subFrm2Tr = (UINT8)(b_subFrm2Tr << 2u); /* XXXX|XX00 */ b_subFrm2Tr = (UINT8)(b_subFrm2Tr | (HIGH8(ps_hdrInfo->w_tadr) & k_TADR_MASK_AND)); /* XXXX|XXYY */ /* check if payload data is doubled */ if ( k_SERVICE_REQ_FAST == (ps_hdrInfo->b_id & k_SERVICE_REQ_FAST)) { /* no double payload data */ /* if payload data length is larger than 8 bytes, 2 byte CRC is used */ if(ps_hdrInfo->b_le > k_MAX_DATA_LEN_SHORT) { /* calculate reference to start of sub frame ONE header (2 byte CRC) NOTE: sub frame ONE and TWO are twisted within the openSAFETY frame in tx dir. !!! */ pb_subFrm1 = &pb_frame[(k_SFRM2_HDR_LEN + k_CRC_LEN_LONG)]; } else /* payload data length is 8 byte or less and 1 byte CRC is used */ { /* calculate reference to start of sub frame ONE header (1 byte CRC) NOTE: sub frame ONE and TWO are twisted within the openSAFETY frame in tx dir. !!! */ pb_subFrm1 = &pb_frame[(k_SFRM2_HDR_LEN + k_CRC_LEN_SHORT)]; } /* calculate length of sub frames and calculate reference to CRC field of sub frames TWO and sub frame ONE */ w_subFrm1Len = (UINT16)(k_SFRM1_HDR_LEN + ps_hdrInfo->b_le); w_subFrm2Len = (UINT16)(k_SFRM2_HDR_LEN); pb_subFrm1Crc = &pb_subFrm1[k_SFRM1_DATA + ps_hdrInfo->b_le]; pb_subFrm2Crc = &pb_frame[k_SFRM2_DATA]; } else { /* if payload data length is larger than 8 bytes, 2 byte CRC is used */ if(ps_hdrInfo->b_le > k_MAX_DATA_LEN_SHORT) { /* calculate reference to start of sub frame ONE header (2 byte CRC) NOTE: sub frame ONE and TWO are twisted within the openSAFETY frame in tx dir. !!! */ pb_subFrm1 = &pb_frame[(k_SFRM2_HDR_LEN + ps_hdrInfo->b_le + k_CRC_LEN_LONG)]; } else /* payload data length is 8 byte or less and 1 byte CRC is used */ { /* calculate reference to start of sub frame ONE header (1 byte CRC) NOTE: sub frame ONE and TWO are twisted within the openSAFETY frame in tx dir. !!! */ pb_subFrm1 = &pb_frame[(k_SFRM2_HDR_LEN + ps_hdrInfo->b_le + k_CRC_LEN_SHORT)]; } /* calculate length of sub frames and calculate reference to CRC field of sub frames TWO and sub frame ONE */ w_subFrm1Len = (UINT16)(k_SFRM1_HDR_LEN + ps_hdrInfo->b_le); w_subFrm2Len = (UINT16)(k_SFRM2_HDR_LEN + ps_hdrInfo->b_le); pb_subFrm1Crc = &pb_subFrm1[k_SFRM1_DATA + ps_hdrInfo->b_le]; pb_subFrm2Crc = &pb_frame[k_SFRM2_DATA + ps_hdrInfo->b_le]; } /* copy payload data from sub frame TWO into sub frame ONE */ /*lint -save -e119 -e746 -i830: the prototype is not really missing but there is a problem with the * standard lib*/ (void)MEMMOVE(&pb_subFrm1[k_SFRM1_DATA], &pb_frame[k_SFRM2_DATA], (UINT32)ps_hdrInfo->b_le); /*lint -restore */ /* fill header bytes and data bytes of sub frame ONE into the memory block of serialized openSAFETY frame. */ SFS_NET_CPY8(&(pb_subFrm1[k_SFRM1_HDR_ADR]),&LOW8(ps_hdrInfo->w_adr)); SFS_NET_CPY8(&(pb_subFrm1[k_SFRM1_HDR_ID]), &b_subFrm1Id); SFS_NET_CPY8(&(pb_subFrm1[k_SFRM1_HDR_LE]), &ps_hdrInfo->b_le); SFS_NET_CPY8(&(pb_subFrm1[k_SFRM1_HDR_CT]), &LOW8(ps_hdrInfo->w_ct)); /* fill header bytes and data bytes of sub frame TWO into the memory block of serialized openSAFETY frame. */ SFS_NET_CPY8(&(pb_frame[k_SFRM2_HDR_ADR]), &b_subFrm2Adr); SFS_NET_CPY8(&(pb_frame[k_SFRM2_HDR_ID]), &b_subFrm2Id); SFS_NET_CPY8(&(pb_frame[k_SFRM2_HDR_CT]), &(HIGH8(ps_hdrInfo->w_ct))); SFS_NET_CPY8(&(pb_frame[k_SFRM2_HDR_TADR]), &(LOW8(ps_hdrInfo->w_tadr))); SFS_NET_CPY8(&(pb_frame[k_SFRM2_HDR_TR]), &b_subFrm2Tr); /* NOTE: payload data is already written into sub frame TWO by the calling function and for special frame types already overwritten */ /* if payload data length is larger than 8 bytes */ if(ps_hdrInfo->b_le > k_MAX_DATA_LEN_SHORT) { if ( k_SERVICE_REQ_FAST == (ps_hdrInfo->b_id & k_SERVICE_REQ_FAST)) { /* get 16 bit CRC as reference for sub frame TWO/ONE from unit SHNF */ w_calcCrc1Long = SHNF_Crc16CalcSlim(0U, (INT32)w_subFrm1Len, (void *)pb_subFrm1); w_calcCrc2Long = SHNF_Crc16CalcSlim(0U, (INT32)w_subFrm2Len, (void *)pb_frame); } else { /* get 16 bit CRC as reference for sub frame TWO/ONE from unit SHNF */ w_calcCrc1Long = SHNF_Crc16Calc(0U, (INT32)w_subFrm1Len, (void *)pb_subFrm1); w_calcCrc2Long = SHNF_Crc16Calc(0U, (INT32)w_subFrm2Len, (void *)pb_frame); } SFS_NET_CPY16(pb_subFrm1Crc, &w_calcCrc1Long); SFS_NET_CPY16(pb_subFrm2Crc, &w_calcCrc2Long); } else /* payload data length is 8 byte or less */ { /* get 8 bit CRC as reference for sub frame TWO/ONE from unit SHNF */ b_calcCrc1Short = SHNF_Crc8Calc(0U, (INT32)w_subFrm1Len, (void *)pb_subFrm1); b_calcCrc2Short = SHNF_Crc8Calc(0U, (INT32)w_subFrm2Len, (void *)pb_frame); SFS_NET_CPY8(pb_subFrm1Crc, &b_calcCrc1Short); SFS_NET_CPY8(pb_subFrm2Crc, &b_calcCrc2Short); } /* the UDID of the SCM encoding */ SFS_ScmUdidCode(B_INSTNUM_ ps_hdrInfo->b_id, pb_frame); /* if openSAFETY frame cannot be passed to SHNF */ if(!(SHNF_MarkTxMemBlock(B_INSTNUM_ pb_frame))) { /* error: SHNF cannot mark openSAFETY frame as "ready to process" */ SERR_SetError(B_INSTNUM_ SFS_k_ERR_SHNF_CANNOT_MARK_MEM_BLK, SERR_k_NO_ADD_INFO); } else /* openSAFETY frame processed successfully from SHNF */ { o_return = TRUE; } } /* else the header info provided by the calling function is incorrect */ SCFM_TACK_PATH(); return o_return; }