From 211696c95c1ec3fc48e0096d47d4278910274195 Mon Sep 17 00:00:00 2001 From: takeshi_hoshina Date: Thu, 22 Oct 2020 13:28:36 +0900 Subject: ps-communication branch 0.1 --- communication/server/src/threads/CAN_Thread.cpp | 609 +++++---------------- communication/server/src/threads/Thread_Common.cpp | 232 ++++---- 2 files changed, 270 insertions(+), 571 deletions(-) (limited to 'communication/server/src/threads') diff --git a/communication/server/src/threads/CAN_Thread.cpp b/communication/server/src/threads/CAN_Thread.cpp index 3393e60f..1b327e7b 100644 --- a/communication/server/src/threads/CAN_Thread.cpp +++ b/communication/server/src/threads/CAN_Thread.cpp @@ -1,5 +1,5 @@ /* - * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,10 @@ * limitations under the License. */ -/******************************************************************************* - * SYSTEM :_CWORD107_ - * SUBSYSTEM :EXL process - * Module configuration :CAN_Thread() CAN thread domain processing - * CANMainThreadInit() CAN thread initialization processing - * CANTimeOutMsg() Timeout message processing - * CANCommonTimerStart() CAN thread common timer start processing - * CANBufferLogOut() CAN thread buffer log output processing - * CANDebugLogOut() Debug log output processing - ******************************************************************************/ -/*!----------------------------------------------------------------------------- - * @file CAN_Thread.cpp - * @~english - * @brief CAN Thread - */ #include "CAN_Thread.h" extern "C" { -#include //NOLINT (build/include) +#include #include } #include @@ -40,126 +25,109 @@ extern "C" { #include #include #include -//#include +#include #include #include #include #include #include #include "CAN_Delivery.h" -#include "CAN_DeliveryData.h" -#include "CAN_Transmission.h" -#include "CAN_TransmissionData.h" #include "CAN_CommWatch.h" -#include "CAN_CommWatchData.h" -#include "CAN_Command.h" -#include "CAN_CommandData.h" #include "CAN_TxMsg.h" -#include "CAN_TimerCtrl.h" #include "communication_communicationlog.h" #include "communication_cid.h" #include "Thread_Common.h" -#define NTFY_PSM_INITCOMP MN_PS_PSMSHADOW"/InitComp" - -//static EFrameworkunifiedStatus CANHalRcvProcess(CanMessage *p); -//static EFrameworkunifiedStatus CANHal_CWORD29_RcvProcess(CanMessage_CWORD29_ *p); -//static EFrameworkunifiedStatus CANHalSndStsProcess(CanSendResult *p); -//static EFrameworkunifiedStatus CANHal_CWORD29_SndStsProcess(CanSendResult_CWORD29_ *p); -static EFrameworkunifiedStatus CANIcrCmdRcvProcess(HANDLE h_app); -static EFrameworkunifiedStatus CANIcrSndStsProcess(HANDLE h_app); +static EFrameworkunifiedStatus CANStateCallback(HANDLE h_app); +static EFrameworkunifiedStatus CANHalRcvProcess(HANDLE h_app); +static EFrameworkunifiedStatus CANHalSndStsProcess(HANDLE h_app); -/*************************************************/ -/* Global variable */ -/*************************************************/ -static const FrameworkunifiedProtocolCallbackHandler kCanPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch -// {CID_ICR_CMD_RCV, CANIcrCmdRcvProcess}, -// {CID_ICR_CMD_SND_CNF, CANIcrSndStsProcess}, +static const FrameworkunifiedProtocolCallbackHandler kCanPcbhs[] = { {CID_CANIF_DELIVERY_ENTRY, CANDeliveryEntry}, - {CID_CANIF__CWORD29__DELIVERY_ENTRY, CAN_CWORD29_DeliveryEntry}, + {CID_CANIF_DELIVERY_ERASE, CANClearEntry}, {CID_COMMSYS_TIMEOUT, CANCallbackForTimeOut}, -#ifdef CAN_DEBUG - {CID_CANIF_DELETE_DELIVERY_ENTRY, CANAllDeleteDeliveryEntry}, -#endif - {CID_CANIF_TX_START, CANTxStart}, - {CID_CANIF_TX_STOP, CANFreqTxStop}, - {CID_CANIF_TX_BIT_START, CANTxBitStart}, - {CID_CANIF_TX_BIT_STOP, CANTxBitStop}, + {CID_CANIF_TX_START, CANTxMsg}, + {CID_CANIF_TX_BIT_START, CANTxMsgBit}, {CID_CANIF_COMM_WATCH, CANCommWatch}, - {CID_CANIF__CWORD29__TX_START, CAN_CWORD29_TxMsg}, - {CID_CANIF_CMD_CTRL, CANCommandTransmission}, + {CID_CANIF_CMD_CTRL, CANTxMsgCommand}, + {CID_CANHAL_CMD_CAN_READY, CANStateCallback}, + {CID_CANHAL_CMD_ERROR_NOTIFY, CommonCanHalErrorNotify}, + {CID_CANHAL_CMD_CAN_RECV, CANHalRcvProcess}, + {CID_CANHAL_CMD_CAN_SEND_STATUS, CANHalSndStsProcess}, }; -static UI_32 kCanPcbhsD[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch -// CID_ICR_CMD_RCV, -// CID_ICR_CMD_SND_CNF, +static UI_32 kCanPcbhsD[] = { CID_CANIF_DELIVERY_ENTRY, - CID_CANIF__CWORD29__DELIVERY_ENTRY, + CID_CANIF_DELIVERY_ERASE, CID_COMMSYS_TIMEOUT, -#ifdef CAN_DEBUG - CID_CANIF_DELETE_DELIVERY_ENTRY, -#endif CID_CANIF_TX_START, - CID_CANIF_TX_STOP, CID_CANIF_TX_BIT_START, - CID_CANIF_TX_BIT_STOP, CID_CANIF_COMM_WATCH, - CID_CANIF__CWORD29__TX_START, - CID_CANIF_CMD_CTRL + CID_CANIF_CMD_CTRL, + CID_CANHAL_CMD_CAN_READY, + CID_CANHAL_CMD_ERROR_NOTIFY, + CID_CANHAL_CMD_CAN_RECV, + CID_CANHAL_CMD_CAN_SEND_STATUS }; -static const FrameworkunifiedProtocolCallbackHandler kCanDebugPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch - {CID_CANIF_COMMWATCH_CLEAR_FOR_DEBUG, CANCommWatchAllClearDebug}, -}; +static EFrameworkunifiedStatus CANStateCallback(HANDLE h_app) { + bool result; + EFrameworkunifiedStatus err = eFrameworkunifiedStatusOK; -static UI_32 kCanDebugPcbhsD[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch - CID_CANIF_COMMWATCH_CLEAR_FOR_DEBUG, -}; + err = FrameworkunifiedGetMsgDataOfSize(h_app, &result, sizeof(result), eSMRRelease); + if (err != eFrameworkunifiedStatusOK) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize failed"); + } + if (err == eFrameworkunifiedStatusInvldBufSize) { + FrameworkunifiedClearMsgData(h_app); + return eFrameworkunifiedStatusFail; + } else if (err != eFrameworkunifiedStatusOK) { + return eFrameworkunifiedStatusFail; + } -//static CanHalParam canParam; + CommSetAvailabilityCurrent(CAN_AVAILABILITY); + return CommonStartNotify(h_app, NTFY_Communication_CAN_ISAVAILABLE); +} -//static EFrameworkunifiedStatus CANStateCallback(DEVICE_STATE state, void *ctxid) { -// HANDLE h_app = canParam.callbacks.can.cmn.ctxid_state; -// CommSetAvailabilityCurrent(CAN_AVAILABILITY); -// return CommonStartNotify(h_app, NTFY_Communication_CAN_ISAVAILABLE); -//} +static EFrameworkunifiedStatus CANThreadCanOpen(HANDLE h_app) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + const char *result = "Unknown"; + const char *called = "Unknown"; + UI_16 z = ZONE_ERR; + + e_status = ConvRet(CanOpen(h_app, CAN_HAL_TYPE_CAN)); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "CanOpen"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s", called, result); + return e_status; +} EFrameworkunifiedStatus CANThreadStart(HANDLE h_app) { EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; CommClrAvailabilityCurrent(CAN_AVAILABILITY); - CANDeliveryDataInit(); - CANTransmissionDataInit(); - CANCommWatchDataInit(); - CANCommandDataInit(); + CANDeliveryInit(); CANCommWatchInit(); - CANTimerTblInit(); + CANTxMsgInit(); -// canParam.type = CAN_HAL_TYPE_CAN; -// canParam.callbacks.can.cmn.ctxid_state = h_app; -// canParam.callbacks.can.cmn.StateCallback = CANStateCallback; -// canParam.callbacks.can.cmn.ctxid_error = h_app; -// canParam.callbacks.can.cmn.ErrorCallback = CommonCanHalErrorNotify; -// canParam.callbacks.can.cmn.ctxid_tx = h_app; -// canParam.callbacks.can.cmn.SendResultCallback = CANHalSndStsProcess; -// canParam.callbacks.can.cmn.ctxid_rx = h_app; -// canParam.callbacks.can.cmn.ReceiveCallback = CANHalRcvProcess; -// canParam.callbacks.can.ctxid_tx__CWORD118_ = h_app; -// canParam.callbacks.can.SendResultCallback_CWORD29_ = CANHal_CWORD29_SndStsProcess; -// canParam.callbacks.can.ctxid_rx__CWORD118_ = h_app; -// canParam.callbacks.can.ReceiveCallback_CWORD29_ = CANHal_CWORD29_RcvProcess; -// e_status = CommonCanHalThreadStart(h_app, kCanPcbhs, _countof(kCanPcbhs), -// NTFY_Communication_CAN_ISAVAILABLE, &canParam); - - e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app, - "CAN_TEST", kCanDebugPcbhs, _countof(kCanDebugPcbhs)); - if (e_status != eFrameworkunifiedStatusOK) { - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, - "FrameworkunifiedAttachCallbacksToDispatcher Error(%d)", e_status); - return e_status; - } + e_status = CommonThreadStart(h_app, kCanPcbhs, _countof(kCanPcbhs), + NTFY_Communication_CAN_ISAVAILABLE, CANThreadCanOpen); + return e_status; +} +static EFrameworkunifiedStatus CANThreadCanClose(HANDLE h_app) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + const char *result = "Unknown"; + const char *called = "Unknown"; + UI_16 z = ZONE_ERR; + + e_status = ConvRet(CanClose(h_app, CAN_HAL_TYPE_CAN)); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "CanClose"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s", called, result); return e_status; } @@ -167,385 +135,104 @@ EFrameworkunifiedStatus CANThreadStop(HANDLE h_app) { EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; CommClrAvailabilityCurrent(CAN_AVAILABILITY); -// e_status = CommonCanHalThreadStop(h_app, kCanPcbhsD, _countof(kCanPcbhsD), -// NTFY_Communication_CAN_ISAVAILABLE, -// CAN_HAL_TYPE_CAN); - - e_status = FrameworkunifiedDetachCallbacksFromDispatcher(h_app, "CAN_TEST", - kCanDebugPcbhsD, _countof(kCanDebugPcbhsD)); - if (e_status != eFrameworkunifiedStatusOK) { - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, - "CommunicationDettachCallbacksFromDispatcher Error(%d)", e_status); - return e_status; - } - + e_status = CommonThreadStop(h_app, kCanPcbhsD, _countof(kCanPcbhsD), + NTFY_Communication_CAN_ISAVAILABLE, + CANThreadCanClose); return e_status; } -//static EFrameworkunifiedStatus CANHalRcvProcess(CanMessage *p) { -// RET_CAN ret = RET_CAN_ERROR_CANCEL; -//// T_ICR_CMD_DATA *p_can_data = NULL; -// CanMessage canhal_recv_data; -// CAN_MSG_DATA st_recv_msg; -// BOOL bcmdopc = FALSE; /* CAN command OPC judgment */ -// int32_t lcnt; /* General Variables */ -// HANDLE h_app = canParam.callbacks.can.cmn.ctxid_rx; -// -// memcpy(&canhal_recv_data, p, sizeof(canhal_recv_data)); -// if (canhal_recv_data.dlc > CAN_MESSAGE_LEN) { -// return eFrameworkunifiedStatusFail; -// } -// -// const uint8_t ucOpcTable[] = { -// /* OPC search table */ -// CAN_CMDID_STARTUP_FIN_RESP_RX, /* CAN startup completion notice received */ -// CAN_CMDID_MRST_INFO_RESP_RX, /* CAN Master Reset Information Notification Reception */ -// CAN_CMDID_VERSION_RESP_RX, /* CAN Version Response Reception */ -// CAN_CMDID_CONNECTION_NODE_RESP_RX, /* Receive CAN Connection Node Notification Response */ -// CAN_CMDID_FUELCALC_RST_REQ_RX, /* RECEIVE REQUEST FREE OF CAN SECTION */ -// }; -// -// bcmdopc = FALSE; -// for (lcnt = 0; lcnt < (int32_t)((sizeof(ucOpcTable)) / (sizeof(uint8_t))); lcnt++) { -// if ((int32_t)canhal_recv_data.can_id == (int32_t)ucOpcTable[lcnt]) { -// bcmdopc = TRUE; -// break; -// } -// } -// -// if (FALSE == bcmdopc) { -//// p_can_data = reinterpret_cast(&st_recv_msg.ucData[0]); -//// p_can_data->opc = CAN_OPC_RX; -//// CANCanidUserToIfCvt(canhal_recv_data.can_id, p_can_data->data); -//// p_can_data->data[CAN_MSGBUF_DLC_POS] = static_cast(canhal_recv_data.dlc); -//// memcpy(&(p_can_data->data[CAN_MSGBUF_DATA_POS]), -//// canhal_recv_data.data, -//// canhal_recv_data.dlc); -// ret = CANDataReceiveMsg(h_app, &st_recv_msg); -// } else { -//// p_can_data = reinterpret_cast(&st_recv_msg.ucData[0]); -//// CANCommandidUserToOpcCvt((uint8_t)canhal_recv_data.can_id, &p_can_data->opc); -// -// switch (canhal_recv_data.can_id) { // LCOV_EXCL_LINE 6: double check by ucOpcTable -// case CAN_CMDID_STARTUP_FIN_RESP_RX: -//// p_can_data->opc = CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX; -// break; -// case CAN_CMDID_MRST_INFO_RESP_RX: -//// p_can_data->opc = CAN_OPC_COMMAND_MRST_INFO_RESP_RX; -// break; -// case CAN_CMDID_VERSION_RESP_RX: -//// p_can_data->opc = CAN_OPC_COMMAND_VERSION_RESP_RX; -// break; -// case CAN_CMDID_CONNECTION_NODE_RESP_RX: -//// p_can_data->opc = CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX; -// break; -// case CAN_CMDID_FUELCALC_RST_REQ_RX: -//// p_can_data->opc = CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX; -// break; -// // LCOV_EXCL_START 6:Excluded due to value never returned at present -// default: -// return eFrameworkunifiedStatusFail; -// // LCOV_EXCL_STOP 6:Excluded due to value never returned at present -// } -// -//// CANCanidUserToIfCvt(canhal_recv_data.can_id, p_can_data->data); -//// memcpy(&(p_can_data->data[0]), -//// canhal_recv_data.data, -//// canhal_recv_data.dlc); -// ret = CANCommandDelivery(h_app, &st_recv_msg); -// } -// -// if (RET_CAN_NORMAL != ret) { -// return eFrameworkunifiedStatusFail; -// } else { -// return eFrameworkunifiedStatusOK; -// } -//} +static EFrameworkunifiedStatus CANHalRcvProcess(HANDLE h_app) { + CanMessage canhal_recv_data; + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail; + uint8_t cmd = 0; -//static EFrameworkunifiedStatus CANHal_CWORD29_RcvProcess(CanMessage_CWORD29_ *p) { -// RET_CAN ret = RET_CAN_ERROR_CANCEL; -// CanMessage_CWORD29_ canhal_recv_data; -// HANDLE h_app = canParam.callbacks.can.ctxid_rx__CWORD118_; -// -// memcpy(&canhal_recv_data, p, sizeof(canhal_recv_data)); -// if (canhal_recv_data.dlc > CAN_L_MESSAGE_LEN) { -// return eFrameworkunifiedStatusFail; -// } -// -// ret = CANDeliveryRcv_CWORD29_Data(h_app, canhal_recv_data.opc, canhal_recv_data.dlc, canhal_recv_data.data); -// -// if (RET_CAN_NORMAL != ret) { -// return eFrameworkunifiedStatusFail; -// } else { -// return eFrameworkunifiedStatusOK; -// } -//} - -//static EFrameworkunifiedStatus CANHalSndStsProcess(CanSendResult *p) { -// BOOL bcmdopc = FALSE; /* CAN command OPC judgment */ -// int32_t lcnt; -// BOOL ret = TRUE; -// uint8_t ui_can_rid; -// uint8_t uc_sts; -// CanSendResult canhal_recv_data; -// HANDLE h_app = canParam.callbacks.can.cmn.ctxid_tx; -// -// memcpy(&canhal_recv_data, p, sizeof(canhal_recv_data)); -// ui_can_rid = canhal_recv_data.rid; -// if (CAN_RID_NOTUSE_CODE == ui_can_rid) { -// return eFrameworkunifiedStatusOK; -// } -// -// if (CAN_SEND_RESULT_SUCCESS == canhal_recv_data.result) { -// uc_sts = CAN_SUCCESS; -// } else { -// uc_sts = CAN_RETRYOUT; -// } -// -// const uint8_t ucOpcTable[] = { -// /* OPC search table */ -// CAN_CMDID_MRST_INFO_REQ_TX, /* CAN master reset information notification request transmission */ -// CAN_CMDID_CONNECTION_NODE_REQ_TX, /* CAN connection node notification request transmission */ -// CAN_CMDID_FUELCALC_REQ_TX, /* CAN section flame reset response transmission */ -// }; -// -// bcmdopc = FALSE; -// for (lcnt = 0; lcnt < (int32_t)((sizeof(ucOpcTable)) / (sizeof(uint8_t))); lcnt++) { -// if ((int32_t)canhal_recv_data.can_id == (int32_t)ucOpcTable[lcnt]) { -// bcmdopc = TRUE; -// break; -// } -// } -// -// if (bcmdopc) { -// ret = CANCommandTxRsltSndMsg(h_app, ui_can_rid, uc_sts); -// -// if (TRUE == ret) { // LCOV_EXCL_BR_LINE 4: NSFW error case -// CANCommandTxRsltDelete(ui_can_rid); -// } -// } else { -// ret = CANTxRsltSndMsg(h_app, ui_can_rid, uc_sts); -// -// if (TRUE == ret) { -// CANTxRsltFin(ui_can_rid); /* CANDataTransmission result notification completed */ -// } -// } -// -// if (FALSE == ret) { -// return eFrameworkunifiedStatusFail; -// } else { -// return eFrameworkunifiedStatusOK; -// } -//} - -//static EFrameworkunifiedStatus CANHal_CWORD29_SndStsProcess(CanSendResult_CWORD29_ *p) { -// BOOL ret = TRUE; -// uint8_t ui_can_rid; -// uint8_t uc_sts; -// CanSendResult_CWORD29_ canhal_recv_data; -// HANDLE h_app = canParam.callbacks.can.ctxid_tx__CWORD118_; -// -// memcpy(&canhal_recv_data, p, sizeof(canhal_recv_data)); -// ui_can_rid = canhal_recv_data.rid; -// if (CAN_RID_NOTUSE_CODE == ui_can_rid) { -// return eFrameworkunifiedStatusOK; -// } -// -// if (CAN_SEND_RESULT_SUCCESS == canhal_recv_data.result) { -// uc_sts = CAN_SUCCESS; -// } else { -// uc_sts = CAN_RETRYOUT; -// } -// -// ret = CAN_CWORD29_TxRsltSndMsg(h_app, ui_can_rid, uc_sts); -// if (TRUE == ret) { // LCOV_EXCL_LINE 11:Excluded due to gcov constraints (others) -// CAN_CWORD29_TxRsltFin(ui_can_rid); /* CANDataTransmission result notification completed */ -// return eFrameworkunifiedStatusOK; -// } else { -// return eFrameworkunifiedStatusFail; -// } -//} + e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &canhal_recv_data, + sizeof(canhal_recv_data), eSMRRelease); + if (e_status != eFrameworkunifiedStatusOK) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : FrameworkunifiedGetMsgDataOfSize is failed, e_status=%d", e_status); + } -static EFrameworkunifiedStatus CANIcrCmdRcvProcess(HANDLE h_app) { - RET_CAN l_ret = RET_CAN_INIT_SUCCESS; /* Return value of the function */ - BOOL bCmdOpc = FALSE; /* CAN command OPC judgment */ - int32_t l_cnt; /* General Variables */ - EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; -// T_ICR_CMD_RCV rcv_msg; + if (e_status == eFrameworkunifiedStatusInvldBufSize) { + FrameworkunifiedClearMsgData(h_app); + goto cleanup; + } else if (e_status != eFrameworkunifiedStatusOK) { + goto cleanup; + } - const uint8_t ucOpcTable[] = { - /* OPC search table */ - CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX, /* CAN startup completion notice received */ - CAN_OPC_COMMAND_MRST_INFO_RESP_RX, /* CAN Master Reset Information Notification Reception */ - CAN_OPC_COMMAND_VERSION_RESP_RX, /* CAN Version Response Reception */ - CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX, /* Receive CAN Connection Node Notification Response */ - CAN_OPC_COMMAND_BUS_STATUS_RESP_RX, /* CAN Bus Status Notification Response Reception */ - CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX, /* RECEIVE REQUEST FREE OF CAN SECTION */ - }; + if (canhal_recv_data.dlc > CAN_MESSAGE_LEN) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : Invalid data length, dlc=%d", canhal_recv_data.dlc); + return eFrameworkunifiedStatusFail; + } -// e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease); - if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case - // LCOV_EXCL_START 4: NSFW error case - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedGetMsgDataOfSize Error"); - if (e_status == eFrameworkunifiedStatusInvldBufSize) { - FrameworkunifiedClearMsgData(h_app); - } - l_ret = RET_CAN_ERROR_CANCEL; - goto exit; + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "can_id=%x dlc=%d rid=%x", + canhal_recv_data.can_id, canhal_recv_data.dlc, canhal_recv_data.rid); + FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s", + MessageDataOutputLog(canhal_recv_data.data, canhal_recv_data.dlc).c_str()); + + cmd = (uint8_t)(canhal_recv_data.can_id & 0xFF); + switch (canhal_recv_data.can_id) { + case CAN_CMDID_STARTUP_FIN_RESP_RX: + e_status = CANCommandDeliveryRcvProcess(h_app, &canhal_recv_data, cmd); + break; + case CAN_CMDID_MRST_INFO_RESP_RX: + e_status = CANCommandDeliveryRcvProcess(h_app, &canhal_recv_data, cmd); + break; + case CAN_CMDID_VERSION_RESP_RX: + e_status = CANCommandDeliveryRcvProcess(h_app, &canhal_recv_data, cmd); + break; + case CAN_CMDID_CONNECTION_NODE_RESP_RX: + e_status = CANCommandDeliveryRcvProcess(h_app, &canhal_recv_data, cmd); + break; + case CAN_CMDID_FUELCALC_RST_REQ_RX: + CANCommandSetFuelCalcRstReq(); + e_status = CANCommandDeliveryRcvProcess(h_app, &canhal_recv_data, cmd); + break; + default: + e_status = CANDeliveryRcvProcess(h_app, &canhal_recv_data); } - // LCOV_EXCL_STOP +cleanup: + return e_status; +} -// FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "from:%02x to:%02x opc:%02x", rcv_msg.cmd_data.lgadr_from, rcv_msg.cmd_data.lgadr_to, rcv_msg.cmd_data.opc); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length) -// if (rcv_msg.cmd_data.lgadr_from == (uint8_t)CAN_TX_TO_ADRS) { - bCmdOpc = FALSE; - for (l_cnt = 0; l_cnt < (int32_t)((sizeof(ucOpcTable)) / (sizeof(uint8_t))); l_cnt++) { -// if ((int32_t)rcv_msg.cmd_data.opc == (int32_t)ucOpcTable[l_cnt]) { // LCOV_EXCL_BR_LINE 8: cmd recv is CANHalRcvProcess // NOLINT (whitespace/line_length) - bCmdOpc = TRUE; - break; -// } - } +static EFrameworkunifiedStatus CANHalSndStsProcess(HANDLE h_app) { + CanSendResult canhal_recv_data; + EFrameworkunifiedStatus err = eFrameworkunifiedStatusOK; + uint8_t ui_can_rid; + PS_CommunicationProtocol cid; - if (FALSE == bCmdOpc) { // LCOV_EXCL_BR_LINE 8: cmd recv is CANHalRcvProcess - FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN RCVDATA #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length) -// l_ret = CANDataReceiveMsg(h_app, reinterpret_cast(&rcv_msg)); /* CANDataProcess of Received Messages */ - } else { - // LCOV_EXCL_START 8: same as above - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN RCVCMD #####"); -// l_ret = CANCommandDelivery(h_app, reinterpret_cast(&rcv_msg)); /* CAN command delivery process */ - // LCOV_EXCL_STOP - } + err = FrameworkunifiedGetMsgDataOfSize(h_app, &canhal_recv_data, + sizeof(canhal_recv_data), eSMRRelease); + if (err != eFrameworkunifiedStatusOK) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : FrameworkunifiedGetMsgDataOfSize is failed, err=%d", err); + } -// } -exit: - if (l_ret == RET_CAN_NORMAL) - return eFrameworkunifiedStatusOK; - else + if (err == eFrameworkunifiedStatusInvldBufSize) { + FrameworkunifiedClearMsgData(h_app); return eFrameworkunifiedStatusFail; -} + } else if (err != eFrameworkunifiedStatusOK) { + return eFrameworkunifiedStatusFail; + } -static EFrameworkunifiedStatus CANIcrSndStsProcess(HANDLE h_app) { // LCOV_EXCL_START 8: dead code - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - RET_CAN l_ret = RET_CAN_INIT_SUCCESS; /* Return value of the function */ - EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; -// T_ICR_CMDSNDCNF rcv_msg; + ui_can_rid = canhal_recv_data.rid; + if (CAN_RID_NOTUSE_CODE == ui_can_rid) { + return eFrameworkunifiedStatusOK; + } -// e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease); - if (e_status != eFrameworkunifiedStatusOK) { - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedGetMsgDataOfSize Error"); - if (e_status == eFrameworkunifiedStatusInvldBufSize) { - FrameworkunifiedClearMsgData(h_app); - } - e_status = eFrameworkunifiedStatusFail; - goto exit; + switch (canhal_recv_data.can_id) { + case CAN_CMDID_MRST_INFO_REQ_TX: + case CAN_CMDID_CONNECTION_NODE_REQ_TX: + case CAN_CMDID_FUELCALC_REQ_TX: + cid = CID_CAN_CMD_TX_RESULT; + break; + default: + cid = CID_CAN_TX_RESULT; + break; } -// if (((uint32_t)CAN_CMD_RID_MASK & (uint32_t)rcv_msg.msg_hdr.hdr.rid) != 0) { - /* CAN command transmission result notification processing */ -// l_ret = CANCommandTxRslt(h_app, reinterpret_cast(&rcv_msg)); -// } else { - /* CANDataReceive message processing of transmission result */ -// l_ret = CANTxRsltReceiveMsg(h_app, reinterpret_cast(&rcv_msg)); -// } -exit: - if (l_ret == RET_CAN_NORMAL) - return eFrameworkunifiedStatusOK; - else - return eFrameworkunifiedStatusFail; + return CANSndStsProcess(h_app, &canhal_recv_data, cid); } -// LCOV_EXCL_STOP 8: dead code -/******************************************************************************* - * MODULE : CANTimeOutMsg - * ABSTRACT : Timeout message processing - * FUNCTION : Timeout message processing - * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer - * NOTE : - * RETURN : None - ******************************************************************************/ EFrameworkunifiedStatus CANCallbackForTimeOut(HANDLE h_app) { - CANTimeOutMsg(h_app, CAN_TIMER_SEQNO_CODE); + CANCommWatchTimeout(h_app); return eFrameworkunifiedStatusOK; } - -/******************************************************************************* - * MODULE : CANTimeOutMsg - * ABSTRACT : Timeout message processing - * FUNCTION : Timeout message processing - * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer - * NOTE : - * RETURN : None - ******************************************************************************/ -void CANTimeOutMsg(HANDLE h_app, uint16_t timer_seq) { - CANFreqTransTimeOut(h_app, timer_seq, CAN_PROTOCOL_TYPE_CAN); /* CAN periodic transmission timeout check */ - CANFreqTransTimeOutMap(h_app); - CANCommWatchTimeOut(h_app, CAN_PROTOCOL_TYPE_CAN); /* Confirmation of CAN communication interruption monitoring timeout */ -} - -/******************************************************************************* - * MODULE : CANBufferLogOut - * ABSTRACT : CAN thread buffer log output processing - * FUNCTION : CAN thread buffer log output processing - * ARGUMENT : None - * NOTE : - * RETURN : None - ******************************************************************************/ -void CANBufferLogOut(void) { // LCOV_EXCL_START 8: dead code - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - FILE *afp_log = NULL; - - afp_log = fopen(CAN_BUFFER_LOGOUT_NAME, "r"); /* Opening Log Files in Read Mode */ - - if (NULL != afp_log) { - /* When a log file is opened */ - (void)fclose(afp_log); /* Close the log file */ - afp_log = fopen(CAN_BUFFER_LOGOUT_NAME, "a"); /* Opening Log Files in Append Mode */ - - if (NULL != afp_log) { - /* When a log file is opened */ - CANDeliveryBufferOut(afp_log); /* CAN shipping table log output */ - (void)fprintf(afp_log, "\n\n\n\n\n"); - CANCycleTransBufferOut(afp_log); /* CAN Periodic Transmission Table Log Output */ - (void)fprintf(afp_log, "\n\n\n\n\n"); - CANCommWatchBufferOut(afp_log, CAN_PROTOCOL_TYPE_CAN); /* CAN communication disruption table log output */ - (void)fprintf(afp_log, "\n\n\n\n\n"); - - (void)fclose(afp_log); /* Close the log file */ - } - } -} -// LCOV_EXCL_STOP - -/******************************************************************************* - * MODULE : CANDebugLogOut - * ABSTRACT : Debug log output processing - * FUNCTION : Output a debug log - * ARGUMENT : u_int16 err_code Error code - * : void* msg_ptr Message start pointers - * NOTE : - * RETURN : - ******************************************************************************/ -void CANDebugLogOut(uint16_t err_code, void *msg_ptr) { - CAN_MSG_DATA *can_msg; - uint16_t i; - uint16_t data_sz; - uint8_t *data_p; - int8_t out_cha[100]; - - can_msg = reinterpret_cast(msg_ptr); - data_p = reinterpret_cast(msg_ptr); -// data_sz = (uint16_t)((uint32_t)can_msg->stHead.hdr.msgbodysize + sizeof(T_APIMSG_MSGBUF_HEADER_COMM)); - if (0x30 < (uint32_t)data_sz) { - data_sz = 0x30; - } - for (i = 0; i < data_sz; i++) { - (void)snprintf(reinterpret_cast(&out_cha[i * 2]), sizeof(char), "%02x", data_p[i]); - } - if ((uint16_t)CAN_DELIVERY_ERR == err_code) { // LCOV_EXCL_BR_LINE 8: dead code(CAN_DELIVERY_ERR is impossible) - AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert - FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "#CAN_thread# ERRCODE:%04x %s", err_code, &out_cha[0]); // LCOV_EXCL_LINE 8:dead code //NOLINT (readability/naming) - } else { - FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# ERRCODE:%04x %s", err_code, &out_cha[0]); - } -} // LCOV_EXCL_LINE 10: final line diff --git a/communication/server/src/threads/Thread_Common.cpp b/communication/server/src/threads/Thread_Common.cpp index 72d80eab..718d9481 100644 --- a/communication/server/src/threads/Thread_Common.cpp +++ b/communication/server/src/threads/Thread_Common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 TOYOTA MOTOR CORPORATION + * Copyright (c) 2019-2020 TOYOTA MOTOR CORPORATION * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,20 +16,50 @@ #include #include +#include + #include #include #include #include -//#include +#include #include "communication_communicationlog.h" #include "communication_cid.h" #include "Thread_Common.h" -static boost::atomic availabilityMask; +static std::map g_map_sender; +static pthread_mutex_t g_sender_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; static boost::atomic availabilityCurrent; -void CommSetAvailabilityMask(int32_t mask) { - availabilityMask |= mask; +void CommonInit(void) { + pthread_mutex_lock(&g_sender_mutex); + g_map_sender.clear(); + pthread_mutex_unlock(&g_sender_mutex); +} + +HANDLE CommonFindSender(HANDLE h_app, std::string s) { + HANDLE ret = NULL; + std::string app(FrameworkunifiedGetAppName(h_app)); + std::string key = s + app; + std::map::iterator it = g_map_sender.find(key); + + pthread_mutex_lock(&g_sender_mutex); + + if (it != g_map_sender.end()) { + ret = g_map_sender[key]; + goto cleanup; + } + + ret = FrameworkunifiedMcOpenSender(h_app, s.c_str()); + if (ret) { + g_map_sender[key] = ret; + } else { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedMcOpenSender Error(to:%s)", s.c_str()); + } + +cleanup: + pthread_mutex_unlock(&g_sender_mutex); + return ret; } void CommSetAvailabilityCurrent(int32_t current) { @@ -44,35 +74,12 @@ BOOL CommGetAvailabilityCurrent(int32_t current) { return !(!(availabilityCurrent & current)); } -static BOOL CommCheckAvailabilityMask(void) { - return (availabilityMask == availabilityCurrent); -} - EFrameworkunifiedStatus CommonStartNotify(HANDLE h_app, PCSTR cmd) { EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; const char *result = "Unknown"; const char *called = "Unknown"; const BOOL avail = TRUE; UI_16 z = ZONE_ERR; - HANDLE hdl = NULL; - uint8_t c = 0; - - hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_MAIN); - result = (NULL == hdl) ? "failed" : "success"; - z = (NULL == hdl) ? ZONE_INFO : ZONE_ERR; - called = "FrameworkunifiedMcOpenSender"; - FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s", called, result); - if (e_status != eFrameworkunifiedStatusOK) - return e_status; - - if (TRUE == CommCheckAvailabilityMask()) { - e_status = FrameworkunifiedSendMsg(hdl, CID_COMMSYS_CAN_READY, c, &c); - result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; - z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; - called = "FrameworkunifiedSendMsg"; - FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); - } - FrameworkunifiedMcClose(hdl); e_status = FrameworkunifiedNPPublishNotification(h_app, cmd, &avail , sizeof(avail)); result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; @@ -82,89 +89,94 @@ EFrameworkunifiedStatus CommonStartNotify(HANDLE h_app, PCSTR cmd) { return e_status; } -EFrameworkunifiedStatus CommonCanHalErrorNotify(const char *msg, void *ctxid) { +EFrameworkunifiedStatus CommonCanHalErrorNotify(HANDLE h_app) { + char msg[CANHAL_ERROR_MESSAGE_LEN] = {0}; + EFrameworkunifiedStatus err = eFrameworkunifiedStatusOK; + + err = FrameworkunifiedGetMsgDataOfSize(h_app, &msg, sizeof(msg), eSMRRelease); + if (err != eFrameworkunifiedStatusOK) { + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize is failed, err=%d", err); + } + + if (err == eFrameworkunifiedStatusInvldBufSize) { + FrameworkunifiedClearMsgData(h_app); + return eFrameworkunifiedStatusFail; + } else if (err != eFrameworkunifiedStatusOK) { + return eFrameworkunifiedStatusFail; + } FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "can_hal error : %s", msg); - return eFrameworkunifiedStatusOK; + return err; +} + +EFrameworkunifiedStatus CommonThreadStart(HANDLE h_app, const FrameworkunifiedProtocolCallbackHandler *cb, + UI_32 count, PCSTR cmd, EFrameworkunifiedStatus (*open_func)(HANDLE)) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + const char *result = "Unknown"; + const char *called = "Unknown"; + UI_16 z = ZONE_ERR; + + e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, cb, count); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "FrameworkunifiedAttachCallbacksFromDispatcher"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + e_status = open_func(h_app); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + e_status = FrameworkunifiedNPRegisterNotification(h_app, cmd, + sizeof(EFrameworkunifiedStatus), eFrameworkunifiedStateVar); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "FrameworkunifiedNPRegisterNotification"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + return e_status; } -//EFrameworkunifiedStatus CommonCanHalThreadStart(HANDLE h_app, -// const FrameworkunifiedProtocolCallbackHandler *cb, -// UI_32 count, PCSTR cmd, CanHalParam *p) { -// EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; -// CANHAL_RET_API ret = CANHAL_RET_NORMAL; -// const char *result = "Unknown"; -// const char *called = "Unknown"; -// UI_16 z = ZONE_ERR; -// -// e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, cb, count); -// result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; -// z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; -// called = "CommunicationAttachCallbacksFromDispatcher"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -//// ret = CanOpen(p); -// result = (ret != CANHAL_RET_NORMAL) ? "failed" : "success"; -// z = (ret != CANHAL_RET_NORMAL) ? ZONE_INFO : ZONE_ERR; -// called = "CanOpen"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, ret); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -// e_status = FrameworkunifiedNPRegisterNotification(h_app, cmd, -// sizeof(EFrameworkunifiedStatus), eFrameworkunifiedStateVar); -// result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; -// z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; -// called = "FrameworkunifiedNPRegisterNotification"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -// return e_status; -//} - -//EFrameworkunifiedStatus CommonCanHalThreadStop(HANDLE h_app, const PUI_32 cb, -// UI_32 count, PCSTR cmd, CanHalType type) { -// EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; -// CANHAL_RET_API ret = CANHAL_RET_NORMAL; -// const BOOL avail = FALSE; -// const char *result = "Unknown"; -// const char *called = "Unknown"; -// UI_16 z = ZONE_ERR; -// -// e_status = FrameworkunifiedNPPublishNotification(h_app, cmd, &avail , sizeof(avail)); -// result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; -// z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; -// called = "FrameworkunifiedNPPublishNotification"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -// e_status = FrameworkunifiedNPUnRegisterNotification(h_app, cmd); -// result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; -// z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; -// called = "FrameworkunifiedNPUnRegisterNotification"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -// e_status = FrameworkunifiedDetachCallbacksFromDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, cb, count); -// result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; -// z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; -// called = "FrameworkunifiedDetachCallbacksFromDispatcher"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -//// ret = CanClose(type); -// result = (ret != CANHAL_RET_NORMAL) ? "failed" : "success"; -// z = (ret != CANHAL_RET_NORMAL) ? ZONE_INFO : ZONE_ERR; -// called = "CanClose"; -// FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); -// if (e_status != eFrameworkunifiedStatusOK) -// return e_status; -// -// return e_status; -//} +EFrameworkunifiedStatus CommonThreadStop(HANDLE h_app, const PUI_32 cb, + UI_32 count, PCSTR cmd, EFrameworkunifiedStatus (*close_func)(HANDLE)) { + EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK; + const BOOL avail = FALSE; + const char *result = "Unknown"; + const char *called = "Unknown"; + UI_16 z = ZONE_ERR; + + e_status = FrameworkunifiedNPPublishNotification(h_app, cmd, &avail , sizeof(avail)); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "FrameworkunifiedNPPublishNotification"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + e_status = FrameworkunifiedNPUnRegisterNotification(h_app, cmd); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "FrameworkunifiedNPUnRegisterNotification"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + e_status = FrameworkunifiedDetachCallbacksFromDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, cb, count); + result = (e_status != eFrameworkunifiedStatusOK) ? "failed" : "success"; + z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR; + called = "FrameworkunifiedDetachCallbacksFromDispatcher"; + FRAMEWORKUNIFIEDLOG(z, __func__, "%s %s(%d)", called, result, e_status); + if (e_status != eFrameworkunifiedStatusOK) + return e_status; + + e_status = close_func(h_app); + if (e_status != eFrameworkunifiedStatusOK){ + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: close_func() failed"); + return e_status; + } + + return e_status; +} -- cgit 1.2.3-korg