summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 13:28:36 +0900
committertakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 13:28:36 +0900
commit211696c95c1ec3fc48e0096d47d4278910274195 (patch)
treef3e0a5461f83a0ec191b788070fe59639148fb17
parentaacd1728939f2b6f4c811cd93502966265cd8203 (diff)
ps-communication branch 0.1sandbox/ToshikazuOhiwa/ps-communication
-rw-r--r--communication/Makefile.client2
-rw-r--r--communication/Makefile.server2
-rw-r--r--communication/client_can/Makefile3
-rw-r--r--communication/client_can/include/API_Local_Common.h55
-rw-r--r--communication/client_can/include/Canif_API_Local.h101
-rw-r--r--communication/client_can/include/Canif_TransmissionData.h48
-rw-r--r--communication/client_can/include/Canif_TransmissionData21PF.h30
-rw-r--r--communication/client_can/include/peripheral_service/Canif_API.h427
-rw-r--r--communication/client_can/include/peripheral_service/communication_can.h2
-rw-r--r--communication/client_can/libCAN_API.ver6
-rw-r--r--communication/client_can/src/Canif_API.cpp925
-rw-r--r--communication/server/Makefile21
-rw-r--r--communication/server/include/CAN/CommWatch/CAN_CommWatch.h45
-rw-r--r--communication/server/include/CAN/CommWatch/CAN_CommWatchData.h125
-rw-r--r--communication/server/include/CAN/CommWatch/CommWatchCommon.h22
-rw-r--r--communication/server/include/CAN/Command/CAN_Command.h23
-rw-r--r--communication/server/include/CAN/Command/CAN_CommandData.h96
-rw-r--r--communication/server/include/CAN/Delivery/CAN_Delivery.h46
-rw-r--r--communication/server/include/CAN/Delivery/CAN_DeliveryData.h7
-rw-r--r--communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h82
-rw-r--r--communication/server/include/CAN/Transmission/CAN_Transmission.h56
-rw-r--r--communication/server/include/CAN/Transmission/CAN_TransmissionData.h162
-rw-r--r--communication/server/include/CAN/TxMsg/CAN_TxMsg.h128
-rw-r--r--communication/server/include/com_error_type.h20
-rw-r--r--communication/server/include/main/communication_cid.h16
-rw-r--r--communication/server/include/main/communication_communicationlog.h2
-rw-r--r--communication/server/include/main/communication_version.h2
-rw-r--r--communication/server/include/peripheral_service/communication.h2
-rw-r--r--communication/server/include/peripheral_service/communication_notifications.h2
-rw-r--r--communication/server/include/peripheral_service/ps_services.h2
-rw-r--r--communication/server/include/private/ICR_Common.h30
-rw-r--r--communication/server/include/threads/CAN_Thread.h133
-rw-r--r--communication/server/include/threads/Thread_Common.h28
-rw-r--r--communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp406
-rw-r--r--communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp447
-rw-r--r--communication/server/src/CAN/Command/CAN_Command.cpp319
-rw-r--r--communication/server/src/CAN/Command/CAN_CommandData.cpp534
-rw-r--r--communication/server/src/CAN/Delivery/CAN_Delivery.cpp684
-rw-r--r--communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp214
-rw-r--r--communication/server/src/CAN/TimerCtrl/CAN_TimerCtrl.cpp405
-rw-r--r--communication/server/src/CAN/Transmission/CAN_Transmission.cpp603
-rw-r--r--communication/server/src/CAN/Transmission/CAN_TransmissionData.cpp713
-rw-r--r--communication/server/src/CAN/TxMsg/CAN_TxMsg.cpp1201
-rw-r--r--communication/server/src/main/communication_application.cpp177
-rw-r--r--communication/server/src/main/communication_main.cpp145
-rw-r--r--communication/server/src/threads/CAN_Thread.cpp609
-rw-r--r--communication/server/src/threads/Thread_Common.cpp232
-rw-r--r--peripheral_service.mk2
48 files changed, 1790 insertions, 7552 deletions
diff --git a/communication/Makefile.client b/communication/Makefile.client
index 8ba47d4b..8d254863 100644
--- a/communication/Makefile.client
+++ b/communication/Makefile.client
@@ -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.
diff --git a/communication/Makefile.server b/communication/Makefile.server
index ca58ea62..6ebcc1ac 100644
--- a/communication/Makefile.server
+++ b/communication/Makefile.server
@@ -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.
diff --git a/communication/client_can/Makefile b/communication/client_can/Makefile
index e94c5261..49d57081 100644
--- a/communication/client_can/Makefile
+++ b/communication/client_can/Makefile
@@ -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.
@@ -68,6 +68,5 @@ LDFLAGS += -Wl,--no-undefined
######### linked library (dynamic) #############
LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
LDLIBS += -Wl,-Bdynamic -lrt
-LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
include ../../peripheral_service.mk
diff --git a/communication/client_can/include/API_Local_Common.h b/communication/client_can/include/API_Local_Common.h
new file mode 100644
index 00000000..c5e3f780
--- /dev/null
+++ b/communication/client_can/include/API_Local_Common.h
@@ -0,0 +1,55 @@
+/*
+ * @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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_API_LOCAL_COMMON_H_
+#define COMMUNICATION_CLIENT_CAN_INCLUDE_API_LOCAL_COMMON_H_
+#include <string.h>
+enum CANIF_PROTOCOL_IDX {
+ CANIF_CAN = 0,
+ NUM_OF_CANIF_PROTOCOL
+};
+
+static inline const char *Canif_PidxTosname(enum CANIF_PROTOCOL_IDX idx) {
+ switch (idx) {
+ case CANIF_CAN:
+ return LAN_SERVICE_CAN;
+ break;
+ default:
+ return "Unknown";
+ break;
+ }
+}
+
+#define CANIF_NOTIFY_NAME_MAX_SIZE 15
+static inline bool Canif_CheckNotifyName(PCSTR notify_name) {
+ size_t n = CANIF_NOTIFY_NAME_MAX_SIZE + 1;
+
+ if (!notify_name)
+ return false;
+
+ return (strnlen(notify_name, n) < n);
+}
+
+static inline bool Canif_CheckNotifyNameWithoutNullCheck(PCSTR notify_name) {
+ size_t n = CANIF_NOTIFY_NAME_MAX_SIZE + 1;
+ return (strnlen(notify_name, n) < n);
+}
+
+static inline void Canif_CopyNotifyName(char *dest, PCSTR notify_name) {
+ strncpy(dest, notify_name,
+ strnlen(notify_name, CANIF_NOTIFY_NAME_MAX_SIZE));
+}
+#endif
diff --git a/communication/client_can/include/Canif_API_Local.h b/communication/client_can/include/Canif_API_Local.h
index 9ab205ad..d17fcc50 100644
--- a/communication/client_can/include/Canif_API_Local.h
+++ b/communication/client_can/include/Canif_API_Local.h
@@ -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,90 +14,33 @@
* limitations under the License.
*/
-/****************************************************************************
- * FILE Canif_API_Local.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :Local header for CAN I/F provided APIs
- * TITLE :Data header files needed to use the CAN I/F API
- ****************************************************************************/
#ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_API_LOCAL_H_
#define COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_API_LOCAL_H_
-/************************************************************************
-* Definition *
-************************************************************************/
-
-/* CANDataControl code used in the transmission/reception relationship */
#define CAN_ID_MASK_CODE 0xE0000000UL // CAN ID Mask Codes
+static inline bool Canif_CheckCanID(CANID id) {
+ if (id == 0)
+ return false;
-/*********************************************************************
-* Defining Return Values
-***********************************************************************/
-/* Defined in Canif_API.h */
-
-/*********************************************************************
-* Defining Event Generation
-***********************************************************************/
-#define CANIF_API_EVT_INIT 0 /* Initial value of the event */
-#define CANIF_API_ENT_EVT_MIN CANIF_RET_NORMAL /* Minimum Event Wait */
-#define CANIF_API_ENT_EVT_MAX CANIF_RET_ERROR_CREATE_EVENT /* Maximum value waiting for an event */
-
-/*********************************************************************
-* Type definition
-***********************************************************************/
-
-/***********************************************************************
-* CANIF API Functions Prototypes *
-************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/**
-* \~english Data struct used to transfer CAN data(_CWORD29_)
-* \~english (transfer data from CANIF API to CAN)
-*/
-typedef struct {
- /**
- * \~english Delivery target thread name
- */
- char notifyName[MAX_NAME_SIZE_APP];
- /**
- * \~english Resource ID
- */
- uint8_t ucRid;
- /**
- * \~english Data size
- */
- uint32_t ulDataSize;
- /**
- * \~english OPC
- */
- uint16_t opc;
- /**
- * \~english Data buffer
- */
- uint8_t data[CAN__CWORD29__MEM_SZ];
-} CAN__CWORD29__TRANS_MSG;
+ // upper 3 bit from MSB should be 0x0
+ if ((CAN_ID_MASK_CODE & id) != 0x0)
+ return false;
-/* The most significant part is defined in Canif_API.h. */
-CANIF_RET_API CanifDeliveryEntryCore(HANDLE h_app, PCSTR notify_name, uint8_t can_num, CANID *p_can_id, uint16_t cid);
-CANIF_RET_API Canif_CWORD29_DeliveryEntryCore(const HANDLE h_app, const PCSTR notify_name,
- const uint8_t opc_num, const uint16_t* const p_opc, const uint16_t cid);
-CANIF_RET_API CanifTransmissionStartCore(HANDLE h_app, PCSTR notify_name, uint8_t rid,
- uint16_t freq, CAN_DATA *p_data, uint16_t cid);
-CANIF_RET_API CanifTransmissionStopCore(HANDLE h_app, PCSTR notify_name, CANID can_id, uint16_t cid);
-CANIF_RET_API CanifCommandCtrlCore(HANDLE h_app, PCSTR notify_name, uint8_t rid, uint32_t cmd_id, uint16_t cid);
-CANIF_RET_API CanifCommWatchCore(HANDLE h_app, PCSTR notify_name, CANID can_id, DID did,
- uint8_t ig_cooperation, uint16_t watch_time, uint16_t cid);
-
-void CanifMsgHeaderGenerate(CAN_MSG_DATA *, uint16_t, uint16_t, uint16_t); /* Private Functions */
-CANIF_RET_API CanifSndMsg(CAN_MSG_DATA *); /* Private Functions */
-
-CANIF_RET_API CanifCommWatchExtSndMsgData(uint16_t us_pid, CANID ul_canid, DID ul_did,
- uint8_t uc_ig, uint16_t us_watch_time); /* Private Functions */
+ return true;
+}
-#if defined(__cplusplus)
+static inline bool Canif_IsCommand(uint32_t cmd_id) {
+ switch (cmd_id) {
+ case CAN_CMDID_FUELCALC_RST_REQ_DELIVERY:
+ case CAN_CMDID_STARTUP_FIN_REQ_TX:
+ case CAN_CMDID_MRST_INFO_REQ_TX:
+ case CAN_CMDID_VERSION_REQ_TX:
+ case CAN_CMDID_CONNECTION_NODE_REQ_TX:
+ case CAN_CMDID_FUELCALC_REQ_TX:
+ return true;
+ default:
+ return false;
+ }
}
-#endif
+
#endif // COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_API_LOCAL_H_
diff --git a/communication/client_can/include/Canif_TransmissionData.h b/communication/client_can/include/Canif_TransmissionData.h
new file mode 100644
index 00000000..e9f82ac2
--- /dev/null
+++ b/communication/client_can/include/Canif_TransmissionData.h
@@ -0,0 +1,48 @@
+/*
+ * @copyright Copyright (c) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_TRANSMISSIONDATA_H_
+#define COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_TRANSMISSIONDATA_H_
+
+#define LAN_TYPE_21PF "CAN_21PF"
+
+typedef struct {
+ uint8_t dlc;
+ CAN_DATA_BIT dat;
+} CAN_TRANS_START_TABLE_VAL;
+
+typedef struct {
+ CANID canid;
+ CAN_TRANS_START_TABLE_VAL val;
+} CAN_INIT_TABLE;
+
+#include "Canif_TransmissionData21PF.h"
+
+static inline bool Canif_InitDataIsDefined21PF(CANID id) {
+ int32_t count;
+ int i;
+
+ count = sizeof(Can_TransInitData_21PF) /
+ sizeof(Can_TransInitData_21PF[0]);
+ for (i = 0; i < count; i++) {
+ if (id == Can_TransInitData_21PF[i].canid)
+ return true;
+ }
+
+ return false;
+}
+
+#endif // COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_TRANSMISSIONDATA_H_
diff --git a/communication/client_can/include/Canif_TransmissionData21PF.h b/communication/client_can/include/Canif_TransmissionData21PF.h
new file mode 100644
index 00000000..e608ca58
--- /dev/null
+++ b/communication/client_can/include/Canif_TransmissionData21PF.h
@@ -0,0 +1,30 @@
+/*
+ * @copyright Copyright (c) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Following table could not be const because server will use this as R/W.
+static CAN_INIT_TABLE Can_TransInitData_21PF[] __attribute__((unused)) =
+{
+ /*
+ * Note.
+ * This feature needs to be defined by the vendor.
+ */
+ { 0x0000, 1, { 0x00 } },
+ { 0x0001, 1, { 0x00 } },
+ { 0x0002, 8, { 0x00 } },
+ { 0x0100, 1, { 0x00 } },
+ { 0x0101, 8, { 0x00 } },
+ { 0x0102, 8, { 0x00 } }
+};
diff --git a/communication/client_can/include/peripheral_service/Canif_API.h b/communication/client_can/include/peripheral_service/Canif_API.h
index d522c5a1..a68783ca 100644
--- a/communication/client_can/include/peripheral_service/Canif_API.h
+++ b/communication/client_can/include/peripheral_service/Canif_API.h
@@ -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.
@@ -48,12 +48,7 @@
#include <stdio.h>
#include <unistd.h>
#include <asm/unistd.h>
-//#include <stub/com_message_header.h>
-
-/**
- * \~english Debug defination for DeliveryEntry IT Test
- */
-#define CAN_DEBUG
+#include <stub/com_message_header.h>
/**
* \~english Defination of Service name
@@ -112,6 +107,20 @@
#define CANIF_RET_ERROR_NULL 10
/**
+ * \~english Flags for specifiy Delivery is echoback or not.
+ */
+enum CanIfEchoBackFlags {
+ /**
+ * \~english Delivery is recv data
+ */
+ CANIF_PURERECV = 0,
+ /**
+ * \~english Delivery is echo data
+ */
+ CANIF_ECHOBACK = 1
+};
+
+/**
* \~english Defination of Command ID ( CAN -> user )
*/
typedef enum _PS_CommunicationProtocol {
@@ -132,14 +141,6 @@ typedef enum _PS_CommunicationProtocol {
*/
CID_CAN_TX_RESULT,
/**
- * \~english CAN _CWORD29_ transmission result
- */
- CID_CAN__CWORD29__TX_RESULT,
- /**
- * \~english Delivery CAN data(_CWORD29_)
- */
- CID_CAN_DIAG_CWORD29__DELIVERY,
- /**
* \~english Delivery CAN command
*/
CID_CAN_CMD_DELIVERY,
@@ -162,26 +163,18 @@ typedef enum _PS_Communication_InternalProtocol {
*/
CID_CANIF_DELIVERY_ENTRY = 0x0501,
/**
- * \~english Delivery registration of _CWORD29_data
+ * \~english Delivery deregistration of CAN data
*/
- CID_CANIF__CWORD29__DELIVERY_ENTRY,
+ CID_CANIF_DELIVERY_ERASE,
/**
* \~english CAN data transmission start
*/
CID_CANIF_TX_START,
/**
- * \~english CAN data transmission stop
- */
- CID_CANIF_TX_STOP,
- /**
* \~english CAN data communication stop watching
*/
CID_CANIF_COMM_WATCH,
/**
- * \~english CAN data(_CWORD29_) transmission
- */
- CID_CANIF__CWORD29__TX_START,
- /**
* \~english CAN command control
*/
CID_CANIF_CMD_CTRL,
@@ -189,28 +182,8 @@ typedef enum _PS_Communication_InternalProtocol {
* \~english CAN data transmission start
*/
CID_CANIF_TX_BIT_START,
- /**
- * \~english CAN data regular transmission stop
- */
- CID_CANIF_TX_BIT_STOP,
} PS_Communication_InternalProtocol;
-#ifdef CAN_DEBUG
-/**
- * \~english Defination of Command ID (Used for debug)
- */
-typedef enum _PS_Communication_Internal_DebugProtocol {
- /**
- * \~english Delivery unregister (Used for debug)
- */
- CID_CANIF_DELETE_DELIVERY_ENTRY = 0x0511,
- /**
- * \~english CANIF communication data all clear(Used for debug)
- */
- CID_CANIF_COMMWATCH_CLEAR_FOR_DEBUG
-} PS_Communication_Internal_DebugProtocol;
-#endif
-
/*********************************************************************
* Definitions of CAN command IDs
***********************************************************************/
@@ -370,11 +343,6 @@ typedef enum _PS_Communication_Internal_DebugProtocol {
*/
#define CANGW_DLC_MAX_SIZE 0x08
-/**
-* \~english Memory size used for _CWORD29_ can data
-*/
-#define CAN__CWORD29__MEM_SZ (4100)
-
/*********************************************************************
* Type definition
***********************************************************************/
@@ -427,11 +395,15 @@ typedef struct {
/**
* \~english header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ T_APIMSG_MSGBUF_HEADER_COMM hdr;
/**
* \~english data
*/
CAN_MSG_CANDATA_DAT data;
+ /**
+ * \~english echoback flag
+ */
+ enum CanIfEchoBackFlags echoback;
} CAN_MSG_CANDATA;
/**
@@ -458,15 +430,6 @@ typedef struct {
} CAN_MSG_CANGWDATA_DAT;
/**
- * \~english Data struct used to transfer CAN _CWORD29_ data.(transfer data from CAN to user)
- */
-typedef struct {
- uint16_t opc; //!< \~english OPC
- uint32_t dlc; //!< \~english Data length(1~4100)
- uint8_t data[CAN__CWORD29__MEM_SZ]; //!< \~english Data buffer
-} CAN_MSG_CAN__CWORD29_DATA;
-
-/**
* \~english Message struct used to transfer CAN data to CANGW
* \~english (transfer message from CAN to user)
*/
@@ -559,7 +522,7 @@ typedef struct {
/**
* \~english header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ T_APIMSG_MSGBUF_HEADER_COMM hdr;
/**
* \~english Data
*/
@@ -567,40 +530,6 @@ typedef struct {
} CAN_MSG_SENDSTS;
/**
-* \~english Data struct used to notify _CWORD29_ transmission result
-* \~english (transfer data from CAN API to user)
-*/
-typedef struct {
- /**
- * \~english OPC
- */
- uint16_t usOpc;
- /**
- * \~english Transmission result status
- */
- uint8_t ucStatus;
- /**
- * \~english Reserve
- */
- uint8_t reserve[1];
-} CAN_MSG__CWORD29__SENDSTS_DAT;
-
-/**
-* \~english Message struct used to notify _CWORD29_ transmission result
-* \~english (transfer message from CAN API to user)
-*/
-typedef struct {
- /**
- * \~english header
- */
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
- /**
- * \~english Data
- */
- CAN_MSG__CWORD29__SENDSTS_DAT data;
-} CAN_MSG__CWORD29__SENDSTS;
-
-/**
* \~english Data struct used for regular transmission stop
* \~english (transfer data from CANIF API to CAN)
*/
@@ -639,7 +568,7 @@ typedef struct {
/**
* \~english Header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ T_APIMSG_MSGBUF_HEADER_COMM hdr;
/**
* \~english Data
*/
@@ -671,25 +600,6 @@ typedef struct {
} CAN_DELIVERY_ENTRY;
/**
-* \~english _CWORD29_data struct used for delivery entry
-* \~english (transfer data from CANIF API to CAN)
-*/
-typedef struct {
- /**
- * \~english Delivery target thread name
- */
- char notifyName[MAX_NAME_SIZE_APP];
- /**
- * \~english Number of OPC entry
- */
- uint16_t usOpcNum;
- /**
- * \~english OPC entry array
- */
- uint16_t usOpc[CAN_DELIVERY_OPC_ENTRY_MAX];
-} CAN__CWORD29__DELIVERY_ENTRY;
-
-/**
* \~english Data struct used for communication stop
* \~english (transfer data from CANIF API to CAN)
*/
@@ -767,7 +677,7 @@ typedef struct {
/**
* \~english Header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ T_APIMSG_MSGBUF_HEADER_COMM hdr;
/**
* \~english Data
*/
@@ -801,7 +711,7 @@ typedef struct {
/**
* \~english Header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ T_APIMSG_MSGBUF_HEADER_COMM hdr;
/**
* \~english Data
*/
@@ -815,7 +725,7 @@ typedef struct {
/**
* \~english Header
*/
-// T_APIMSG_MSGBUF_HEADER_COMM stHead;
+ T_APIMSG_MSGBUF_HEADER_COMM stHead;
/**
* \~english Data
*/
@@ -960,62 +870,6 @@ CANIF_RET_API Canif_DeliveryEntry(HANDLE h_app, PCSTR notify_name,
uint8_t can_num, CANID *p_can_id);
/*******************************************************************************
- * MODULE : Canif_Diag_CWORD29_DeliveryEntry
- ******************************************************************************/
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_Diag_CWORD29_DeliveryEntry
-/// \~english @par Brief
-/// Delivery registration of _CWORD29_data
-/// \~english @param [in] h_app
-/// const HANDLE - Handle for application
-/// \~english @param [in] notify_name
-/// const PCSTR - Delivery target thread name
-/// \~english @param [in] opc_num
-/// const uint8_t - Number of delivery registration OPC
-/// \~english @param [in] p_opc
-/// const uint16_t* const - Pointer of delivery registration OPC array
-/// \~english @retval CANIF_RET_NORMAL Normality
-/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
-/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
-/// \~english @par Prerequisite
-/// None
-/// \~english @par Change of internal state
-/// - Change of internal state according to the API does not occur
-/// \~english @par Conditions of processing failure
-/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
-/// - notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
-/// [CANIF_RET_ERROR_PARAM]
-/// - opc_num is 0.[CANIF_RET_ERROR_PARAM]
-/// - OPC pointer is null.[CANIF_RET_ERROR_PARAM]
-/// - malloc failed to get the message queue management information area
-/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - malloc failed to get the message queue name storage area for
-/// transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - mq_open failed to open the message queue for transmission
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - The session message queue to communication service is full.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - The transmission file descriptor of the session
-/// message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
-/// - The interruption by the system call (signal) occurred while
-/// transmitting the session message to communication service.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - Any error occurred in the transmission of the session message
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - It failed to access to the shared memory for the transmission of
-/// session message to communication service. [CANIF_RET_ERROR_CANCEL]
-/// \~english @par Classification
-/// Public
-/// \~english @par Type
-/// Sync
-/// \~english @par Detail
-/// - Delivery registration of _CWORD29_data. \n
-/// \~english @see None
-////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_Diag_CWORD29_DeliveryEntry(const HANDLE h_app, const PCSTR notify_name,
- const uint8_t opc_num, const uint16_t* const p_opc);
-
-/*******************************************************************************
* MODULE : Canif_TransmissionStart
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
@@ -1046,6 +900,8 @@ CANIF_RET_API Canif_Diag_CWORD29_DeliveryEntry(const HANDLE h_app, const PCSTR n
/// - Transmission data pointer is null.[CANIF_RET_ERROR_PARAM]
/// - DLC size is bigger than 8 bytes.[CANIF_RET_ERROR_PARAM]
/// - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
+/// - CAN ID is not defined in the _CWORD108_ bit asignment table
+/// [CANIF_RET_ERROR_PARAM]
/// - malloc failed to get the message queue management information area
/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
/// - malloc failed to get the message queue name storage area for
@@ -1075,122 +931,6 @@ CANIF_RET_API Canif_TransmissionStart(HANDLE h_app, PCSTR notify_name,
uint8_t rid, uint16_t freq, CAN_DATA *p_data);
/*******************************************************************************
- * MODULE : Canif_TransmissionStop
- ******************************************************************************/
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_TransmissionStop
-/// \~english @par Brief
-/// CAN data regular transmission stop
-/// \~english @param [in] h_app
-/// HANDLE - Handle for application
-/// \~english @param [in] notify_name
-/// PCSTR - Delivery target thread name
-/// \~english @param [in] can_id
-/// CANID - CAN ID
-/// \~english @retval CANIF_RET_NORMAL Normality
-/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
-/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
-/// \~english @par Prerequisite
-/// None
-/// \~english @par Change of internal state
-/// - Change of internal state according to the API does not occur
-/// \~english @par Conditions of processing failure
-/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
-/// -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
-/// [CANIF_RET_ERROR_PARAM]
-/// - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
-/// - malloc failed to get the message queue management information area
-/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - malloc failed to get the message queue name storage area for
-/// transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - mq_open failed to open the message queue for transmission
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - The session message queue to communication service is full.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - The transmission file descriptor of the session
-/// message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
-/// - The interruption by the system call (signal) occurred while
-/// transmitting the session message to communication service.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - Any error occurred in the transmission of the session message
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - It failed to access to the shared memory for the transmission of
-/// session message to communication service. [CANIF_RET_ERROR_CANCEL]
-/// \~english @par Classification
-/// Public
-/// \~english @par Type
-/// Sync
-/// \~english @par Detail
-/// - CAN data regular transmission stop. \n
-/// \~english @see None
-////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_TransmissionStop(HANDLE h_app, PCSTR notify_name, CANID can_id);
-
-/*******************************************************************************
- * MODULE : Canif_Diag_CWORD29_Transmission
- ******************************************************************************/
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_Diag_CWORD29_Transmission
-/// \~english @par Brief
-/// Transmission of CAN data (_CWORD29_) transmission
-/// \~english @param [in] h_app
-/// HANDLE - Handle for application
-/// \~english @param [in] notify_name
-/// PCSTR - Delivery target thread name
-/// \~english @param [in] opc
-/// const uint16_t - OPC
-/// \~english @param [in] rid
-/// uint8_t - Resource ID
-/// \~english @param [in] data_size
-/// uint32_t - Data size
-/// \~english @param [in] p_data
-/// uint8_t* - Pointer of transmission data
-/// \~english @retval CANIF_RET_NORMAL Normality
-/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
-/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
-/// \~english @par Prerequisite
-/// None
-/// \~english @par Change of internal state
-/// - Change of internal state according to the API does not occur
-/// \~english @par Conditions of processing failure
-/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
-/// -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
-/// [CANIF_RET_ERROR_PARAM]
-/// - Transmission data pointer is null.[CANIF_RET_ERROR_PARAM]
-/// - DLC size is bigger than 8 bytes.[CANIF_RET_ERROR_PARAM]
-/// - malloc failed to get the message queue management information area
-/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - malloc failed to get the message queue name storage area for
-/// transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - mq_open failed to open the message queue for transmission
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - The session message queue to communication service is full.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - The transmission file descriptor of the session
-/// message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
-/// - The interruption by the system call (signal) occurred while
-/// transmitting the session message to communication service.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - Any error occurred in the transmission of the session message
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - It failed to access to the shared memory for the transmission of
-/// session message to communication service. [CANIF_RET_ERROR_CANCEL]
-/// \~english @par Classification
-/// Public
-/// \~english @par Type
-/// ASync
-/// \~english @par Detail
-/// - Transmission of CAN data (_CWORD29_) transmission notification. \n
-/// \~english @see None
-////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_Diag_CWORD29_Transmission(HANDLE h_app,
- PCSTR notify_name,
- const uint16_t opc,
- uint8_t rid,
- uint32_t data_size,
- uint8_t *p_data);
-
-/*******************************************************************************
* MODULE : Canif_CommandCtrl
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
@@ -1329,6 +1069,8 @@ CANIF_RET_API Canif_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id,
/// - CAN ID is NULL.[CANIF_RET_ERROR_PARAM]
/// - Mask Data is NULL.[CANIF_RET_ERROR_PARAM]
/// - Transmission Data is NULL.[CANIF_RET_ERROR_PARAM]
+/// - CAN ID is not defined in the _CWORD108_ bit asignment table
+/// [CANIF_RET_ERROR_PARAM]
/// - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
/// - malloc failed to get the message queue management information area
/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
@@ -1359,107 +1101,13 @@ CANIF_RET_API Canif_TransStart(HANDLE h_app, CANID can_id, CAN_DATA_MASK *mask,
CAN_DATA_BIT *dat, uint32_t freq);
////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_TransStop
-/// \~english @par Brief
-/// Stop periodic transmission of CAN Command
-/// \~english @param [in] h_app
-/// HANDLE - Handle for application
-/// \~english @param [in] can_id
-/// CANID - CAN ID
-/// \~english @retval CANIF_RET_NORMAL Normality
-/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
-/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
-/// \~english @par Prerequisite
-/// None
-/// \~english @par Change of internal state
-/// - Change of internal state according to the API does not occur
-/// \~english @par Conditions of processing failure
-/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
-/// - can_id is NULL.[CANIF_RET_ERROR_PARAM]
-/// - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
-/// - malloc failed to get the message queue management information area
-/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - malloc failed to get the message queue name storage area for
-/// transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - mq_open failed to open the message queue for transmission
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - The session message queue to communication service is full.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - The transmission file descriptor of the session
-/// message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
-/// - The interruption by the system call (signal) occurred while
-/// transmitting the session message to communication service.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - Any error occurred in the transmission of the session message
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - It failed to access to the shared memory for the transmission of
-/// session message to communication service. [CANIF_RET_ERROR_CANCEL]
-/// \~english @par Classification
-/// Public
-/// \~english @par Type
-/// Sync
-/// \~english @par Detail
-/// - Stop periodic Transmission of CAN Command API. \n
-/// \~english @see None
-////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_TransStop(HANDLE h_app, CANID can_id);
-
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_Send
-/// \~english @par Brief
-/// Transmission CAN Command(for OpeningMovie)
-/// \~english @param [in] can_id
-/// CANID - CAN ID
-/// \~english @param [in] mask
-/// CAN_DATA_MASK* - Mask Data
-/// \~english @param [in] dat
-/// CAN_DATA_BIT* - Transmission Data
-/// \~english @retval CANIF_RET_NORMAL Normality
-/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
-/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
-/// \~english @par Prerequisite
-/// None
-/// \~english @par Change of internal state
-/// - Change of internal state according to the API does not occur
-/// \~english @par Conditions of processing failure
-/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
-/// - Mask Data is NULL.[CANIF_RET_ERROR_PARAM]
-/// - Transmission Data is NULL.[CANIF_RET_ERROR_PARAM]
-/// - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
-/// - malloc failed to get the message queue management information area
-/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - malloc failed to get the message queue name storage area for
-/// transmission to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - mq_open failed to open the message queue for transmission
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - The session message queue to communication service is full.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - The transmission file descriptor of the session
-/// message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
-/// - The interruption by the system call (signal) occurred while
-/// transmitting the session message to communication service.
-/// [CANIF_RET_ERROR_CANCEL]
-/// - Any error occurred in the transmission of the session message
-/// to communication service. [CANIF_RET_ERROR_CANCEL]
-/// - It failed to access to the shared memory for the transmission of
-/// session message to communication service. [CANIF_RET_ERROR_CANCEL]
-/// \~english @par Classification
-/// Public
-/// \~english @par Type
-/// ASync
-/// \~english @par Detail
-/// - CAN Command Send API. \n
-/// \~english @see None
-////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_Send(CANID can_id, CAN_DATA_MASK *mask, CAN_DATA_BIT *dat);
-
-#ifdef CAN_DEBUG
-////////////////////////////////////////////////////////////////////////////////
-/// \ingroup Canif_Debug_Delete_AllDeliveryEntryList
+/// \ingroup Canif_DeliveryEraseAll
/// \~english @par Brief
/// Delete all delivery entry
/// \~english @param [in] h_app
/// HANDLE - Handle for application
+/// \~english @param [in] notify_name
+/// PCSTR - Delivery target thread name
/// \~english @retval CANIF_RET_NORMAL Normality
/// \~english @retval CANIF_RET_ERROR_PARAM Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL Abnormal termination
@@ -1469,6 +1117,8 @@ CANIF_RET_API Canif_Send(CANID can_id, CAN_DATA_MASK *mask, CAN_DATA_BIT *dat);
/// - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
/// - h_app is NULL.[CANIF_RET_ERROR_PARAM]
+/// -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
+/// [CANIF_RET_ERROR_PARAM]
/// - malloc failed to get the message queue management information area
/// for transmission to communication service. [CANIF_RET_ERROR_CANCEL]
/// - malloc failed to get the message queue name storage area for
@@ -1494,8 +1144,7 @@ CANIF_RET_API Canif_Send(CANID can_id, CAN_DATA_MASK *mask, CAN_DATA_BIT *dat);
/// - Delete all delivery entry. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
-CANIF_RET_API Canif_Debug_Delete_AllDeliveryEntryList(HANDLE h_app);
-#endif
+CANIF_RET_API Canif_DeliveryEraseAll(HANDLE h_app, PCSTR notify_name);
/** @}*/ // end of CAN
/** @}*/ // end of communication
diff --git a/communication/client_can/include/peripheral_service/communication_can.h b/communication/client_can/include/peripheral_service/communication_can.h
index 59cc1bd2..8b6119a2 100644
--- a/communication/client_can/include/peripheral_service/communication_can.h
+++ b/communication/client_can/include/peripheral_service/communication_can.h
@@ -1,5 +1,5 @@
//
-// @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION.
+// @copyright Copyright (c) 2017-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.
diff --git a/communication/client_can/libCAN_API.ver b/communication/client_can/libCAN_API.ver
index ede5fcac..47e5e866 100644
--- a/communication/client_can/libCAN_API.ver
+++ b/communication/client_can/libCAN_API.ver
@@ -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.
@@ -21,16 +21,14 @@
global:
### .text section ###
Canif_DeliveryEntry;
+ Canif_DeliveryEraseAll;
Canif_TransmissionStart;
Canif_TransmissionStop;
- Canif_Diag_CWORD29_Transmission;
- Canif_SetMultiID_Interval;
Canif_CommandCtrl;
Canif_CommWatch;
Canif_TransStart;
Canif_TransStop;
Canif_Send;
- Canif_Debug_Delete_AllDeliveryEntryList;
### .data section ###
local:
*;
diff --git a/communication/client_can/src/Canif_API.cpp b/communication/client_can/src/Canif_API.cpp
index 9adce907..499d187e 100644
--- a/communication/client_can/src/Canif_API.cpp
+++ b/communication/client_can/src/Canif_API.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.
@@ -13,840 +13,289 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*******************************************************************************
- * SYSTEM :_CWORD107_
- * Module configuration :Canif_DeliveryEntry() CANDataDelivery registration process
- * Canif_TransmissionStart() CANDataTransmission start processing
- * Canif_TransmissionStop() CANDataPeriodic transmission stop processing
- * Canif_CommWatch() CANDataCommunication interruption monitoring processing (deprecated)
- * Canif_CommandCtrl() CAN command control processing
- * CanifMsgHeaderGenerate() Message header creation process
- * CanifSndMsg() Message transmission processing
- * Canif_CommWatchExt() CANDataCommunication interruption monitoring process
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @file Canif_API.cpp
- * @~english
- * @brief CAN I/F API module
- *----------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
-#include <other_service/strlcpy.h>
-
#include <native_service/frameworkunified_framework_if.h>
-
#include <peripheral_service/Canif_API.h>
+
+#include "API_Local_Common.h"
#include "Canif_API_Local.h"
+#include "Canif_TransmissionData.h"
#include "com_error_type.h"
-static __thread HANDLE g_hdl = NULL;
-static __thread HANDLE g_mchdl = NULL;
-
-CANIF_RET_API Canif_CWORD29_TransmissionCore(HANDLE h_app, PCSTR notify_name, const uint16_t opc,
- uint8_t rid, uint32_t data_size, uint8_t *p_data);
-
-#define NOTIFY_NAME_MAX_SIZE 15
-/*******************************************************************************
- * MODULE : Canif_DeliveryEntry
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Delivery registration of CAN data
- *
- * @~english
- * Delivery registration of CAN data
- *
- * @~english
- * @note Details of process
- * -# CNAID registration number check
- * -# Delivery CAN ID check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <notifyId> Snd ID
- * @param[in] <can_num> Number of delivery registration CAN ID
- * @param[in] <*p_can_id> Pointer of delivery registration CAN ID array
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_DeliveryEntry(HANDLE h_app, PCSTR notify_name, uint8_t can_num, CANID *p_can_id) {
- return CanifDeliveryEntryCore(h_app, notify_name, can_num, p_can_id, CID_CANIF_DELIVERY_ENTRY);
-}
-
-CANIF_RET_API CanifDeliveryEntryCore(HANDLE h_app, PCSTR notify_name, uint8_t can_num, CANID *p_can_id, uint16_t cid) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN_DELIVERY_ENTRY pst_delivery_entry; /* CANDataDelivery registration structure */
- int32_t i; /* Generic counters */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
-
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (p_can_id == reinterpret_cast<CANID *>(NULL)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- if (notify_name == (PCSTR)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (NOTIFY_NAME_MAX_SIZE < strlen(notify_name)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- /* Checking CNAID registrations*/
- if (((uint8_t)0 == can_num) || ((uint8_t)CAN_DELIVERY_CANID_ENTRY_MAX < can_num)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- for (i = 0; i < (int32_t)can_num; i++) {
- if (((CANID)CAN_ID_MASK_CODE & p_can_id[i]) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
- }
+static __thread HANDLE g_sender = NULL;
- /* Initialization of transmission data */
- memset(reinterpret_cast<void *>(&pst_delivery_entry), (int32_t)0x00, (size_t)sizeof(pst_delivery_entry));
+static EFrameworkunifiedStatus CanifMsgToSrv(HANDLE h, UI_32 cmd, size_t len, PCVOID data) {
+ if (data == NULL)
+ return eFrameworkunifiedStatusFail;
- /* Delivery registration information setting */
- snprintf(pst_delivery_entry.notifyName, sizeof(pst_delivery_entry.notifyName),
- "%s", notify_name); /* Destination thread name */
- pst_delivery_entry.usCanNum = (uint16_t)can_num; /* CAN ID count */
- memcpy(pst_delivery_entry.ulCanid, p_can_id, sizeof(CANID) * can_num); /* Contain the CAN ID */
+ if (len > UINT32_MAX)
+ return eFrameworkunifiedStatusFail;
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* Command delivery registration */
- e_status = FrameworkunifiedSendMsg(g_hdl, cid, sizeof(pst_delivery_entry), &pst_delivery_entry);
- 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
- l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ if (g_sender == NULL) {
+ g_sender = FrameworkunifiedMcOpenSender(h, LAN_SERVICE_CAN);
+ if (g_sender == NULL)
+ return eFrameworkunifiedStatusFail;
}
- return l_ret;
+ return FrameworkunifiedSendMsg(g_sender, cmd, (UI_32)len, data);
}
-/*******************************************************************************
- * MODULE : Canif_Diag_CWORD29_DeliveryEntry
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Delivery registration of Phse5data
- *
- * @~english
- * Delivery registration of _CWORD29_data
- *
- * @~english
- * @note Details of process
- * -# OPC registration number check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <PCSTR> Notification name
- * @param[in] <can_num> Number of delivery registration OPC
- * @param[in] <*p_can_id> Pointer of delivery registration OPC array
- */
-CANIF_RET_API Canif_Diag_CWORD29_DeliveryEntry(const HANDLE h_app, const PCSTR notify_name,
- const uint8_t opc_num, const uint16_t* const p_opc) {
- if (reinterpret_cast<HANDLE>(NULL) == h_app) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
+CANIF_RET_API Canif_DeliveryEntry(HANDLE h_app, PCSTR notify_name,
+ uint8_t can_num, CANID *p_can_id) {
- if (reinterpret_cast<uint16_t *>(NULL) == p_opc) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- if (reinterpret_cast<PCSTR>(NULL) == notify_name) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- if ((size_t)NOTIFY_NAME_MAX_SIZE < strnlen(notify_name, (size_t)NOTIFY_NAME_MAX_SIZE+(size_t)1)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- return Canif_CWORD29_DeliveryEntryCore(h_app, notify_name, opc_num, p_opc,
- static_cast<const uint16_t>(CID_CANIF__CWORD29__DELIVERY_ENTRY));
-}
-
-CANIF_RET_API Canif_CWORD29_DeliveryEntryCore(const HANDLE h_app, const PCSTR notify_name,
- const uint8_t opc_num, const uint16_t* const p_opc, const uint16_t cid) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN__CWORD29__DELIVERY_ENTRY pst_delivery_entry; /* _CWORD29_ data-delivery registry structures */
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
+ CAN_DELIVERY_ENTRY pst_delivery_entry;
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- size_t copysize;
-
- /* OPC registration number check*/
- if (static_cast<uint8_t>(0) == opc_num) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
+ PS_Communication_InternalProtocol cmd = CID_CANIF_DELIVERY_ENTRY;
+ void *tx = reinterpret_cast<void *>(&pst_delivery_entry);
+ size_t len = sizeof(pst_delivery_entry);
+ memset(tx, 0x0, len);
+ int32_t i;
- copysize = sizeof(uint16_t) * static_cast<const size_t>(opc_num);
+ if (NULL == h_app)
+ goto cleanup;
- /* Initialization of transmission data */
- memset(reinterpret_cast<void *>(&pst_delivery_entry), (int32_t)0x00,
- static_cast<size_t>(sizeof(CAN__CWORD29__DELIVERY_ENTRY)));
+ if (NULL == p_can_id)
+ goto cleanup;
- /* Delivery registration information setting */
- snprintf(reinterpret_cast<char *>(pst_delivery_entry.notifyName), (size_t)MAX_NAME_SIZE_APP,
- "%s", reinterpret_cast<const char *>(notify_name)); /* Destination thread name */
- pst_delivery_entry.usOpcNum = static_cast<uint16_t>(opc_num); /* Number of OPCs */
- memcpy(reinterpret_cast<void *>(pst_delivery_entry.usOpc), reinterpret_cast<const void *>(p_opc),
- copysize); /* Install OPC */
+ if (!Canif_CheckNotifyName(notify_name))
+ goto cleanup;
- if (reinterpret_cast<HANDLE>(NULL) == g_hdl) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* Command delivery registration */
- e_status = FrameworkunifiedSendMsg(g_hdl, static_cast<UI_32>(cid), sizeof(CAN__CWORD29__DELIVERY_ENTRY),
- reinterpret_cast<void *>(&pst_delivery_entry));
- if (eFrameworkunifiedStatusOK != e_status) {
- l_ret = CANIF_RET_ERROR_CANCEL;
- } else {
- l_ret = CANIF_RET_NORMAL;
- }
- return l_ret;
-}
+ if (0 == can_num)
+ goto cleanup;
-/*******************************************************************************
- * MODULE : Canif_TransmissionStart
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data transmission starting
- *
- * @~english
- * The transmission of the CAN data starts(Regular/One)
- *
- * @~english
- * @note Details of process
- * -# DLC check
- * -# CAN ID check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <notifyId>Snd ID
- * @param[in] <rid> Resource ID for CAN data transmission result notification
- * @param[in] <freq> Cycle of regular transmission
- * @param[in] <*p_data> Pointer of transmission data
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_TransmissionStart(HANDLE h_app, PCSTR notify_name, uint8_t rid, uint16_t freq, CAN_DATA *p_data) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN_TRANSMISSION_START_MSG_DAT pst_transmission_start; /* CANDataSending structure */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ if (CAN_DELIVERY_CANID_ENTRY_MAX < can_num)
+ goto cleanup;
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (p_data == reinterpret_cast<CAN_DATA *>(NULL)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (rid != (uint8_t)0xff) {
- if (notify_name == (PCSTR)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (NOTIFY_NAME_MAX_SIZE < strlen(notify_name)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- }
-
- /* DLC check*/
- if ((uint8_t)CAN_TXDATA_SIZE < (p_data->dlc)) { /* Is the DLC over the transmission data size? */
- return CANIF_RET_ERROR_PARAM;
- }
- /* CAN ID checking */
- if (((CANID)CAN_ID_MASK_CODE & p_data->can_id) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
-
- /* CANDataInitialization of transmission start information */
- memset(reinterpret_cast<void *>(&pst_transmission_start), (int32_t)0x00, (size_t)sizeof(pst_transmission_start));
-
- /* CANDataTransmission start information setting */
- if (rid != (uint8_t)0xff) {
- snprintf(pst_transmission_start.notifyName, sizeof(pst_transmission_start.notifyName),
- "%s", notify_name); /* Destination thread name */
- } else {
- snprintf(pst_transmission_start.notifyName, sizeof(pst_transmission_start.notifyName), "%s", "");
+ for (i = 0; i < (int32_t)can_num; i++) {
+ if (!Canif_CheckCanID(p_can_id[i]))
+ goto cleanup;
}
- pst_transmission_start.ucRid = rid; /* Resources ID */
- pst_transmission_start.usFreq = freq; /* Periodic transmission cycle */
- memcpy(reinterpret_cast<void *>(&pst_transmission_start.stCandata),
- reinterpret_cast<int8_t *>(p_data), (size_t)sizeof(CAN_DATA)); /* CANData */
-
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
+ Canif_CopyNotifyName(pst_delivery_entry.notifyName, notify_name);
+ pst_delivery_entry.usCanNum = (uint16_t)can_num;
+ memcpy(pst_delivery_entry.ulCanid, p_can_id, sizeof(CANID) * can_num);
- /* CAN data transmission start */
- e_status = FrameworkunifiedSendMsg(g_hdl, CID_CANIF_TX_START, sizeof(pst_transmission_start), &pst_transmission_start);
- 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
+ e_status = CanifMsgToSrv(h_app, cmd, len, tx);
+ if (e_status != eFrameworkunifiedStatusOK) {
l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ goto cleanup;
}
+
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
return l_ret;
}
-/*******************************************************************************
- * MODULE : Canif_TransmissionStop
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data regular transmission stop
- *
- * @~english
- * CAN data regular transmission stop
- *
- * @~english
- * @note Details of process
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Event generation failure
- *
- * @~english
- * @param[in] <notifyId>Snd ID
- * @param[in] <can_id> CAN ID
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_TransmissionStop(HANDLE h_app, PCSTR notify_name, CANID can_id) {
- return CanifTransmissionStopCore(h_app, notify_name, can_id, CID_CANIF_TX_STOP);
-}
+CANIF_RET_API Canif_TransmissionStart(HANDLE h_app, PCSTR notify_name,
+ uint8_t rid, uint16_t freq, CAN_DATA *p_data) {
-CANIF_RET_API CanifTransmissionStopCore(HANDLE h_app, PCSTR notify_name, CANID can_id, uint16_t cid) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN_FREQ_TRANS_STOP_MSG_DAT pst_freq_trans_stop; /* CANDataPeriodic transmission stop structure */
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
+ CAN_TRANSMISSION_START_MSG_DAT pst_transmission_start;
+ PS_Communication_InternalProtocol cmd = CID_CANIF_TX_START;
+ void *tx = reinterpret_cast<void *>(&pst_transmission_start);
+ size_t len = sizeof(pst_transmission_start);
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ PCSTR _notify_name = notify_name;
+ memset(tx, 0x0, len);
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- /* CAN ID checking */
- if (((CANID)CAN_ID_MASK_CODE & can_id) != 0) {
- /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
+ if (h_app == NULL)
+ goto cleanup;
- if (notify_name == (PCSTR)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (NOTIFY_NAME_MAX_SIZE < strlen(notify_name)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- /* CANDataInitialization of periodic transmission stop information */
- memset(reinterpret_cast<void *>(&pst_freq_trans_stop), (int32_t)0x00, (size_t)sizeof(pst_freq_trans_stop));
-
- /* CANDataPeriodic transmission stop information setting */
- snprintf(pst_freq_trans_stop.notifyName, sizeof(pst_freq_trans_stop.notifyName),
- "%s", notify_name); /* Destination thread name */
- pst_freq_trans_stop.ulCanid = can_id; /* CAN ID */
+ if (p_data == NULL)
+ goto cleanup;
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* CAN data transmission start */
- e_status = FrameworkunifiedSendMsg(g_hdl, cid, sizeof(pst_freq_trans_stop), &pst_freq_trans_stop);
- 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
- l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ if (rid == 0xFF) {
+ _notify_name = ""; // using dummy name;
}
- return l_ret;
-}
-/*******************************************************************************
- * MODULE : Canif_CommWatch
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data regular transmission stop
- *
- * @~english
- * CAN data regular transmission stop
- *
- * @~english
- * @note Details of process
- * -# Parameter check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <pid> Thread ID
- * @param[in] <can_id> CAN ID
- * @param[in] <did> Data ID
- * @param[in] <watch_time> Communication watch suspension time(Unit of 100ms)
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id, DID did, uint16_t watch_time) {
- return CanifCommWatchCore(h_app, notify_name, can_id, did, CAN_IG_COOPERATION_OFF, watch_time, CID_CANIF_COMM_WATCH);
-}
+ if (!Canif_CheckNotifyName(_notify_name))
+ goto cleanup;
-/*******************************************************************************
- * MODULE : Canif_CommandCtrl
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN command control
- *
- * @~english
- * Transmission control of CAN command
- *
- * @~english
- * @note Details of process
- * -# Parameter check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <notifyId> Snd ID
- * @param[in] <rid> Resource ID
- * @param[in] <cmd_id> CAN command ID(32bit)
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_CommandCtrl(HANDLE h_app, PCSTR notify_name, uint8_t rid, uint32_t cmd_id) {
- /* Parameter anomaly check */
- if (((uint8_t)CAN_CMDID_FUELCALC_RST_REQ_DELIVERY != (uint8_t)cmd_id) && /* Request for delivery of request for flame reset in CAN section */
- ((uint8_t)CAN_CMDID_STARTUP_FIN_REQ_TX != (uint8_t)cmd_id) && /* CAN start completion notification request transmission */
- ((uint8_t)CAN_CMDID_MRST_INFO_REQ_TX != (uint8_t)cmd_id) && /* CAN master reset information notification request transmission */
- ((uint8_t)CAN_CMDID_VERSION_REQ_TX != (uint8_t)cmd_id) && /* CAN Version Request Send */
- ((uint8_t)CAN_CMDID_CONNECTION_NODE_REQ_TX != (uint8_t)cmd_id) && /* CAN connection node notification request transmission */
- ((uint8_t)CAN_CMDID_FUELCALC_REQ_TX != (uint8_t)cmd_id)) { /* CAN section flame reset response transmission */
- return CANIF_RET_ERROR_PARAM; /* CAN Thread-> When it is not a CAN command to be sent to the SYS microcomputer */
- }
-
- return CanifCommandCtrlCore(h_app, notify_name, rid, cmd_id, CID_CANIF_CMD_CTRL);
-}
-
-CANIF_RET_API CanifCommandCtrlCore(HANDLE h_app, PCSTR notify_name, uint8_t rid, uint32_t cmd_id, uint16_t cid) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN_CMD_CTRL_MSG_DAT pst_cmd_ctrl_msg; /* CAN command control message data structure */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ if (CAN_TXDATA_SIZE < (p_data->dlc))
+ goto cleanup;
- /* Initialization of CAN command control information */
- memset(reinterpret_cast<void *>(&pst_cmd_ctrl_msg), (int32_t)0x00, (size_t)sizeof(pst_cmd_ctrl_msg));
+ if (!Canif_CheckCanID(p_data->can_id))
+ goto cleanup;
- if (h_app == (HANDLE)NULL) {
- /* Parameter error */
- return CANIF_RET_ERROR_PARAM;
- }
- if (rid != 0xFF) {
- if (notify_name == (PCSTR)NULL) {
- /* Parameter error */
- return CANIF_RET_ERROR_PARAM;
- }
- if (NOTIFY_NAME_MAX_SIZE < strlen(notify_name)) {
- /* Parameter error */
- return CANIF_RET_ERROR_PARAM;
- }
- }
-
- /* Setting CAN command control information */
- snprintf(pst_cmd_ctrl_msg.notifyName, sizeof(pst_cmd_ctrl_msg.notifyName),
- "%s", notify_name); /* Destination thread name */
- pst_cmd_ctrl_msg.ucRid = rid; /* Resources ID */
- pst_cmd_ctrl_msg.ucCmdid = (uint8_t)cmd_id; /* CAN command ID */
-
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
-
- /* CAN data transmission start */
- e_status = FrameworkunifiedSendMsg(g_hdl, cid, sizeof(pst_cmd_ctrl_msg), &pst_cmd_ctrl_msg);
- 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
+ if (!Canif_InitDataIsDefined21PF(p_data->can_id))
+ goto cleanup;
+
+ Canif_CopyNotifyName(pst_transmission_start.notifyName, _notify_name);
+ pst_transmission_start.ucRid = rid;
+ pst_transmission_start.usFreq = freq;
+ memcpy(reinterpret_cast<void *>(&pst_transmission_start.stCandata),
+ reinterpret_cast<int8_t *>(p_data), (size_t)sizeof(CAN_DATA));
+ e_status = CanifMsgToSrv(h_app, cmd, len, tx);
+ if (e_status != eFrameworkunifiedStatusOK) {
l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ goto cleanup;
}
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
return l_ret;
}
-CANIF_RET_API CanifCommWatchCore(HANDLE h_app, PCSTR notify_name, CANID can_id, DID did,
- uint8_t ig_cooperation, uint16_t watch_time, uint16_t cid) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN_COMM_WATCHEXT_MSG_DAT pst_comm_watch_msg; /* CANDataCommunication disruption registration structure */
+CANIF_RET_API Canif_CommandCtrl(HANDLE h_app, PCSTR notify_name, uint8_t rid,
+ uint32_t cmd_id) {
+
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
+ CAN_CMD_CTRL_MSG_DAT pst_cmd_ctrl_msg;
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ PS_Communication_InternalProtocol cmd = CID_CANIF_CMD_CTRL;
+ void *tx = reinterpret_cast<void *>(&pst_cmd_ctrl_msg);
+ size_t len = sizeof(pst_cmd_ctrl_msg);
+ PCSTR _notify_name = notify_name;
+ memset(tx, 0x0, len);
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (notify_name == (PCSTR)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
- if (NOTIFY_NAME_MAX_SIZE < strlen(notify_name)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
+ if (!Canif_IsCommand(cmd_id))
+ goto cleanup;
+
+ if (h_app == NULL)
+ goto cleanup;
- /* Parameter anomaly check */
- if (((CANID)CAN_ID_MASK_CODE & can_id) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
+ if (rid == 0xFF) {
+ _notify_name = ""; // using dummy name;
}
- /* CANDataInitialization of communication disruption monitoring information */
- memset(reinterpret_cast<void *>(&pst_comm_watch_msg), (int32_t)0x00, (size_t)sizeof(pst_comm_watch_msg));
+ if (!Canif_CheckNotifyName(_notify_name))
+ goto cleanup;
- /* CANDataSetting of communication interruption monitoring information */
- strlcpy(pst_comm_watch_msg.notifyName, notify_name, sizeof(pst_comm_watch_msg.notifyName)); /* Destination thread name */
- pst_comm_watch_msg.ulCanid = can_id; /* CAN ID */
- pst_comm_watch_msg.ulDid = did; /* Data ID */
- pst_comm_watch_msg.ucIg = ig_cooperation; /* IG linkage */
- pst_comm_watch_msg.usWatchTime = watch_time; /* Communication interruption monitoring time (in units of 100ms) */
+ Canif_CopyNotifyName(pst_cmd_ctrl_msg.notifyName, _notify_name);
+ pst_cmd_ctrl_msg.ucRid = rid;
+ pst_cmd_ctrl_msg.ucCmdid = (uint8_t)cmd_id;
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* CANDataCommunication disruption monitoring */
- e_status = FrameworkunifiedSendMsg(g_hdl, cid, sizeof(pst_comm_watch_msg), &pst_comm_watch_msg);
- 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
+ e_status = CanifMsgToSrv(h_app, cmd, len, tx);
+ if (e_status != eFrameworkunifiedStatusOK) {
l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ goto cleanup;
}
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
return l_ret;
}
-/*******************************************************************************
- * MODULE : Canif_Diag_CWORD29_Transmission
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Transmission of CAN data (_CWORD29_) transmission notification
- *
- * @~english
- * Transmission of CAN data (_CWORD29_) transmission notification
- *
- * @~english
- * @note Details of process
- * -# Maximum check
- * -# CAN ID check
- * -# Creation of event
- * -# Message sending to CAN
- * -# Result notification event receive
- * -# Deletion of event
- *
- * @~english
- * @return Normality/Abnormality
- * @retval <CANIF_RET_NORMAL> Normality
- * @retval <CANIF_RET_ERROR_PARAM> Abnormality of parameter
- * @retval <CANIF_RET_ERROR_BUFFULL> Buffer fully
- * @retval <CANIF_RET_ERROR_CREATE_EVENT> Failure of event create
- *
- * @~english
- * @param[in] <notifyId> Snd ID
- * @param[in] <opc> OPC
- * @param[in] <rid> Resource ID
- * @param[in] <data_size> Data size
- * @param[in] <*p_data> Pointer of transmission data
- */
-CANIF_RET_API Canif_Diag_CWORD29_Transmission(HANDLE h_app, PCSTR notify_name, const uint16_t opc,
- uint8_t rid, uint32_t data_size, uint8_t *p_data) {
- return Canif_CWORD29_TransmissionCore(h_app, notify_name, opc, rid, data_size, p_data);
-}
+CANIF_RET_API Canif_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id,
+ DID did, uint16_t watch_time) {
-CANIF_RET_API Canif_CWORD29_TransmissionCore(HANDLE h_app, PCSTR notify_name, const uint16_t opc,
- uint8_t rid, uint32_t data_size, uint8_t *p_data) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL; /* Return value of this function */
- CAN__CWORD29__TRANS_MSG pst__CWORD29__trans; /* CANDataPointer to the send structure */
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
+ CAN_COMM_WATCHEXT_MSG_DAT pst_comm_watch_msg;
+ PS_Communication_InternalProtocol cmd = CID_CANIF_COMM_WATCH;
+ void *tx = reinterpret_cast<void *>(&pst_comm_watch_msg);
+ size_t len = sizeof(pst_comm_watch_msg);
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ memset(tx, 0x0, len);
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
-
- if (rid != 0xFF) {
- if (notify_name == (PCSTR)NULL) {
- return CANIF_RET_ERROR_PARAM;
- }
-
- if (strlen(const_cast<char *>(notify_name)) > NOTIFY_NAME_MAX_SIZE) {
- return CANIF_RET_ERROR_PARAM;
- }
- }
-
- if (p_data == reinterpret_cast<uint8_t *>(NULL)) {
- return CANIF_RET_ERROR_PARAM; /* Parameter error */
- }
+ if (h_app == NULL)
+ goto cleanup;
- /* Maximum Size Check */
- if (CAN__CWORD29__MEM_SZ < data_size) {
- return CANIF_RET_ERROR_PARAM;
- }
+ if (!Canif_CheckNotifyName(notify_name))
+ goto cleanup;
- /* CANDataInitialization of transmission start information */
- memset(reinterpret_cast<void *>(&pst__CWORD29__trans), (int32_t)0x00, (size_t)sizeof(pst__CWORD29__trans));
+ if (!Canif_CheckCanID(can_id))
+ goto cleanup;
- /* CANDataTransmission start information setting */
- if (rid != (uint8_t)0xff) {
- snprintf(pst__CWORD29__trans.notifyName, sizeof(pst__CWORD29__trans.notifyName), "%s", notify_name);
- } else {
- snprintf(pst__CWORD29__trans.notifyName, sizeof(pst__CWORD29__trans.notifyName), "%s", "");
- }
+ Canif_CopyNotifyName(pst_comm_watch_msg.notifyName, notify_name);
+ pst_comm_watch_msg.ulCanid = can_id;
+ pst_comm_watch_msg.ulDid = did;
+ pst_comm_watch_msg.ucIg = CAN_IG_COOPERATION_OFF;
+ pst_comm_watch_msg.usWatchTime = watch_time;
- pst__CWORD29__trans.ucRid = rid; /* Resources ID */
- pst__CWORD29__trans.ulDataSize = data_size;
- pst__CWORD29__trans.opc = opc;
- memcpy(reinterpret_cast<void *>(&pst__CWORD29__trans.data), reinterpret_cast<int8_t *>(p_data), data_size);
-
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
-
- /* CAN data transmission start */
- e_status = FrameworkunifiedSendMsg(g_hdl, CID_CANIF__CWORD29__TX_START, sizeof(pst__CWORD29__trans), &pst__CWORD29__trans);
+ e_status = CanifMsgToSrv(h_app, cmd, len, tx);
if (e_status != eFrameworkunifiedStatusOK) {
l_ret = CANIF_RET_ERROR_CANCEL;
- } else {
- l_ret = CANIF_RET_NORMAL;
+ goto cleanup;
}
+
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
return l_ret;
}
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Transmission CAN Command
- *
- * @~english
- * Start Transmission CAN Command API
- *
- * @~english
- * @return Return value
- * @retval <CANIF_RET_NORMAL> OK
- * @retval <CANIF_RET_ERROR_CANCEL> Abnormal termination
- * @retval <CANIF_RET_ERROR_PARAM> Parameter Error
- *
- * @~english
- * @param[in] <h_app> Application handle
- * @param[in] <can_id> CAN ID
- * @param[in] <mask> Mask Data
- * @param[in] <dat> Transmission Data
- * @param[in] <freq> Transmission Cycle
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_TransStart(HANDLE h_app, CANID can_id, CAN_DATA_MASK *mask, CAN_DATA_BIT *dat, uint32_t freq) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL;
+CANIF_RET_API Canif_TransStart(HANDLE h_app, CANID can_id,
+ CAN_DATA_MASK *mask, CAN_DATA_BIT *dat, uint32_t freq) {
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
CAN_TRANS_START_MSG_DAT pst_trans_start;
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ PS_Communication_InternalProtocol cmd = CID_CANIF_TX_BIT_START;
+ void *tx = reinterpret_cast<void *>(&pst_trans_start);
+ size_t len = sizeof(pst_trans_start);
+ memset(tx, 0x0, len);
- /* Check parameter */
- if (h_app == (HANDLE)NULL || can_id == (CANID)NULL || mask == reinterpret_cast<CAN_DATA_MASK *>(NULL) ||
- dat == reinterpret_cast<CAN_DATA_BIT *>(NULL) || (uint32_t)0xFFFF < freq) {
- return CANIF_RET_ERROR_PARAM;
- }
- if (((CANID)CAN_ID_MASK_CODE & can_id) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
+ if (h_app == NULL)
+ goto cleanup;
- memset(reinterpret_cast<void *>(&pst_trans_start), (int32_t)0x00, (size_t)sizeof(pst_trans_start));
+ if (!Canif_CheckCanID(can_id))
+ goto cleanup;
- /* Create Transmission Data */
- pst_trans_start.id = can_id; /* CAN ID */
- pst_trans_start.freq = freq; /* Transmission Interval */
- memcpy(&pst_trans_start.mask.dat, mask->dat, sizeof(mask->dat));
- memcpy(&pst_trans_start.dat.dat, dat->dat, sizeof(dat->dat));
+ if (!Canif_InitDataIsDefined21PF(can_id))
+ goto cleanup;
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
+ if (mask == NULL)
+ goto cleanup;
- /* Start CAN Data transmission */
- e_status = FrameworkunifiedSendMsg(g_hdl, CID_CANIF_TX_BIT_START, sizeof(pst_trans_start), &pst_trans_start);
- 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
- l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
- }
- return l_ret;
-}
+ if (dat == NULL)
+ goto cleanup;
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Stop periodic transmission of CAN Command
- *
- * @~english
- * Stop periodic Transmission of CAN Command API
- *
- * @~english
- * @return Return value
- * @retval <CANIF_RET_NORMAL> OK
- * @retval <CANIF_RET_ERROR_CANCEL> Abnormal termination
- * @retval <CANIF_RET_ERROR_PARAM> Parameter Error
- *
- * @~english
- * @param[in] <h_app> Application handle
- * @param[in] <can_id> CAN ID
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_TransStop(HANDLE h_app, CANID can_id) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ if (0xFFFF < freq)
+ goto cleanup;
- /* Check parameter */
- if (h_app == (HANDLE)NULL || can_id == (CANID)NULL) {
- return CANIF_RET_ERROR_PARAM;
- }
- if (((CANID)CAN_ID_MASK_CODE & can_id) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
+ pst_trans_start.id = can_id;
+ pst_trans_start.freq = freq;
+ memcpy(&pst_trans_start.mask.dat, mask->dat, sizeof(mask->dat));
+ memcpy(&pst_trans_start.dat.dat, dat->dat, sizeof(dat->dat));
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* Start CAN ID transmission */
- e_status = FrameworkunifiedSendMsg(g_hdl, CID_CANIF_TX_BIT_STOP, sizeof(CANID), &can_id);
- 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
+ e_status = CanifMsgToSrv(h_app, cmd, len, tx);
+ if (e_status != eFrameworkunifiedStatusOK) {
l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ goto cleanup;
}
+
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
return l_ret;
}
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Transmission CAN Command(for OpeningMovie)
- *
- * @~english
- * CAN Command Send API
- *
- * @~english
- * @return Return value
- * @retval <CANIF_RET_NORMAL> OK
- * @retval <CANIF_RET_ERROR_CANCEL> Abnormal termination
- * @retval <CANIF_RET_ERROR_PARAM> Parameter Error
- *
- * @~english
- * @param[in] <can_id> CAN ID
- * @param[in] <mask> Mask Data
- * @param[in] <dat> Transmission Data
- *----------------------------------------------------------------------------*/
-CANIF_RET_API Canif_Send(CANID can_id, CAN_DATA_MASK *mask, CAN_DATA_BIT *dat) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL;
- CAN_TRANS_START_MSG_DAT pst_trans_start;
+CANIF_RET_API Canif_DeliveryEraseAll(HANDLE h_app, PCSTR notify_name) {
+ CANIF_RET_API l_ret = CANIF_RET_ERROR_PARAM;
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ HANDLE handle[NUM_OF_CANIF_PROTOCOL];
+ int i = 0;
- /* Check parameter */
- if (can_id == (CANID)NULL || mask == NULL || dat == NULL) {
- return CANIF_RET_ERROR_PARAM;
+ for (i = 0; i < NUM_OF_CANIF_PROTOCOL; i++) {
+ handle[i] = NULL;
}
- if (((CANID)CAN_ID_MASK_CODE & can_id) != 0) { /* Parameter error when the upper 3 bits are set to numeric value */
- return CANIF_RET_ERROR_PARAM;
- }
-
- memset(reinterpret_cast<void *>(&pst_trans_start), (int32_t)0x00, (size_t)sizeof(pst_trans_start));
- /* Create Transmission Data */
- pst_trans_start.id = can_id; /* CAN ID */
- pst_trans_start.freq = 0; /* Transmission Interval */
- memcpy(&pst_trans_start.mask.dat, mask->dat, sizeof(mask->dat));
- memcpy(&pst_trans_start.dat.dat, dat->dat, sizeof(dat->dat));
+ if (NULL == h_app)
+ goto cleanup;
- if (g_mchdl == NULL) {
- g_mchdl = McOpenSender(LAN_SERVICE_CAN);
- }
+ if (!Canif_CheckNotifyName(notify_name))
+ goto cleanup;
- /* Start CAN Data transmission */
- e_status = McSend(g_mchdl, "ViewerApp", CID_CANIF_TX_BIT_START, sizeof(pst_trans_start), &pst_trans_start);
- 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
- l_ret = CANIF_RET_ERROR_CANCEL;
- // LCOV_EXCL_STOP 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ for (i = 0; i < NUM_OF_CANIF_PROTOCOL; i++) {
+ handle[i] = FrameworkunifiedMcOpenSender(h_app,
+ Canif_PidxTosname((enum CANIF_PROTOCOL_IDX)i));
+ if (!handle[i])
+ goto cleanup;
}
- return l_ret;
-}
-
-#ifdef CAN_DEBUG
-CANIF_RET_API Canif_Debug_Delete_AllDeliveryEntryList(HANDLE h_app) {
- CANIF_RET_API l_ret = CANIF_RET_NORMAL;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- UI_32 len = 0;
- /* Check parameter */
- if (h_app == (HANDLE)NULL) {
- return CANIF_RET_ERROR_PARAM;
+ for (i = 0; i < NUM_OF_CANIF_PROTOCOL; i++) {
+ e_status = FrameworkunifiedSendMsg(handle[i], CID_CANIF_DELIVERY_ERASE,
+ CANIF_NOTIFY_NAME_MAX_SIZE, (PCVOID)notify_name);
+ if (e_status != eFrameworkunifiedStatusOK)
+ goto cleanup;
}
- if (g_hdl == NULL) {
- g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
- }
- /* Start CAN ID transmission */
- e_status = FrameworkunifiedInvokeSync(g_hdl, CID_CANIF_DELETE_DELIVERY_ENTRY, 0, NULL, 0, NULL, &len);
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- l_ret = CANIF_RET_ERROR_CANCEL; // LCOV_EXCL_LINE 4: NSFW error case.
- } else {
- l_ret = CANIF_RET_NORMAL;
+ l_ret = CANIF_RET_NORMAL;
+cleanup:
+ for (i = 0; i < NUM_OF_CANIF_PROTOCOL; i++) {
+ if (handle[i] != NULL)
+ FrameworkunifiedMcClose(handle[i]);
}
return l_ret;
}
-#endif
-// LCOV_EXCL_BR_LINE 10:THE_END_LINE_OF_THE_FILE
+
diff --git a/communication/server/Makefile b/communication/server/Makefile
index aa0ddf3f..069c3333 100644
--- a/communication/server/Makefile
+++ b/communication/server/Makefile
@@ -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.
@@ -33,24 +33,11 @@ communication_SRCS += ./src/main/communication_application.cpp
communication_SRCS += ./src/threads/CAN_Thread.cpp
communication_SRCS += ./src/threads/Thread_Common.cpp
-## from ./src/CAN/Command/
-communication_SRCS += ./src/CAN/Command/CAN_Command.cpp
-communication_SRCS += ./src/CAN/Command/CAN_CommandData.cpp
-
## from ./src/CAN/CommWatch/
communication_SRCS += ./src/CAN/CommWatch/CAN_CommWatch.cpp
-communication_SRCS += ./src/CAN/CommWatch/CAN_CommWatchData.cpp
## from ./src/CAN/Delivery/
communication_SRCS += ./src/CAN/Delivery/CAN_Delivery.cpp
-communication_SRCS += ./src/CAN/Delivery/CAN_DeliveryData.cpp
-
-## from ./src/CAN/TimerCtrl/
-communication_SRCS += ./src/CAN/TimerCtrl/CAN_TimerCtrl.cpp
-
-## from ./src/CAN/Transmission/
-communication_SRCS += ./src/CAN/Transmission/CAN_Transmission.cpp
-communication_SRCS += ./src/CAN/Transmission/CAN_TransmissionData.cpp
## from ./src/CAN/TxMsg/
communication_SRCS += ./src/CAN/TxMsg/CAN_TxMsg.cpp
@@ -61,8 +48,6 @@ VPATH += \
./src/CAN/CommWatch \
./src/CAN/Delivery \
./src/CAN/main \
- ./src/CAN/TimerCtrl \
- ./src/CAN/Transmission \
./src/CAN/TxMsg \
./src/main \
@@ -76,7 +61,6 @@ CPPFLAGS += \
-I./include/CAN/Delivery \
-I./include/CAN/main \
-I./include/CAN/TimerCtrl \
- -I./include/CAN/Transmission \
-I./include/CAN/TxMsg \
-I./include/main \
-I./include/threads \
@@ -107,7 +91,6 @@ LDLIBS += -Wl,-Bdynamic -lstdc++
LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
LDLIBS += -Wl,-Bdynamic -lcommon
-LDLIBS += -Wl,-Bdynamic -lvp
-#LDLIBS += -Wl,-Bdynamic -lcan_hal
+LDLIBS += -Wl,-Bdynamic -lcan_hal
include ../../peripheral_service.mk
diff --git a/communication/server/include/CAN/CommWatch/CAN_CommWatch.h b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h
index 3b6c8840..16aa54ff 100644
--- a/communication/server/include/CAN/CommWatch/CAN_CommWatch.h
+++ b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h
@@ -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.
@@ -16,34 +16,27 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_
#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_
-/******************************************************************************
- * FILE :CAN_CommWatch.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-#include "CAN_CommWatchData.h"
+#include <native_service/frameworkunified_types.h>
+#include <peripheral_service/Canif_API.h>
+#include <vector>
+#include <map>
+#include <string>
+#include "CommWatchCommon.h"
-/************************************************************************
-* Macro definitions *
-************************************************************************/
+typedef struct {
+ char notify_name[MAX_NAME_SIZE_APP];
+ uint32_t data_id;
+ uint8_t comm_watch_flag;
+ uint16_t set_time;
+ uint16_t timer_cnt;
+} CAN_COMM_WATCH_VAL;
-/* Flag relationship */
-#define CAN_COMM_IG_OFF 0x00 /* IG OFF */
-#define CAN_COMM_IG_ON 0x01 /* IG ON */
-#define CAN_COMM_IG_NORCV 0xFF /* IG not yet */
+typedef std::multimap<CANID, CAN_COMM_WATCH_VAL> CAN_CommWatchTable;
+typedef std::pair<const CANID, CAN_COMM_WATCH_VAL> CAN_CommWatchTablePair;
+typedef CAN_CommWatchTable::iterator CAN_CommWatchTableIt;
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
void CANCommWatchInit(void);
-RET_CAN CANCommWatchTimeoutMsg(HANDLE h_app, uint16_t);
EFrameworkunifiedStatus CANCommWatch(HANDLE h_app);
-EFrameworkunifiedStatus CANCommWatchCore(HANDLE h_app, CAN_PROTOCOL_TYPE type);
-void CANCommWatchClear(HANDLE h_app, CANID);
-EFrameworkunifiedStatus CANVehicleInfoMsg(HANDLE h_app);
-uint8_t CANIgStatGet(void);
+EFrameworkunifiedStatus CANCommWatchTimeout(HANDLE h_app);
+void CANCommWatchClear(HANDLE h_app, CANID id);
#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_
diff --git a/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h b/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h
deleted file mode 100644
index 7a982e03..00000000
--- a/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_
-#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_
-/******************************************************************************
- * FILE :CAN_CommWatchData.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
-#include <peripheral_service/Canif_API.h>
-#include "CAN_Thread.h"
-
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-/* #001 start */
-#define COMM_WATICH_TIMER_SEQ_NO_MIN 0x0001 /* Minimum value of timer sequence number */
-/* #100 start */
-#define COMM_WATICH_TIMER_SEQ_NO_MAX 0x0FFF /* Maximum value of timer sequence number */
-/* #001 end */
-/* #100 end */
-
-/* Flag Relationship */
-#define CAN_COMM_OFF 0x00 /* Monitoring OFF */
-#define CAN_COMM_NORMAL 0x01 /* Communicating */
-#define CAN_COMM_STOP 0x02 /* Interruption of communication */
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-/***************************************************
-* TAG : CAN_COMM_WATCH_DAT
-* ABSTRACT : Communication interruption monitoring management table structure (1 item)
-* Use in arrays when used
-* (CAN internal data management table) Not used because API is used in the TBD_Z first game
-****************************************************/
-typedef struct { /* Type definition of communication disconnection monitoring management table (1 case) */
- CANID ul_can_id; /* CAN ID */
- DID ul_did; /* Data ID */
- uint16_t us_watch_time; /* Communication interruption monitoring time (in units of 100ms) */
- // uint32_t notifyId; /* Addresses for delivery ID */
- uint8_t uc_comm_stop; /* Communication status */
- uint8_t uc_ig; /* IG linkage */
- uint16_t us_timer_seq_no; /* Timer Sequence Number*/
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN_COMM_WATCH_DAT;
-
-/************************************************************************
-* Variable prototype *
-************************************************************************/
-/* Communication disruption monitoring management table */
-extern CAN_COMM_WATCH_DAT g_st_comm_watch_dat[CAN_PROTOCOL_TYPE_TERMINATE][COMM_WATCH_LIST_NUM];
-/* Number of effective registrations of communication disruption monitoring management table */
-extern uint16_t g_us_comm_watch_dat_cnt[CAN_PROTOCOL_TYPE_TERMINATE];
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-void CANCommWatchDataInit(void);
-BOOL CANCommWatchCanidDidEntryCheck(uint8_t, CANID canid, DID did, CAN_PROTOCOL_TYPE);
-BOOL CANCommWatchTimerSeqNoEntryCheck(uint16_t, uint8_t *, uint8_t *, CAN_PROTOCOL_TYPE);
-BOOL CANCommWatchEntryCheck(CANID canid, DID did, PCSTR namel, uint8_t *, CAN_PROTOCOL_TYPE);
-void CANCommWatchEntry(uint8_t uc_index, const CAN_COMM_WATCHEXT_MSG_DAT *pst_msg_data,
- uint16_t us_timer_seq_no, uint8_t uc_comm_stop, CAN_PROTOCOL_TYPE);
-void CANCommWatchDelete(uint8_t, CAN_PROTOCOL_TYPE);
-void CANCommWatchCtrl(uint8_t, uint8_t, CAN_PROTOCOL_TYPE);
-void CANCommWatchDataGet(uint8_t, char *, DID *, uint8_t *, CAN_PROTOCOL_TYPE);
-uint16_t CANCommWatchTimerSeqNoGet(uint8_t, CAN_PROTOCOL_TYPE);
-uint16_t CANCommWatchTimerSeqNoRenwal(uint8_t, uint16_t *, CAN_PROTOCOL_TYPE);
-BOOL CANCommWatchSndCheck(uint8_t, PCSTR name, CAN_PROTOCOL_TYPE);
-uint8_t CANCommWatchIgcoopGet(uint8_t uc_index, CAN_PROTOCOL_TYPE);
-void CANCommWatchBufferOut(FILE *fp_log, CAN_PROTOCOL_TYPE);
-inline BOOL CANCommWatchCanidEntryCheck(uint8_t uc_index, CANID ul_can_id, uint8_t *puc_comm_stop,
- uint16_t *pus_chk_cnt, CAN_PROTOCOL_TYPE);
-
-/* for debug */
-EFrameworkunifiedStatus CANCommWatchAllClearDebug(HANDLE h_app);
-/*******************************************************************************
- * MODULE : CANCommWatchCanidEntryCheck
- * ABSTRACT : CANDataCommunication Disruption Monitoring Control Table Registration Status Checking Process (CAN ID Search)
- * FUNCTION : Compare the communication discontinuity monitoring control data indicated by the index with the specified CAN ID.
- * ARGUMENT : uc_index :Indexed
- * can_id :CAN ID
- * puc_comm_stop :Communication status return pointer
- * pusChkCnt :Pointer to number of valid data checks for table registration
- * NOTE :
- * RETURN : TRUE :Data consistency
- * FALSE :Data mismatch
- ******************************************************************************/
-
-inline BOOL CANCommWatchCanidEntryCheck(uint8_t uc_index, CANID can_id, uint8_t *puc_comm_stop,
- uint16_t *pusChkCnt, CAN_PROTOCOL_TYPE mode) {
- BOOL ret = FALSE;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Is the specified index monitoring interrupted? */
- if ((uint16_t)0 != ptr->us_watch_time) {
- /* Specified index-data CANID matches the arguments? */
- if (can_id == ptr->ul_can_id) {
- ret = TRUE;
- *puc_comm_stop = ptr->uc_comm_stop;
- }
- /* Updating the number of effective data checks for table registration */
- *pusChkCnt = (uint16_t)(*pusChkCnt + (uint16_t)1);
- }
-
- return (ret);
-}
-
-#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_
diff --git a/communication/server/include/CAN/CommWatch/CommWatchCommon.h b/communication/server/include/CAN/CommWatch/CommWatchCommon.h
new file mode 100644
index 00000000..7306214e
--- /dev/null
+++ b/communication/server/include/CAN/CommWatch/CommWatchCommon.h
@@ -0,0 +1,22 @@
+/*
+ * @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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_COMMWATCH_COMMON_H_
+#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_COMMWATCH_COMMON_H_
+#define CAN_COMM_OFF 0x00
+#define CAN_COMM_NORMAL 0x01
+#define CAN_COMM_STOP 0x02
+#endif
diff --git a/communication/server/include/CAN/Command/CAN_Command.h b/communication/server/include/CAN/Command/CAN_Command.h
index ca385b2d..43abcdcd 100644
--- a/communication/server/include/CAN/Command/CAN_Command.h
+++ b/communication/server/include/CAN/Command/CAN_Command.h
@@ -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.
@@ -16,27 +16,6 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_
#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_
-/******************************************************************************
- * FILE :CAN_Command.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
-#include "CAN_Thread.h"
-
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
EFrameworkunifiedStatus CANCommandTransmission(HANDLE h_app);
RET_CAN CANCommandTxRslt(HANDLE h_app, CAN_MSG_DATA*);
-RET_CAN CANCommandDelivery(HANDLE h_app, CAN_MSG_DATA*);
-
#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_
diff --git a/communication/server/include/CAN/Command/CAN_CommandData.h b/communication/server/include/CAN/Command/CAN_CommandData.h
deleted file mode 100644
index 3d476a68..00000000
--- a/communication/server/include/CAN/Command/CAN_CommandData.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_
-#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_
-/******************************************************************************
- * FILE :CAN_CommandData.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
-#include <native_service/frameworkunified_types.h>
-
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-/* Number of table elements */
-#define CAN_COMMAND_DELIVERY_SNDID_NUM 16 /* CAN Command Delivery Registered Delivery Destination ID Max. */
-#define CAN_COMMAND_DELIVERY_NUM 6 /* Max. number of CAN command delivery control tables (6 for CAN command) */
-#define CAN_COMMAND_TXRSLT_SNDID_NUM 16 /* Maximum number of registered delivery destination IDs for CAN command transmission results */
-#define CAN_COMMAND_TXRSLT_NUM (6 * CAN_COMMAND_TXRSLT_SNDID_NUM) /* Maximum number of CAN command transmission result management tables */
-
-/* Control method */
-#define CAN_CMD_DELIVERY_CTRL 0 /* Delivery control type */
-#define CAN_CMD_1TIME_TRANCE 1 /* One-time communication */
-#define CAN_CMD_TRANCE 2 /* Continuous communication type */
-
-/* Controlling flag */
-#define CAN_CMD_RST_NOT_RCV 0 /* Not received */
-#define CAN_CMD_RST_RCV 1 /* Received */
-
-/* Resource ID Mask */
-#define CAN_CMD_RID_MASK 0x80
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-/***************************************************
-* TAG : CAN_COMMAND_DELIVERY_LIST_DAT
-* ABSTRACT : CAN command delivery management table structure (1 item)
-* Use in arrays when used
-* (CAN internal data management table)
-****************************************************/
-typedef struct {
- uint8_t uc_ctrl; /* Control method */
- uint8_t uc_flag; /* Controlling flag */
- uint8_t notify_name_num; /* Number of registered shipping destinations */
- uint8_t reserve; /* ----- */
- // uint32_t notifyIdList[CAN_COMMAND_DELIVERY_SNDID_NUM]; /* Addresses for delivery ID */
- char notify_name_list[CAN_COMMAND_DELIVERY_SNDID_NUM][MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN_COMMAND_DELIVERY_LIST_DAT;
-
-/***************************************************
-* TAG : CAN_COMMAND_TXRSLT_LIST_DAT
-* ABSTRACT : CAN command transmission result management table structure (1 item)
-* Use in arrays when used
-* (CAN internal data management table)
-****************************************************/
-typedef struct {
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
- // uint32_t notifyId; /* Addresses for delivery ID */
- uint8_t uc_rid; /* Resources ID */
- uint8_t uc_cmd_id; /* CAN command ID */
-} CAN_COMMAND_TXRSLT_LIST_DAT;
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-BOOL CANCommandDeliveryEntryCheck(PCSTR name, uint8_t);
-void CANCommandDeliveryEntry(PCSTR name, uint8_t);
-void CANCommandDeliveryDataGet(uint8_t, CAN_COMMAND_DELIVERY_LIST_DAT *);
-void CANCommandDeliveryDelete(uint8_t);
-void CANCommandDeliveryDeletesingle(uint8_t, PCSTR);
-BOOL CANCommandTxRsltEntryCheck(uint8_t, uint8_t *);
-void CANCommandTxRsltEntry(uint8_t, PCSTR name, uint8_t);
-void CANCommandTxRsltDataGet(uint8_t, char *, uint8_t *, uint8_t *);
-void CANCommandTxRsltDelete(uint8_t);
-BOOL CANCommandTxRsltCheck(uint8_t);
-BOOL CANCommandFuelCalcRstReqCheck(void);
-void CANCommandFuelCalcRstReq(void);
-void CANCommandDataInit(void);
-
-#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_
diff --git a/communication/server/include/CAN/Delivery/CAN_Delivery.h b/communication/server/include/CAN/Delivery/CAN_Delivery.h
index 74e226c1..01f2e2ff 100644
--- a/communication/server/include/CAN/Delivery/CAN_Delivery.h
+++ b/communication/server/include/CAN/Delivery/CAN_Delivery.h
@@ -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.
@@ -16,33 +16,25 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_
#define COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_
-/******************************************************************************
- * FILE :CAN_Delivery.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
-#include <peripheral_service/Canif_API.h>
+#include <native_service/frameworkunified_types.h>
#include "CAN_Thread.h"
+#include <vector>
+#include <map>
+#include <string>
+#include <can_hal.h>
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-#define CAN_CSUM_CHECKTBL_STOP_CODE 0xFFFFFFFFUL
-/* CANDataStop code of the table for which checksum checksumming is to be performed */
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
+typedef std::multimap<CANID, std::string> CAN_DeliveryEntryList;
+typedef CAN_DeliveryEntryList::iterator CAN_DeliveryEntryListIt;
+typedef std::pair<const CANID, std::string> CAN_DeliveryEntryListPair;
-/************************************************************************
-* Function prototype *
-************************************************************************/
-RET_CAN CANDataReceiveMsg(HANDLE h_app, CAN_MSG_DATA*); /* CANDataProcess of Received Messages */
-//RET_CAN CANDlcCheck(const T_ICR_CMD_DATA*); /* DLC check process */
-CANID CANCanidIfToUserCvt(uint8_t*); /* CAN ID Conversion Process 1 */
-CANID CANPacCanidIfToUserCvt(uint8_t*);
-RET_CAN CANDeliveryRcvData(HANDLE h_app, CANID ul_canid, uint8_t n_ta,
- uint8_t uc_dlc, uint8_t* puc_data_pos, uint8_t opc);
-RET_CAN CANDeliveryRcv_CWORD29_Data(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, uint8_t *puc_data_pos);
+void CANDeliveryInit(void);
+bool CANDeliveryInsert(CANID canid, std::string s);
+EFrameworkunifiedStatus CANDeliveryRcvProcess(HANDLE h_app, CanMessage *msg);
+EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app);
+EFrameworkunifiedStatus CANClearEntry(HANDLE h_app);
+EFrameworkunifiedStatus CANDeliverySndMsg(HANDLE h_app, CANID ul_canid, uint8_t n_ta,
+ uint8_t uc_dlc, const uint8_t *puc_data,
+ PS_CommunicationProtocol cid, enum CanIfEchoBackFlags flag = CANIF_PURERECV);
+EFrameworkunifiedStatus CANCommandDeliveryRcvProcess(HANDLE h_app,
+ CanMessage *msg, uint8_t cmd);
#endif // COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_
diff --git a/communication/server/include/CAN/Delivery/CAN_DeliveryData.h b/communication/server/include/CAN/Delivery/CAN_DeliveryData.h
index 692b8216..ae0302c7 100644
--- a/communication/server/include/CAN/Delivery/CAN_DeliveryData.h
+++ b/communication/server/include/CAN/Delivery/CAN_DeliveryData.h
@@ -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.
@@ -131,10 +131,7 @@ typedef struct {
************************************************************************/
void CANDeliveryDataInit(void); /* CANDataDelivery Management Data Initialization Process */
EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app); /* CANDataDelivery registration process */
-EFrameworkunifiedStatus CAN_CWORD29_DeliveryEntry(HANDLE h_app); /* Process of registering the delivery of _CWORD29_ data */
void CANDeliveryBufferOut(FILE* fp_log); /* CAN shipping table log output processing */
-#ifdef CAN_DEBUG
-EFrameworkunifiedStatus CANAllDeleteDeliveryEntry(HANDLE h_app);
-#endif
+EFrameworkunifiedStatus CANClearEntry(HANDLE h_app);
#endif // COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_
diff --git a/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h b/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h
deleted file mode 100644
index bf273dd7..00000000
--- a/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_
-#define COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_
-/******************************************************************************
- * FILE :CAN_TimerCtrl.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
-#include "CAN_Thread.h"
-
-/************************************************************************
-* Macro Definitions *
-************************************************************************/
-#define CAN_TIM_RETRY_NUM 3 /* Number of retries for alarm API errors */
-/************************************************************************
-* Struct Definitions *
-************************************************************************/
-
-/***************************************************
-* TAG : CAN_TIMER_CTRL_DATA
-* ABSTRACT : Timer management data section structure
-****************************************************/
-typedef struct {
- uint16_t us_set_tim; /* Timeout value */
- uint16_t us_tim_cnt; /* Measured value of timer */
-} CAN_TIMER_CTRL_DATA;
-
-/***************************************************
-* TAG : CAN_FREQTRANS_TIMER
-* ABSTRACT : Periodic transmission timer management table structure
-****************************************************/
-typedef struct {
- uint16_t us_num; /* Number of timer registrations */
- uint8_t reserve[2]; /* Reserve */
- CAN_TIMER_CTRL_DATA data[CAN_FREQTRANS_TIMER_DATA]; /* Timer management data */
-} CAN_FREQTRANS_TIMER;
-
-/***************************************************
-* TAG : CAN_COMMWATCH_TIMER
-* ABSTRACT : Disruption monitoring timer management table structure
-****************************************************/
-typedef struct {
- uint16_t us_num; /* Number of timer registrations */
- uint8_t reserve[2]; /* Reserve */
- CAN_TIMER_CTRL_DATA data[CAN_COMMWATCH_TIMER_DATA]; /* Timer management data */
-} CAN_COMMWATCH_TIMER;
-
-/************************************************************************
-* Function Prototype *
-************************************************************************/
-RET_CAN CANFreqTransTimerStart(uint8_t, uint16_t, CAN_PROTOCOL_TYPE); /* Periodic transmission timer start processing */
-RET_CAN CANFreqTransTimerStop(uint8_t, CAN_PROTOCOL_TYPE); /* Periodic transmission timer start processing */
-RET_CAN CANCommWatchTimerStart(uint8_t, uint16_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer start processing */
-RET_CAN CANCommWatchTimerStop(uint8_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer stop processing */
-RET_CAN CANCommWatchTimerRenewal(uint8_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer update processing */
-void CANFreqTransTimeOut(HANDLE h_app, uint16_t, CAN_PROTOCOL_TYPE); /* CAN periodic transmission timeout confirmation processing */
-void CANCommWatchTimeOut(HANDLE h_app, CAN_PROTOCOL_TYPE); /* CAN Communication Disruption Monitoring Timeout Confirmation Process */
-void CANTimerStart(uint16_t, CAN_TIMER_CTRL_DATA*); /* CAN Timer Master Processing */
-void CANTimerTblInit(void); /* CAN timer table initialization processing */
-
-void CANFreqTimerEntry(CANID canid, uint32_t);
-void CANFreqTransTimeOutMap(HANDLE h_app);
-RET_CAN CANFreqTransTimerStopMap(CANID);
-void CANFreqTimerResetMap(CANID);
-
-#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_
diff --git a/communication/server/include/CAN/Transmission/CAN_Transmission.h b/communication/server/include/CAN/Transmission/CAN_Transmission.h
deleted file mode 100644
index bca233ea..00000000
--- a/communication/server/include/CAN/Transmission/CAN_Transmission.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_
-#define COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_
-/******************************************************************************
- * FILE :CAN_Transmission.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-#include <native_service/frameworkunified_types.h>
-#include "CAN_Thread.h"
-
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-#define TIMER_SEQNO_MASK_CODE (uint16_t)(0x00FF) /* Mask code for acquiring timer sequence number */
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-/* CANDataTransmission start message processing */
-EFrameworkunifiedStatus CANTxStart(HANDLE);
-/* CANDataSend start message check processing */
-RET_CAN CANTxStartMsgCheck(const CAN_TRANSMISSION_START_MSG_DAT *, uint8_t *);
-/* CANDataPeriodic transmission stop message processing */
-EFrameworkunifiedStatus CANFreqTxStop(HANDLE);
-/* CANDataPeriodic transmission time-up message processing */
-RET_CAN CANFreqTxTimeupMsg(HANDLE h_app, uint16_t);
-/* CANDataReceive message processing of transmission result */
-RET_CAN CANTxRsltReceiveMsg(HANDLE h_app, CAN_MSG_DATA *);
-/* CANDataSend result received message check processing */
-RET_CAN CANTxRsltReceiveMsgCheck(CAN_MSG_DATA *);
-/* CANData(_CWORD29_) outgoing message processing */
-EFrameworkunifiedStatus CAN_CWORD29_TxMsg(HANDLE h_app);
-EFrameworkunifiedStatus CANTxBitStart(HANDLE); /* CANDataTransmission start message processing */
-EFrameworkunifiedStatus CANTxBitStop(HANDLE); /* CANDataPeriodic transmission stop message processing */
-
-#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_
diff --git a/communication/server/include/CAN/Transmission/CAN_TransmissionData.h b/communication/server/include/CAN/Transmission/CAN_TransmissionData.h
deleted file mode 100644
index 0c389276..00000000
--- a/communication/server/include/CAN/Transmission/CAN_TransmissionData.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_
-#define COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_
-/******************************************************************************
- * FILE :CAN_TransmissionData.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-#include <native_service/frameworkunified_types.h>
-#include <peripheral_service/Canif_API.h>
-#include "Canif_API_Local.h"
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-/* Data size relationship */
-/* Maximum number of transmission results management tables */
-#define CAN_1TIME_TRSNSMISSION_RSLT_NUM 16
-#define CAN__CWORD29__TRSNSMISSION_RSLT_NUM 16
-
-/* Regular transmission, one transmission result management table relationship */
-#define CAN_TXRSLT_CANRID_START 0x00 /* Send result CANRID starting No. */
-/* Transmission result (1 transmission) CANRID starting number */
-#define CAN_TXRSLT_CANRID_1TIME_START CAN_FREQ_TRSNSMISSION_LIST_NUM
-/* Send result (_CWORD29_) CANRID starting number) */
-#define CAN_TXRSLT_CANRID__CWORD29__START (CAN_FREQ_TRSNSMISSION_LIST_NUM + CAN_1TIME_TRSNSMISSION_RSLT_NUM) // NOLINT(whitespace/line_length)
-/* Send result CANRID end No. */
-#define CAN_TXRSLT_CANRID_END (CAN_FREQ_TRSNSMISSION_LIST_NUM + CAN_1TIME_TRSNSMISSION_RSLT_NUM + CAN__CWORD29__TRSNSMISSION_RSLT_NUM - 1) // NOLINT(whitespace/line_length)
-
-/* Others */
-#define CAN_FREQ_TXRSLT_NUM 1 /* Number of notifications of periodic transmission results */
-
-#define LAN_TYPE_19PF "CAN_19PF"
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-/***************************************************
-* TAG : CAN_FREQ_TRANSMISSION_DAT
-* ABSTRACT : Periodic transmission management table structure (1 item)
-* Use in arrays when used
-* (CAN internal data management table)
-****************************************************/
-typedef struct { /* Type definitions for the periodic transmission management table (1 item) */
- uint16_t us_freq; /* Periodic transmission period (in 100ms) */
- // uint32_t notifyId; /* Thread ID */
- uint8_t uc_rid; /* Resources ID */
- uint8_t uc_resp_num; /* Number of transmission result notifications (number of remaining notifications) */
- uint8_t reserve[2]; /* Reserved */
- CAN_DATA st_can_data; /* Transmitted data */
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN_FREQ_TRANSMISSION_DAT;
-
-/***************************************************
-* TAG : CAN_1TIME_TXRSLT_DAT
-* ABSTRACT : One transmission result management table structure (1 item)
-* (CAN internal data management table)
-****************************************************/
-typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */
- CANID ul_canid; /* CAN ID */
- // uint32_t notifyId; /* Addresses for delivery ID */
- uint8_t uc_rid; /* Resources ID */
- uint8_t reserve; /* Reserved */
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN_1TIME_TXRSLT_DAT;
-
-/***************************************************
-* TAG : CAN_1TIME_TXRSLT_MSG_DAT
-* ABSTRACT : List of Messages Sent Once (1 item)
-* (CAN-internal Work)
-****************************************************/
-typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */
- CANID ul_canid; /* CAN ID */
- // uint32_t notifyId; /* Addresses for delivery ID */
- uint8_t uc_rid; /* Resources ID */
- uint8_t uc_sts; /* Transmission result status */
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN_1TIME_TXRSLT_MSG_DAT;
-
-/***************************************************
-* TAG : CAN_1TIME_TXRSLT_MSG_LIST_DAT
-* ABSTRACT : List of Messages Sent Once (All Messages)
-* (CAN-internal Work)
-****************************************************/
-typedef struct { /* Type definition of the delivery destination ID data to which the message is sent */
- int32_t i_num; /* Number of messages sent */
- CAN_1TIME_TXRSLT_MSG_DAT st_list[CAN_1TIME_TRSNSMISSION_RSLT_NUM]; /* List */
-} CAN_1TIME_TXRSLT_MSG_LIST_DAT;
-
-/***************************************************
-* TAG : CAN__CWORD29__TXRSLT_DAT
-* ABSTRACT : _CWORD29_ send result control table structure (1 item)
-* (CAN internal data management table)
-****************************************************/
-typedef struct {
- uint16_t opc; /* OPC */
- uint8_t uc_rid; /* Resources ID */
- char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
-} CAN__CWORD29__TXRSLT_DAT;
-
-/***************************************************
-* TAG : CAN_TRANS_START_TABLE_VAL
-* ABSTRACT : Transmit data management table structure (1 item)
-* (CAN internal data management table)
-****************************************************/
-typedef struct {
- uint8_t dlc;
- CAN_DATA_BIT dat;
-} CAN_TRANS_START_TABLE_VAL;
-
-/***************************************************
-* TAG : CAN_INIT_TABLE
-* ABSTRACT : Transmission data initial value management table structure
-****************************************************/
-typedef struct {
- CANID canid;
- CAN_TRANS_START_TABLE_VAL val;
-} CAN_INIT_TABLE;
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-void CANTransmissionDataInit(void);
-BOOL CANFreqTransEntryCheck(CANID canid, uint8_t *);
-void CANFreqTransEntry(uint8_t, const CAN_TRANSMISSION_START_MSG_DAT *);
-void CANFreqTransDataGet(uint8_t uc_index, CAN_FREQ_TRANSMISSION_DAT *pst_data);
-BOOL CANFreqTransCanidEntryCheck(uint8_t, CANID);
-BOOL CANFreqTransIdEntryCheck(uint8_t, PCSTR);
-void CANFreqTransStop(uint8_t);
-BOOL CANFreqTransIndexEntryCheck(uint8_t);
-BOOL CAN1TimeTransEntryCheck(uint8_t *);
-BOOL CAN_CWORD29_TransEntryCheck(uint8_t *);
-EFrameworkunifiedStatus CAN1TimeTransEntry(uint8_t, const CAN_TRANSMISSION_START_MSG_DAT *);
-EFrameworkunifiedStatus CAN_CWORD29_TransEntry(uint8_t, const CAN__CWORD29__TRANS_MSG *);
-BOOL CANTxRsltEntryCheck(uint8_t);
-void CANTxRsltDataGet(uint8_t, CAN_1TIME_TXRSLT_DAT *);
-void CAN_CWORD29_TxRsltDataGet(const uint8_t, CAN__CWORD29__TXRSLT_DAT* const);
-void CANTxRsltFin(uint8_t);
-void CAN_CWORD29_TxRsltFin(const uint8_t);
-BOOL CANTxRsltSndCheck(uint8_t, uint32_t);
-void CANCycleTransBufferOut(FILE *fp_log);
-
-BOOL CANTransDataEntry(CAN_TRANS_START_MSG_DAT *);
-BOOL CANTransStartTxMsg(HANDLE h_app, CANID);
-BOOL CANEntryTransCanidCheck(CANID);
-
-BOOL CAN_SubIDTransStartTxMsg(HANDLE h_app, CAN_TRANS_START_MSG_DAT *);
-
-#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_
diff --git a/communication/server/include/CAN/TxMsg/CAN_TxMsg.h b/communication/server/include/CAN/TxMsg/CAN_TxMsg.h
index 15fc56d1..dc4f6e8e 100644
--- a/communication/server/include/CAN/TxMsg/CAN_TxMsg.h
+++ b/communication/server/include/CAN/TxMsg/CAN_TxMsg.h
@@ -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.
@@ -16,101 +16,39 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_
#define COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_
-/******************************************************************************
- * FILE :CAN_TxMsg.h
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :
- ******************************************************************************/
-
+#include <vector>
+#include <map>
+#include <string>
+#include <can_hal.h>
#include "CAN_Thread.h"
+#include "API_Local_Common.h"
+#include "Canif_API_Local.h"
+
+
+#define CAN_OPC_PAC_RX 0x00
+#define CAN_OPC_COMMAND_STARTUP_FIN_REQ_TX 0x00 // CAN start completion notification request transmission
+#define CAN_OPC_COMMAND_MRST_INFO_REQ_TX 0x01 // CAN master reset information notification request transmission
+#define CAN_OPC_COMMAND_VERSION_REQ_TX 0x02 // CAN Version Request Send
+#define CAN_OPC_COMMAND_CONNECTION_NODE_REQ_TX 0x03 // CAN connection node notification request transmission
+#define CAN_OPC_COMMAND_BUS_STATUS_REQ_TX 0x04 // CAN bus status notification request transmission
+#define CAN_OPC_COMMAND_FUELCALC_REQ_TX 0x05 // CAN section flame reset response transmission
+#define CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX 0x06 // CAN startup completion notice received
+#define CAN_OPC_COMMAND_MRST_INFO_RESP_RX 0x07 // CAN Master Reset Information Notification Reception
+#define CAN_OPC_COMMAND_VERSION_RESP_RX 0x08 // CAN Version Response Reception
+#define CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX 0x09 // Receive CAN Connection Node Notification Response
+#define CAN_OPC_COMMAND_BUS_STATUS_RESP_RX 0x10 // CAN Bus Status Notification Response Reception
+#define CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX 0x11 // RECEIVE REQUEST FREE OF CAN SECTION
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-#define CAN_TX_COMM_KIND 0x00 /* CANDataCommunication type for transmission */
-#define CAN_TX_PHYS_ADRS 0x0000 /* CANDataPhysical address for transmission */
-#define CAN_TX_FROM_ADRS 0x00 /* CANDataSource address for sending (wildcard) */
-#define CAN_TX_TO_ADRS 0x00 /* CANDataDestination address for sending (wildcard) */
-
-/****** OPC ******/
-#define CAN_OPC_RX 0x00 /* CANData reception notice */
-#define CAN_OPC_PAC_RX 0x00 /* CAN Packaging Data Reception Notification */
-#define CAN_OPC_TX 0x00 /* CANDataReport request */
-
-#define CAN_OPC_COMMAND_STARTUP_FIN_REQ_TX 0x00 /* CAN start completion notification request transmission */
-#define CAN_OPC_COMMAND_MRST_INFO_REQ_TX 0x01 /* CAN master reset information notification request transmission */
-#define CAN_OPC_COMMAND_VERSION_REQ_TX 0x02 /* CAN Version Request Send */
-#define CAN_OPC_COMMAND_CONNECTION_NODE_REQ_TX 0x03 /* CAN connection node notification request transmission */
-#define CAN_OPC_COMMAND_BUS_STATUS_REQ_TX 0x04 /* CAN bus status notification request transmission */
-#define CAN_OPC_COMMAND_FUELCALC_REQ_TX 0x05 /* CAN section flame reset response transmission */
-#define CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX 0x06 /* CAN startup completion notice received */
-#define CAN_OPC_COMMAND_MRST_INFO_RESP_RX 0x07 /* CAN Master Reset Information Notification Reception */
-#define CAN_OPC_COMMAND_VERSION_RESP_RX 0x08 /* CAN Version Response Reception */
-#define CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX 0x09 /* Receive CAN Connection Node Notification Response */
-#define CAN_OPC_COMMAND_BUS_STATUS_RESP_RX 0x10 /* CAN Bus Status Notification Response Reception */
-#define CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX 0x11 /* RECEIVE REQUEST FREE OF CAN SECTION */
-
-/************************************************************************
-* Struct definitions *
-************************************************************************/
-/***************************************************
-* TAG : CAN_TXMSG_DAT
-* ABSTRACT : CANDataTransmission data section structure
-* (Data structure passed from tha CAN to router)
-****************************************************/
-typedef struct { /* Type definition of send command */
- uint8_t reserve; /* Reserved */
- uint8_t uc_length; /* Data length */
- uint8_t uc_kind_padrs; /* Data type/Physical address */
- uint8_t uc_p_adrs; /* Physical address */
- uint8_t uc_from_adrs; /* Source address */
- uint8_t uc_to_adrs; /* Forwarding address */
- uint8_t uc_opc; /* OPC */
- uint8_t uc_operand[CAN_TX_OPERAND_SIZE]; /* Operand*/
-} CAN_TXMSG_DAT;
-
-/***************************************************
-* TAG : CAN_TXMSG
-* ABSTRACT : CANDataTransmission data section structure
-* (Data structure passed from tha CAN to router)
-****************************************************/
-typedef struct { /* For main processing */
-// T_APIMSG_MSGBUF_HEADER_COMM st_head; /* Header */
- CAN_TXMSG_DAT st_data; /* Data portion */
-} CAN_TXMSG;
-
-/***************************************************
-* TAG : HANDLE_DAT
-* ABSTRACT : MapHandler data-section structures
-****************************************************/
typedef struct {
- HANDLE handle;
- BOOL is_q_full; /* Queue full judgment flag */
-} HANDLE_DAT;
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-BOOL CANDeliverySndMsg(HANDLE h_app, CANID canid, uint8_t, const uint8_t *, uint8_t, uint8_t);
-BOOL CANDelivery_CWORD29_SndMsg(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, const uint8_t *puc_data);
-/* CANDataDelivery Messages Sending Process (Except for CANGW) */
-BOOL CANDeliverySndMsgToCANGW(HANDLE h_app, CAN_MSG_CANGWDATA *cangw_data);
-/* CAN-data-delivery-messaging process to the CANGW */
-BOOL CANFreqTransStartTxMsg(HANDLE h_app, uint8_t); /* CANDataPeriodic transmission start message transmission processing */
-BOOL CAN1TimeTransStartTxMsg(HANDLE h_app, uint8_t, const CAN_DATA *); /* CANDataSend one transmission start message processing */
-void CANCommWatchSndMsg(HANDLE h_app, uint8_t); /* CANDataTransmission of communication interruption detection/recovery message */
-BOOL CANTxRsltSndMsg(HANDLE h_app, uint8_t, uint8_t); /* CANDataTransmission result notification message transmission processing */
-/* _CWORD29_ data transmission result notification message transmission process */
-BOOL CAN_CWORD29_TxRsltSndMsg(const HANDLE h_app, const uint8_t uc_can_rid, const uint8_t uc_status);
-void CANCanidUserToIfCvt(CANID canid, uint8_t *); /* CAN ID Conversion Process 2 */
-
-BOOL CANCommandDeliverySndMsg(HANDLE h_app, uint8_t, const uint8_t *); /* CAN command delivery message transmission processing */
-BOOL CANCommandTxRsltSndMsg(HANDLE h_app, uint8_t, uint8_t); /* CAN command transmission result notification message transmission processing */
-BOOL CANCommandTransmissionSndMsg(uint8_t, uint8_t); /* CAN command message transmission processing */
-BOOL CANCommandFuelCalcRstReqSndMsg(HANDLE h_app, PCSTR name); /* CAN section flame reset request reception message transmission processing */
-BOOL CANCommandidOpcToUserCvt(uint8_t, uint8_t *); /* CAN Command ID Conversion Processing 1 */
-BOOL CANCommandidUserToOpcCvt(uint8_t, uint8_t *); /* CAN command ID conversion process 2 */
-
-BOOL CANTransStartTxMsgCore(HANDLE h_app, CANID canid, uint8_t, CAN_DATA_BIT *);
-
+ uint8_t rid;
+ char notify_name[CANIF_NOTIFY_NAME_MAX_SIZE + 1];
+} CAN_SEND_STATUS_DAT;
+
+void CANTxMsgInit(void);
+EFrameworkunifiedStatus CANTxMsg(HANDLE h_app);
+EFrameworkunifiedStatus CANTxMsgBit(HANDLE h_app);
+void CANCommandSetFuelCalcRstReq(void);
+EFrameworkunifiedStatus CANTxMsgCommand(HANDLE h_app);
+EFrameworkunifiedStatus CANSndStsProcess(HANDLE h_app, CanSendResult *rcv_msg,
+ PS_CommunicationProtocol cid);
#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_
diff --git a/communication/server/include/com_error_type.h b/communication/server/include/com_error_type.h
index bfd96b3a..4d15f827 100644
--- a/communication/server/include/com_error_type.h
+++ b/communication/server/include/com_error_type.h
@@ -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.
@@ -16,20 +16,6 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_
#define COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_
-
-/*************************************************************************
- * RET_API define
- *************************************************************************/
-
-#define RET_NORMAL 0 /* Normal completion */
-
-/* Function code (normal termination) system */
-#define RET_RCVMSG 1 /* Receive only message */
-
-/* Error code system */
-#define RET_OSERROR -127 /* OS System call error*/
-#define RET_ERROR -1 /* Error termination (content is unspecified) */
-#define RET_ERRPARAM -2 /* Parameter error */
-#define RET_ERRTIMEOUT -5 /* Timeout with Processing Not Complete */
-
+const int32_t RET_NORMAL = 0;
+const int32_t RET_ERROR = -1;
#endif // COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_
diff --git a/communication/server/include/main/communication_cid.h b/communication/server/include/main/communication_cid.h
index 21882eea..d8176247 100644
--- a/communication/server/include/main/communication_cid.h
+++ b/communication/server/include/main/communication_cid.h
@@ -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,16 +14,6 @@
* limitations under the License.
*/
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup
-/// \brief
-///
-///
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
/*
* This file has been generated automatically.
* User hand written code entry is not allowed. Do not modify the file content.
@@ -32,10 +22,6 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_
#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Files
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
#define LAN_SERVICE_MAIN "Communication"
typedef enum PSCommunicationServiceProtocol {
diff --git a/communication/server/include/main/communication_communicationlog.h b/communication/server/include/main/communication_communicationlog.h
index c8a46e5f..37016ad1 100644
--- a/communication/server/include/main/communication_communicationlog.h
+++ b/communication/server/include/main/communication_communicationlog.h
@@ -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.
diff --git a/communication/server/include/main/communication_version.h b/communication/server/include/main/communication_version.h
index cdb83e66..7cd2c3ba 100644
--- a/communication/server/include/main/communication_version.h
+++ b/communication/server/include/main/communication_version.h
@@ -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.
diff --git a/communication/server/include/peripheral_service/communication.h b/communication/server/include/peripheral_service/communication.h
index e99996ce..94f55449 100644
--- a/communication/server/include/peripheral_service/communication.h
+++ b/communication/server/include/peripheral_service/communication.h
@@ -1,5 +1,5 @@
//
-// @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION.
+// @copyright Copyright (c) 2017-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.
diff --git a/communication/server/include/peripheral_service/communication_notifications.h b/communication/server/include/peripheral_service/communication_notifications.h
index 97817177..9c207f3f 100644
--- a/communication/server/include/peripheral_service/communication_notifications.h
+++ b/communication/server/include/peripheral_service/communication_notifications.h
@@ -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.
diff --git a/communication/server/include/peripheral_service/ps_services.h b/communication/server/include/peripheral_service/ps_services.h
index dbb823ee..fd556d6d 100644
--- a/communication/server/include/peripheral_service/ps_services.h
+++ b/communication/server/include/peripheral_service/ps_services.h
@@ -1,5 +1,5 @@
/*
- * @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION.
+ * @copyright Copyright (c) 2017-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.
diff --git a/communication/server/include/private/ICR_Common.h b/communication/server/include/private/ICR_Common.h
deleted file mode 100644
index c9bae1c1..00000000
--- a/communication/server/include/private/ICR_Common.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*!-----------------------------------------------------------------------------
- * @file ICR_Common.h
- * @~english
- * @brief ICR common definitions
- *----------------------------------------------------------------------------*/
-#ifndef COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_
-#define COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_
-
-#include <sys/types.h>
-//#include <stub/com_message_header.h>
-
-//#include <stub/CommSubCpu_API.h>
-
-#endif // COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_
diff --git a/communication/server/include/threads/CAN_Thread.h b/communication/server/include/threads/CAN_Thread.h
index 67a814a0..b6960efd 100644
--- a/communication/server/include/threads/CAN_Thread.h
+++ b/communication/server/include/threads/CAN_Thread.h
@@ -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.
@@ -16,143 +16,36 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_
#define COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_
-/*!-----------------------------------------------------------------------------
- * @file CAN_Thread.h
- * @~english
- * @brief CAN Thread main block header file
- *----------------------------------------------------------------------------*/
#include <peripheral_service/Canif_API.h>
#include <stdlib.h>
#include "com_error_type.h"
-#include "ICR_Common.h"
#include "communication_communicationlog.h"
-/************************************************************************
-* Macro definitions *
-************************************************************************/
-/* Data size relationship */
-
-#define CAN_TRX_HEADER_SIZE 7 /* Size of send/receive header section (data length excluding operands) */
-#define CAN_TRX_HEADER_LEN_SIZE 5 /* Size included in the data length calculation of the send/receive header section */
-
-#define CAN_TRX_CANID_SIZE 4 /* Transmit/Receive CAN ID Size */
-#define CAN_TRX_DLC_SIZE 1 /* Transmit/Receive DLC Data Size */
-#define CAN_TRX_DLC_RESERVE_SIZE 3 /* Reserved data size after transmit/receive DLC */
+#if 0
+#define CAN_TX_COMMAND_SIZE (CAN_TRX_HEADER_SIZE + CAN_TX_OPERAND_SIZE)
-#define CAN_RX_CANDATA_SIZE CAN_DATA_SIZE /* Reserve CANData(DATA#1 ~ #x)size */
+#define CAN_RX_CANDATA_SIZE CAN_DATA_SIZE /* Receive CANData(DATA#1 ~ #x)size */
/* Reserve the structure if it is not a multiple of 4. */
#define CAN_TX_CANDATA_SIZE CAN_DATA_SIZE /* Send CANData(DATA#1 ~ #x)size */
/* Reserve the structure if it is not a multiple of 4. */
#define CAN_RX_OPERAND_SIZE (CAN_TRX_CANID_SIZE + CAN_TRX_DLC_SIZE + CAN_RX_CANDATA_SIZE)
-/* Receive operand size */
-#define CAN_RX_COMMAND_SIZE (CAN_TRX_HEADER_SIZE + CAN_RX_OPERAND_SIZE)
-/* Receive command size */
#define CAN_TX_OPERAND_SIZE (CAN_TRX_CANID_SIZE + CAN_TRX_DLC_SIZE + CAN_TX_CANDATA_SIZE) // NOLINT(whitespace/line_length)
/* Send operand size */
-#define CAN_TX_COMMAND_SIZE (CAN_TRX_HEADER_SIZE + CAN_TX_OPERAND_SIZE)
-/* Send command size */
+
+#endif
+
+#define CAN_CMDSND_DATA_SIZE 0 /* Command transmission data section size (CAN command control) */
+
#define CAN_TX_CMD_DELIVERY_SIZE 4 /* Transmitting CAN Command Delivery Data Size Common Block */
#define CAN_TX_CMD_FUELCALC_RST_SIZE 0 /* Transmit CAN Command Delivery Data Size CAN Section Burn Cost Reset Request Receive Data */
#define CAN_TX_CMD_STARTUP_FIN_SIZE 3 /* Transmit CAN Command Delivery Data Size CAN Startup Completion Notification Data */
#define CAN_TX_CMD_MRST_INFO_SIZE 33 /* Transmit CAN Command Delivery Data Size CAN Master Reset Information Notification Receive Data */
#define CAN_TX_CMD_VERSION_SIZE 4 /* Transmit CAN Command Delivery Data Size CAN Version Response Receive Data */
-#define CAN_TX_CMD_BUS_STATUS_SIZE 1 /* Transmit CAN Command Delivery Data Size Receive CAN Bus Status Notification Response */
-
-#define CAN_CMDSND_DATA_SIZE 0 /* Command transmission data section size (CAN command control) */
-
-/* Data location relationship */
-#define CAN_MSGBUF_CANID_POS 0 /* How many operands the CAN ID contains? */
-#define CAN_MSGBUF_DLC_POS 4 /* No. of operand from which DLC contains data? */
-#define CAN_MSGBUF_DATA_POS 5 /* How many operands does the DATA contain? */
-
-#define CAN_MSGBUF_PAC_CANID_POS 1 /* How many operands the CAN ID contains? */
-#define CAN_MSGBUF_PAC_DLC_POS 3 /* No. of operand from which DLC contains data? */
-#define CAN_MSGBUF_PAC_DATA_POS 4 /* How many operands does the DATA contain? */
-
-/* Error definitions */
-#define RET_CAN_INIT_SUCCESS RET_NORMAL /* Success in initialization */
-#define RET_CAN_INIT_ERROR RET_ERROR /* Master Clear failed */
-
-#define RET_CAN_NORMAL CANIF_RET_NORMAL /* Normal completion */
-#define RET_CAN_ERROR_CREATE_EVENT CANIF_RET_ERROR_CREATE_EVENT /* Event generation failure */
-#define RET_CAN_ERROR_PARAM CANIF_RET_ERROR_PARAM /* Specified parameter is invalid */
-#define RET_CAN_ERROR_UNDEF CANIF_RET_ERROR_UNDEF /* Unregistered ID */
-#define RET_CAN_ERROR_SNDID CANIF_RET_ERROR_PID /* Discrepancy of Destination ID */
-#define RET_CAN_ERROR_BUFFULL CANIF_RET_ERROR_BUFFULL /* Registered FULL (Delivery/Periodic Transmission/Communication Disruption Monitor) */
-#define RET_CAN_ERROR_CANIDFULL CANIF_RET_ERROR_CANIDFULL /* CAN ID type is FULL */
-#define RET_CAN_ERROR_TIMER CANIF_RET_ERROR_TIMER /* Timer acquisition failed */
-#define RET_CAN_ERROR_CANCEL CANIF_RET_ERROR_CANCEL /* Abnormal termination (discard/cancel data) */
-/* CANDataControl code used in the transmission/reception relationship */
-#define CAN_ID_EXT_FLAG 0x80000000UL /* CAN ID Extended Identity Codes */
-
-/* Timer Relationship */
-#define CAN_TIMER_SEQNO_CODE 0x0001 /* CAN thread timer sequence number */
-#define CAN_TIMER_SEQNO_BUFFLOGOUT 0x0002 /* Buffer log output timer No. */
-
-#define COMM_WATCH_SEQNO_CODE 0x0000 /* Timer Sequence Number Identification Flag of Communication Disruption */
-#define FREQ_TRANS_SEQNO_CODE 0x8000 /* Timer Sequence Number Identification Flag for Periodic Transmission */
-#define CAN_TIMER_DISTINCTION_CODE 0xF000 /* Timer Sequence Number Identification Flag */
-
-#define CAN_COMTIM_OFF 0x00 /* Timer not started */
-#define CAN_COMTIM_ON 0x01 /* Timer activation state */
-
-#define CAN_FREQ_TRSNSMISSION_LIST_NUM 32 /* Maximum number of periodic transmission management tables */
-#define COMM_WATCH_LIST_NUM 64 /* Maximum number of communication disruption monitoring management tables */
-
-
-/* Maximum number of CAN periodic transmission timer management data */
-#define CAN_FREQTRANS_TIMER_DATA CAN_FREQ_TRSNSMISSION_LIST_NUM
-/* Maximum number of CAN disruption monitoring timer management data */
-#define CAN_COMMWATCH_TIMER_DATA COMM_WATCH_LIST_NUM
-
-#define CAN_BUFFER_LOGOUT_NAME "/fs/U0/can_buffer_log.txt" /* */
-
-#define CAN_USAGE_RATE_THRESHOLD 80 /* Buffer Utilization Threshold (80%) */
-
-#define CAN_DELIVERY_DLCERR 0xfeff /* CAN delivery error (DLC) */
-#define CAN_DELIVERY_CSUMERR 0xfefe /* CAN delivery errors (CSUM) */
-#define CAN_DELIVERY_ERR 0xfefd /* CAN delivery error (delivery unregistered) */
-#define CAN_TRANCE_ICR_ERR 0xfefc /* CAN transmission error (ICR) */
-#define CAN_TRANCE_SYSCOM_ERR 0xfefb /* CAN transmission errors (SYSCOM) */
-
-/*********************************************************************
-* Type definition
-***********************************************************************/
+#define CAN_TRX_HEADER_SIZE 7 /* Size of send/receive header section (data length excluding operands) */
+#define CAN_TRX_CANID_SIZE 4 /* Transmit/Receive CAN ID Size */
+#define CAN_TRX_DLC_SIZE 1 /* Transmit/Receive DLC Data Size */
typedef CANIF_RET_API RET_CAN;
-
-typedef enum {
- CAN_PROTOCOL_TYPE_CAN = 0, /* CAN */
- /* -------------------------------------------------------------------- */
- CAN_PROTOCOL_TYPE_TERMINATE /* Mode termination */
-} CAN_PROTOCOL_TYPE;
-
-/************************************************************************
-* Function prototype *
-************************************************************************/
-RET_CAN CANMainThreadInit(void);
EFrameworkunifiedStatus CANCallbackForTimeOut(HANDLE);
-void CANTimeOutMsg(HANDLE h_app, uint16_t);
-void CANCommonTimerStart(void);
-void CANBufferLogOut(void);
-void CANDebugLogOut(uint16_t, void*);
-void CANFreqTransTimeOutMap(void);
-
-/*******************************************************************************
- * MODULE : CANMsgErrChk
- * ABSTRACT : Message Send/Receive Error Check Processing
- * FUNCTION : Check for message transmission and reception errors and perform error processing.
- * ARGUMENT : RET_API ret_api Message send/receive return value
- * : u_int16 communication_code Registration code
- * NOTE :
- * RETURN :
- ******************************************************************************/
-
-inline void CANMsgErrChk(int32_t ret_api, uint16_t communication_code) {
- if (RET_ERROR == ret_api) { /* In case of an error */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CANMsgErrChk Called.");
- exit(EXIT_FAILURE);
- }
-}
-#endif // COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_
+#endif // COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_ \ No newline at end of file
diff --git a/communication/server/include/threads/Thread_Common.h b/communication/server/include/threads/Thread_Common.h
index 91b907d5..6cda5aaf 100644
--- a/communication/server/include/threads/Thread_Common.h
+++ b/communication/server/include/threads/Thread_Common.h
@@ -1,5 +1,5 @@
/*
- * @copyright Copyright (c) 2019 TOYOTA MOTOR CORPORATION.
+ * @copyright 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,17 +16,27 @@
#ifndef COMMUNICATION_SERVER_INCLUDE_THREADS_THREAD_COMMON_H_
#define COMMUNICATION_SERVER_INCLUDE_THREADS_THREAD_COMMON_H_
#include <stdint.h>
-//#include <can_hal.h>
+#include <can_hal.h>
+#include <string>
+#include <sstream>
+#include <iostream>
+
const int32_t CAN_AVAILABILITY = 0x1;
+void CommonInit(void);
+HANDLE CommonFindSender(HANDLE h_app, std::string s);
BOOL CommGetAvailabilityCurrent(int32_t current);
void CommSetAvailabilityCurrent(int32_t current);
void CommClrAvailabilityCurrent(int32_t current);
EFrameworkunifiedStatus CommonStartNotify(HANDLE h_app, PCSTR cmd);
-//EFrameworkunifiedStatus CommonCanHalThreadStart(HANDLE h_app,
-// const FrameworkunifiedProtocolCallbackHandler *cb,
-// UI_32 count, PCSTR cmd, CanHalParam *p);
-//EFrameworkunifiedStatus CommonCanHalThreadStop(HANDLE h_app, const PUI_32 cb,
-// UI_32 count, PCSTR cmd, CanHalType type);
-EFrameworkunifiedStatus CommonCanHalErrorNotify(const char *msg, void *ctxid);
-#endif
+EFrameworkunifiedStatus CommonThreadStart(HANDLE h_app, const FrameworkunifiedProtocolCallbackHandler *cb,
+ UI_32 count, PCSTR cmd, EFrameworkunifiedStatus (*open_func)(HANDLE));
+EFrameworkunifiedStatus CommonThreadStop(HANDLE h_app, const PUI_32 cb, UI_32 count,
+ PCSTR cmd, EFrameworkunifiedStatus (*close_func)(HANDLE));
+EFrameworkunifiedStatus CommonCanHalErrorNotify(HANDLE h_app);
+
+static inline EFrameworkunifiedStatus ConvRet(CANHAL_RET_API ret) {
+ return ((ret != CANHAL_RET_NORMAL) ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK);
+}
+std::string MessageDataOutputLog(uint8_t *msg_data, uint32_t len);
+#endif \ No newline at end of file
diff --git a/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp b/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp
index abb727bd..2ece1072 100644
--- a/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp
+++ b/communication/server/src/CAN/CommWatch/CAN_CommWatch.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,255 +14,227 @@
* limitations under the License.
*/
-/*******************************************************************************
- * FILE :CAN_CommWatch.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN Thread CAN Data Communication Disruption Monitoring Management Process
- * Module configuration :CANCommWatchTimeoutMsg() CANDataCommunication Disruption Timeout Message Processing
- * :CAN_CommWatch() CANDataCommunication Disruption Monitoring Message Processing
- * :CANCommWatchClear() CANDataCommunication interruption clear processing
- * :CANVehicleInfoMsg() Vehicle sensor information notification message processing
- * :CANIgStatGet() IG reception status acquisition processing
- ******************************************************************************/
#include "CAN_CommWatch.h"
-#include <native_service/frameworkunified_types.h> // NOLINT (build/include)
+#include <native_service/frameworkunified_types.h>
#include <native_service/frameworkunified_framework_if.h>
-
#include <peripheral_service/Canif_API.h>
+#include <utility>
+#include <map>
+#include <string>
#include "CAN_Thread.h"
-#include "CAN_CommWatchData.h"
-#include "CAN_TxMsg.h"
-#include "CAN_TimerCtrl.h"
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-
-static uint8_t g_uc_comm_watch_ig_stat; /* IG receive mode */
-
-/*******************************************************************************
- * MODULE : CANCommWatchInit
- * ABSTRACT : CANDataCommunication Disruption Monitoring Initialization Process
- * FUNCTION : CANDataInitialize communication interruption monitoring
- * ARGUMENT : void
- * NOTE :
- * RETURN : void
- ******************************************************************************/
+#include "Thread_Common.h"
+
+static CAN_CommWatchTable g_map_comm_watch_list_can;
+
void CANCommWatchInit(void) {
- g_uc_comm_watch_ig_stat = CAN_COMM_IG_NORCV; /* Initialization of IG reception status */
+ g_map_comm_watch_list_can.clear();
+ return;
}
-/*******************************************************************************
- * MODULE : CANCommWatchTimeoutMsg
- * ABSTRACT : CANDataCommunication Disruption Timeout Message Processing
- * FUNCTION : Send communication interruption message when communication interruption of monitored CAN data is detected.
- * ARGUMENT : us_timer_seq_no : Timer sequence number that timed out
- * NOTE :
- * RETURN : RET_CAN_NORMAL :Normal completion
- * : RET_CAN_ERROR_CANCEL :Data destruction
- ******************************************************************************/
-RET_CAN CANCommWatchTimeoutMsg(HANDLE h_app, uint16_t us_timer_seq_no) {
- RET_CAN ret = RET_CAN_ERROR_CANCEL; /* Return value of this function */
- uint8_t uc_index; /* Index of the corresponding timer sequence number */
- uint8_t uc_comm_stop; /* Communication status of the corresponding timer sequence number */
-
- /* Determine whether communication interruption monitoring of the corresponding sequence number is registered. */
- /* Timer Sequence Number Search*/
- if (TRUE == CANCommWatchTimerSeqNoEntryCheck(us_timer_seq_no, &uc_index, &uc_comm_stop, CAN_PROTOCOL_TYPE_CAN)) {
- /* Determining whether communication is in progress */
- if ((uint8_t)CAN_COMM_NORMAL == uc_comm_stop) {
- /* Change the communication status to "Communication interrupted" */
- (void)CANCommWatchCtrl(uc_index, CAN_COMM_STOP, CAN_PROTOCOL_TYPE_CAN); /* Communication interruption state control processing */
-
- /* Send Communication Disruption Detection Message */
- (void)CANCommWatchSndMsg(h_app, uc_index); /* Transmission of communication interruption detection/recovery message */
-
- ret = RET_CAN_NORMAL;
+static CAN_CommWatchTableIt CANCommWatchFind(CANID k, CAN_COMM_WATCH_VAL *val) {
+ std::pair<CAN_CommWatchTableIt, CAN_CommWatchTableIt> range;
+ CAN_CommWatchTableIt it;
+ bool found = false;
+
+ range = g_map_comm_watch_list_can.equal_range(k);
+ for (it = range.first; it != range.second; it++) {
+ if (!memcmp(&(it->second.notify_name),
+ val->notify_name, sizeof(val->notify_name))) {
+ found = true;
+ break;
}
}
- return (ret);
+ if (!found)
+ it = g_map_comm_watch_list_can.end();
+
+ return it;
}
-/*******************************************************************************
- * MODULE : CANCommWatch
- * ABSTRACT : CANDataCommunication Disruption Monitoring Message Processing
- * FUNCTION : CANDataRegister/delete communication disruption monitoring management table
- * ARGUMENT : pst_rcv_msg :Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL :Normal completion
- * : RET_CAN_ERROR_SNDID :Distribution destination ID mismatch
- * : RET_CAN_ERROR_UNDEF :Unregistered ID
- * : RET_CAN_ERROR_TIMER :Timer acquisition failed
- * : RET_CAN_ERROR_BUFFULL :Communication Disruption Monitoring Registered Number FULL
- ******************************************************************************/
-EFrameworkunifiedStatus CANCommWatch(HANDLE h_app) {
- return CANCommWatchCore(h_app, CAN_PROTOCOL_TYPE_CAN);
+static bool CANCommWatchInsert(CANID k, CAN_COMM_WATCH_VAL *val) {
+ CAN_CommWatchTableIt it = CANCommWatchFind(k, val);
+ CAN_CommWatchTablePair p = std::make_pair((const CANID)k, *val);
+ bool inserted = false;
+
+ if (it == g_map_comm_watch_list_can.end()) {
+ g_map_comm_watch_list_can.insert(p);
+ inserted = true;
+ }
+ return inserted;
}
-EFrameworkunifiedStatus CANCommWatchCore(HANDLE h_app, CAN_PROTOCOL_TYPE mode) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
- uint8_t uc_cnt; /* Generic counters */
- uint8_t uc_index; /* Indexed */
- uint8_t uc_comm_stop = CAN_COMM_OFF; /* Communication status */
- BOOL b_id_flag = FALSE; /* Variables for Stopping Monitoring */ /* ID match flag */
- BOOL b_snd_id_flag = FALSE; /* Variables for Stopping Monitoring */ /* Destination ID match flag */
- uint16_t us_timer_seq_no; /* Variables for Starting Monitoring */ /* Acquisition Timer Sequence Number */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_COMM_WATCHEXT_MSG_DAT rcv_msg;
+static void CANCommWatchUpdate(HANDLE h_app, CANID key,
+ CAN_COMM_WATCH_VAL *val) {
+ if (CANCommWatchInsert(key, val)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "Can CommWatch : "
+ "Entry (CANID=%x, DataID=%x, dst=%s, time=%d, cnt=%lu)",
+ key, val->data_id,
+ val->notify_name, val->set_time,
+ g_map_comm_watch_list_can.size());
+ } else {
+ CAN_CommWatchTableIt it = CANCommWatchFind(key, val);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "Can CommWatch : Update the time "
+ "(CANID=%x, DataID=%x, dst=%s, time:%d -> %d, cnt =%lu)",
+ key, val->data_id, val->notify_name,
+ it->second.set_time, val->set_time,
+ g_map_comm_watch_list_can.size());
+ it->second.comm_watch_flag = val->comm_watch_flag;
+ it->second.set_time = val->set_time;
+ it->second.timer_cnt = val->timer_cnt;
+ it->second.data_id = val->data_id;
+ }
+
+ return;
+}
+
+static void CANCommWatchStop(HANDLE h_app, CANID key,
+ CAN_COMM_WATCH_VAL *val) {
+ CAN_CommWatchTableIt it = CANCommWatchFind(key, val);
+ if (it != g_map_comm_watch_list_can.end()) {
+ g_map_comm_watch_list_can.erase(it);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "Can CommWatch : Stop the commwatch"
+ "(CANID=%x, dst=%s, cnt=%lu)",
+ key, val->notify_name, g_map_comm_watch_list_can.size());
+ }
+
+ return;
+}
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN COMMWATCH START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
+EFrameworkunifiedStatus CANCommWatch(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "@@@ Start communication CanCommWatch");
+
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_COMM_WATCHEXT_MSG_DAT rcv_msg;
+ CANID key;
+ CAN_COMM_WATCH_VAL val;
+ CAN_CommWatchTableIt it;
+ memset(&rcv_msg, 0, sizeof(rcv_msg));
+ memset(&val, 0, sizeof(val));
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 != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
if (e_status == eFrameworkunifiedStatusInvldBufSize) {
FrameworkunifiedClearMsgData(h_app);
}
- ret = RET_CAN_ERROR_CANCEL;
- goto exit;
+ goto cleanup;
}
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- /* Monitor Registration/Suspension Determination */
- if ((uint16_t)0 == rcv_msg.usWatchTime) { /* Is the communication interruption time zero? */
- /*** Suspend Monitoring(Communication interruption time = 0) ***/
-
- /* Is the delivery destination ID and CANID, DID registered in the disruption monitoring table? */
- for (uc_cnt = 0; uc_cnt < (uint8_t)COMM_WATCH_LIST_NUM; uc_cnt++) {
- /* Are data with matching CANID and data IDs registered? ? */
- if (FALSE == CANCommWatchCanidDidEntryCheck(uc_cnt, rcv_msg.ulCanid, rcv_msg.ulDid, mode)) {
- continue;
- }
- b_id_flag = TRUE; /* Set the ID match flag */
-
- /* Does the shipping ID match? */
- if (FALSE == CANCommWatchSndCheck(uc_cnt, rcv_msg.notifyName, mode)) {
- continue;
- }
- b_snd_id_flag = TRUE; /* Set the delivery destination ID match flag */
- uc_index = uc_cnt; /* Store the index subject to monitoring termination. */
- break;
- }
- if (TRUE != b_id_flag) { /* No matching data */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN CommWatchStop CanID Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- ret = RET_CAN_ERROR_UNDEF; /* Undefined ID error */
- goto exit;
- }
- if (TRUE != b_snd_id_flag) { /* Distribution destination ID mismatch */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN CommWatchStop SNDID Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- ret = RET_CAN_ERROR_SNDID; /* Distribution destination ID mismatch */
- goto exit;
- }
+ // Create search data
+ key = rcv_msg.ulCanid;
+ snprintf(val.notify_name, sizeof(val.notify_name), "%s", rcv_msg.notifyName);
+ val.data_id = rcv_msg.ulDid;
+ val.comm_watch_flag = CAN_COMM_NORMAL;
+ val.set_time = rcv_msg.usWatchTime;
+ val.timer_cnt = rcv_msg.usWatchTime;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "CAN CommWatch : dst=%s, CANID=%x, dataID=%x, time=%d",
+ rcv_msg.notifyName,
+ rcv_msg.ulCanid,
+ rcv_msg.ulDid, rcv_msg.usWatchTime);
+
+ if (0 == rcv_msg.usWatchTime) {
+ CANCommWatchStop(h_app, key, &val);
+ } else {
+ CANCommWatchUpdate(h_app, key, &val);
+ }
+ e_status = eFrameworkunifiedStatusOK;
+cleanup:
+ return e_status;
+}
- /* Suspend Monitoring */
- /* Communication interruption timer stop processing */
- if (RET_CAN_NORMAL == CANCommWatchTimerStop(uc_index, mode)) { // LCOV_EXCL_BR_LINE 200:the function is always returned to RET_CAN_NORMAL //NOLINT (readability/naming)
- /* Successful stop -> delete from communication disconnection monitoring management table */
- CANCommWatchDelete(uc_index, mode);
- }
+static EFrameworkunifiedStatus CANCommWatchSndMsg(HANDLE h_app,
+ CAN_COMM_WATCH_VAL *v, uint32_t cid) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_MSG_COMM_WATCHSTS msg;
+ HANDLE h_client = NULL;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.hdr.hdr.cid = (uint16_t)cid;
+ msg.hdr.hdr.msgbodysize = sizeof(CAN_MSG_COMM_WATCHSTS_DAT);
+ msg.hdr.hdr.rid = 0;
+ msg.data.ulDid = v->data_id;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "cid=%x msgbodysize=%x ulDid=%x",
+ msg.hdr.hdr.cid, msg.hdr.hdr.msgbodysize, msg.data.ulDid);
+
+ h_client = CommonFindSender(h_app, v->notify_name);
+ if (!h_client){
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CommonFindSender failed");
+ goto cleanup;
+ }
+
+ e_status = FrameworkunifiedSendMsg(h_client, cid, sizeof(msg), &msg);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
+ "FrameworkunifiedSendMSg Error(e_status:%d to %s)",
+ e_status, v->notify_name);
+ goto cleanup;
+ }
+ e_status = eFrameworkunifiedStatusOK;
+cleanup:
+ return e_status;
+}
+
+static void CANCommWatchTimeoutCore(HANDLE h_app, CAN_COMM_WATCH_VAL *v) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+
+ if (CAN_COMM_NORMAL != v->comm_watch_flag)
+ return;
+
+ if (v->timer_cnt != 0)
+ v->timer_cnt--;
+
+ if (v->timer_cnt != 0)
+ return;
+
+ e_status = CANCommWatchSndMsg(h_app, v, CID_CAN_COMM_STOP);
+ if (eFrameworkunifiedStatusOK == e_status) {
+ v->comm_watch_flag = CAN_COMM_STOP;
} else {
- /* Storage status can be checked? */
- /* No free space */
- if (TRUE != CANCommWatchEntryCheck(rcv_msg.ulCanid, rcv_msg.ulDid, rcv_msg.notifyName, &uc_index, mode)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN CommWatch BufferFull"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- ret = RET_CAN_ERROR_BUFFULL;
- goto exit;
- }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CANCommWatchSndMsg failed");
+ // retry at next timeout.
+ }
+}
- /* Timer stop */
- (void)CANCommWatchTimerStop(uc_index, mode);
-
- /* IG linkage OFF or IG linkage ON and IG reception in progress */
- if ((rcv_msg.ucIg == (uint8_t)CAN_IG_COOPERATION_OFF) || ((rcv_msg.ucIg == (uint8_t)CAN_IG_COOPERATION_ON) && (g_uc_comm_watch_ig_stat == (uint8_t)CAN_COMM_IG_ON))) { // LCOV_EXCL_BR_LINE 200: rcv_msg.ucIg is always be CAN_IG_COOPERATION_OFF //NOLINT (readability/naming)
- /* Timer activation */
- /* Communication interruption monitoring timer start processing */
- if (RET_CAN_NORMAL != CANCommWatchTimerStart(uc_index, rcv_msg.usWatchTime, mode)) { // LCOV_EXCL_BR_LINE 200:the function is always returned to RET_CAN_NORMAL //NOLINT (readability/naming)
- // LCOV_EXCL_START 200: the function is always returned to RET_CAN_NORMAL
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = RET_CAN_ERROR_TIMER; /* Timer start failure -> Return value setting: Timer acquisition error */
- goto exit;
- } // LCOV_EXCL_STOP 200: the function is always returned to RET_CAN_NORMAL
- /* Communication type = set during communication */
- uc_comm_stop = CAN_COMM_NORMAL;
- }
+EFrameworkunifiedStatus CANCommWatchTimeout(HANDLE h_app) {
+ CAN_CommWatchTableIt it;
- /* Timer sequence number acquisition */
- us_timer_seq_no = CANCommWatchTimerSeqNoGet(uc_index, mode);
- /* CANDataCommunication Disruption Monitoring Management Table Registration Process */
- CANCommWatchEntry(uc_index, &rcv_msg, us_timer_seq_no, uc_comm_stop, mode);
+ for (it = g_map_comm_watch_list_can.begin();
+ it != g_map_comm_watch_list_can.end(); it++) {
+ CANCommWatchTimeoutCore(h_app, &(it->second));
}
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "END(ret=%x)", ret); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- if (ret == RET_CAN_NORMAL)
- return eFrameworkunifiedStatusOK;
- else
- return eFrameworkunifiedStatusFail;
- // return RET_CAN_NORMAL;
+ return eFrameworkunifiedStatusOK;
}
-/*******************************************************************************
- * MODULE : CANCommWatchClear
- * ABSTRACT : CANDataCommunication interruption clear processing
- * FUNCTION : Sends a communication recovery message and restarts the timer.
- * ARGUMENT : can_id :Received CAN ID
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchClear(HANDLE h_app, CANID can_id) {
- uint8_t uc_cnt; /* Counter */
- uint8_t uc_comm_stop; /* Communication status */
- BOOL ret;
- uint16_t us_tbl_chk_cnt = 0; /* Number of effective data checks for communication disruption table */
-
- /* Corresponding CAN ID retrieval in communication interruption monitoring control table */
- for (uc_cnt = 0; uc_cnt < (uint8_t)COMM_WATCH_LIST_NUM; uc_cnt++) {
- ret = CANCommWatchCanidEntryCheck(uc_cnt, can_id, &uc_comm_stop, &us_tbl_chk_cnt, CAN_PROTOCOL_TYPE_CAN);
- /* CAN ID matching ? */
- if (TRUE == ret) {
- /* Is communication interrupted? */
- if ((uint8_t)CAN_COMM_STOP == uc_comm_stop) {
- /* Change the communication state to "Communicating" */
- (void)CANCommWatchCtrl(uc_cnt, CAN_COMM_NORMAL, CAN_PROTOCOL_TYPE_CAN); /* Communication interruption state control processing */
- uc_comm_stop = CAN_COMM_NORMAL;
- /* Send communication disruption recovery message */
- (void)CANCommWatchSndMsg(h_app, uc_cnt); /* Transmission of communication interruption detection/recovery message */
- }
-
- /* Timer restart only when communication status is in progress */
- if (uc_comm_stop == (uint8_t)CAN_COMM_NORMAL) {
- /* Timer restart */
- (void)CANCommWatchTimerRenewal(uc_cnt, CAN_PROTOCOL_TYPE_CAN); /* Communication interruption monitoring timer update processing */
- }
- }
- /* Check for completion of retrieval of all valid table data */
- if (us_tbl_chk_cnt >= g_us_comm_watch_dat_cnt[CAN_PROTOCOL_TYPE_CAN]) {
- /* Completion of retrieval of all valid data for the table */
- break;
- }
- }
+static void CANCommWatchClearCore(HANDLE h_app, CANID id,
+ CAN_COMM_WATCH_VAL *v) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
- return;
+ v->timer_cnt = v->set_time;
+
+ if (CAN_COMM_STOP != v->comm_watch_flag)
+ return;
+
+ e_status = CANCommWatchSndMsg(h_app, v, CID_CAN_COMM_RESTORE);
+ if (eFrameworkunifiedStatusOK == e_status) {
+ v->comm_watch_flag = CAN_COMM_NORMAL;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "Can CommWatch Clear : CANID=%x", id);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CANCommWatchSndMsg failed");
+ // retry at next timeout.
+ }
}
-/*******************************************************************************
- * MODULE : CANIgStatGet
- * ABSTRACT : IG reception status acquisition processing
- * FUNCTION : Obtain IG reception information
- * ARGUMENT : void
- * NOTE :
- * RETURN : IG Information Received
- ******************************************************************************/
-
-uint8_t CANIgStatGet(void) { // LCOV_EXCL_START 8: for dead code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- return (g_uc_comm_watch_ig_stat);
+void CANCommWatchClear(HANDLE h_app, CANID id) {
+ std::pair<CAN_CommWatchTableIt, CAN_CommWatchTableIt> range;
+ CAN_CommWatchTableIt it;
+
+ range = g_map_comm_watch_list_can.equal_range(id);
+ for (it = range.first; it != range.second; it++) {
+ CANCommWatchClearCore(h_app, id, &(it->second));
+ }
}
-// LCOV_EXCL_STOP
diff --git a/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp b/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp
deleted file mode 100644
index 8b5a4681..00000000
--- a/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * FILE :CAN_CommWatchData.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN thread CAN data communication interruption monitoring data management
- * Module configuration :Can_CommWatchData_Init() CAN Data Communication Disruption Monitoring Management Data Initialization Process
- * :CANCommWatchCanidDidEntryCheck() CANDataCommunication Disruption Monitoring Control Table Registration Status Checking Process (CAN ID and DataID Retrieval)
- * :CANCommWatchTimerSeqNoEntryCheck() CANDataCommunication Disruption Monitoring Management Table Registration Status Checking Process (Timer Sequence Number Search)
- * :CANCommWatchEntryCheck() CANDataCommunication Disruption Monitoring Management Table Registration Destination Confirmation Process
- * :CANCommWatchEntry() CANDataCommunication Disruption Monitoring Management Table Registration Process
- * :CANCommWatchDelete() CANDataCommunication Disruption Monitoring Management Table Deletion Processing
- * :CANCommWatchCtrl() Communication interruption state control processing
- * :CANCommWatchDataGet() Communication interruption data acquisition process
- * :CANCommWatchTimerSeqNoGet() Acquisition of Communication Disruption Monitor Timer Sequence Number
- * :CANCommWatchTimerSeqNoRenwal() Communication interruption monitoring timer sequence number update processing
- * :CANCommWatchSndCheck() CANDataCommunication Disruption Monitoring Management Table Delivery Destination ID Confirmation Process
- * :CANCommWatchIgcoopGet() IG linkage information acquisition processing of the communication disruption monitoring management table
- ******************************************************************************/
-#include "CAN_CommWatchData.h"
-
-#include <string.h> // NOLINT (build/include)
-#include <native_service/frameworkunified_types.h>
-#include <other_service/strlcpy.h>
-
-#include <peripheral_service/Canif_API.h>
-#include "CAN_Thread.h"
-
-/*************************************************/
-/* Global variables */
-/*************************************************/
-/* Timer sequence number increment counter */
-static uint16_t g_us_comm_watch_timer_seq_no = COMM_WATICH_TIMER_SEQ_NO_MIN;
-CAN_COMM_WATCH_DAT g_st_comm_watch_dat[CAN_PROTOCOL_TYPE_TERMINATE][COMM_WATCH_LIST_NUM]; /* Communication disruption monitoring management table */
-uint16_t g_us_comm_watch_dat_cnt[CAN_PROTOCOL_TYPE_TERMINATE]; /* Number of effective registrations of communication disruption monitoring management table */
-
-/*******************************************************************************
- * MODULE : CANCommWatchDataInit
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Data Initialization Process
- * FUNCTION : CANDataInitializing management data for communication disruption monitoring
- * ARGUMENT : void
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchDataInit(void) {
- for (int i = 0; i < CAN_PROTOCOL_TYPE_TERMINATE; i++) {
- /* Communication disruption monitoring management table */
- memset(g_st_comm_watch_dat[i], 0x00, sizeof(CAN_COMM_WATCH_DAT) * COMM_WATCH_LIST_NUM);
- g_us_comm_watch_dat_cnt[i] = 0; /* Number of effective registrations of communication disruption monitoring management table */
- }
- return;
-}
-
-/*******************************************************************************
- * MODULE : CAN_CommWatchCanidDidIDEntryCheck
- * ABSTRACT : CANDataCommunication Disruption Monitoring Control Table Registration Status Checking Process (CAN ID and DataID Retrieval)
- * FUNCTION : Compares the specified indexes of the communication interruption monitoring control table with the CAN ID and data IDs.
- * ARGUMENT : uc_index :Indexed
- * can_id :CAN ID
- * ul_did :Data ID
- * NOTE :
- * RETURN : TRUE :Data consistency
- * FALSE :Data mismatch
- ******************************************************************************/
-BOOL CANCommWatchCanidDidEntryCheck(uint8_t uc_index, CANID can_id, DID ul_did, CAN_PROTOCOL_TYPE mode) {
- BOOL ret = FALSE;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Is the specified index monitoring interrupted? */
- if ((uint16_t)0 != ptr->us_watch_time) {
- /* The CANID and data identifier of the named index data matches the arguments? */
- if (can_id == ptr->ul_can_id) {
- if (ul_did == ptr->ul_did) {
- ret = TRUE;
- }
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerSeqNoEntryCheck
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Table Registration Status Checking Process (Timer Sequence Number Search)
- * FUNCTION : Returns the index of the communication interruption monitoring management table with the specified timer sequence number
- * ARGUMENT : us_timer_seq_no :Search timer sequence number
- * puc_index :Index return pointer
- * puc_comm_stop :Communication status return pointer
- * NOTE :
- * RETURN : TRUE :Registered
- * FALSE :No registration
- ******************************************************************************/
-BOOL CANCommWatchTimerSeqNoEntryCheck(uint16_t us_timer_seq_no, uint8_t *puc_index,
- uint8_t *puc_comm_stop, CAN_PROTOCOL_TYPE mode) {
- uint32_t ul_cnt;
- BOOL ret = FALSE;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][0];
-
- /* Timer Sequence Number Search */
- for (ul_cnt = 0; ul_cnt < COMM_WATCH_LIST_NUM; ul_cnt++) {
- /* Is monitoring interrupted? */
- if ((uint16_t)0 != ptr[ul_cnt].us_watch_time) {
- /* Match Timer Sequence Number */
- if (us_timer_seq_no == ptr[ul_cnt].us_timer_seq_no) {
- ret = TRUE;
- *puc_index = (uint8_t)ul_cnt;
- *puc_comm_stop = ptr[ul_cnt].uc_comm_stop;
-
- break;
- }
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchEntryCheck
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Table Registration Destination Confirmation Process
- * FUNCTION : Returns the registerable index in the communication disconnection monitoring management table
- * ARGUMENT : can_id :CAN ID
- * ul_did :Data ID
- * notifyId :Addresses for delivery ID
- * puc_index :Index return pointer
- * NOTE :
- * RETURN : TRUE :Can be registered
- * FALSE :Unable to register
- ******************************************************************************/
-BOOL CANCommWatchEntryCheck(CANID can_id, DID ul_did, PCSTR notify_name, uint8_t *puc_index, CAN_PROTOCOL_TYPE mode) {
- uint32_t ul_cnt;
- BOOL ret = FALSE;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][0];
-
- /* Search duplicate data */
- for (ul_cnt = 0; ul_cnt < COMM_WATCH_LIST_NUM; ul_cnt++) {
- /* CANID, DataID, Shipping ID Matching? */
- if ((can_id == ptr[ul_cnt].ul_can_id) &&
- (ul_did == ptr[ul_cnt].ul_did) &&
- (strcmp(notify_name, ptr[ul_cnt].notify_name) == 0)) {
- ret = TRUE;
- *puc_index = (uint8_t)ul_cnt;
-
- break;
- }
- }
- if (FALSE == ret) {
- /* Search for free table */
- for (ul_cnt = 0; ul_cnt < COMM_WATCH_LIST_NUM; ul_cnt++) {
- /* Free (communication interruption time = 0)? */
- if ((uint16_t)0 == ptr[ul_cnt].us_watch_time) {
- ret = TRUE;
- *puc_index = (uint8_t)ul_cnt;
- break;
- }
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchEntry
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Table Registration Process
- * FUNCTION : Register data in the communication interruption monitoring management table
- * ARGUMENT : uc_index :Index of registration destination
- * ul_did :Data to register ID
- * notifyId :Process ID to register
- * ulCanid :CAN ID to register
- * usWatchTime :Communication interruption time to register
- * ucIg :IG linkage flag to be registered
- * us_timer_seq_no :Timer sequence number to register
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchEntry(uint8_t uc_index, const CAN_COMM_WATCHEXT_MSG_DAT *pst_msg_data,
- uint16_t us_timer_seq_no, uint8_t uc_comm_stop, CAN_PROTOCOL_TYPE mode) {
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Confirm whether overwriting or addition of communication disruption monitoring management table */
- if ((uint16_t)0 == ptr->us_watch_time) {
- /* In case of additional registration, update the number of registered data */
- g_us_comm_watch_dat_cnt[mode]++;
- }
- /* Register new monitoring data in communication interruption monitoring management table */
- strlcpy(ptr->notify_name, pst_msg_data->notifyName, sizeof(ptr->notify_name)); /* Store Destination Thread Name */
- ptr->ul_did = pst_msg_data->ulDid; /* Data ID storage */
- ptr->ul_can_id = pst_msg_data->ulCanid; /* CAN ID storage */
- ptr->us_watch_time = pst_msg_data->usWatchTime; /* Communication interruption time storage */
- ptr->uc_comm_stop = uc_comm_stop; /* Communication state storage */
- ptr->uc_ig = pst_msg_data->ucIg; /* IG linkage information storage */
- ptr->us_timer_seq_no = us_timer_seq_no; /* Store timer sequence number */
- /* Log output */
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__,
- "##### COMMWaitTable [Index:0x%04x, SndId:0x%s, Did:0x%08x, CanID:0x%08x, Tim:0x%04x, Comm:0x%04x, IG:0x%04x, TimSeq:0x%04x] ##### ", // NOLINT (whitespace/line_length)
- uc_index, ptr->notify_name, ptr->ul_did, ptr->ul_can_id,
- ptr->us_watch_time, ptr->uc_comm_stop, ptr->uc_ig, ptr->us_timer_seq_no);
- // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchDelete
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Table Deletion Processing
- * FUNCTION : Delete the data in the communication disconnection monitoring management table.
- * ARGUMENT : uc_index :Destination index
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchDelete(uint8_t uc_index, CAN_PROTOCOL_TYPE mode) {
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* To 0 all members of the data for the specified index */
- memset(ptr->notify_name, 0x00, sizeof(ptr->notify_name)); /* Initialization of delivery destination thread name */
- ptr->ul_did = 0; /* Data ID initialization */
- ptr->ul_can_id = 0; /* CAN ID initialization */
- ptr->us_watch_time = 0; /* Communication interruption time initialization */
- ptr->uc_comm_stop = 0; /* Communication status initialization */
- ptr->uc_ig = 0; /* Initialization of IG linkage information */
- ptr->us_timer_seq_no = 0; /* Initialization of timer sequence number */
-
- if ((uint16_t)0 != g_us_comm_watch_dat_cnt[mode]) {
- g_us_comm_watch_dat_cnt[mode]--; /* Updating the number of registered data */
- }
- /* Log output */
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### COMMWaitTableDel [Index:0x%04x] #####", uc_index); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchCtrl
- * ABSTRACT : Communication interruption state control processing
- * FUNCTION : Setting communication interruption status
- * ARGUMENT : uc_index :Index to set
- * uc_comm_stop :Communication status to be set
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchCtrl(uint8_t uc_index, uint8_t uc_comm_stop, CAN_PROTOCOL_TYPE mode) {
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Change communication status */
- ptr->uc_comm_stop = uc_comm_stop;
- /* Log output */
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__,
- "##### COMMWaitTable [Index:0x%04x, SndId:0x%s, Did:0x%08x, CanID:0x%08x, Tim:0x%04x, Comm:0x%04x, IG:0x%04x, TimSeq:0x%04x] #####", // NOLINT (whitespace/line_length)
- uc_index, ptr->notify_name, ptr->ul_did, ptr->ul_can_id,
- ptr->us_watch_time, ptr->uc_comm_stop, ptr->uc_ig, ptr->us_timer_seq_no);
- // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchDataGet
- * ABSTRACT : Communication interruption data acquisition process
- * FUNCTION : Returns the disconnected data for the specified index
- * ARGUMENT : uc_index :Indexed
- * pNotifyId :Destination ID Return Pointer
- * pul_did :Data ID return pointer
- * puc_comm_stop :Communication status return pointer
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANCommWatchDataGet(uint8_t uc_index, char *p_notify_name, DID *pul_did,
- uint8_t *puc_comm_stop, CAN_PROTOCOL_TYPE mode) {
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- snprintf(p_notify_name, strlen(ptr->notify_name) + 1, "%s", ptr->notify_name);
- *pul_did = ptr->ul_did; /* Data ID */
- *puc_comm_stop = ptr->uc_comm_stop; /* Communication status */
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerSeqNoGet
- * ABSTRACT : Acquisition of Communication Disruption Monitor Timer Sequence Number
- * FUNCTION : Returns the timer sequence number at the specified index
- * ARGUMENT : uc_index :Indexed
- * NOTE :
- * RETURN : Timer Sequence Number
- ******************************************************************************/
-uint16_t CANCommWatchTimerSeqNoGet(uint8_t uc_index, CAN_PROTOCOL_TYPE mode) {
- uint16_t us_timer_seq_no;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Timer sequence number of the target index */
- us_timer_seq_no = ptr->us_timer_seq_no;
-
- return (us_timer_seq_no);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerSeqNoRenwal
- * ABSTRACT : Communication interruption monitoring timer sequence number update processing
- * FUNCTION : Updates the timer sequence number at the specified index
- * ARGUMENT : uc_index :Indexed
- * pus_watch_time :Communication interruption time return pointer
- * NOTE :
- * RETURN : Timer Sequence Number
- ******************************************************************************/
-uint16_t CANCommWatchTimerSeqNoRenwal(uint8_t uc_index, uint16_t *pus_watch_time, CAN_PROTOCOL_TYPE mode) {
- uint16_t us_timer_seq_no;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Updating the timer sequence number of the target index */
- ptr->us_timer_seq_no = g_us_comm_watch_timer_seq_no;
-
- /* Timer sequence number increment counter + 1 */
- g_us_comm_watch_timer_seq_no++;
-
- /* Check whether it is within the range of the sequence number used for communication interruption monitoring */
- if (g_us_comm_watch_timer_seq_no > (uint16_t)COMM_WATICH_TIMER_SEQ_NO_MAX) {
- g_us_comm_watch_timer_seq_no = COMM_WATICH_TIMER_SEQ_NO_MIN;
- }
-
- /* Return value setting */
- us_timer_seq_no = ptr->us_timer_seq_no;
- *pus_watch_time = ptr->us_watch_time;
- /* Log output */
- // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__,
- "##### COMMWaitTable [Index:0x%04x, SndId:0x%s, Did:0x%08x, CanID:0x%08x, Tim:0x%04x, Comm:0x%04x, IG:0x%04x, TimSeq:0x%04x] #####", // NOLINT (whitespace/line_length)
- uc_index, ptr->notify_name, ptr->ul_did, ptr->ul_can_id,
- ptr->us_watch_time, ptr->uc_comm_stop, ptr->uc_ig, ptr->us_timer_seq_no);
- // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return (us_timer_seq_no);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchSndCheck
- * ABSTRACT : CANDataCommunication Disruption Monitoring Management Table Delivery Destination ID Confirmation Process
- * FUNCTION : Compare the specified index of the communication interruption monitoring management table with the delivery destination ID.
- * ARGUMENT : uc_index :Indexed
- * notifyId :Addresses for delivery ID
- * NOTE :
- * RETURN : TRUE :Data consistency
- * FALSE :Data mismatch
- ******************************************************************************/
-BOOL CANCommWatchSndCheck(uint8_t uc_index, PCSTR notify_name, CAN_PROTOCOL_TYPE mode) {
- BOOL ret = FALSE;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* Destination ID of specified index data matches argument? */
- if (strcmp(notify_name, ptr->notify_name) == 0) {
- ret = TRUE;
- }
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchIgcoopGet
- * ABSTRACT : IG linkage information acquisition processing of the communication disruption monitoring management table
- * FUNCTION : Returns the IG linkage value of the specified index
- * ARGUMENT : uc_index :Indexed
- * NOTE :
- * RETURN : CAN_IG_COOPERATION_OFF :IG no collaboration
- * CAN_IG_COOPERATION_ON :IG Has collaborations
- ******************************************************************************/
-
-uint8_t CANCommWatchIgcoopGet(uint8_t uc_index, CAN_PROTOCOL_TYPE mode) { // LCOV_EXCL_START 8:the function is not used
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- uint8_t uc_ig_cooperation;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index];
-
- /* IG linkage value of the target index */
- uc_ig_cooperation = ptr->uc_ig;
-
- return (uc_ig_cooperation);
-}
-// LCOV_EXCL_STOP
-
-/*******************************************************************************
- * MODULE : CANCommWatchBufferOut
- * ABSTRACT : CAN communication interruption table log output processing
- * FUNCTION : Output CAN communication disruption table log
- * ARGUMENT : FILE *fp_log : File pointer of the log output file
- * NOTE :
- * RETURN :
- ******************************************************************************/
-
-void CANCommWatchBufferOut(FILE *fp_log, CAN_PROTOCOL_TYPE mode) { // LCOV_EXCL_START 8:the function is not used
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- int32_t usage_rate;
- uint16_t i;
- uint16_t data_cnt = 0;
- CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][0];
-
- if (NULL != fp_log) {
- /* Output of communication disruption management table */
- (void)fprintf(fp_log, "CAN CommWatch Buffer \n");
- (void)fprintf(fp_log, "CanID: SNDID: DID: Time: State: IG_mode: TimeSeq:\n");
- for (i = 0; i < (uint16_t)COMM_WATCH_LIST_NUM; i++) {
- /* Free (communication interruption time = 0)? */
- if ((uint16_t)0 != ptr[i].us_watch_time) {
- (void)fprintf(fp_log, "%08x %s %08x %04x %04x %04x %04x\n",
- ptr[i].ul_can_id,
- ptr[i].notify_name,
- ptr[i].ul_did,
- ptr[i].us_watch_time,
- ptr[i].uc_comm_stop,
- ptr[i].uc_ig,
- ptr[i].us_timer_seq_no);
- data_cnt++;
- }
- }
- usage_rate = (((int32_t)data_cnt * 100) / COMM_WATCH_LIST_NUM);
- (void)fprintf(fp_log, "BUFFER_Use: %04d BUFFER_Max: %04d Usage_Rate: %04d \n",
- data_cnt, COMM_WATCH_LIST_NUM, usage_rate);
- if (usage_rate >= CAN_USAGE_RATE_THRESHOLD) {
- (void)fprintf(fp_log, "Warning: Buffer utilization exceeds a threshold.\n");
- }
- }
-}
-// LCOV_EXCL_STOP
-
-// LCOV_EXCL_START 7: debug code
-EFrameworkunifiedStatus CANCommWatchAllClearDebug(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- if (access("/tmp/communication_debug", F_OK) == 0) {
- FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "g_st_comm_watch_dat[CAN].");
- /* Communication disruption monitoring management table */
- memset(g_st_comm_watch_dat[0], 0x00, sizeof(CAN_COMM_WATCH_DAT) * COMM_WATCH_LIST_NUM);
- g_us_comm_watch_dat_cnt[0] = 0; /* Number of effective registrations of communication disruption monitoring management table */
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "/tmp/communication_debug Not found.");
- }
- return eFrameworkunifiedStatusOK;
-}
-// LCOV_EXCL_STOP 7: debug code
diff --git a/communication/server/src/CAN/Command/CAN_Command.cpp b/communication/server/src/CAN/Command/CAN_Command.cpp
deleted file mode 100644
index f7875362..00000000
--- a/communication/server/src/CAN/Command/CAN_Command.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * Module configuration :CANCommandTransmission() CAN command transmission processing
- * :CANCommandTxRslt() CAN command transmission result notification processing
- * :CANCommandDelivery() CAN command delivery process
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @file CAN_Command.cpp
- * @~english
- * @brief CAN Command process
- */
-#include "CAN_Command.h"
-
-#include <native_service/frameworkunified_types.h> // NOLINT (build/include)
-#include <native_service/frameworkunified_framework_if.h>
-#include <peripheral_service/Canif_API.h>
-//#include <can_hal.h>
-#include <string>
-#include "CAN_Thread.h"
-#include "CAN_Delivery.h"
-#include "CAN_CommandData.h"
-#include "CAN_TxMsg.h"
-#include "ICR_Common.h"
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-
-/*******************************************************************************
- * MODULE : CANCommandTransmission
- * ABSTRACT : CAN command transmission processing
- * FUNCTION : Control the transmission of CAN commands
- * ARGUMENT : pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_CREATE_EVENT : Event generation failure
- * RET_CAN_ERROR_BUFFULL : Delivery registration FULL or result notification registration FULL
- ******************************************************************************/
-EFrameworkunifiedStatus CANCommandTransmission(HANDLE h_app) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
- BOOL b_dlvry_flag = TRUE; /* Delivery registration flag */
- BOOL b_tx_rslt_flag = TRUE; /* Notification registration flag */
- BOOL b_com_flag = TRUE; /* Command transmission flag */
- BOOL b_snd_msg_flag = FALSE; /* RST request MSG send flag */
- uint8_t uc_can_rid = CAN_RID_NOTUSE_CODE;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_CMD_CTRL_MSG_DAT rcv_msg;
-
- 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);
- }
- ret = RET_CAN_ERROR_CANCEL;
- goto exit;
- }
-
- if ((uint8_t)CAN_CMDID_VERSION_REQ_TX == rcv_msg.ucCmdid) {
- CAN_MSG_CANCMD data = {0x00};
- std::string version_info;
-// CANHAL_RET_API ret;
-
-// ret = CanGetVersion(&version_info);
-// if (CANHAL_RET_NORMAL != ret) {
-// return eFrameworkunifiedStatusFail;
-// }
-
- if (CAN_TX_CMD_VERSION_SIZE != version_info.length()) {
- return eFrameworkunifiedStatusFail;
- }
-
- memcpy(data.data.data, version_info.c_str(), CAN_TX_CMD_VERSION_SIZE);
-
-// data.hdr.hdr.cid = CID_CAN_CMD_DELIVERY;
-// data.hdr.hdr.rid = 0;
-// data.hdr.hdr.msgbodysize = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_VERSION_SIZE;
- data.data.cmd_id = CAN_CMDID_VERSION_RESP_RX;
-
- HANDLE client = FrameworkunifiedMcOpenSender(h_app, rcv_msg.notifyName); // LCOV_EXCL_BR_LINE 11:except,C++ STL
- if (NULL == client) {
- return eFrameworkunifiedStatusFail;
- }
-
- e_status = FrameworkunifiedSendMsg(client, CID_CAN_CMD_DELIVERY, sizeof(CAN_MSG_CANCMD), &data); // LCOV_EXCL_BR_LINE 200: unexpect branch //NOLINT (readability/naming)
- if (eFrameworkunifiedStatusOK != e_status) {
- return eFrameworkunifiedStatusFail;
- }
-
- return eFrameworkunifiedStatusOK;
- }
-
- /* Reset request delivery request */
- if ((uint8_t)CAN_CMDID_FUELCALC_RST_REQ_DELIVERY == rcv_msg.ucCmdid) { /* #104 */
- b_tx_rslt_flag = FALSE;
-
- /* Check reset reception status */
- if (TRUE == CANCommandFuelCalcRstReqCheck()) {
- /* Cost reset request received in CAN section */
- b_dlvry_flag = FALSE;
- b_snd_msg_flag = TRUE;
- } else {
- /* CAN section flammability reset request not received */
- b_com_flag = FALSE;
- if (FALSE == CANCommandDeliveryEntryCheck(rcv_msg.notifyName, rcv_msg.ucCmdid)) {
- ret = RET_CAN_ERROR_BUFFULL; /* CAN-command delivery control table FULL */
- goto exit;
- }
- }
- } else {
- /* Delivery Registration? */
- if ((uint8_t)CAN_CMDID_FUELCALC_REQ_TX == rcv_msg.ucCmdid) { /* #104 */
- /* Not registered for delivery */
- b_dlvry_flag = FALSE;
- } else {
- /* Register for delivery */
- if (FALSE == CANCommandDeliveryEntryCheck(rcv_msg.notifyName, rcv_msg.ucCmdid)) {
- ret = RET_CAN_ERROR_BUFFULL; /* CAN-command delivery control table FULL */
- goto exit;
- }
- }
-
- /* Register transmission result notification? */
- if ((uint8_t)CAN_RID_NOTUSE_CODE == rcv_msg.ucRid) { /* #104 */
- /* Not to register transmission result notification */
- b_tx_rslt_flag = FALSE;
- } else {
- /* Register transmission result notification */
- if (FALSE == CANCommandTxRsltEntryCheck(rcv_msg.ucCmdid, &uc_can_rid)) {
- ret = RET_CAN_ERROR_BUFFULL; /* CAN-command-send-result-management-table FULL */
- goto exit;
- }
- }
- }
-
- if (TRUE == b_snd_msg_flag) {
- /* CAN section flame reset request message transmission */
- CANCommandFuelCalcRstReqSndMsg(h_app, rcv_msg.notifyName);
- } else {
- if (TRUE == b_dlvry_flag) {
- /* CAN command delivery registration */
- CANCommandDeliveryEntry(rcv_msg.notifyName, rcv_msg.ucCmdid);
- }
- if (TRUE == b_tx_rslt_flag) {
- /* CAN command transmission result notification registration */
- CANCommandTxRsltEntry(uc_can_rid, rcv_msg.notifyName, rcv_msg.ucRid);
- }
- if (TRUE == b_com_flag) {
-// CanMessage st_can_data;
-//
-// st_can_data.can_id = rcv_msg.ucCmdid;
-// st_can_data.rid = uc_can_rid;
-// st_can_data.dlc = (uint8_t)CAN_CMDSND_DATA_SIZE;
-
-// if (CANHAL_RET_NORMAL != CanSend(&st_can_data, CAN_HAL_TYPE_CAN)) {
-// ret = RET_CAN_ERROR_PARAM;
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission CANHAL Error"); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
-// }
- }
- }
-
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "ret=%x", ret); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
- if (ret == RET_CAN_NORMAL)
- return eFrameworkunifiedStatusOK;
- else
- return eFrameworkunifiedStatusFail;
- // return RET_CAN_NORMAL;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandTxRslt
- *******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN command transmission result notification processing
- *
- * CAN command transmission result notification processing
- *
- * Notify the result of CAN command transmission
- *
- * @~english
- * @note
- * -# Transmission result status acquisition
- * -# Transmission result notification registration detection
- * -# Message sending
- * -# Result notification registration deletion
- *
- * @~english
- * @return Transmission result
- * @retval <RET_CAN_NORMAL> Normality
- * @retval <RET_CAN_ERROR_CANCEL> Data annulment
- *
- * @~english
- * @param[in] <pst_rcv_msg> Reception message reference pointer
- */
-RET_CAN CANCommandTxRslt(HANDLE h_app, CAN_MSG_DATA *pst_rcv_msg) { // LCOV_EXCL_START 8:this IF is called in CANIcrSndStsProcess, and CAN command TX to can_hal, but not ICR // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-// T_ICR_CMDSNDCNF_STS *pst_msg_data; /* Receive data structure pointer */
- uint8_t uc_status; /* Reception status */
-
- /* Type conversion */
-// pst_msg_data = reinterpret_cast<T_ICR_CMDSNDCNF_STS *>(reinterpret_cast<void *>(&pst_rcv_msg->ucData[0]));
-
- /* Acquisition of transmission result status */
-// switch (pst_msg_data->cnf_sts) {
-// case ICR_SND_SUCCESS:
-// uc_status = CAN_SUCCESS; /* Transmission completion */
-// break;
-// case ICR_SND_ERR_RETRYOUT:
-// uc_status = CAN_RETRYOUT; /* Re-tryout */
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// case ICR_SND_ERR_BUFFERFULL:
-// uc_status = CAN_BUFFERFUL; /* Transmit Buffer Full */
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// default:
-// ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// }
-
- if (RET_CAN_NORMAL == ret) {
- /* Send result notification registration detection */
-// if (FALSE == CANCommandTxRsltCheck(pst_rcv_msg->stHead.hdr.rid)) {
-// ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
-// }
- }
-
- if (RET_CAN_NORMAL == ret) {
- /* Send Result Notification Message */
-// CANCommandTxRsltSndMsg(h_app, pst_rcv_msg->stHead.hdr.rid, uc_status);
-
- /* Delete registered result notification */
-// CANCommandTxRsltDelete(pst_rcv_msg->stHead.hdr.rid);
- }
-
- return (ret);
-}
-// LCOV_EXCL_STOP
-
-/*******************************************************************************
- * MODULE : CANCommandDelivery
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN command delivery processing
- *
- * CAN command delivery processing
- *
- * Deliver CAN commands
- *
- * @~english
- * @note
- * -# CAN command ID conversion
- * -# Control flag operation (The reset demand is received).
- * -# Message sending
- * -# Delivery registration deletion
- *
- * @~english
- * @return Delivery result
- * @retval <RET_CAN_NORMAL> Normality
- * @retval <RET_CAN_ERROR_CANCEL> Data annulment
- *
- * @~english
- * @param[in] <pst_rcv_msg> Reception message reference pointer
- */
-RET_CAN CANCommandDelivery(HANDLE h_app, CAN_MSG_DATA *pst_rcv_msg) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-// T_ICR_CMD_DATA *pst_msg_data; /* Receive data structure pointer */
- uint8_t uc_cmd_id; /* Receive CAN command ID */
-
- /* Type conversion */
-// pst_msg_data = reinterpret_cast<T_ICR_CMD_DATA *>(reinterpret_cast<void *>(&pst_rcv_msg->ucData[0]));
-
- /* OPC-> CAN command ID conversion */
-// if (FALSE == CANCommandidOpcToUserCvt(pst_msg_data->opc, &uc_cmd_id)) { // LCOV_EXCL_BR_LINE 6: double check
-// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-// ret = RET_CAN_ERROR_CANCEL; /* Data destruction */ // LCOV_EXCL_LINE 6: double check
-// }
-
- if (RET_CAN_NORMAL == ret) { // LCOV_EXCL_BR_LINE 200: ret will not assigned to other value forever
- /* Set the control flag to received if CAN command section flagreset request */
- if ((uint8_t)CAN_CMDID_FUELCALC_RST_REQ_RX == uc_cmd_id) {
- /* Receive Reset Request */
- (void)CANCommandFuelCalcRstReq();
- }
-
- /* Send Delivery Message */
-// if (!CANCommandDeliverySndMsg(h_app, uc_cmd_id, &pst_msg_data->data[0])) {
-// ret = RET_CAN_ERROR_PARAM;
-// }
-
- /* Delete Delivery Registration */
- CANCommandDeliveryDelete(uc_cmd_id);
- }
-
- return (ret);
-}
diff --git a/communication/server/src/CAN/Command/CAN_CommandData.cpp b/communication/server/src/CAN/Command/CAN_CommandData.cpp
deleted file mode 100644
index fe85ebfd..00000000
--- a/communication/server/src/CAN/Command/CAN_CommandData.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * FILE :CAN_CommandData.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN Thread CAN Command Control Data Management
- * :
- * Module configuration :CANCommandDeliveryEntryCheck() CAN command delivery management table registration status confirmation processing
- * :CANCommandDeliveryEntry() CAN command delivery management table registration process
- * :CANCommandDeliveryDataGet() CAN command delivery management table data acquisition processing
- * :CANCommandDeliveryDelete() CAN command delivery management table deletion processing
- * :CANCommandTxRsltEntryCheck() CAN command transmission result management table registration status confirmation processing
- * :CANCommandTxRsltEntry() CAN command transmission result management table registration process
- * :CANCommandTxRsltDataGet() CAN command transmission result management table data acquisition processing
- * :CANCommandTxRsltDelete() CAN command transmission result management table deletion processing
- * :CANCommandTxRsltCheck() CAN command transmission result management table notification registration confirmation processing
- * :CANCommandFuelCalcRstReqCheck() CAN section flame reset request reception status confirmation processing
- * :CANCommandFuelCalcRstReq() CAN section flammability reset request reception processing
- * :CANCommandDataInit() CAN command management data initialization processing
- * :
- ******************************************************************************/
-#include "CAN_CommandData.h"
-
-#include <string.h> // NOLINT (build/include)
-#include <native_service/frameworkunified_types.h>
-#include <other_service/strlcpy.h>
-
-#include <peripheral_service/Canif_API.h>
-#include "CAN_Thread.h"
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-static CAN_COMMAND_DELIVERY_LIST_DAT g_st_can_cmd_delivery_dat[CAN_COMMAND_DELIVERY_NUM]; /* CAN command delivery management table */ //NOLINT (readability/naming)
-/* CAN command transmission result management table */
-static CAN_COMMAND_TXRSLT_LIST_DAT g_st_can_cmd_transrslt_dat[CAN_COMMAND_TXRSLT_NUM]; //NOLINT (readability/naming)
-
-/*******************************************************************************
- * MODULE : CANCmdidConvertIndexTX
- * ABSTRACT : CAN Command ID->Index conversion processing (during delivery)
- * FUNCTION : Convert the CAN command ID to an index in the CAN command delivery management table
- * ARGUMENT : uc_cmd_id : CAN command ID
- * : *uc_index : Pointer to the index
- * NOTE :
- * RETURN : TRUE : Successful conversion
- * : FALSE : Conversion failed
- ******************************************************************************/
-static BOOL CANCmdidConvertIndexTX(uint8_t uc_cmd_id, uint8_t* uc_index) {
- BOOL b_ret = TRUE;
-
- switch (uc_cmd_id) {
- case CAN_CMDID_FUELCALC_RST_REQ_DELIVERY: /* Request for delivery of request for flame reset in CAN section */
- *uc_index = 0;
- break;
-
- case CAN_CMDID_STARTUP_FIN_REQ_TX: /* CAN start completion notification request */
- *uc_index = 1;
- break;
-
- case CAN_CMDID_MRST_INFO_REQ_TX: /* CAN Master Reset Information Notification Request */
- *uc_index = 2;
- break;
-
- case CAN_CMDID_VERSION_REQ_TX: /* CAN version request */
- *uc_index = 3;
- break;
-
- case CAN_CMDID_CONNECTION_NODE_REQ_TX: /* CAN Connection Node Notification Request */
- *uc_index = 4;
- break;
-
- default: /* IDs that are not subject to undefined ID or registration */
- b_ret = FALSE;
- break;
- }
-
- return b_ret;
-}
-
-/*******************************************************************************
- * MODULE : CANCmdidConvertIndexRX
- * ABSTRACT : CAN Command ID->Index conversion processing (at reception)
- * FUNCTION : Convert the CAN command ID to an index in the CAN command delivery management table
- * ARGUMENT : uc_cmd_id : CAN command ID
- * *uc_index : Pointer to the index
- * NOTE :
- * RETURN : TRUE : Successful conversion
- * FALSE : Conversion failed
- ******************************************************************************/
-static BOOL CANCmdidConvertIndexRX(uint8_t uc_cmd_id, uint8_t* uc_index) {
- BOOL b_ret = TRUE;
-
- switch (uc_cmd_id) {
- case CAN_CMDID_FUELCALC_RST_REQ_RX: /* RECEIVE REQUEST FREE OF CAN SECTION */
- *uc_index = 0;
- break;
-
- case CAN_CMDID_STARTUP_FIN_RESP_RX: /* CAN start completion notification request transmission */
- *uc_index = 1;
- break;
-
- case CAN_CMDID_MRST_INFO_RESP_RX: /* CAN master reset information notification request transmission */
- *uc_index = 2;
- break;
-
- case CAN_CMDID_VERSION_RESP_RX: /* CAN Version Request Send */
- *uc_index = 3;
- break;
-
- case CAN_CMDID_CONNECTION_NODE_RESP_RX: /* CAN connection node notification request transmission */
- *uc_index = 4;
- break;
-
- default: /* IDs that are not subject to undefined ID or registration */
- b_ret = FALSE;
- break;
- }
- return b_ret;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDeliveryEntryCheck
- * ABSTRACT : CAN command delivery management table registration status confirmation processing
- * FUNCTION : Confirm whether registration is possible in the CAN command delivery management table.
- * ARGUMENT : notifyId : Addresses for delivery ID
- * uc_cmd_id : CAN command ID
- * NOTE :
- * RETURN : TRUE : Can be registered
- * FALSE : Cannot be stored
- ******************************************************************************/
-BOOL CANCommandDeliveryEntryCheck(PCSTR notify_name, uint8_t uc_cmd_id) {
- BOOL ret = TRUE; /* Return value of this function */
- uint8_t uc_index; /* Index that references the delivery management table */
- int32_t l_cnt; /* Generic counters */
- CAN_COMMAND_DELIVERY_LIST_DAT* ptr;
-
- ret = CANCmdidConvertIndexTX(uc_cmd_id, &uc_index);
-
- if (TRUE == ret) { // LCOV_EXCL_BR_LINE 6: double check
- ret = FALSE;
- ptr = &g_st_can_cmd_delivery_dat[uc_index];
- /* Search destination */
- for (l_cnt = 0; l_cnt < CAN_COMMAND_DELIVERY_SNDID_NUM; l_cnt++) {
- if ((strcmp(ptr->notify_name_list[l_cnt], notify_name) == 0) ||
- (ptr->notify_name_num == (uint8_t)l_cnt)) {
- /* When overwriting or registering a new entry */
- ret = TRUE;
- break;
- }
- }
- }
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDeliveryEntry
- * ABSTRACT : CAN command delivery management table registration process
- * FUNCTION : Register in the CAN command delivery management table
- * ARGUMENT : notifyId : Addresses for delivery ID
- * uc_cmd_id : CAN command ID
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandDeliveryEntry(PCSTR notify_name, uint8_t uc_cmd_id) {
- BOOL b_cont = TRUE; /* Processing Continuation Flag */
- uint8_t uc_index; /* Index that references the delivery management table */
- int32_t l_cnt; /* Generic counters */
- CAN_COMMAND_DELIVERY_LIST_DAT* ptr;
-
- b_cont = CANCmdidConvertIndexTX(uc_cmd_id, &uc_index);
-
- if (TRUE == b_cont) { // LCOV_EXCL_BR_LINE 6: double check
- ptr = &g_st_can_cmd_delivery_dat[uc_index];
- /* Search destination */
- for (l_cnt = 0; (l_cnt < CAN_COMMAND_DELIVERY_SNDID_NUM); l_cnt++) {
- if (strcmp(ptr->notify_name_list[l_cnt], notify_name) == 0) {
- /* For overwriting */
- b_cont = FALSE;
- } else if (ptr->notify_name_num == (uint8_t)l_cnt) {
- /* For new entry */
- strlcpy(ptr->notify_name_list[l_cnt], notify_name, sizeof(ptr->notify_name_list[l_cnt]));
- ptr->notify_name_num++;
- b_cont = FALSE;
- } else {
- /* Do nothing */
- }
- if (FALSE == b_cont) {
- break;
- }
- }
- }
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDeliveryDataGet
- * ABSTRACT : CAN command delivery management table data acquisition processing
- * FUNCTION : Retrieve registration data from CAN command delivery management table
- * ARGUMENT : uc_cmd_id : CAN command ID
- * pNotifyNameNum : Return Pointer to Number of Destination Registrations
- * pNotifyIdList : Shipping list reference pointer
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandDeliveryDataGet(uint8_t uc_cmd_id, CAN_COMMAND_DELIVERY_LIST_DAT* dst) {
- BOOL b_cont; /* Processing Continuation Flag */
- uint8_t uc_index; /* Index that references the delivery management table */
- CAN_COMMAND_DELIVERY_LIST_DAT* src;
-
- b_cont = CANCmdidConvertIndexRX(uc_cmd_id, &uc_index);
-
- if (TRUE == b_cont) { /* For registration ID*/ // LCOV_EXCL_BR_LINE 6: double check
- src = &g_st_can_cmd_delivery_dat[uc_index];
- dst->notify_name_num = src->notify_name_num; /* Number of registered delivery destination IDs */
- memcpy(dst->notify_name_list, src->notify_name_list, sizeof(dst->notify_name_list));
- }
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDeliveryDelete
- * ABSTRACT : CAN command delivery management table deletion processing
- * FUNCTION : Delete registered data from CAN command delivery management table
- * ARGUMENT : uc_cmd_id : CAN command ID
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandDeliveryDelete(uint8_t uc_cmd_id) {
- BOOL b_cont = TRUE; /* Processing Continuation Flag */
- uint8_t uc_index; /* Index that references the delivery management table */
- CAN_COMMAND_DELIVERY_LIST_DAT* ptr;
-
- b_cont = CANCmdidConvertIndexRX(uc_cmd_id, &uc_index);
-
- if (TRUE == b_cont) { /* For registration ID */ // LCOV_EXCL_BR_LINE 6: double check
- ptr = &g_st_can_cmd_delivery_dat[uc_index];
- /* Whether the control method is delivery control type or one-time communication type */
- if (((uint8_t)CAN_CMD_DELIVERY_CTRL == ptr->uc_ctrl) ||
- ((uint8_t)CAN_CMD_1TIME_TRANCE == ptr->uc_ctrl)) {
- /* Delete registered data */
- ptr->notify_name_num = 0; /* Number of delivery destination ID registrations = 0 */
- memset((ptr->notify_name_list), 0x00, sizeof(ptr->notify_name_list)); /* Destination ID List = 0 */
- }
- }
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDeliveryDeletesingle
- * ABSTRACT : CAN command delivery management table deletion processing
- * FUNCTION : Delete registered data from CAN command delivery management table
- * ARGUMENT : uc_cmd_id : CAN command ID
- * : notifyId : Service client ID
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandDeliveryDeletesingle(uint8_t uc_cmd_id, PCSTR notify_name) { // LCOV_EXCL_START 4: only be executed when NSFW error // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL b_cont = TRUE; /* Processing Continuation Flag */
- uint8_t uc_index; /* Index that references the delivery management table */
- int i, j;
- CAN_COMMAND_DELIVERY_LIST_DAT* ptr;
-
- b_cont = CANCmdidConvertIndexRX(uc_cmd_id, &uc_index);
-
- if (TRUE == b_cont) { // LCOV_EXCL_BR_LINE 6: double check
- ptr = &g_st_can_cmd_delivery_dat[uc_index];
- /* Delete registered data */
- for (i = 0; i < ptr->notify_name_num; i++) {
- if (strcmp(notify_name, ptr->notify_name_list[i]) != 0) {
- continue;
- }
- for (j = i; j < ptr->notify_name_num - 1; j++) {
- memmove(ptr->notify_name_list[j], ptr->notify_name_list[j + 1], sizeof(char) * MAX_NAME_SIZE_APP);
- }
- ptr->notify_name_num--;
- }
- }
- return;
-}
-// LCOV_EXCL_STOP 8: only be executed when NSFW error
-
-/*******************************************************************************
- * MODULE : CANCommandTxRsltEntryCheck
- * ABSTRACT : CAN command transmission result management table registration status confirmation processing
- * FUNCTION : Check that the CAN command can be registered in the transmission result management table.
- * ARGUMENT : uc_cmd_id : CAN command ID
- * pucCanRid : Resource ID return pointer from CAN
- * NOTE :
- * RETURN : TRUE : Can be registered
- * FALSE : Cannot be stored
- ******************************************************************************/
-BOOL CANCommandTxRsltEntryCheck(uint8_t uc_cmd_id, uint8_t* uc_can_rid) {
- BOOL ret = FALSE; /* Return value of this function */
- uint8_t uc_index; /* Index that references the communication result management table */
-
- /* CAN command transmission result management table retrieval */
- for (uc_index = 0; uc_index < (uint8_t)CAN_COMMAND_TXRSLT_NUM; uc_index++) {
- /* CAN command ID match? */
- if (uc_cmd_id == g_st_can_cmd_transrslt_dat[uc_index].uc_cmd_id) {
- /* RID = 0xFF (not registered)? */
- if ((uint8_t)CAN_RID_NOTUSE_CODE == g_st_can_cmd_transrslt_dat[uc_index].uc_rid) {
- ret = TRUE;
- *uc_can_rid = (uint8_t)(CAN_CMD_RID_MASK | (uint32_t)uc_index);
- break;
- }
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommandTxRsltEntry
- * ABSTRACT : CAN command transmission result management table registration process
- * FUNCTION : Register in the CAN command transmission result management table
- * ARGUMENT : uc_can_rid : CAN_RID of registration destination
- * notifyId : Process ID to register
- * uc_rid : Resource ID to register
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandTxRsltEntry(uint8_t uc_can_rid, PCSTR notify_name, uint8_t uc_rid) {
- uint8_t uc_index; /* Index that references the communication result management table */
-
- /* Table's registration index */
- uc_index = (uint8_t)((uint32_t)(~CAN_CMD_RID_MASK) & (uint32_t)uc_can_rid);
-
- /* Registration */
- strlcpy(g_st_can_cmd_transrslt_dat[uc_index].notify_name, notify_name,
- sizeof(g_st_can_cmd_transrslt_dat[uc_index].notify_name));
- g_st_can_cmd_transrslt_dat[uc_index].uc_rid = uc_rid;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandTxRsltDataGet
- * ABSTRACT : CAN command transmission result management table data acquisition processing
- * FUNCTION : Acquire registration data from CAN command transmission result management table
- * ARGUMENT : uc_can_rid : CAN_RID
- * pNotifyId : Destination ID Return Pointer
- * pusRid : Resource ID return pointer
- * pusCmdid : CAN command ID return pointer
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandTxRsltDataGet(uint8_t uc_can_rid, char* p_notify_name, uint8_t* puc_rid, uint8_t* puc_cmd_id) {
- uint8_t uc_index; /* Index that references the communication result management table */
-
- /* Index from which to retrieve data for the table */
- uc_index = (uint8_t)((uint32_t)(~CAN_CMD_RID_MASK) & (uint32_t)uc_can_rid);
-
- /* Data acquisition */
- strncpy(p_notify_name, g_st_can_cmd_transrslt_dat[uc_index].notify_name,
- sizeof(g_st_can_cmd_transrslt_dat[uc_index].notify_name));
- *puc_rid = g_st_can_cmd_transrslt_dat[uc_index].uc_rid;
- *puc_cmd_id = g_st_can_cmd_transrslt_dat[uc_index].uc_cmd_id;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandTxRsltDelete
- * ABSTRACT : CAN command transmission result management table deletion processing
- * FUNCTION : Delete registered data from the CAN command transmission result management table
- * ARGUMENT : uc_can_rid : CAN_RID
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandTxRsltDelete(uint8_t uc_can_rid) {
- uint8_t uc_index; /* Index that references the communication result management table */
-
- /* Drop index for the table */
- uc_index = (uint8_t)((uint32_t)(~CAN_CMD_RID_MASK) & (uint32_t)uc_can_rid);
-
- /* Delete */
- memset(g_st_can_cmd_transrslt_dat[uc_index].notify_name, 0x00,
- sizeof(g_st_can_cmd_transrslt_dat[uc_index].notify_name));
- g_st_can_cmd_transrslt_dat[uc_index].uc_rid = CAN_RID_NOTUSE_CODE;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandTxRsltCheck
- * ABSTRACT : CAN command transmission result management table notification registration confirmation processing
- * FUNCTION : Check if the notification is registered in the CAN command transmission result management table.
- * ARGUMENT : uc_can_rid : CAN_RID
- * NOTE :
- * RETURN : TRUE : Registered
- * FALSE : No registration
- ******************************************************************************/
-BOOL CANCommandTxRsltCheck(uint8_t uc_can_rid) { // LCOV_EXCL_START 8: is called in CANCommandTxRslt, but CANCommandTxRslt is dead code // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = FALSE; /* Return value of this function */
- uint8_t uc_index; /* Index that references the communication result management table */
-
- /* Reference index of the table */
- uc_index = (uint8_t)((uint32_t)(~CAN_CMD_RID_MASK) & (uint32_t)uc_can_rid);
-
- /* Not out of range of the table */
- if (uc_index < (uint8_t)CAN_COMMAND_TXRSLT_NUM) {
- /* Registered? */
- if ((uint8_t)CAN_RID_NOTUSE_CODE != g_st_can_cmd_transrslt_dat[uc_index].uc_rid) {
- ret = TRUE;
- }
- }
-
- return (ret);
-}
-// LCOV_EXCL_STOP
-
-/*******************************************************************************
- * MODULE : CANCommandFuelCalcRstReqCheck
- * ABSTRACT : CAN section flame reset request reception status confirmation processing
- * FUNCTION : Confirm whether or not a CAN section flame reset request has been received
- * ARGUMENT : None
- * NOTE :
- * RETURN : TRUE : Registered
- * FALSE : Unregistered
- ******************************************************************************/
-BOOL CANCommandFuelCalcRstReqCheck(void) {
- BOOL ret; /* Return value of this function */
-
- if ((uint8_t)CAN_CMD_RST_RCV == g_st_can_cmd_delivery_dat[0].uc_flag) {
- ret = TRUE; /* Registered */
- } else {
- ret = FALSE; /* Unregistered */
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommandFuelCalcRstReq
- * ABSTRACT : CAN section flammability reset request reception processing
- * FUNCTION : Set CAN section flame reset request as received
- * ARGUMENT : None
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandFuelCalcRstReq(void) {
- /* Set the control flag (interval flammability reset) of the CAN command transmission result management table as received */
- g_st_can_cmd_delivery_dat[0].uc_flag = CAN_CMD_RST_RCV;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANCommandDataInit
- * ABSTRACT : CAN command management data initialization processing
- * FUNCTION : Initializing CAN Command Management Data
- * ARGUMENT : None
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommandDataInit(void) {
- int32_t l_cnt1 = 0; /* Counter */
- int32_t l_cnt2 = 0;
- int32_t l_index = 0;
- CAN_COMMAND_DELIVERY_LIST_DAT* ptr_dl;
- CAN_COMMAND_TXRSLT_LIST_DAT* ptr_tl;
-
- /*** CAN command delivery management table initialization ***/
- /* Control method initialization */
- g_st_can_cmd_delivery_dat[0].uc_ctrl = CAN_CMD_DELIVERY_CTRL; /* Delivery control type */
- g_st_can_cmd_delivery_dat[1].uc_ctrl = CAN_CMD_1TIME_TRANCE; /* One-time communication */
- g_st_can_cmd_delivery_dat[2].uc_ctrl = CAN_CMD_1TIME_TRANCE;
- g_st_can_cmd_delivery_dat[3].uc_ctrl = CAN_CMD_1TIME_TRANCE;
- g_st_can_cmd_delivery_dat[4].uc_ctrl = CAN_CMD_TRANCE; /* Continuous communication type */
- g_st_can_cmd_delivery_dat[5].uc_ctrl = CAN_CMD_TRANCE;
- for (l_cnt1 = 0; l_cnt1 < CAN_COMMAND_DELIVERY_NUM; l_cnt1++) {
- ptr_dl = &g_st_can_cmd_delivery_dat[l_cnt1];
- /* Control flag initialization */
- ptr_dl->uc_flag = CAN_CMD_RST_NOT_RCV;
- /* Initialization of number of registered delivery destination IDs */
- ptr_dl->notify_name_num = 0x00;
- /* Delivery ID list initialization */
- memset((ptr_dl->notify_name_list), 0x00, (sizeof(ptr_dl->notify_name_list)));
- }
-
- /*** Initialization of CAN command transmission result management table ***/
- for (l_cnt1 = 0; l_cnt1 < CAN_COMMAND_TXRSLT_NUM; l_cnt1++) {
- ptr_tl = &g_st_can_cmd_transrslt_dat[l_cnt1];
- /* Initialization of delivery destination ID */
- memset(ptr_tl->notify_name, 0x00, sizeof(ptr_tl->notify_name));
- /* Resource ID Initialization */
- ptr_tl->uc_rid = CAN_RID_NOTUSE_CODE;
- }
-
- /* CAN command ID initialization */
- for (l_cnt1 = 0; l_cnt1 < CAN_COMMAND_TXRSLT_NUM; l_cnt1++) {
- ptr_tl = &g_st_can_cmd_transrslt_dat[l_cnt1];
- switch (l_index) {
- case 0: /* CAN section flame reset response transmission */
- ptr_tl->uc_cmd_id = CAN_CMDID_FUELCALC_REQ_TX;
- break;
- case 1: /* CAN start completion notification request transmission */
- ptr_tl->uc_cmd_id = CAN_CMDID_STARTUP_FIN_REQ_TX;
- break;
- case 2: /* CAN master reset information notification request transmission */
- ptr_tl->uc_cmd_id = CAN_CMDID_MRST_INFO_REQ_TX;
- break;
- case 3: /* CAN Version Request Send */
- ptr_tl->uc_cmd_id = CAN_CMDID_VERSION_REQ_TX;
- break;
- case 4: /* CAN connection node notification request transmission */
- ptr_tl->uc_cmd_id = CAN_CMDID_CONNECTION_NODE_REQ_TX;
- break;
- }
- l_cnt2++;
- if (l_cnt2 == CAN_COMMAND_TXRSLT_SNDID_NUM) {
- l_cnt2 = 0;
- l_index++;
- }
- }
- return;
-}
diff --git a/communication/server/src/CAN/Delivery/CAN_Delivery.cpp b/communication/server/src/CAN/Delivery/CAN_Delivery.cpp
index f4ee1f82..b9914313 100644
--- a/communication/server/src/CAN/Delivery/CAN_Delivery.cpp
+++ b/communication/server/src/CAN/Delivery/CAN_Delivery.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,336 +14,392 @@
* limitations under the License.
*/
-/*******************************************************************************
- * Module configuration :CANDataReceiveMsg() CANDataProcess of Received Messages
- * CANDlcCheck() DLC check process
- * CANDeliveryEntryMsgCheck() CANDataDelivery registration message check process
- * CAN_DeliveryCtrlMsg() CANDataDelivery control message processing Not mounted
- * CAN_DeliveryCtrlMsgCheck() CANDataDelivery control message check processing Not mounted
- * CANCanidIfToUserCvt() CAN ID Conversion Process 1
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @file CAN_Delivery.cpp
- * @~english
- * @brief CAN Delivery process
- */
#include "CAN_Delivery.h"
-#include <native_service/frameworkunified_types.h> // NOLINT(build/include)
-#include <string.h>
-#include "CAN_DeliveryData.h"
-#include "CAN_CommWatch.h"
+
+#include <can_hal.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <peripheral_service/Canif_API.h>
+#include <can_hal.h>
+#include <utility>
+#include <map>
+#include <string>
#include "CAN_TxMsg.h"
+#include "CAN_CommWatch.h"
+#include "Canif_API_Local.h"
+#include "API_Local_Common.h"
+#include "Thread_Common.h"
-/*************************************************/
-/* Global variables */
-/*************************************************/
-const CANID kCulCanidCsumTbl[] = {/* CAN ID table that performs CSUM checks */
- (CANID)CAN_CSUM_CHECKTBL_STOP_CODE /* Stop code */
-};
-
-CAN_MSG_CANGWDATA g_cangw_msg_data; /* CANdata to be sent to the CANGW */
-/*******************************************************************************
- * MODULE : CANDataReceiveMsg
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data reply processing
- *
- * CAN data reply processing
- *
- * CANDataReceive processing
- *
- * @~english
- * @note
- * -# OPC check
- * -# DLC check
- * -# CSUM check
- * -# Communication blackout clearness
- * -# Filter processing
- * -# ID list making for delivery
- * -# Message sending
- *
- * @~english
- * @return Data reception result
- * @retval <RET_CAN_NORMAL> Normality
- * @retval <RET_CAN_ERROR_CANCEL> Data annulment
- *
- * @~english
- * @param[in] <pst_rcv_msg> Reception message
- */
-RET_CAN CANDataReceiveMsg(HANDLE h_app, CAN_MSG_DATA *pst_rcv_msg) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-// T_ICR_CMD_DATA *pst_msg_data; /* Data part structure pointer */
- CANID can_id; /* CAN ID */
- uint8_t n_ta = CAN_NTA_INVALID; /* N_TA */
- uint8_t uc_dlc; /* DLC */
- uint8_t *puc_data_pos; /* Data */
- uint8_t i;
-
-// pst_msg_data = reinterpret_cast<T_ICR_CMD_DATA *>(reinterpret_cast<void *>(&pst_rcv_msg->ucData[0]));
- g_cangw_msg_data.num = 0;
-
- /****** OPC check process ******/
-// switch (pst_msg_data->opc) {
-// case CAN_OPC_RX: /* CANData reception notice */
-#if 0
- /****** DLC check process ******/
- if (RET_CAN_NORMAL != (ret = CANDlcCheck(pst_msg_data))) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery DLC Error");
- CANDebugLogOut(CAN_DELIVERY_DLCERR, reinterpret_cast<void *>(pst_rcv_msg));
+static CAN_DeliveryEntryList g_map_delivery_list_can;
+// Member of g_msg_rx_msg exist as long as communication exists.
+static std::map<CANID, CanMessage *> g_can_rx_msg;
+
+void CANDeliveryInit(void) {
+ g_map_delivery_list_can.clear();
+ return;
+}
+
+static CanMessage *CANMsgFind(CANID k) {
+ std::map<CANID, CanMessage *>::iterator it;
+
+ it = g_can_rx_msg.find(k);
+ if (it == g_can_rx_msg.end())
+ return NULL;
+ return it->second;
+}
+
+static void CANMsgInsert(CANID k, CanMessage *msg) {
+ CanMessage *latest = CANMsgFind(k);
+ if (!latest) {
+ latest = new CanMessage();
+ }
+ g_can_rx_msg[k] = latest;
+ memcpy(latest, msg, sizeof(CanMessage));
+}
+
+static CAN_DeliveryEntryListIt CANDeliveryFind(CANID canid, std::string s) {
+ std::pair<CAN_DeliveryEntryListIt, CAN_DeliveryEntryListIt> range;
+ CAN_DeliveryEntryListPair p = std::make_pair(canid, s);
+ CAN_DeliveryEntryListIt it;
+ bool found = false;
+ range = g_map_delivery_list_can.equal_range(canid);
+ for (it = range.first; it != range.second; ++it) {
+ if (*it == p) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ it = g_map_delivery_list_can.end();
+
+ return it;
+}
+
+bool CANDeliveryInsert(CANID canid, std::string s) {
+ CAN_DeliveryEntryListIt it = CANDeliveryFind(canid, s);
+ CAN_DeliveryEntryListPair p = std::make_pair(canid, s);
+ bool inserted = false;
+
+ if (it == g_map_delivery_list_can.end()) {
+ g_map_delivery_list_can.insert(p);
+ inserted = true;
+ }
+
+ return inserted;
+}
+
+static EFrameworkunifiedStatus CANDeliverySndCmdSingle(HANDLE h_app, CANID cmd,
+ CanMessage *msg, std::string dest) {
+ CAN_MSG_CANCMD st_delivery_msg;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ HANDLE h_client;
+ uint16_t len = 0;
+
+ // Create delivery data
+ memset(&st_delivery_msg, 0, sizeof(st_delivery_msg));
+ switch (cmd) {
+ case CAN_CMDID_FUELCALC_RST_REQ_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_FUELCALC_RST_SIZE;
+ break;
+ case CAN_CMDID_STARTUP_FIN_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_STARTUP_FIN_SIZE;
+ break;
+ case CAN_CMDID_MRST_INFO_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_MRST_INFO_SIZE;
+ break;
+ case CAN_CMDID_VERSION_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_VERSION_SIZE;
+ break;
+ case CAN_CMDID_CONNECTION_NODE_RESP_RX:
+ len = (uint16_t)(CAN_TX_CMD_DELIVERY_SIZE + msg->data[0] + 1);
+ break;
+ default:
+ return e_status;
+ }
+ st_delivery_msg.hdr.hdr.rid = 0;
+ st_delivery_msg.hdr.hdr.cid = (uint16_t)CID_CAN_CMD_DELIVERY;
+ st_delivery_msg.hdr.hdr.msgbodysize = len;
+ st_delivery_msg.data.cmd_id = (uint8_t)cmd;
+ memcpy(&st_delivery_msg.data.data, msg->data,
+ (size_t)(len - CAN_TX_CMD_DELIVERY_SIZE));
+
+ h_client = CommonFindSender(h_app, dest);
+ if (!h_client) {
+ return e_status;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "cid=%x msgbodysize=%x cmd_id=%x",
+ st_delivery_msg.hdr.hdr.cid, st_delivery_msg.hdr.hdr.msgbodysize,
+ st_delivery_msg.data.cmd_id);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(st_delivery_msg.data.data, len).c_str());
+
+ e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CMD_DELIVERY,
+ sizeof(st_delivery_msg), &st_delivery_msg);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(e_status:%d to:%s)",
+ e_status, dest.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "CAN Delivery : dst = %s, CMD = %x, DLC = %x",
+ dest.c_str(), cmd, msg->dlc);
+ }
+ return e_status;
+}
+
+static EFrameworkunifiedStatus CANDeliverySndMsgSingle(HANDLE h_app, CANID ul_canid,
+ uint8_t uc_dlc, const uint8_t *puc_data,
+ enum CanIfEchoBackFlags flag, std::string dest) {
+ CAN_MSG_CANDATA st_delivery_msg;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ HANDLE h_client;
+ uint8_t uc_size = uc_dlc;
+
+ // Create delivery data
+ memset(&st_delivery_msg, 0, sizeof(st_delivery_msg));
+ st_delivery_msg.hdr.hdr.cid = CID_CAN_DATA_DELIVERY;
+ st_delivery_msg.hdr.hdr.msgbodysize = (uint16_t)(CAN_TRX_CANID_SIZE +
+ CAN_TRX_DLC_SIZE +
+ (uint32_t)uc_size);
+ st_delivery_msg.hdr.hdr.rid = 0;
+ st_delivery_msg.data.can_id = ul_canid;
+ st_delivery_msg.data.dlc = uc_size;
+ st_delivery_msg.echoback = flag;
+ if (uc_size > (uint8_t)CAN_DATA_SIZE)
+ uc_size = CAN_DATA_SIZE;
+ memcpy(st_delivery_msg.data.data, puc_data, (size_t)uc_size);
+
+ h_client = CommonFindSender(h_app, dest);
+ if (!h_client) {
+ return e_status;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "can_id=%x dlc=%x echoback=%d",
+ st_delivery_msg.data.can_id, st_delivery_msg.data.dlc,
+ st_delivery_msg.echoback);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(st_delivery_msg.data.data, uc_size).c_str());
+
+ e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_DATA_DELIVERY,
+ sizeof(st_delivery_msg), &st_delivery_msg);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(e_status:%d to:%s)",
+ e_status, dest.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "CAN Delivery : dst = %s, CANID = %x, DLC = %x",
+ dest.c_str(), ul_canid, uc_dlc);
+ }
+ return e_status;
+}
+
+EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "@@@ Start communication CanRecv");
+
+ uint16_t i;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ CAN_DELIVERY_ENTRY rcv_msg;
+ CAN_DeliveryEntryListIt it;
+ bool fail = false;
+
+ memset(&rcv_msg, 0, sizeof(rcv_msg));
+ e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg,
+ sizeof(rcv_msg), eSMRRelease);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
+ "CAN DeliveryEntry FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
+ if (e_status == eFrameworkunifiedStatusInvldBufSize) {
+ FrameworkunifiedClearMsgData(h_app);
+ }
+ goto cleanup;
+ }
+
+ for (i = 0; i < rcv_msg.usCanNum; i++) {
+ CANID canid = rcv_msg.ulCanid[i];
+ CanMessage *latest = CANMsgFind(canid);
+
+ if (CANDeliveryInsert(canid, rcv_msg.notifyName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "(cnd:%lu) : CANID=0x%x, dst=%s",
+ g_map_delivery_list_can.size(), canid, rcv_msg.notifyName);
+ }
+
+ if (latest) {
+ switch (canid) {
+ case CAN_CMDID_FUELCALC_RST_REQ_RX:
+ case CAN_CMDID_STARTUP_FIN_RESP_RX:
+ case CAN_CMDID_MRST_INFO_RESP_RX:
+ case CAN_CMDID_VERSION_RESP_RX:
+ case CAN_CMDID_CONNECTION_NODE_RESP_RX:
+ if (eFrameworkunifiedStatusOK != CANDeliverySndCmdSingle(h_app, canid,
+ latest, rcv_msg.notifyName)) {
+ fail = true;
+ }
+ break;
+ default:
+ if (eFrameworkunifiedStatusOK != CANDeliverySndMsgSingle(h_app, canid,
+ static_cast<uint8_t>(latest->dlc),
+ latest->data, CANIF_PURERECV, rcv_msg.notifyName)) {
+ fail = true;
+ }
break;
}
-#endif
-
-// can_id = CANCanidIfToUserCvt(&(pst_msg_data->data[0]));
-
-// if (pst_msg_data->opc == CAN_OPC_RX) {
-// uc_dlc = pst_msg_data->data[CAN_MSGBUF_DLC_POS];
-// puc_data_pos = &pst_msg_data->data[CAN_MSGBUF_DATA_POS];
-// }
-
-// ret = CANDeliveryRcvData(h_app, can_id, n_ta, uc_dlc, puc_data_pos, pst_msg_data->opc);
-// if (ret != RET_CAN_NORMAL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
-// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery Error"); // LCOV_EXCL_LINE 4: NSFW error case
-// CANDebugLogOut(CAN_DELIVERY_ERR, reinterpret_cast<void *>(pst_rcv_msg)); /* Delivery destination unregistered log output */ // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
-// }
-// break;
-// case CAN_OPC_PAC_RX:
- /* Check CAN Data num */
-// if (0 >= pst_msg_data->data[0] || CAN_EXRCV_DATA_NUM < pst_msg_data->data[0]) {
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery CAN Data num Error CAN Data num=%02X",
-// pst_msg_data->data[0]); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
-// break;
-// }
-#if 0
- /****** DLC check process ******/
- if (RET_CAN_NORMAL != (ret = CANDlcCheck(pst_msg_data))) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery CAN Data size over");
- CANDebugLogOut(CAN_DELIVERY_DLCERR, reinterpret_cast<void *>(pst_rcv_msg));
- }
-
-#endif
-// for (i = 0; i < pst_msg_data->data[0]; i++) {
-// can_id = CANPacCanidIfToUserCvt(&pst_msg_data->data[i * CAN_EXRCV_DATA_SIZE + CAN_MSGBUF_PAC_CANID_POS]);
-
-// uc_dlc = pst_msg_data->data[i * CAN_EXRCV_DATA_SIZE + CAN_MSGBUF_PAC_DLC_POS];
-// puc_data_pos = &pst_msg_data->data[i * CAN_EXRCV_DATA_SIZE + CAN_MSGBUF_PAC_DATA_POS];
-
-// if (RET_CAN_NORMAL != CANDeliveryRcvData(h_app, can_id, n_ta, uc_dlc, puc_data_pos, pst_msg_data->opc)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
-// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-// ret = RET_CAN_ERROR_CANCEL; // LCOV_EXCL_LINE 4: NSFW error case
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery Error"); // LCOV_EXCL_LINE 4: NSFW error case
-// CANDebugLogOut(CAN_DELIVERY_ERR, reinterpret_cast<void *>(pst_rcv_msg)); /* Delivery destination unregistered log output */ // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
-// }
-// }
-// break;
-// default:
-// ret = RET_CAN_ERROR_CANCEL;
-// break;
-// }
- // When the number of data to be delivered to CANGW_M is 1 or more, the data is sent to CANGW_M by CANDeliverySndMsgToCANGW.
- if (0 < g_cangw_msg_data.num) {
- // Sending CAN-data delivery messages to the CANGW
- if (FALSE == CANDeliverySndMsgToCANGW(h_app, &g_cangw_msg_data)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery Error"); // LCOV_EXCL_LINE 4: NSFW error case
- ret = RET_CAN_ERROR_CANCEL; // LCOV_EXCL_LINE 4: NSFW error case
}
}
- return (ret);
+
+ if (fail)
+ e_status = eFrameworkunifiedStatusFail;
+
+cleanup:
+ return e_status;
}
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Recieve data delivery before processing
- *
- * @~english
- * @return Return value
- * @retval <RET_CAN_NORMAL> OK
- * @retval <RET_CAN_ERROR_CANCEL> Delivery Error
- *
- * @~english
- * @param[in] <h_app> Application handle
- * @param[in] <ul_canid> CAN ID
- * @param[in] <n_ta> N_TA
- * @param[in] <uc_dlc> DLC
- * @param[in] <puc_data_pos> CAN Data
- * @param[in] <opc> OPC
- */
-RET_CAN CANDeliveryRcvData(HANDLE h_app, CANID ul_canid, uint8_t n_ta,
- uint8_t uc_dlc, uint8_t *puc_data_pos, uint8_t opc) {
- RET_CAN ret = RET_CAN_NORMAL;
-
- /****** Communication interruption clear processing ******/
- CANCommWatchClear(h_app, ul_canid);
-
- /****** CANDataSending a delivery message ******/
- if (FALSE == CANDeliverySndMsg(h_app, ul_canid, uc_dlc, puc_data_pos, opc, n_ta)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
- /* CANDataDelivery message transmission processing */
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery Error"); // LCOV_EXCL_LINE 4: NSFW error case
- ret = RET_CAN_ERROR_CANCEL; // LCOV_EXCL_LINE 4: NSFW error case
+static EFrameworkunifiedStatus CANDeliverySndMsgToClient(HANDLE h_app, CANID ul_canid,
+ void *data, size_t size, PS_CommunicationProtocol cid) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ HANDLE h_client = NULL;
+ CAN_DeliveryEntryListIt it;
+ std::pair<CAN_DeliveryEntryListIt, CAN_DeliveryEntryListIt> range;
+ bool fail = false;
+
+ it = g_map_delivery_list_can.find(ul_canid);
+ range = g_map_delivery_list_can.equal_range(ul_canid);
+ for (it = range.first; it != range.second; ++it) {
+ h_client = CommonFindSender(h_app, it->second);
+ if (!h_client) {
+ continue;
+ }
+
+ e_status = FrameworkunifiedSendMsg(h_client, cid, (UI_32)size, data);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(e_status:%d to:%s)",
+ e_status, it->second.c_str());
+ fail = true;
+ }
}
+ return fail ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CANDeliverySndMsg(HANDLE h_app, CANID ul_canid, uint8_t n_ta,
+ uint8_t uc_dlc, const uint8_t *puc_data,
+ PS_CommunicationProtocol cid, enum CanIfEchoBackFlags flag) {
+ CAN_MSG_CANDATA st_delivery_msg;
+ uint8_t uc_size = uc_dlc;
+
+ // Create delivery data
+ memset(&st_delivery_msg, 0, sizeof(st_delivery_msg));
+ st_delivery_msg.hdr.hdr.cid = cid;
+ st_delivery_msg.hdr.hdr.msgbodysize = (uint16_t)(CAN_TRX_CANID_SIZE +
+ CAN_TRX_DLC_SIZE +
+ (uint32_t)uc_size);
+ st_delivery_msg.hdr.hdr.rid = 0;
+ st_delivery_msg.data.can_id = ul_canid;
+ st_delivery_msg.data.dlc = uc_size;
+ st_delivery_msg.echoback = flag;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "can_id=%x dlc=%x echoback=%d",
+ st_delivery_msg.data.can_id, st_delivery_msg.data.dlc,
+ st_delivery_msg.echoback);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(st_delivery_msg.data.data, uc_size).c_str());
- return ret;
+
+ if (uc_size > (uint8_t)CAN_DATA_SIZE)
+ uc_size = CAN_DATA_SIZE;
+ memcpy(st_delivery_msg.data.data, puc_data, (size_t)uc_size);
+
+ return CANDeliverySndMsgToClient(h_app, ul_canid, &st_delivery_msg,
+ sizeof(st_delivery_msg), cid);
}
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Recieve _CWORD29_ data delivery before processing
- *
- * @~english
- * @return Return value
- * @retval <RET_CAN_NORMAL> OK
- * @retval <RET_CAN_ERROR_CANCEL> Delivery Error
- *
- * @~english
- * @param[in] <h_app> Application handle
- * @param[in] <us_opc> OPC
- * @param[in] <uc_dlc> DLC
- * @param[in] <puc_data_pos> CAN Data
- */
-RET_CAN CANDeliveryRcv_CWORD29_Data(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, uint8_t *puc_data_pos) {
- RET_CAN ret = RET_CAN_NORMAL;
-
- /****** CANDataSending a delivery message ******/
- if (FALSE == CANDelivery_CWORD29_SndMsg(h_app, us_opc, uc_dlc, puc_data_pos)) {
- /* CANDataDelivery message transmission processing */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Delivery Error");
- ret = RET_CAN_ERROR_CANCEL;
+EFrameworkunifiedStatus CANCommandDeliveryRcvProcess(HANDLE h_app,
+ CanMessage *msg, uint8_t cmd) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_MSG_CANCMD st_delivery_msg;
+ uint16_t len = 0;
+
+ memset(&st_delivery_msg, 0, sizeof(st_delivery_msg));
+ switch (cmd) {
+ case CAN_CMDID_FUELCALC_RST_REQ_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_FUELCALC_RST_SIZE;
+ break;
+ case CAN_CMDID_STARTUP_FIN_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_STARTUP_FIN_SIZE;
+ break;
+ case CAN_CMDID_MRST_INFO_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_MRST_INFO_SIZE;
+ break;
+ case CAN_CMDID_VERSION_RESP_RX:
+ len = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_VERSION_SIZE;
+ break;
+ case CAN_CMDID_CONNECTION_NODE_RESP_RX:
+ len = (uint16_t)(CAN_TX_CMD_DELIVERY_SIZE + msg->data[0] + 1);
+ break;
+ default:
+ return e_status;
}
+ st_delivery_msg.hdr.hdr.rid = 0;
+ st_delivery_msg.hdr.hdr.cid = (uint16_t)CID_CAN_CMD_DELIVERY;
+ st_delivery_msg.hdr.hdr.msgbodysize = len;
+ st_delivery_msg.data.cmd_id = cmd;
+ memcpy(&st_delivery_msg.data.data, msg->data,
+ (size_t)(len - CAN_TX_CMD_DELIVERY_SIZE));
+ CANMsgInsert(cmd, msg);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "cid=%x msgbodysize=%x cmd_id=%x",
+ st_delivery_msg.hdr.hdr.cid, st_delivery_msg.hdr.hdr.msgbodysize,
+ st_delivery_msg.data.cmd_id);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(st_delivery_msg.data.data, len).c_str());
- return ret;
+ return CANDeliverySndMsgToClient(h_app, msg->can_id, &st_delivery_msg,
+ sizeof(st_delivery_msg), CID_CAN_CMD_DELIVERY);
}
-/*******************************************************************************
- * MODULE : CANDlcCheck
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief DLC check processing
- *
- * DLC check processing of received CAN data
- *
- * CANDataCheck the PROCESS
- *
- * @~english
- * @note
- * -# Length acquisition of header
- * -# Positional change of DLC
- * -# Data length calculation
- * -# Data length comparison
- *
- * @~english
- * @param[in] <pst_msg_data> Pointer of reference to data division of reception message
- */
-//RET_CAN CANDlcCheck(const T_ICR_CMD_DATA *pst_msg_data) { // LCOV_EXCL_START 8: dead code
-// AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
-// RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-// int32_t l_len1; /* For data length calculation */
-// int32_t l_len2; /* For data length calculation */
-// uint8_t offset = 0; /* N_TA offset size */
-// uint8_t uc_dlc; /* DLC value */
-
- /* Length collection of headers */
-// l_len1 = (int32_t)pst_msg_data->d_length;
-
-// if ((uint8_t)CAN_OPC_PAC_RX == pst_msg_data->opc) {
-// l_len2 = (int32_t)(CAN_EXRCV_DATA_SIZE * pst_msg_data->data[0] + CAN_EXRCV_CANNUM_SIZE);
-
- /* DLC check of pacaging CAN data */
-// if (l_len1 != l_len2) {
-// ret = RET_CAN_ERROR_CANCEL; /* DLC error */
-// }
-// } else {
-// uc_dlc = (uint8_t)pst_msg_data->data[CAN_MSGBUF_DLC_POS];
- /* Data length considered from the DLC */
-// l_len2 = (int32_t)CAN_TRX_CANID_SIZE /* CAN ID sizes */
-// + (int32_t)CAN_TRX_DLC_SIZE /* Size of the DLC */
-// + (int32_t)offset /* Size of N_TA */
-// + (int32_t)uc_dlc; /* CANDataLength: DLC content */
-
- /* "Comparison of Length of headers and data length considered from DLCs */
- /* "Valid if the actual data length is equal to or less than the DLC */
-// if (l_len1 < l_len2) {
-// ret = RET_CAN_ERROR_CANCEL; /* DLC error */
-// } else if (uc_dlc > (uint8_t)CAN_DATA_SIZE) {
- /* CANDataDisabled when exceeding maximum size */
-// ret = RET_CAN_ERROR_CANCEL; /* DLC error */
-// } else {
- /* No DLC error */
-// }
-// }
-
-// return (ret);
-//}
-// LCOV_EXCL_STOP
-
-/*******************************************************************************
- * MODULE : CANCanidIfToUserCvt
- * ABSTRACT : CAN ID Conversion Process 1
- * FUNCTION : Convert CAN ID for interfaces to CAN ID for USER
- * ARGUMENT : *puc_operand :Operand reference pointer
- * NOTE :
- * RETURN : CAN ID
- ******************************************************************************/
-CANID CANCanidIfToUserCvt(uint8_t *puc_operand) {
- CANID can_id = 0; /* CAN ID */
- uint8_t *puc; /* Generic pointer */
- uint32_t ul = 0; /* General Variables */
-
- /* Concept of conversion
- Input data format (8-bit data with the following structure)
- Base Address +0 :ext_flag, CAN ID[10:4]
- +1 :CAN ID[3:0], Empty[1:0], CAN ID[28:27]
- +2 :CAN ID[26:19]
- +3 :CAN ID[18:11]
- Output data format (32-bit data)
- Bit assignment [31:29] [28:0]
- CAN ID Empty[2:0] CAN ID[28:0]
-*/
-
- puc = &puc_operand[CAN_MSGBUF_CANID_POS]; /* Get Base Address of CAN ID */
- ul = (uint32_t)puc[0] & 0x7F; /* Contain [10:4] data */
- ul <<= 4;
- can_id |= (CANID)ul;
- ul = (uint32_t)puc[1] & 0xF0; /* Insert data of [3:0] */
- ul >>= 4;
- can_id |= (CANID)ul;
- ul = (uint32_t)puc[1] & 0x03; /* Populate [28:27] */
- ul <<= 27;
- can_id |= (CANID)ul;
- ul = (uint32_t)puc[2]; /* Contain [26:19] data */
- ul <<= 19;
- can_id |= (CANID)ul;
- ul = (uint32_t)puc[3]; /* Populate [18:11] */
- ul <<= 11;
- can_id |= (CANID)ul;
-
- return (can_id);
+EFrameworkunifiedStatus CANDeliveryRcvProcess(HANDLE h_app, CanMessage *msg) {
+ if (!Canif_CheckCanID(msg->can_id)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CANID is invalid (%x)", msg->can_id);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ CANCommWatchClear(h_app, msg->can_id);
+ CANMsgInsert(msg->can_id, msg);
+ if (eFrameworkunifiedStatusOK != CANDeliverySndMsg(h_app, msg->can_id, CAN_NTA_INVALID,
+ (uint8_t)msg->dlc, msg->data, CID_CAN_DATA_DELIVERY)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CAN Delivery Error");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ return eFrameworkunifiedStatusOK;
}
-/*******************************************************************************
- * MODULE : CANPacCanidIfToUserCvt
- * ABSTRACT : CAN ID Conversion Process 1
- * FUNCTION : Convert CAN ID for interfaces to CAN ID for USER
- * ARGUMENT : *puc_operand :Operand reference pointer
- * NOTE :
- * RETURN : CAN ID
- ******************************************************************************/
-CANID CANPacCanidIfToUserCvt(uint8_t *puc_operand) {
- CANID can_id = 0;
- uint8_t *puc;
- uint32_t ul = 0;
-
- puc = &puc_operand[0];
- ul = (uint32_t)puc[0] & 0x7F;
- ul <<= 4;
- can_id |= (CANID)ul;
- ul = (uint32_t)puc[1] & 0xF0;
- ul >>= 4;
- can_id |= (CANID)ul;
-
- return (can_id);
+EFrameworkunifiedStatus CANClearEntry(HANDLE h_app) {
+ char notify_name[CANIF_NOTIFY_NAME_MAX_SIZE + 1] = {0};
+ CAN_DeliveryEntryListIt it;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &notify_name,
+ CANIF_NOTIFY_NAME_MAX_SIZE, eSMRRelease);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
+ "#CAN thread# FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
+ if (e_status == eFrameworkunifiedStatusInvldBufSize) {
+ FrameworkunifiedClearMsgData(h_app);
+ }
+ return e_status;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "notify_name=%s", notify_name);
+
+ // To avoid destruction of iterator.
+ it = g_map_delivery_list_can.begin();
+ while (it != g_map_delivery_list_can.end()) {
+ size_t n = strnlen(it->second.c_str(), CANIF_NOTIFY_NAME_MAX_SIZE);
+ if (!strncmp(it->second.c_str(), notify_name, n)) {
+ g_map_delivery_list_can.erase(it++);
+ } else {
+ ++it;
+ }
+ }
+
+ return eFrameworkunifiedStatusOK;
}
diff --git a/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp b/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp
deleted file mode 100644
index a0bc1f0f..00000000
--- a/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * FILE :CAN_DeliveryData.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN thread CAN data delivery data management
- * Module configuration :CANDeliveryDataInit( ) CANDataDelivery Management Data Initialization Process
- * CAN_DeliveryCanidCheck( ) CAN ID registration and delivery registration checking process
- * CAN_DeliveryListCapacityCheck( ) CANDataDistribution destination management table free space confirmation processing
- * CAN_DeliveryCanidEntryCheck( ) CANDataChecking the status of delivery CAN ID control table entries
- * CANDeliveryEntry( ) CANDataDelivery registration process
- * CAN_SndListGenerate( ) CANData ID List Creation Process for Delivery
- ******************************************************************************/
-#include "CAN_DeliveryData.h"
-
-#include <string.h> // NOLINT(build/include)
-#include <native_service/frameworkunified_framework_if.h>
-#include <other_service/strlcpy.h>
-
-#include <utility>
-#include <string>
-#include <map>
-
-#include "CAN_Thread.h"
-#include "CAN_Delivery.h"
-#include "Canif_API_Local.h"
-//#include "can_hal.h"
-
-/*************************************************/
-/* Global variables */
-/*************************************************/
-std::multimap<CANID, std::string> g_map_delivery_list;
-std::multimap<uint16_t, std::string> g_map__CWORD29__delivery_list;
-
-/*******************************************************************************
- * MODULE : CANDeliveryDataInit
- * ABSTRACT : CANDataDelivery Management Data Initialization Process
- * FUNCTION : CANDataInitialize delivery management data for
- * ARGUMENT : void
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANDeliveryDataInit(void) {
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANDeliveryEntry
- * ABSTRACT : CANDataDelivery registration process
- * FUNCTION : CANDataRegister delivery
- * ARGUMENT : notifyId : Addresses for delivery ID
- * usCanNum : Registered number
- * *pulCanid : CAN ID array pointers
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app) {
- uint16_t i;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_DELIVERY_ENTRY rcv_msg;
- std::string notify_name;
- std::multimap<CANID, std::string>::iterator it;
-
- e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease); // LCOV_EXCL_BR_LINE 200: unexpect branch // NOLINT (whitespace/line_length)
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN DeliveryEntry FrameworkunifiedGetMsgDataOfSize Error"); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
- goto exit; // LCOV_EXCL_LINE 4: NSFW error case
- }
-
- for (i = 0; (i < rcv_msg.usCanNum) && (i < static_cast<uint16_t>(CAN_DELIVERY_CANID_ENTRY_MAX)); i++) {
- // Check for duplicate data
- // If the data to be registered is duplicated, an eFrameworkunifiedStatusOK is returned and the data is not registered.
- bool isDuplication = false;
- it = g_map_delivery_list.find(static_cast<std::multimap<CANID, std::string>::key_type>(rcv_msg.ulCanid[i]));
- for (; it != g_map_delivery_list.end(); ++it) {
- if (it->second == rcv_msg.notifyName) {
- isDuplication = true;
- break;
- }
- }
- if (isDuplication) {
- continue;
- }
-
- if ((uint32_t)g_map_delivery_list.size() >= CAN_DELIVERY_LIST_NUM) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN DeliveryEntry Table MAX size over"); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
- e_status = eFrameworkunifiedStatusFail;
- break;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_ENTRY, "", "[CAN] %04x %s", rcv_msg.ulCanid[i], rcv_msg.notifyName); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
- notify_name = rcv_msg.notifyName;
- g_map_delivery_list.insert(std::make_pair(rcv_msg.ulCanid[i], notify_name)); // LCOV_EXCL_BR_LINE 200: unexpect branch // NOLINT (whitespace/line_length)
- }
-
-exit:
- return e_status;
-}
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_DeliveryEntry
- * ABSTRACT : Process of registering the delivery of _CWORD29_ data
- * FUNCTION : Register the delivery of _CWORD29_ data
- * ARGUMENT : h_app : HANDLE
- * NOTE :
- * RETURN : EFrameworkunifiedStatus
- ******************************************************************************/
-EFrameworkunifiedStatus CAN_CWORD29_DeliveryEntry(HANDLE h_app) {
- uint16_t i;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN__CWORD29__DELIVERY_ENTRY rcv_msg;
- std::string notify_name;
- std::multimap<uint16_t, std::string>::iterator it;
-
- if (reinterpret_cast<HANDLE>(NULL) == h_app) {
- return eFrameworkunifiedStatusFail;
- }
-
- e_status = FrameworkunifiedGetMsgDataOfSize(h_app, reinterpret_cast<PVOID>(&rcv_msg),
- static_cast<UI_32>(sizeof(CAN__CWORD29__DELIVERY_ENTRY)), eSMRRelease);
- if (e_status != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN DeliveryEntry FrameworkunifiedGetMsgDataOfSize Error");
- return e_status;
- }
-
- if (CAN_DELIVERY_OPC_ENTRY_MAX <= rcv_msg.usOpcNum) {
- e_status = eFrameworkunifiedStatusFail;
- return e_status;
- }
-
- for (i = 0; i < rcv_msg.usOpcNum; i++) {
- // Check for duplicate data
- // If the data to be registered is duplicated, an eFrameworkunifiedStatusOK is returned and the data is not registered.
- bool isDuplication = false;
- it = g_map__CWORD29__delivery_list.find(static_cast<std::multimap<uint16_t, std::string>::key_type>(rcv_msg.usOpc[i]));
- for (; it != g_map__CWORD29__delivery_list.end(); ++it) {
- if (it->second == rcv_msg.notifyName) {
- isDuplication = true;
- break;
- }
- }
- if (isDuplication) {
- continue;
- }
-
- if (static_cast<uint32_t>(g_map__CWORD29__delivery_list.size()) >= CAN_DELIVERY_LIST_NUM) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# _CWORD29_DeliveryEntry Table MAX size over");
- e_status = eFrameworkunifiedStatusFail;
- break;
- }
- FRAMEWORKUNIFIEDLOG(ZONE_ENTRY, "", "[OPC] %04x %s", rcv_msg.usOpc[i], rcv_msg.notifyName);
- notify_name = rcv_msg.notifyName;
- g_map__CWORD29__delivery_list.insert(std::make_pair(rcv_msg.usOpc[i], notify_name));
- }
-
- return e_status;
-}
-
-/*******************************************************************************
- * MODULE : CANDeliveryBufferOut
- * ABSTRACT : CAN shipping table log output processing
- * FUNCTION : Output the CAN shipping table log
- * ARGUMENT : FILE *fp_log : File pointer of the log output file
- * NOTE :
- * RETURN : Thread ID
- ******************************************************************************/
-void CANDeliveryBufferOut(FILE *fp_log) { // LCOV_EXCL_START 8:dead code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- uint32_t usage_rate;
- std::multimap<CANID, std::string>::iterator it;
-
- if (NULL != fp_log) {
- /* Destination management table output */
- usage_rate = (((uint32_t)g_map_delivery_list.size() * 100) / CAN_DELIVERY_LIST_NUM);
- (void)fprintf(fp_log, "CAN DeliveryList_Buffer \n");
- (void)fprintf(fp_log, "BUFFER_Use: %04zu BUFFER_Max: %04d Usage_Rate: %04u \n",
- g_map_delivery_list.size(), CAN_DELIVERY_LIST_NUM, usage_rate);
- if (usage_rate >= CAN_USAGE_RATE_THRESHOLD) {
- (void)fprintf(fp_log, "Warning: Buffer utilization exceeds a threshold.\n");
- }
- (void)fprintf(fp_log, "CanID: notifyId:\n");
-
- for (it = g_map_delivery_list.begin(); it != g_map_delivery_list.end(); it++) {
- (void)fprintf(fp_log, "%08x %s\n",
- it->first,
- it->second.c_str());
- }
- }
-}
-// LCOV_EXCL_STOP
-
-#ifdef CAN_DEBUG
-EFrameworkunifiedStatus CANAllDeleteDeliveryEntry(HANDLE h_app) {
- g_map_delivery_list.clear();
- g_map__CWORD29__delivery_list.clear();
-
- return eFrameworkunifiedStatusOK;
-} // LCOV_EXCL_BR_LINE 10 last Line
-#endif
diff --git a/communication/server/src/CAN/TimerCtrl/CAN_TimerCtrl.cpp b/communication/server/src/CAN/TimerCtrl/CAN_TimerCtrl.cpp
deleted file mode 100644
index 9e3ac384..00000000
--- a/communication/server/src/CAN/TimerCtrl/CAN_TimerCtrl.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * FILE :CAN_TimerCtrl.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN thread timer management processing
- * Module configuration :CANFreqTransTimerStart() Periodic transmission timer start processing
- * :CANFreqTransTimerStop() Periodic transmission timer stop processing
- * :CANCommWatchTimerStart() Communication interruption monitoring timer start processing
- * :CANCommWatchTimerStop() Communication interruption monitoring timer stop processing
- * :CANCommWatchTimerRenewal() Communication interruption monitoring timer update processing
- * :CANFreqTransTimeOut() CAN periodic transmission timeout confirmation processing
- * :CANCommWatchTimeOut() CAN Communication Disruption Monitoring Timeout Confirmation Process
- * :CANTimerStart() CAN Timer Master Processing
- * :CANTimerTblInit() CAN timer table initialization processing
- ******************************************************************************/
-#include "CAN_TimerCtrl.h"
-
-#include <string.h> // NOLINT (build/include)
-#include <native_service/frameworkunified_types.h>
-#include <peripheral_service/Canif_API.h>
-#include <map>
-#include "CAN_Thread.h"
-#include "CAN_CommWatch.h"
-#include "CAN_Transmission.h"
-#include "CAN_TransmissionData.h"
-#include "CAN_CommWatchData.h"
-
-
-using std::map;
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-CAN_FREQTRANS_TIMER g_st_can_freq_trans_tim[CAN_PROTOCOL_TYPE_TERMINATE]; /* CAN Periodic Transmission Timer Management Table */
-CAN_COMMWATCH_TIMER g_st_can_comm_watch_tim[CAN_PROTOCOL_TYPE_TERMINATE]; /* CAN communication interruption monitoring timer management table */
-map<CANID, CAN_TIMER_CTRL_DATA> g_map_can_freq_trans_time; /* Periodic transmission CAN Command management table */
-
-/*******************************************************************************
- * MODULE : CANFreqTransTimerStart
- * ABSTRACT : Periodic transmission timer start processing
- * FUNCTION : Registering a Periodic Transmission Timer (Periodic Timer)
- * ARGUMENT : uc_index : Indexed
- * : us_time : Periodic send timer value
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_TIMER : Timer acquisition failed
- ******************************************************************************/
-RET_CAN CANFreqTransTimerStart(uint8_t uc_index, uint16_t us_time, CAN_PROTOCOL_TYPE type) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-
- /* Timer not started for specified index */
- if ((uint16_t)0 == g_st_can_freq_trans_tim[type].data[uc_index].us_set_tim) {
- /* Updating the number of timer registrations */
- g_st_can_freq_trans_tim[type].us_num++;
- }
- /* Regular transmission interval timer registration */
- CANTimerStart(us_time, & g_st_can_freq_trans_tim[type].data[uc_index]);
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransTimerStop
- * ABSTRACT : Periodic transmission timer stop processing
- * FUNCTION : Stops the periodic transmission timer (periodic timer).
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_TIMER : Failed to stop timer
- ******************************************************************************/
-RET_CAN CANFreqTransTimerStop(uint8_t uc_index, CAN_PROTOCOL_TYPE type) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-
- if ((uint16_t)0 < g_st_can_freq_trans_tim[type].data[uc_index].us_set_tim) {
- /* Stop the CAN periodic transmission timer. */
- g_st_can_freq_trans_tim[type].data[uc_index].us_set_tim = 0;
- g_st_can_freq_trans_tim[type].data[uc_index].us_tim_cnt = 0;
- g_st_can_freq_trans_tim[type].us_num--;
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerStart
- * ABSTRACT : Communication interruption monitoring timer start processing
- * FUNCTION : Register the communication interruption monitoring timer (single occurrence timer)
- * ARGUMENT : uc_index : Indexed
- * : usWatchTim : Communication interruption monitoring time
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_TIMER : Timer acquisition failed
- ******************************************************************************/
-RET_CAN CANCommWatchTimerStart(uint8_t uc_index, uint16_t us_watch_time, CAN_PROTOCOL_TYPE type) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
- uint16_t us_val;
- uint16_t us_tim;
-
- /* Update Timer Sequence Number */
- CANCommWatchTimerSeqNoRenwal(uc_index, &us_val, type);
- us_tim = (uint16_t)((uint32_t)us_watch_time + 1);
- /* Registration of communication interruption monitoring timer */
- CANTimerStart(us_tim, &g_st_can_comm_watch_tim[type].data[uc_index]);
- /* Updating the number of timer registrations */
- g_st_can_comm_watch_tim[type].us_num++;
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerStop
- * ABSTRACT : Communication interruption monitoring timer stop processing
- * FUNCTION : Stop the communication interruption monitoring timer (single occurrence timer)
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_TIMER : Failed to stop timer
- ******************************************************************************/
-RET_CAN CANCommWatchTimerStop(uint8_t uc_index, CAN_PROTOCOL_TYPE type) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
-
- if ((uint16_t)0 < g_st_can_comm_watch_tim[type].data[uc_index].us_set_tim) {
- /* Timer stop */
- g_st_can_comm_watch_tim[type].data[uc_index].us_set_tim = 0;
- g_st_can_comm_watch_tim[type].data[uc_index].us_tim_cnt = 0;
- g_st_can_comm_watch_tim[type].us_num--;
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimerRenewal
- * ABSTRACT : Communication interruption monitoring timer update processing
- * FUNCTION : Update communication interruption monitoring timer
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_TIMER : Timer acquisition or stop failed
- ******************************************************************************/
-RET_CAN CANCommWatchTimerRenewal(uint8_t uc_index, CAN_PROTOCOL_TYPE type) {
- RET_CAN ret = RET_CAN_NORMAL; /* Return value of this function */
- uint16_t us_time; /* Communication interruption time */
-
- /* Stop timer during startup */
- ret = CANCommWatchTimerStop(uc_index, type);
- /* Update Timer Sequence Number */
- (void)CANCommWatchTimerSeqNoRenwal(uc_index, &us_time, type);
- /* Registration of communication interruption monitoring timer */
- CANTimerStart(us_time, &g_st_can_comm_watch_tim[type].data[uc_index]);
- /* Updating the number of timer registrations */
- g_st_can_comm_watch_tim[type].us_num++;
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransTimeOut
- * ABSTRACT : CAN periodic transmission timeout confirmation processing
- * FUNCTION : CAN periodic transmission timeout confirmation processing
- * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANFreqTransTimeOut(HANDLE h_app, uint16_t timer_seq, CAN_PROTOCOL_TYPE type) {
- uint16_t us_tim_pos;
- uint16_t us_tim_num;
-
- us_tim_num = g_st_can_freq_trans_tim[type].us_num;
- /* Timer start */
- if ((uint16_t)0 < us_tim_num) {
- /* Check the timeout of the CAN periodic transmission timer table */
- for (us_tim_pos = 0; us_tim_pos < (uint16_t)CAN_FREQTRANS_TIMER_DATA; us_tim_pos++) {
- /* When the timer is starting */
- if ((uint16_t)0 < g_st_can_freq_trans_tim[type].data[us_tim_pos].us_tim_cnt) {
- /* Decrement timer value */
- g_st_can_freq_trans_tim[type].data[us_tim_pos].us_tim_cnt--;
- /* Detect timeouts */
- if ((uint16_t)0 == g_st_can_freq_trans_tim[type].data[us_tim_pos].us_tim_cnt) {
- /* Execute the CAN periodic transmission timeout processing */
- if (type == CAN_PROTOCOL_TYPE_CAN) {
- /* Setting data for timeout messages */
- timer_seq = (uint16_t)((uint32_t)us_tim_pos | FREQ_TRANS_SEQNO_CODE);
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "CANFreqTxTimeupMsg Execute(us_tim_pos=%d, TimerSeq=%x)", us_tim_pos,
- timer_seq);
- CANFreqTxTimeupMsg(h_app, timer_seq);
- }
- /* Reset timer value and continue timer operation */
- g_st_can_freq_trans_tim[type].data[us_tim_pos].us_tim_cnt =
- g_st_can_freq_trans_tim[type].data[us_tim_pos].us_set_tim;
- }
- us_tim_num--;
- /* Check completed for the number of timer entries */
- if ((uint16_t)0 == us_tim_num) {
- break;
- }
- }
- }
- }
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchTimeOut
- * ABSTRACT : CAN Communication Disruption Monitoring Timeout Confirmation Process
- * FUNCTION : CAN Communication Disruption Monitoring Timeout Confirmation Process
- * ARGUMENT : None
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommWatchTimeOut(HANDLE h_app, CAN_PROTOCOL_TYPE type) {
- uint8_t us_tim_pos;
- uint16_t us_tim_num;
- uint16_t us_timer_seq_no;
- RET_CAN ret;
-
- us_tim_num = g_st_can_comm_watch_tim[type].us_num;
- /* Timer start */
- if ((uint16_t)0 < us_tim_num) {
- /* Check timeout of CAN communication interruption monitoring timer table */
- for (us_tim_pos = 0; us_tim_pos < (uint8_t)CAN_COMMWATCH_TIMER_DATA; us_tim_pos++) {
- /* When the timer is starting */
- if ((uint16_t)0 < g_st_can_comm_watch_tim[type].data[us_tim_pos].us_tim_cnt) {
- /* Decrement timer value */
- g_st_can_comm_watch_tim[type].data[us_tim_pos].us_tim_cnt--;
- /* Detect timeouts */
- if ((uint16_t)0 == g_st_can_comm_watch_tim[type].data[us_tim_pos].us_tim_cnt) {
- /* Time-out detected */
- us_timer_seq_no = CANCommWatchTimerSeqNoGet(us_tim_pos, type);
-
- /* Execute CAN communication interruption monitoring timeout processing */
- switch (type) {
- case CAN_PROTOCOL_TYPE_CAN:
- ret = CANCommWatchTimeoutMsg(h_app, us_timer_seq_no);
- if (RET_CAN_NORMAL != ret) { // LCOV_EXCL_BR_LINE 8: If us_timer_seq_no is valid, it will not return NON-RET_CAN_NORMAL // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: same with above // NOLINT (whitespace/line_length)
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN CommWatch TimeoutMsg Error"); // LCOV_EXCL_LINE 8: same with above // NOLINT (whitespace/line_length)
- }
- break;
- default:
- break;
- }
-
- /* Deletes the CAN communication interruption monitoring timer table. */
- CANCommWatchTimerStop(us_tim_pos, type);
- }
- us_tim_num--;
- /* Check completed for the number of timer entries */
- if (us_tim_num == (uint16_t)0) {
- break;
- }
- }
- }
- }
-}
-
-/*******************************************************************************
- * MODULE : CANTimerStart
- * ABSTRACT : CAN Timer Master Processing
- * FUNCTION : CAN Timer Master Processing
- * ARGUMENT : u_int16 us_time Setting timer value
- * : CAN_TIMER_CTRL_DATA *pst_can_timer_tbl Timer table pointer to edit
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANTimerStart(uint16_t us_time, CAN_TIMER_CTRL_DATA *pst_can_timer_tbl) {
- /* Update the timeout value */
- pst_can_timer_tbl->us_set_tim = us_time;
- /* Begin detecting timeouts */
- pst_can_timer_tbl->us_tim_cnt = us_time;
-}
-
-/*******************************************************************************
- * MODULE : CANTimerTblInit
- * ABSTRACT : CAN timer table initialization processing
- * FUNCTION : CAN Timer Table Initialization Processing
- * ARGUMENT : None
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANTimerTblInit(void) {
- for (int i = 0; i < CAN_PROTOCOL_TYPE_TERMINATE; i++) {
- /* Initialization of the CAN periodic transmission timer table */
- memset(& g_st_can_freq_trans_tim[i], 0, sizeof( g_st_can_freq_trans_tim[i]));
- /* Initialization of CAN communication interruption monitoring timer table */
- memset(&g_st_can_comm_watch_tim[i], 0, sizeof(g_st_can_comm_watch_tim[i]));
- }
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Register Transmission Cycle
- *
- * @~english
- * @return Return value
- * @retval None
- *
- * @~english
- * @param[in] <id> CAN ID
- * @param[in] <freq> Transmission cycle
- */
-void CANFreqTimerEntry(CANID id, uint32_t freq) {
- CAN_TIMER_CTRL_DATA tmp_timer_data;
-
- tmp_timer_data.us_set_tim = (uint16_t)freq;
- tmp_timer_data.us_tim_cnt = (uint16_t)freq;
-
- g_map_can_freq_trans_time[id] = tmp_timer_data;
-
- return;
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Periodic trnasmission time out
- *
- * @~english
- * @return Return value
- * @retval None
- *
- * @~english
- * @param[in] None
- */
-void CANFreqTransTimeOutMap(HANDLE h_app) {
- map<CANID, CAN_TIMER_CTRL_DATA>::iterator it;
- CAN_TIMER_CTRL_DATA timer_data;
- CANID id;
-
- for (it = g_map_can_freq_trans_time.begin(); it != g_map_can_freq_trans_time.end(); ++it) {
- id = it->first;
- timer_data = it->second;
-
- if (0 >= timer_data.us_tim_cnt)
- continue;
-
- timer_data.us_tim_cnt--;
-
- if ((uint16_t)0 == timer_data.us_tim_cnt) {
- CANTransStartTxMsg(h_app, id);
- timer_data.us_tim_cnt = timer_data.us_set_tim;
- }
-
- g_map_can_freq_trans_time[id] = timer_data;
- }
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Clear Transmission Cycle
- *
- * @~english
- * @return Return value
- * @retval None
- *
- * @~english
- * @param[in] <id> CAN ID
- */
-RET_CAN CANFreqTransTimerStopMap(CANID id) {
- RET_CAN ret = RET_CAN_NORMAL;
- CAN_TIMER_CTRL_DATA timer_data;
-
- timer_data.us_set_tim = 0;
- timer_data.us_tim_cnt = 0;
-
- g_map_can_freq_trans_time[id] = timer_data;
-
- return (ret);
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Reset Transmission Cycle
- *
- * @~english
- * @return Return value
- * @retval None
- *
- * @~english
- * @param[in] <id> CAN ID
- */
-void CANFreqTimerResetMap(CANID id) {
- map<CANID, CAN_TIMER_CTRL_DATA>::iterator it;
-
- it = g_map_can_freq_trans_time.find(id);
- if (it != g_map_can_freq_trans_time.end()) {
- it->second.us_tim_cnt = it->second.us_set_tim;
- }
-
- return;
-} // LCOV_EXCL_BR_LINE 10: end of line unknown branch
diff --git a/communication/server/src/CAN/Transmission/CAN_Transmission.cpp b/communication/server/src/CAN/Transmission/CAN_Transmission.cpp
deleted file mode 100644
index 4be88578..00000000
--- a/communication/server/src/CAN/Transmission/CAN_Transmission.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * Module configuration :CANTxStart() CANDataTransmission start message processing
- * CANTxStartMsgCheck() CANDataSend start message check processing
- * CANFreqTxStop() CANDataPeriodic transmission stop message processing
- * CANFreqTxTimeupMsg() CANDataPeriodic transmission time-up message processing
- * CANTxRsltReceiveMsg() CANDataReceive message processing of transmission result
- * CANTxRsltReceiveMsgCheck() CANDataSend result received message check processing
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @file CAN_Transmission.cpp
- * @~english
- * @brief CAN Transmission process
- */
-#include "CAN_Transmission.h"
-#include <string.h> // NOLINT(build/include)
-#include <fcntl.h>
-#include "CAN_TransmissionData.h"
-#include "CAN_TxMsg.h"
-#include "CAN_TimerCtrl.h"
-#include "CAN_Delivery.h"
-#include "CAN_DeliveryData.h"
-#include "Canif_API_Local.h"
-#include "ICR_Common.h"
-#include <native_service/frameworkunified_framework_if.h>
-//#include "can_hal.h"
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-
-/*******************************************************************************
- * MODULE : CANTxStartMsg
- * ABSTRACT : CANDataTransmission start message processing
- * FUNCTION : CANDataStarting transmission when a transmission start message is received
- * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_BUFFULL : Registered FULL
- * RET_CAN_ERROR_TIMER : Timer acquisition failed
- ******************************************************************************/
-EFrameworkunifiedStatus CANTxStart(HANDLE h_app) {
- RET_CAN l_ret = RET_CAN_NORMAL; /* Return value of this function */
- uint8_t uc_index; /* Indexed */
- uint8_t uc_can_rid; /* CAN uint8_t */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_TRANSMISSION_START_MSG_DAT rcv_msg;
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN COMMWATCH START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- 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;
- }
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- /****** Data section check ******/
- l_ret = CANTxStartMsgCheck(&rcv_msg, &uc_index);
- if (RET_CAN_NORMAL != l_ret) {
- goto exit;
- }
-
- /****** Message processing ******/
- if ((uint16_t)0 != rcv_msg.usFreq) {
- /* Periodic transmission */
- CANFreqTransEntry(uc_index, &rcv_msg); /* CANDataRegular transmission registration */
- if (FALSE == CANFreqTransStartTxMsg(h_app, uc_index)) { /* Periodic transmission start message transmission */
- l_ret = RET_CAN_ERROR_CREATE_EVENT; /* Event generation failure */
- goto exit;
- }
- } else {
- if ((uint8_t)CAN_RID_NOTUSE_CODE == uc_index) {
- uc_can_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
- } else {
- uc_can_rid = (uint8_t)((uint32_t)uc_index + CAN_TXRSLT_CANRID_1TIME_START);
- }
- /* Send one transmission start message */
- if (FALSE == CAN1TimeTransStartTxMsg(h_app, uc_can_rid, &rcv_msg.stCandata)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission ICR Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- CANDebugLogOut(CAN_TRANCE_ICR_ERR, &rcv_msg); /* Transmission error log output */
- l_ret = RET_CAN_ERROR_CREATE_EVENT;
- goto exit;
- }
- }
-
- /****** CANDataRegister one transmission result management table ******/
- if (((uint16_t)0 == rcv_msg.usFreq) && ((uint8_t)CAN_RID_NOTUSE_CODE != rcv_msg.ucRid)) {
- e_status = CAN1TimeTransEntry(uc_index, &rcv_msg); /* CANDataRegister 1 transmission result */
- if (eFrameworkunifiedStatusOK != e_status) { // LCOV_EXCL_BR_LINE 8: uc_index can't GL CAN_1TIME_TRSNSMISSION_RSLT_NUM, so e_status is always eFrameworkunifiedStatusOK // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: same with above
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "ERROR !!! CAN1TimeTransEntry failed : e_status=%d, uc_index=%d", e_status, uc_index); // LCOV_EXCL_LINE 8: same with above //NOLINT (readability/naming)
- l_ret = RET_CAN_ERROR_PARAM; // LCOV_EXCL_LINE 8: same with above
- }
- }
-
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "END(l_ret=%x)", l_ret); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- if (l_ret == RET_CAN_NORMAL)
- return eFrameworkunifiedStatusOK;
- else
- return eFrameworkunifiedStatusFail;
- // return RET_CAN_NORMAL;
-}
-
-/*******************************************************************************
- * MODULE : CANTxStartMsgCheck
- * ABSTRACT : CANDataSend start message check processing
- * FUNCTION : CANDataCheck the data contents when a transmission start message is received
- * ARGUMENT : *pst_msg_data : Receive message data section reference pointer
- * *puc_index : Index (pointer output)
- * NOTE :
- * RETURN : RET_CAN_NORMAL :Normal completion
- * RET_CAN_ERROR_BUFFULL :Registered FULL
- * RET_CAN_ERROR_TIMER :Timer acquisition failure
- ******************************************************************************/
-RET_CAN CANTxStartMsgCheck(const CAN_TRANSMISSION_START_MSG_DAT *pst_msg_data, uint8_t *puc_index) {
- RET_CAN l_ret = RET_CAN_NORMAL; /* Return value of the function */
- uint8_t uc_index = 0; /* Indexed */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- /* #106 Periodic transmission */
- if ((uint16_t)0 != pst_msg_data->usFreq) {
- /* CANDataConfirmation of periodic transmission management table registration destination exists */
- if (TRUE == CANFreqTransEntryCheck(pst_msg_data->stCandata.can_id, &uc_index)) {/* Periodic transmission timer start */
- l_ret = CANFreqTransTimerStart(uc_index, pst_msg_data->usFreq, CAN_PROTOCOL_TYPE_CAN);
- } else { /* No registration destination */
- l_ret = RET_CAN_ERROR_BUFFULL; /* Registered FULL */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN FreqTrans BufferFull"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- }
- } else {/* One-time transmission */
- if ((uint8_t)CAN_RID_NOTUSE_CODE == pst_msg_data->ucRid) {/* When transmission results are unnecessary */
- uc_index = (uint8_t)CAN_RID_NOTUSE_CODE; /* Transmission result non-notification code */
- } else { /* When transmission result is required */
- if (FALSE == CAN1TimeTransEntryCheck(&uc_index)) {
- l_ret = RET_CAN_ERROR_BUFFULL; /* One-time transmission results notification lists are FULL. */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN 1TimeTransRslt BufferFull"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- }
- }
- }
- *puc_index = uc_index;
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### END #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return (l_ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTxStop
- * ABSTRACT : CANDataPeriodic transmission stop message processing
- * FUNCTION : CANDataStop periodic transmission when a periodic transmission stop message is received
- * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Parameter Normal
- * RET_CAN_ERROR_UNDEF : Undefined ID
- * RET_CAN_ERROR_PID : Thread ID mismatch
- * RET_CAN_ERROR_TIMER : Failed to stop timer
- * RET_CAN_ERROR_CREATE_EVENT : Event generation failure
- ******************************************************************************/
-EFrameworkunifiedStatus CANFreqTxStop(HANDLE h_app) {
- RET_CAN l_ret = RET_CAN_ERROR_UNDEF; /* Return value of this function */
- int32_t i; /* Generic counters */
- uint8_t uc_index = 0xFF; /* Indexed */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_FREQ_TRANS_STOP_MSG_DAT rcv_msg;
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- 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;
- }
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- /****** Data checking ******/
- for (i = 0; i < (int32_t)CAN_FREQ_TRSNSMISSION_LIST_NUM; i++) {
- /* CANDataPeriodic transmission control table registration status checking process (CAN ID retrieval) */
- if (TRUE != CANFreqTransCanidEntryCheck((uint8_t)i, rcv_msg.ulCanid)) {
- continue;
- }
-
- if (TRUE == CANFreqTransIdEntryCheck((uint8_t)i, rcv_msg.notifyName)) {
- l_ret = RET_CAN_NORMAL; /* Normal completion */
- uc_index = (uint8_t)i; /* Index acquisition */
- break;
- } else {
- l_ret = RET_CAN_ERROR_SNDID; /* Distribution destination ID mismatch */
- }
- }
-
- if (l_ret == RET_CAN_ERROR_UNDEF) { /* CAN ID undefined */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN FreqTxStop CanID Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- goto exit;
- }
- if (l_ret == RET_CAN_ERROR_SNDID) { /* Distribution destination ID mismatch */
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN FreqTxStop SNDID Error"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- goto exit;
- }
-
- /****** Message processing ******/
- l_ret = CANFreqTransTimerStop(uc_index, CAN_PROTOCOL_TYPE_CAN); /* Periodic transmission timer stop */
- if (RET_CAN_NORMAL != l_ret) { // LCOV_EXCL_BR_LINE 200:the function is always returned to RET_CAN_NORMAL
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- goto exit; // LCOV_EXCL_LINE 200:the function is always returned to RET_CAN_NORMAL
- }
-
- CANFreqTransStop(uc_index); /* CANDataPeriodic transmission stop */
-
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "END(l_ret=%x)", l_ret); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- if (l_ret == RET_CAN_NORMAL)
- return eFrameworkunifiedStatusOK;
- else
- return eFrameworkunifiedStatusFail;
-}
-/*******************************************************************************
- * MODULE : CANFreqTxTimeupMsg
- * ABSTRACT : CANDataPeriodic transmission time-up message processing
- * FUNCTION : Start transmission when the periodic timer for periodic transmission expires
- * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_CANCEL : Data destruction
- ******************************************************************************/
-RET_CAN CANFreqTxTimeupMsg(HANDLE h_app, uint16_t timer_seq) {
- RET_CAN l_ret = RET_CAN_NORMAL; /* Return value of this function */
- uint8_t uc_index; /* Indexed */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- /* Check Timer Sequence Range(0x8000 ~ 0x80FF) */
- if (FREQ_TRANS_SEQNO_CODE == (timer_seq & ~TIMER_SEQNO_MASK_CODE)) {
- uc_index = (uint8_t)(timer_seq & TIMER_SEQNO_MASK_CODE);
- if (FALSE == CANFreqTransIndexEntryCheck(uc_index)) { // LCOV_EXCL_BR_LINE 6:Double check code. in CANFreqTransEntryCheck //NOLINT (readability/naming)
- l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
- } else {
- /* CANDataPeriodic transmission start message transmission */
- if (FALSE == CANFreqTransStartTxMsg(h_app, uc_index)) {
- l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
- }
- }
- } else {
- l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### END #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return (l_ret);
-}
-
-/*******************************************************************************
- * MODULE : CANTxRsltReceiveMsg
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data transmission result reply processing
- *
- * It notifies the corresponding thread when the informative message
- * of the CAN data transmission result is received.
- *
- * CANDataWhen a transmission result notification message is received, a notification is sent to the relevant thread...
- *
- * @~english
- * @note
- * -# Transmission result status check
- * -# Transmission result notification registration check
- * -# Transmission result table check
- * -# Transmission result status acquisition
- * -# Message sending
- * -# Transmission result table deletion
- *
- * @~english
- * @return Reception result
- * @retval <RET_CAN_NORMAL> Normality
- * @retval <RET_CAN_ERROR_CANCEL> Data annulment
- *
- * @~english
- * @param[in] <pst_rcv_msg> Reception message reference pointer
- */
-RET_CAN CANTxRsltReceiveMsg(HANDLE h_app, CAN_MSG_DATA *pst_rcv_msg) { // LCOV_EXCL_START 8:this IF is called in CANIcrSndStsProcess, which will not be called // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- RET_CAN l_ret = RET_CAN_NORMAL; /* Return value of this function */
- RET_CAN l_ret_func; /* Lower-order function return value */
- BOOL b_ret_func; /* Lower-order function return value */
-// T_ICR_CMDSNDCNF_STS *pst_msg_data; /* Receive data structure pointer */
- uint8_t us_sts; /* Status */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-// pst_msg_data = reinterpret_cast<T_ICR_CMDSNDCNF_STS *>(reinterpret_cast<void *>(&pst_rcv_msg->ucData[0]));
-
- /****** Transmission result status check ******/
- l_ret_func = CANTxRsltReceiveMsgCheck(pst_rcv_msg); /* Receive command (transmission result) check processing */
-
- /****** Send result notification registration check ******/
- if (RET_CAN_NORMAL == l_ret_func) {
-// b_ret_func = CANTxRsltEntryCheck(pst_rcv_msg->stHead.hdr.rid);
- }
-
- /****** Message processing ******/
- if ((RET_CAN_NORMAL == l_ret_func) && (TRUE == b_ret_func)) {
-// b_ret_func = CANTxRsltSndCheck(pst_rcv_msg->stHead.hdr.rid, (uint32_t)pst_msg_data->cnf_sts);
- /* Determine whether to perform transmission result notification */
- if (TRUE == b_ret_func) {
-// switch (pst_msg_data->cnf_sts) {
-// case ICR_SND_SUCCESS:
-// us_sts = CAN_SUCCESS;
-// break;
-// case ICR_SND_ERR_RETRYOUT:
-// us_sts = CAN_RETRYOUT;
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// case ICR_SND_ERR_BUFFERFULL:
-// us_sts = CAN_BUFFERFUL;
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// default:
-// l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
-// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN Transmission SYSCOM Error");
-// CANDebugLogOut(CAN_TRANCE_SYSCOM_ERR, reinterpret_cast<void *>(pst_rcv_msg));
-// break;
-// }
- if (RET_CAN_NORMAL == l_ret) {
-// b_ret_func = CANTxRsltSndMsg(h_app, pst_rcv_msg->stHead.hdr.rid, us_sts);
- /* CANDataSend result notification message */
- /* Transmission result judgment */
- if (FALSE == b_ret_func) {
- /* Transmission result notification transmission failure */
- l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
- }
- }
- } else {
- /* No need to send result notification */
- }
-
- /****** Delete various transmission results management tables ******/
- if (RET_CAN_NORMAL == l_ret) {
-// CANTxRsltFin(pst_rcv_msg->stHead.hdr.rid); /* CANDataTransmission result notification completed */
- }
- } else {
- /* Transmission result status error */
- l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
- }
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### END #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return (l_ret);
-}
-// LCOV_EXCL_STOP 8
-
-/*******************************************************************************
- * MODULE : CANTxRsltReceiveMsgCheck
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief CAN data transmission result reception message check processing
- *
- * CAN data transmission result reception message check processing
- *
- * CANDataCheck the data contents when a transmission result notification message is received.
- *
- * @~english
- * @note
- * -# Transmission result status check
- * -# RID abnormality check
- *
- * @~english
- * @return Check result
- * @retval <RET_CAN_NORMAL> Normality
- * @retval <RET_CAN_ERROR_CANCEL> Data annulment
- *
- * @~english
- * @param[in] <pst_rcv_msg> Reception message reference pointer
- */
-/*------------------------------------------------------------------------------
- * RETURN : RET_CAN_NORMAL : Parameter Normal
- * RET_CAN_ERROR_CANCEL : Data destruction
- *----------------------------------------------------------------------------*/
-RET_CAN CANTxRsltReceiveMsgCheck(CAN_MSG_DATA *pst_rcv_msg) { // LCOV_EXCL_START 8:this IF is called in CANIcrSndStsProcess, which will not be called // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- RET_CAN l_ret = RET_CAN_NORMAL; /* Return value of this function */
-// T_ICR_CMDSNDCNF_STS *pst_msg_data; /* Receive data structure pointer */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-// pst_msg_data = reinterpret_cast<T_ICR_CMDSNDCNF_STS *>(reinterpret_cast<void *>(&pst_rcv_msg->ucData[0]));
- /* Type conversion */
-
- /****** Transmission result status check ******/
-// if ((ICR_SND_SUCCESS != pst_msg_data->cnf_sts) &&
-// (ICR_SND_ERR_RETRYOUT != pst_msg_data->cnf_sts) &&
-// (ICR_SND_ERR_BUFFERFULL != pst_msg_data->cnf_sts)) {
-// l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
-// }
- /****** RID anomaly check ******/
- /* NG if the ID is out of the table to be searched */
- /* The table range is from 0 (periodic-transmission-management-table + number-of-transmission-results-once-management-tables). */
-// if (((uint8_t)CAN_TXRSLT_CANRID_END < pst_rcv_msg->stHead.hdr.rid)) {
-// l_ret = RET_CAN_ERROR_CANCEL; /* Data destruction */
-// }
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### END #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return (l_ret);
-}
-// LCOV_EXCL_STOP 8
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TxMsg
- * ABSTRACT : CANData(_CWORD29_) outgoing message processing
- * FUNCTION : CANData(_CWORD29_) Start sending a message when it is received
- * ARGUMENT : *pst_rcv_msg : Received Message Reference Pointer
- * NOTE :
- * RETURN : RET_CAN_NORMAL : Normal completion
- * RET_CAN_ERROR_BUFFULL : Registered FULL
- ******************************************************************************/
-EFrameworkunifiedStatus CAN_CWORD29_TxMsg(HANDLE h_app) {
- CAN__CWORD29__TRANS_MSG pst_msg_data; /* Pointer to send start data structure */
- uint8_t uc_can_rid; /* Send Resource ID */
- uint8_t uc_index; /* Indexed */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN_CWORD29_TxMsg START #####"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &pst_msg_data, sizeof(pst_msg_data), eSMRRelease);
- if (e_status != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedGetMsgDataOfSize Error");
- if (e_status == eFrameworkunifiedStatusInvldBufSize) {
- FrameworkunifiedClearMsgData(h_app);
- }
- return eFrameworkunifiedStatusFail;
- }
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### Opc=%04x Name=%s Rid=%02x #####", pst_msg_data.opc, pst_msg_data.notifyName, pst_msg_data.ucRid); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- /* Register transmission result notification? */
- if ((uint8_t)CAN_RID_NOTUSE_CODE == pst_msg_data.ucRid) {/* When transmission results are unnecessary */
- uc_index = (uint8_t)CAN_RID_NOTUSE_CODE; /* Transmission result non-notification code */
- } else { /* When transmission result is required */
- if (FALSE == CAN_CWORD29_TransEntryCheck(&uc_index)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# CAN _CWORD29_TransRslt BufferFull"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- return eFrameworkunifiedStatusFail;
- }
- e_status = CAN_CWORD29_TransEntry(uc_index, &pst_msg_data); /* Save CAN_CWORD29_ Transmission Result */
- if (eFrameworkunifiedStatusOK != e_status) { // LCOV_EXCL_BR_LINE 6:Excluded due to value never returned at present
- // LCOV_EXCL_START 6:Excluded due to value never returned at present
- AGL_ASSERT_NOT_TESTED();
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "ERROR !!! CAN_CWORD29_TransEntry failed : e_status=%d, uc_index=%d", e_status, uc_index);
- return eFrameworkunifiedStatusFail;
- // LCOV_EXCL_STOP 6:Excluded due to value never returned at present
- }
- }
-
- if ((uint8_t)CAN_RID_NOTUSE_CODE == uc_index) {
- uc_can_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
- } else {
- uc_can_rid = (uint8_t)((uint32_t)uc_index + CAN_TXRSLT_CANRID__CWORD29__START);
- }
-
- /****** Message transmission processing ******/
-// CanMessage_CWORD29_ st_can_data;
-//
-// st_can_data.opc = pst_msg_data.opc;
-// st_can_data.rid = uc_can_rid;
-// st_can_data.dlc = (uint8_t)pst_msg_data.ulDataSize;
-// memcpy(st_can_data.data, pst_msg_data.data, (st_can_data.dlc));
-
-// if (CanSend_CWORD29_(&st_can_data) != CANHAL_RET_NORMAL) {
-// return eFrameworkunifiedStatusFail;
-// }
-
- return eFrameworkunifiedStatusOK;
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Start transmission of CAN Command
- *
- * @~english
- * @return Return value
- * @retval <eFrameworkunifiedStatusOK> OK
- * @retval <eFrameworkunifiedStatusFail> Abnormal termination
- *
- * @~english
- * @param[in] <h_app> Application handle
- */
-EFrameworkunifiedStatus CANTxBitStart(HANDLE h_app) {
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CAN_TRANS_START_MSG_DAT rcv_msg;
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CANTxBitStart Start"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- 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__, "FrameworkunifiedGetMsgDataOfSize Error eFrameworkunifiedStatus=%d", e_status);
- if (e_status == eFrameworkunifiedStatusInvldBufSize) {
- FrameworkunifiedClearMsgData(h_app);
- }
- goto exit;
- }
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- /* Merge CAN Data and update Trnasmission management table */
- if (TRUE == CANTransDataEntry(&rcv_msg)) {
-
- /* Interval Data registered to Timer management table */
- if ((uint32_t)0 < rcv_msg.freq) {
- CANFreqTimerEntry(rcv_msg.id, rcv_msg.freq);
- }
-
- /* Transmission CAN Data */
- if (FALSE == CANTransStartTxMsg(h_app, rcv_msg.id)) {
- e_status = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CANTransStartTxMsg Error CAN ID=0x%04X", rcv_msg.id);
- goto exit;
- }
-
- /* Reset Timer */
- if ((uint32_t)0 == rcv_msg.freq) {
- CANFreqTimerResetMap(rcv_msg.id);
- }
- } else if (FALSE == CAN_SubIDTransStartTxMsg(h_app, &rcv_msg)) {
- e_status = eFrameworkunifiedStatusFail;
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Trans NG CAN ID=0x%04X DATA[0]=0x%02X", rcv_msg.id, (rcv_msg.dat.dat[0] & rcv_msg.mask.dat[0]));
- }
-
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "END(eFrameworkunifiedStatus=%x)", e_status); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- return e_status;
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Stop transmission CAN Command
- *
- * @~english
- * @return Return value
- * @retval <eFrameworkunifiedStatusOK> OK
- * @retval <eFrameworkunifiedStatusFail> Abnormal termination
- *
- * @~english
- * @param[in] <h_app> Application handle
- */
-EFrameworkunifiedStatus CANTxBitStop(HANDLE h_app) {
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- CANID rcv_msg;
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "##### CAN_FreqTxBitStop Start"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- 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__, "FrameworkunifiedGetMsgDataOfSize Error eFrameworkunifiedStatus=%d", e_status);
- if (e_status == eFrameworkunifiedStatusInvldBufSize) {
- FrameworkunifiedClearMsgData(h_app);
- }
- e_status = eFrameworkunifiedStatusFail;
- goto exit;
- }
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- /* Check correct CAN ID */
- if (FALSE == CANEntryTransCanidCheck(rcv_msg)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CANEntryTransCanidCheck Error CAN ID=0x%04X", rcv_msg); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
- e_status = eFrameworkunifiedStatusFail;
- goto exit;
- }
-
- /* Stop periodic transmission */
- if (RET_CAN_NORMAL != CANFreqTransTimerStopMap(rcv_msg)) { // LCOV_EXCL_BR_LINE 200:the function is always returned to RET_CAN_NORMAL //NOLINT (readability/naming)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- e_status = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 200:the function is always returned to RET_CAN_NORMAL
- }
-
-exit:
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "END(eFrameworkunifiedStatus=%x)", e_status); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" //NOLINT (readability/naming)
-
- return e_status;
-}
-// LCOV_EXCL_BR_LINE 10:THE_END_LINE_OF_THE_FILE
diff --git a/communication/server/src/CAN/Transmission/CAN_TransmissionData.cpp b/communication/server/src/CAN/Transmission/CAN_TransmissionData.cpp
deleted file mode 100644
index 2858c196..00000000
--- a/communication/server/src/CAN/Transmission/CAN_TransmissionData.cpp
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- * @copyright Copyright (c) 2016-2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
- * FILE :CAN_TransmissionData.cpp
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * PROGRAM :CAN Thread CAN Data Transmission Management Processing
- * Module configuration :CANTransmissionDataInit( ) CANDataTransmission management data initialization processing
- * CANFreqTransEntryCheck( ) CANDataPeriodic transmission management table registration destination confirmation processing
- * CANFreqTransEntry() CANDataRegular transmission management table registration processing
- * CANFreqTransDataGet( ) Periodic transmission data acquisition processing
- * CANFreqTransCanidEntryCheck( ) CANDataPeriodic transmission control table registration status checking process (CAN ID retrieval)
- * CANFreqTransIdEntryCheck( ) Periodic transmission management table send destination ID confirmation processing
- * CANFreqTransStop( ) CANDataPeriodic transmission stop processing
- * CANFreqTransIndexEntryCheck( ) CANDataPeriodic transmission control table registration status checking process (INDEX retrieval)
- * CAN1TimeTransEntryCheck( ) CANDataConfirmation processing of the registration destination of the transmission result management table
- * CAN1TimeTransEntry( ) CANDataOne-time transmission result management table registration processing
- * CANTxRsltEntryCheck( ) CANDataTransmission result management table registration status confirmation processing
- * CANTxRsltDataGet( ) Transmission result data acquisition processing
- * CANTxRsltFin( ) CANDataTransmission result notification completion processing
- ******************************************************************************/
-#include "CAN_TransmissionData.h"
-#include <string.h> // NOLINT(build/include)
-#include <other_service/strlcpy.h>
-#include <map>
-#include "CAN_Thread.h"
-#include "CAN_TxMsg.h"
-#include "communication_communicationlog.h"
-
-using std::map;
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-static CAN_FREQ_TRANSMISSION_DAT g_gst_freq_trans_dat[CAN_FREQ_TRSNSMISSION_LIST_NUM]; /* Periodic transmission management table */
- /* One-time transmission result management table */
-static CAN_1TIME_TXRSLT_DAT g_gst1_time_trans_rslt_dat[CAN_1TIME_TRSNSMISSION_RSLT_NUM]; //NOLINT (readability/naming)
- /* _CWORD29_ send result control table */
-static CAN__CWORD29__TXRSLT_DAT g_gst__CWORD29__trans_rslt_dat[CAN__CWORD29__TRSNSMISSION_RSLT_NUM]; //NOLINT (readability/naming)
-map<CANID, CAN_TRANS_START_TABLE_VAL *> g_map_trans_data; /* CAN Data management table */
-std::multimap<CANID, CAN_TRANS_START_TABLE_VAL *> mapSubIDTransData; /* CAN SubID Data management table */
-static CAN_INIT_TABLE Can_TransInitData_19PF[] = {
- /*
- * Note.
- * This feature needs to be defined by the vendor.
- */
- { (CANID)0x0000, (uint8_t)1, { 0x00 } }
-};
-
-/*******************************************************************************
- * MODULE : :CANTransmissionDataInit
- * ABSTRACT : CANDataTransmission management data initialization processing
- * FUNCTION : CANDataInitializing Transmission Management Data
- * ARGUMENT : void
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANTransmissionDataInit(void) {
- int32_t i; /* Generic counters */
- int32_t cntMaxData;
-
- (void)memset(reinterpret_cast<void *>(&g_gst_freq_trans_dat), (int32_t)0, (size_t)sizeof(g_gst_freq_trans_dat));
- /* Periodic transmission management table */
- (void)memset(reinterpret_cast<void *>(&g_gst1_time_trans_rslt_dat),
- (int32_t)0, (size_t)sizeof(g_gst1_time_trans_rslt_dat));
- /* One-time transmission result management table */
- /* Fill the resource ID of the transmission result management table with an unused code */
- for (i = 0; i < (int32_t)CAN_1TIME_TRSNSMISSION_RSLT_NUM; i++) {
- g_gst1_time_trans_rslt_dat[i].uc_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
- }
-
- (void)memset(reinterpret_cast<void *>(&g_gst__CWORD29__trans_rslt_dat),
- (int32_t)0, (size_t)sizeof(g_gst__CWORD29__trans_rslt_dat));
- /* _CWORD29_ send result control table */
- /* Fill the resource ID of the Phase send result management table with an unused resource ID */
- for (i = 0; i < (int32_t)CAN__CWORD29__TRSNSMISSION_RSLT_NUM; i++) {
- g_gst__CWORD29__trans_rslt_dat[i].uc_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
- }
-
- /* Initialize Transmission data management table */
- cntMaxData = (int32_t)(sizeof(Can_TransInitData_19PF) / sizeof(Can_TransInitData_19PF[0]));
- for (i = 0; i < cntMaxData; i++) {
- g_map_trans_data[ Can_TransInitData_19PF[i].canid ] = &Can_TransInitData_19PF[i].val;
- }
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransEntryCheck
- * ABSTRACT : CANDataPeriodic transmission management table registration destination confirmation processing
- * FUNCTION : CANDataReturns whether or not the periodic transmission management table can be registered and the index.
- * ARGUMENT : can_id : CAN ID
- * *puc_index : Index (pointer output)
- * NOTE : Can be overwritten with the same CAN ID
- * RETURN : TRUE : Can be registered
- * FALSE : Cannot be stored
- ******************************************************************************/
-BOOL CANFreqTransEntryCheck(CANID can_id, uint8_t *puc_index) {
- BOOL ret = FALSE; /* Return value of this function */
- int32_t i; /* Generic counters */
-
- /* Can be overwritten by the same CAN ID detection */
- for (i = 0; i < (int32_t)CAN_FREQ_TRSNSMISSION_LIST_NUM; i++) {
- if (g_gst_freq_trans_dat[i].st_can_data.can_id == can_id) {
- ret = TRUE; /* Can be registered */
- *puc_index = (uint8_t)i; /* Index acquisition */
- break;
- }
- }
-
- if (FALSE == ret) {
- /* If the same CAN ID is not found, free space is checked. */
- for (i = 0; i < (int32_t)CAN_FREQ_TRSNSMISSION_LIST_NUM; i++) {
- if ((uint16_t)0 == g_gst_freq_trans_dat[i].us_freq) {
- ret = TRUE; /* Can be registered */
- *puc_index = (uint8_t)i; /* Index acquisition */
- break;
- }
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransEntry
- * ABSTRACT : CANDataRegular transmission management table registration processing
- * FUNCTION : CANDataRegister in the periodic transmission management table
- * ARGUMENT : uc_index : Indexed
- * *pst_msg_data : Receive message data section reference pointer
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANFreqTransEntry(uint8_t uc_index, const CAN_TRANSMISSION_START_MSG_DAT *pst_msg_data) {
- strlcpy(g_gst_freq_trans_dat[uc_index].notify_name, pst_msg_data->notifyName,
- sizeof(g_gst_freq_trans_dat[uc_index].notify_name));
- g_gst_freq_trans_dat[uc_index].us_freq = pst_msg_data->usFreq; /* Periodic transmission period (in 100ms) */
- g_gst_freq_trans_dat[uc_index].uc_rid = pst_msg_data->ucRid; /* Resources ID */
- if ((uint8_t)CAN_RID_NOTUSE_CODE == pst_msg_data->ucRid) {
- g_gst_freq_trans_dat[uc_index].uc_resp_num = 0; /* Notification of transmission results is not required. */
- } else {
- g_gst_freq_trans_dat[uc_index].uc_resp_num = (uint8_t)CAN_FREQ_TXRSLT_NUM; /* Number of transmission result notifications (number of remaining notifications) */
- }
- g_gst_freq_trans_dat[uc_index].st_can_data = pst_msg_data->stCandata; /* Transmitted data */
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransDataGet
- * ABSTRACT : Periodic transmission data acquisition processing
- * FUNCTION : CANDataRetrieves data for the specified index from the periodic transmission management table
- * ARGUMENT : uc_index : Indexed
- * *pst_data : Periodic transmission data
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANFreqTransDataGet(uint8_t uc_index, CAN_FREQ_TRANSMISSION_DAT *pst_data) {
- *pst_data = g_gst_freq_trans_dat[uc_index]; /* Copy to Output Pointer */
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransCanidEntryCheck
- * ABSTRACT : CANDataPeriodic transmission control table registration status checking process (CAN ID retrieval)
- * FUNCTION : CANDataCheck the registration status of the periodic transmission management table
- * ARGUMENT : uc_index : Indexed
- * : can_id : CAN ID
- * NOTE :
- * RETURN : TRUE : Registered
- * FALSE : No registration
- ******************************************************************************/
-BOOL CANFreqTransCanidEntryCheck(uint8_t uc_index, CANID can_id) {
- BOOL ret = FALSE; /* Return value of this function */
-
- if ((uint16_t)0 != g_gst_freq_trans_dat[uc_index].us_freq) {
- if (can_id == g_gst_freq_trans_dat[uc_index].st_can_data.can_id) {
- ret = TRUE; /* Registered */
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransIdEntryCheck
- * ABSTRACT : Periodic transmission management table send destination ID confirmation processing
- * FUNCTION : CANDataCheck the destination ID in the periodic transmission management table
- * ARGUMENT : uc_index : Indexed
- * : notifyId : Transfer to: ID
- * NOTE :
- * RETURN : TRUE : Match
- * FALSE : Mismatched
- ******************************************************************************/
-BOOL CANFreqTransIdEntryCheck(uint8_t uc_index, PCSTR notify_name) {
- BOOL ret = FALSE; /* Return value of this function */
-
- if (strcmp(notify_name, g_gst_freq_trans_dat[uc_index].notify_name) == 0) {
- ret = TRUE; /* Match */
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransStop
- * ABSTRACT : CANDataPeriodic transmission stop processing
- * FUNCTION : CANDataClears the data of the specified index in the periodic transmission management table.
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANFreqTransStop(uint8_t uc_index) {
- CAN_FREQ_TRANSMISSION_DAT *pst; /* Structure pointer */
-
- pst = &g_gst_freq_trans_dat[uc_index];
- memset(reinterpret_cast<void *>(pst), 0x00, (size_t)sizeof(CAN_FREQ_TRANSMISSION_DAT));
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANFreqTransIndexEntryCheck
- * ABSTRACT : CANDataPeriodic transmission control table registration status checking process (INDEX retrieval)
- * FUNCTION : CANDataCheck the registration status of the specified index in the periodic transmission management table
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : TRUE : Registered
- * FALSE : No registration
- ******************************************************************************/
-BOOL CANFreqTransIndexEntryCheck(uint8_t uc_index) {
- BOOL ret = FALSE; /* Return value of this function */
-
- if ((uint16_t)0 != g_gst_freq_trans_dat[uc_index].us_freq) { // LCOV_EXCL_BR_LINE 6:Double check code. in CANFreqTransEntryCheck //NOLINT (readability/naming)
- ret = TRUE; /* Registered */
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CAN1TimeTransEntryCheck
- * ABSTRACT : CANDataConfirmation processing of the registration destination of the transmission result management table
- * FUNCTION : CANDataWhether or not registration of the transmission results management table can be performed once, and the index is returned.
- * ARGUMENT : *puc_index : Index (pointer output)
- * NOTE :
- * RETURN : TRUE : Can be registered
- * FALSE : Cannot be stored
- ******************************************************************************/
-BOOL CAN1TimeTransEntryCheck(uint8_t *puc_index) {
- BOOL ret = FALSE; /* Return value of this function */
- int32_t i; /* Generic counters */
-
- for (i = 0; i < (int32_t)CAN_1TIME_TRSNSMISSION_RSLT_NUM; i++) {
- if ((uint8_t)CAN_RID_NOTUSE_CODE == g_gst1_time_trans_rslt_dat[i].uc_rid) {
- /* If the resource ID is an unused code, it is not registered. */
- ret = TRUE; /* Can be registered */
- *puc_index = (uint8_t)i;
- break;
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TransEntryCheck
- * ABSTRACT : CAN_CWORD29_ transmission-result-management-table-registration-destination-confirmation-processing
- * FUNCTION : Returns whether or not the CAN_CWORD29_ send results control table can be registered and indexes.
- * ARGUMENT : *puc_index : Index (pointer output)
- * NOTE :
- * RETURN : TRUE : Can be registered
- * FALSE : Cannot be stored
- ******************************************************************************/
-BOOL CAN_CWORD29_TransEntryCheck(uint8_t *puc_index) {
- BOOL ret = FALSE; /* Return value of this function */
- int32_t i; /* Generic counters */
-
- for (i = 0; i < (int32_t)CAN__CWORD29__TRSNSMISSION_RSLT_NUM; i++) {
- if ((uint8_t)CAN_RID_NOTUSE_CODE == g_gst__CWORD29__trans_rslt_dat[i].uc_rid) {
- /* If the resource ID is an unused code, it is not registered. */
- ret = TRUE; /* Can be registered */
- *puc_index = (uint8_t)i;
- break;
- }
- }
-
- return (ret);
-}
-
-/*******************************************************************************
- * MODULE : CAN1TimeTransEntry
- * ABSTRACT : CANDataOne-time transmission result management table registration processing
- * FUNCTION : CANDataRegister in the transmission results management table once
- * ARGUMENT : uc_index : Index to register
- * *pst_msg_data : Receive message data section reference pointer
- * NOTE :
- * RETURN : EFrameworkunifiedStatus
- * eFrameworkunifiedStatusOK : Success
- * eFrameworkunifiedStatusInvldParam : uc_index is invalid
- ******************************************************************************/
-EFrameworkunifiedStatus CAN1TimeTransEntry(uint8_t uc_index, const CAN_TRANSMISSION_START_MSG_DAT *pst_msg_data) {
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- /* Register one transmission result management table */
- if (CAN_1TIME_TRSNSMISSION_RSLT_NUM > uc_index) { // LCOV_EXCL_BR_LINE 6:Double check code. in CAN1TimeTransEntryCheck //NOLINT (readability/naming)
- strlcpy(g_gst1_time_trans_rslt_dat[uc_index].notify_name, pst_msg_data->notifyName,
- sizeof(g_gst1_time_trans_rslt_dat[uc_index].notify_name));
- g_gst1_time_trans_rslt_dat[uc_index].ul_canid = pst_msg_data->stCandata.can_id;
- g_gst1_time_trans_rslt_dat[uc_index].uc_rid = pst_msg_data->ucRid;
- } else {
- e_status = eFrameworkunifiedStatusInvldParam;
- }
- return e_status;
-}
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TransEntry
- * ABSTRACT : CAN_CWORD29_ transmission-result-management-table-registration-process
- * FUNCTION : Register in the CAN_CWORD29_ transmission result management table
- * ARGUMENT : uc_index : Index to register
- * *pst_msg_data : Receive message data section reference pointer
- * NOTE :
- * RETURN : EFrameworkunifiedStatus
- * eFrameworkunifiedStatusOK : Success
- * eFrameworkunifiedStatusInvldParam : uc_index is invalid
- ******************************************************************************/
-EFrameworkunifiedStatus CAN_CWORD29_TransEntry(uint8_t uc_index, const CAN__CWORD29__TRANS_MSG *pst_msg_data) {
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- /* Register _CWORD29_ send result control table */
- if (CAN__CWORD29__TRSNSMISSION_RSLT_NUM > uc_index) {
- strlcpy(g_gst__CWORD29__trans_rslt_dat[uc_index].notify_name, pst_msg_data->notifyName,
- sizeof(g_gst__CWORD29__trans_rslt_dat[uc_index].notify_name));
- g_gst__CWORD29__trans_rslt_dat[uc_index].opc = pst_msg_data->opc;
- g_gst__CWORD29__trans_rslt_dat[uc_index].uc_rid = pst_msg_data->ucRid;
- } else {
- e_status = eFrameworkunifiedStatusInvldParam;
- }
- return e_status;
-}
-
-/*******************************************************************************
- * MODULE : CANTxRsltEntryCheck
- * ABSTRACT : CANDataTransmission result management table registration status confirmation processing
- * FUNCTION : Periodic transmission, one transmission, result control for specified indexes
- * Check the registration status of the table
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * NOTE :
- * RETURN : TRUE : Registered
- * FALSE : No registration
- ******************************************************************************/
-BOOL CANTxRsltEntryCheck(uint8_t uc_can_rid) { // LCOV_EXCL_START 8:this IF is called in CANIcrSndStsProcess, which will not be called // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = FALSE; /* Return value of this function */
- uint8_t uc_index; /* Indexed */
- /*** Periodic transmission ***/
- if ((uint8_t)CAN_TXRSLT_CANRID_1TIME_START > uc_can_rid) {
- uc_index = uc_can_rid;
- /* Checking for User unset code */
- if ((uint8_t)CAN_RID_NOTUSE_CODE != g_gst_freq_trans_dat[uc_index].uc_rid) {
- if ((uint8_t)0 != g_gst_freq_trans_dat[uc_index].uc_resp_num) {
- ret = TRUE; /* Registered */
- }
- }
- } else if ((uint8_t)CAN_TXRSLT_CANRID__CWORD29__START > uc_can_rid) { /*** One-time transmission ***/
- uc_index = (uint8_t)((uint32_t)uc_can_rid - CAN_TXRSLT_CANRID_1TIME_START);
- if ((uint8_t)CAN_RID_NOTUSE_CODE != g_gst1_time_trans_rslt_dat[uc_index].uc_rid) {
- /* Checking for User unset code */
- ret = TRUE; /* Registered */
- }
- }
-
- return (ret);
-}
-// LCOV_EXCL_STOP 8
-
-/*******************************************************************************
- * MODULE : CANTxRsltDataGet
- * ABSTRACT : Transmission result data acquisition processing
- * FUNCTION : Retrieves the send result data for the specified index
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * *pst_data : Transmission result data (pointer output)
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANTxRsltDataGet(uint8_t uc_can_rid, CAN_1TIME_TXRSLT_DAT *pst_data) {
- uint8_t uc_index; /* Indexed */
-
- if ((uint8_t)CAN_TXRSLT_CANRID_1TIME_START > uc_can_rid) { /*** Periodic transmission ***/
- uc_index = uc_can_rid;
- strlcpy(pst_data->notify_name, g_gst_freq_trans_dat[uc_index].notify_name, sizeof(pst_data->notify_name));
- pst_data->ul_canid = g_gst_freq_trans_dat[uc_index].st_can_data.can_id;
- pst_data->uc_rid = g_gst_freq_trans_dat[uc_index].uc_rid;
-
- } else if ((uint8_t)CAN_TXRSLT_CANRID__CWORD29__START > uc_can_rid) { /*** One-time transmission ***/
- uc_index = (uint8_t)((uint32_t)uc_can_rid - CAN_TXRSLT_CANRID_1TIME_START);
- strlcpy(pst_data->notify_name, g_gst1_time_trans_rslt_dat[uc_index].notify_name, sizeof(pst_data->notify_name));
- pst_data->ul_canid = g_gst1_time_trans_rslt_dat[uc_index].ul_canid;
- pst_data->uc_rid = g_gst1_time_trans_rslt_dat[uc_index].uc_rid;
-
- }
- return;
-}
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TxRsltDataGet
- * ABSTRACT : Acquisition of _CWORD29_ Transmission Result Data
- * FUNCTION : Retrieves the _CWORD29_ send results for the specified indexes
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * *pst_data : Transmission result data (pointer output)
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CAN_CWORD29_TxRsltDataGet(const uint8_t uc_can_rid, CAN__CWORD29__TXRSLT_DAT* const pst_data) {
- uint32_t ul_index; /* Indexed */
-
- if (reinterpret_cast<CAN__CWORD29__TXRSLT_DAT *>(NULL) == pst_data) {
- return;
- }
-
- if (static_cast<uint32_t>(CAN_TXRSLT_CANRID__CWORD29__START) > uc_can_rid) {
- return;
- }
-
- ul_index = uc_can_rid - static_cast<uint32_t>(CAN_TXRSLT_CANRID__CWORD29__START);
- if (static_cast<uint32_t>(CAN__CWORD29__TRSNSMISSION_RSLT_NUM) <= ul_index) {
- return;
- }
-
- strlcpy(reinterpret_cast<char *>(pst_data->notify_name),
- reinterpret_cast<const char *>(g_gst__CWORD29__trans_rslt_dat[ul_index].notify_name), MAX_NAME_SIZE_APP);
- pst_data->opc = g_gst__CWORD29__trans_rslt_dat[ul_index].opc;
- pst_data->uc_rid = g_gst__CWORD29__trans_rslt_dat[ul_index].uc_rid;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANTxRsltFin
- * ABSTRACT : CANDataTransmission result notification completion processing
- * FUNCTION : Determine and clear the registration of the specified index.
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CANTxRsltFin(uint8_t uc_can_rid) {
- uint8_t uc_index; /* Indexed */
-
- if ((uint8_t)CAN_TXRSLT_CANRID_1TIME_START > uc_can_rid) { /*** Periodic transmission ***/
- uc_index = uc_can_rid;
- if (g_gst_freq_trans_dat[uc_index].uc_resp_num > (uint8_t)0) {
- g_gst_freq_trans_dat[uc_index].uc_resp_num--; /* Decrement the number of transmission result notifications */
- if ((uint8_t)0 == g_gst_freq_trans_dat[uc_index].uc_resp_num) {
- g_gst_freq_trans_dat[uc_index].uc_rid = 0;
- }
- }
- } else if ((uint8_t)CAN_TXRSLT_CANRID__CWORD29__START > uc_can_rid) { /*** One-time transmission ***/
- uc_index = (uint8_t)((uint32_t)uc_can_rid - CAN_TXRSLT_CANRID_1TIME_START);
- memset(g_gst1_time_trans_rslt_dat[uc_index].notify_name, 0x00,
- sizeof(g_gst1_time_trans_rslt_dat[uc_index].notify_name));
- g_gst1_time_trans_rslt_dat[uc_index].ul_canid = 0;
- g_gst1_time_trans_rslt_dat[uc_index].uc_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
- /* Enter the User unset code */
- }
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TxRsltFin
- * ABSTRACT : _CWORD29_ transmission result notification completion process
- * FUNCTION : Clearing and clearing _CWORD29_ registrations of specified indexes
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * NOTE :
- * RETURN : void
- ******************************************************************************/
-void CAN_CWORD29_TxRsltFin(const uint8_t uc_can_rid) {
- uint32_t ul_index; /* Indexed */
-
- if (static_cast<uint32_t>(CAN_TXRSLT_CANRID__CWORD29__START) > uc_can_rid) {
- return;
- }
-
- ul_index = uc_can_rid - static_cast<uint32_t>(CAN_TXRSLT_CANRID__CWORD29__START);
- if (static_cast<uint32_t>(CAN__CWORD29__TRSNSMISSION_RSLT_NUM) <= ul_index) {
- return;
- }
-
- memset(reinterpret_cast<void *>(g_gst__CWORD29__trans_rslt_dat[ul_index].notify_name), 0x00,
- MAX_NAME_SIZE_APP);
- g_gst__CWORD29__trans_rslt_dat[ul_index].opc = 0;
-
- /* Enter the User unset code */
- g_gst__CWORD29__trans_rslt_dat[ul_index].uc_rid = (uint8_t)CAN_RID_NOTUSE_CODE;
-
- return;
-}
-
-/*******************************************************************************
- * MODULE : CANTxRsltSndCheck
- * ABSTRACT : CANDataTransmission result notification determination processing
- * FUNCTION : CANDataDetermine whether to perform transmission result notification
- * ARGUMENT : uc_can_rid : CAN RID (Resource-ID managed by the CAN thread)
- * ul_sts : Received transmission result status
- * NOTE :
- * RETURN : TRUE : Transmission result notification required
- * FALSE : No need to send result notification
- ******************************************************************************/
-BOOL CANTxRsltSndCheck(uint8_t uc_can_rid, uint32_t ul_sts) { // LCOV_EXCL_START 8:this IF is called in CANIcrSndStsProcess, which will not be called // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = FALSE; /* Return value of this function */
- /*** Periodic transmission ***/
- if ((uint8_t)CAN_TXRSLT_CANRID_1TIME_START > uc_can_rid) {
- /* Always send result notification */
- ret = TRUE;
- } else if ((uint8_t)CAN_TXRSLT_CANRID__CWORD29__START > uc_can_rid) {/*** One-time transmission ***/
- /* Always send result notification */
- ret = TRUE;
- }
-
- return (ret);
-}
-// LCOV_EXCL_STOP 8
-
-/*******************************************************************************
- * MODULE : CANCycleTransBufferOut
- * ABSTRACT : CAN periodic transmission table log output processing
- * FUNCTION : Output the CAN periodic transmission table log
- * ARGUMENT : FILE *fp_log : File pointer of the log output file
- * NOTE :
- * RETURN :
- ******************************************************************************/
-void CANCycleTransBufferOut(FILE *fp_log) { // LCOV_EXCL_START 8: for dead code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- int32_t usage_rate;
- uint16_t i;
- uint16_t data_cnt = 0;
-
- if (NULL != fp_log) {
- /* CAN periodic transmission table output */
- (void)fprintf(fp_log, "CAN CycleTrans Buffer \n");
- (void)fprintf(fp_log, "CanID: Freq: SndId: Rid: DLC:\n");
- for (i = 0; i < (uint16_t)CAN_FREQ_TRSNSMISSION_LIST_NUM; i++) {
- /* Data Registration Max */
- if ((uint16_t)0 != g_gst_freq_trans_dat[i].us_freq) {
- (void)fprintf(fp_log, "%08x %04x %s %04x %04x\n",
- g_gst_freq_trans_dat[i].st_can_data.can_id,
- g_gst_freq_trans_dat[i].us_freq,
- g_gst_freq_trans_dat[i].notify_name,
- g_gst_freq_trans_dat[i].uc_rid,
- g_gst_freq_trans_dat[i].st_can_data.dlc);
- data_cnt++;
- }
- }
- usage_rate = (((int32_t)data_cnt * 100) / CAN_FREQ_TRSNSMISSION_LIST_NUM);
- (void)fprintf(fp_log, "BUFFER_Use: %04d BUFFER_Max: %04d Usage_Rate: %04d \n",
- data_cnt, CAN_FREQ_TRSNSMISSION_LIST_NUM, usage_rate);
- if (usage_rate >= CAN_USAGE_RATE_THRESHOLD) {
- (void)fprintf(fp_log, "Warning: Buffer utilization exceeds a threshold.\n");
- }
- }
-}
-// LCOV_EXCL_STOP
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Merge and Update CAN Data
- *
- * @~english
- * @return Return value
- * @retval <TURE> OK
- * @retval <FALSE> Failure
- *
- * @~english
- * @param[in] <rcv_msg> Start transmission message structure
- */
-BOOL CANTransDataEntry(CAN_TRANS_START_MSG_DAT *rcv_msg) {
- CAN_TRANS_START_TABLE_VAL *tmp_trans_data;
- uint8_t mrg_data[CAN_TXDATA_SIZE] = {};
- CAN_DATA_BIT *mem_data;
- int i;
- BOOL ret = TRUE;
-
- ret = CANEntryTransCanidCheck(rcv_msg->id);
- if (FALSE == ret) {
- goto exit;
- }
-
- /* Get transmission data of corresponding CAN ID */
- tmp_trans_data = g_map_trans_data[rcv_msg->id];
- mem_data = &tmp_trans_data->dat;
-
- /* Merge transmission data */
- for (i = 0; i < tmp_trans_data->dlc; i++) {
- uint8_t mask = rcv_msg->mask.dat[i];
- uint8_t bit = rcv_msg->dat.dat[i];
-
- mrg_data[i] = mask & bit;
- mem_data->dat[i] = (uint8_t)((uint8_t)(mem_data->dat[i]) & (uint8_t)(~mask));
- mem_data->dat[i] |= mrg_data[i];
- }
-
- /* Update Transmission data management table */
- tmp_trans_data->dat = *mem_data;
-
-exit:
- return ret;
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
-* @brief Transmission CAN Data(SubID) with Marge and Update Data
- *
- * @~english
- * @return Return value
- * @retval <TURE> OK
- * @retval <FALSE> Failure
- *
- * @~english
- * @param[in] <rcvMsg> Start transmission message structure
- *----------------------------------------------------------------------------*/
-BOOL CAN_SubIDTransStartTxMsg(HANDLE h_app, CAN_TRANS_START_MSG_DAT *rcvMsg)
-{
- CAN_TRANS_START_TABLE_VAL *transData;
- CAN_DATA_BIT *memData;
-
- std::multimap<CANID, CAN_TRANS_START_TABLE_VAL *>::iterator it;
- // Find CANID Matching
- for (it = mapSubIDTransData.find(rcvMsg->id); it != mapSubIDTransData.end(); it++)
- {
- transData = it->second;
-
- // SubID matches
- if (transData->dat.dat[0] == (rcvMsg->dat.dat[0] & rcvMsg->mask.dat[0])) {
- // CANData(The 1byte eye is fixed to the SubID, so it should not be changed.)
- memData = &transData->dat;
- for (int i = 1; i < transData->dlc; i++) {
- memData->dat[i] &= ~rcvMsg->mask.dat[i];
- memData->dat[i] |= (rcvMsg->mask.dat[i] & rcvMsg->dat.dat[i]);
- }
- // CANDataSend
- return CANTransStartTxMsgCore(h_app, rcvMsg->id, transData->dlc, &transData->dat);
- }
- }
-
- // No matching CAN ID-SubID
- return FALSE;
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Get Transmission data
- *
- * @~english
- * @return Return value
- * @retval <TRUE> Transmission success
- * @retval <FALSE> Transmission failed
- *
- * @~english
- * @param[in] <id> CAN ID
- */
-BOOL CANTransStartTxMsg(HANDLE h_app, CANID id) {
- map<CANID, CAN_TRANS_START_TABLE_VAL *>::iterator it;
- CAN_TRANS_START_TABLE_VAL *trans_data;
-
- /* Get transmission data of corresponding CAN ID */
- it = g_map_trans_data.find(id);
- if (it == g_map_trans_data.end()) {
- return FALSE;
- }
- trans_data = it->second;
-
- /* Transmission CAN Data */
- return CANTransStartTxMsgCore(h_app, id, trans_data->dlc, &trans_data->dat);
-}
-
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Check invalid CAN ID
- *
- * @~english
- * @return Return value
- * @retval <TURE> OK
- * @retval <FALSE> Invalid CAN ID
- *
- * @~english
- * @param[in] <id> CAN ID
- */
-BOOL CANEntryTransCanidCheck(CANID id) {
- map<CANID, CAN_TRANS_START_TABLE_VAL *>::iterator it;
-
- /* Get transmission data of corresponding CAN ID */
- it = g_map_trans_data.find(id);
- if (it == g_map_trans_data.end()) {
- return FALSE;
- }
-
- return TRUE;
-} // LCOV_EXCL_BR_LINE 10:THE_END_LINE_OF_THE_FILE
diff --git a/communication/server/src/CAN/TxMsg/CAN_TxMsg.cpp b/communication/server/src/CAN/TxMsg/CAN_TxMsg.cpp
index 36ddc6d8..fa5d61d6 100644
--- a/communication/server/src/CAN/TxMsg/CAN_TxMsg.cpp
+++ b/communication/server/src/CAN/TxMsg/CAN_TxMsg.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.
@@ -13,949 +13,404 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*******************************************************************************
- * SYSTEM :_CWORD107_
- * SUBSYSTEM :EXL process
- * Module configuration :CANDeliverySndMsg( ) CANDataDelivery message transmission processing
- * CANFreqTransStartTxMsg( ) CANDataPeriodic transmission start message transmission processing
- * CAN1TimeTransStartTxMsg( ) CANDataSend one transmission start message processing
- * CANCommWatchSndMsg( ) CANDataTransmission of communication interruption detection/recovery message
- * CANTxRsltSndMsg( ) CANDataTransmission result notification message transmission processing
- * CANCanidUserToIfCvt( ) CAN ID Conversion Process 2
- * CANCommandDeliverySndMsg( ) CAN command delivery message transmission processing
- * CANCommandTxRsltSndMsg( ) CAN command transmission result notification message transmission processing
- * CANCommandTransmissionSndMsg( ) CAN command message transmission processing
- * CANCommandFuelCalcRstReqSndMsg( ) CAN section flame reset request reception message transmission processing
- * CANCommandidOpcToUserCvt( ) CAN Command ID Conversion Processing 1
- * CANCommandidUserToOpcCvt( ) CAN command ID conversion process 2
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @file CAN_TxMsg.cpp
- * @~english
- * @brief CAN Thread Message transmission process
- */
#include "CAN_TxMsg.h"
-
-#include <string.h> // NOLINT (build/include)
-#include <other_service/strlcpy.h>
+#include "CAN_Delivery.h"
+#include <string.h>
#include <native_service/frameworkunified_types.h>
-#include <agl_thread.h>
#include <native_service/frameworkunified_framework_if.h>
#include <peripheral_service/Canif_API.h>
-//#include <can_hal.h>
+#include <can_hal.h>
#include <map>
-#include <utility>
#include <string>
-#include "ICR_Common.h"
-
#include "CAN_Thread.h"
-#include "CAN_DeliveryData.h"
-#include "CAN_TransmissionData.h"
-#include "CAN_CommWatchData.h"
-#include "CAN_CommandData.h"
-
-/*************************************************/
-/* Prototype declaration */
-/*************************************************/
-
-/*************************************************/
-/* Global variable */
-/*************************************************/
-static std::map<std::string, HANDLE_DAT> g_map_handler;
-extern std::multimap<CANID, std::string> g_map_delivery_list;
-extern std::multimap<uint16_t, std::string> g_map__CWORD29__delivery_list;
-extern CAN_MSG_CANGWDATA g_cangw_msg_data; /* CANdata to be sent to the CANGW */
-extern BOOL g_isaccoff; // Declared in communication_application.cpp
-/*******************************************************************************
- * MODULE : CANDeliverySndMsg
- * ABSTRACT : CANDataDelivery message transmission processing
- * FUNCTION : CANDataSending a Delivery Message
- * ARGUMENT : can_id : CAN ID
- * uc_dlc : DLC
- * *puc_data : CANDataPart pointer
- * uc_opc : OPC
- * n_ta : N_TA
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANDeliverySndMsg(HANDLE h_app, CANID can_id, uint8_t uc_dlc,
- const uint8_t *puc_data, uint8_t uc_opc, uint8_t n_ta) {
- BOOL ret = TRUE;
- CAN_MSG_CANDATA st_delivery_msg;
- uint8_t uc_size;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
- BOOL q_full = FALSE;
- uint16_t can_id_shift = 0;
- std::multimap<CANID, std::string>::iterator it;
- std::pair<std::multimap<CANID, std::string>::iterator, std::multimap<CANID, std::string>::iterator> rang;
-
- /* Initialization of delivery-message-structure to user */
- (void)memset(reinterpret_cast<void *>(&st_delivery_msg), (int32_t)0, (size_t)sizeof(st_delivery_msg));
-
- /****** Header section creation (excluding response destination process No.) ******/
- switch (uc_opc) {
- default: /* CAN_OPC_RX */
-// st_delivery_msg.hdr.hdr.cid = (uint16_t)CID_CAN_DATA_DELIVERY; /* CANDataDelivery notice */
- break;
- }
- /* Message data size */
-// st_delivery_msg.hdr.hdr.msgbodysize = (uint16_t)(CAN_TRX_CANID_SIZE + CAN_TRX_DLC_SIZE +
-// CAN_TRX_DLC_RESERVE_SIZE + (uint32_t)uc_dlc);
-// st_delivery_msg.hdr.hdr.rid = 0; /* Resource ID (not used) */
-
- /****** Creation of data section ******/
- st_delivery_msg.data.can_id = can_id; /* CAN ID */
- st_delivery_msg.data.dlc = uc_dlc; /* DLC */
- if ((uint8_t)CAN_DATA_SIZE < uc_dlc) {
- AGL_ASSERT_NOT_TESTED();
- uc_size = (uint8_t)CAN_DATA_SIZE;
- } else {
- uc_size = uc_dlc;
- }
- memcpy(st_delivery_msg.data.data, puc_data, (size_t)uc_size);
+#include "Thread_Common.h"
+#include "Canif_API_Local.h"
+#include "CAN_TxMsg.h"
+#include "Canif_TransmissionData.h"
- it = g_map_delivery_list.find(can_id);
- if (it == g_map_delivery_list.end()) {
- /* Delivery destination unregistered log output */
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "#CAN_thread# CAN ID 0x%x not found in CAN Delivery entry table", can_id); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
- }
+static std::map<CANID, CAN_SEND_STATUS_DAT> g_m_send_sts;
+static bool can_cmd_rst_rcv = false;
+static std::map<CANID, CAN_TRANS_START_TABLE_VAL *> g_map_trans_data;
- /****** Messaging ******/
- rang = g_map_delivery_list.equal_range(can_id);
- for (it = rang.first; it != rang.second; ++it) {
- // If the delivery destination is other than CANGW, datum is sent.
- if (TN_CANGW_M_RCV != it->second) {
- if (g_map_handler.count(it->second) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, it->second.c_str());
- if (h_client == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- continue; // LCOV_EXCL_LINE 4: NSFW error case
- }
- g_map_handler[it->second].handle = h_client;
- g_map_handler[it->second].is_q_full = FALSE;
- } else {
- h_client = g_map_handler[it->second].handle;
- q_full = g_map_handler[it->second].is_q_full;
- }
+void CANTxMsgInit(void) {
+ g_m_send_sts.clear();
+ uint32_t i;
- if (g_isaccoff && q_full) {
- /* Once queue full has occured during ACC OFF, do nothing */
- } else {
-// e_status = FrameworkunifiedSendMsg(h_client, st_delivery_msg.hdr.hdr.cid, sizeof(st_delivery_msg), &st_delivery_msg);
- if (eFrameworkunifiedStatusMsgQFull == e_status) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- /* eFrameworkunifiedStatusMsgQFull */
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- g_map_handler[it->second].is_q_full = TRUE; // LCOV_EXCL_LINE 4: NSFW error case
- }
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedSendMsg Error(e_status:%d to:%s)", e_status, it->second.c_str()); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
- }
- }
- } else { // If the destination is CANGW, the data is stored in the buffers.
- can_id_shift = (uint16_t)(can_id << 4);
- g_cangw_msg_data.data[g_cangw_msg_data.num].can_id_high = (uint8_t)(can_id_shift >> 8);
- g_cangw_msg_data.data[g_cangw_msg_data.num].can_id_low = (uint8_t)(can_id_shift & 0xFF);
- if (CANGW_DLC_MAX_SIZE < uc_dlc) { // LCOV_EXCL_BR_LINE 6: already checked in CANHalRcvProcess
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- g_cangw_msg_data.data[g_cangw_msg_data.num].dlc = CANGW_DLC_MAX_SIZE; // LCOV_EXCL_LINE 6: same as above
- } else {
- g_cangw_msg_data.data[g_cangw_msg_data.num].dlc = uc_dlc;
- }
- memcpy(g_cangw_msg_data.data[g_cangw_msg_data.num].data, puc_data, (size_t)CANGW_DLC_MAX_SIZE);
- g_cangw_msg_data.num++;
- }
+ for (i = 0; i < _countof(Can_TransInitData_21PF); i++) {
+ CANID canid = Can_TransInitData_21PF[i].canid;
+ CAN_TRANS_START_TABLE_VAL *val = &(Can_TransInitData_21PF[i].val);
+ g_map_trans_data[canid] = val;
}
- return (ret);
+ return;
}
-/*******************************************************************************
- * MODULE : CANDelivery_CWORD29_SndMsg
- * ABSTRACT : CAN_CWORD29_ delivery messaging process
- * FUNCTION : Send CAN_CWORD29_ delivery messages
- * ARGUMENT : h_app : HANDLE
- * us_opc : OPC
- * uc_dlc : DLC
- * *puc_data : CANDataPart pointer
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANDelivery_CWORD29_SndMsg(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, const uint8_t *puc_data) {
- BOOL ret = TRUE;
- CAN_MSG_CAN__CWORD29_DATA st_delivery_msg;
- uint32_t uc_size;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
- BOOL q_full = FALSE;
- std::multimap<uint16_t, std::string>::iterator it;
- std::pair<std::multimap<uint16_t, std::string>::iterator, std::multimap<uint16_t, std::string>::iterator> rang;
- /* Initialization of delivery-message-structure to user */
- (void)memset(reinterpret_cast<void *>(&st_delivery_msg), (int32_t)0, (size_t)sizeof(st_delivery_msg));
-
- /****** Creation of data section ******/
- st_delivery_msg.opc = us_opc; /* OPC */
- st_delivery_msg.dlc = uc_dlc; /* DLC */
- if ((uint32_t)CAN__CWORD29__MEM_SZ < uc_dlc) {
- uc_size = (uint32_t)CAN__CWORD29__MEM_SZ;
- } else {
- uc_size = uc_dlc;
- }
- memcpy(st_delivery_msg.data, puc_data, (size_t)uc_size);
- it = g_map__CWORD29__delivery_list.find(static_cast<const uint16_t>(us_opc));
- if (it == g_map__CWORD29__delivery_list.end()) {
- /* Delivery destination unregistered log output */
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "#CAN_thread# OPC 0x%x not found in CAN Delivery entry table", us_opc);
- }
+static bool CANCommandFuelCalcRstReqCheck(void) {
+ return can_cmd_rst_rcv;
+}
- /****** Messaging ******/
- rang = g_map__CWORD29__delivery_list.equal_range(static_cast<const uint16_t>(us_opc));
- for (it = rang.first; it != rang.second; ++it) {
- if (g_map_handler.count(it->second) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, it->second.c_str());
- if (h_client == NULL) {
- ret = FALSE;
- continue;
- }
- g_map_handler[it->second].handle = h_client;
- g_map_handler[it->second].is_q_full = FALSE;
- } else {
- h_client = g_map_handler[it->second].handle;
- q_full = g_map_handler[it->second].is_q_full;
- }
+void CANCommandSetFuelCalcRstReq(void) {
+ can_cmd_rst_rcv = true;
+}
- if (g_isaccoff && q_full) {
- /* Once queue full has occured during ACC OFF, do nothing */
- } else {
- e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_DIAG_CWORD29__DELIVERY, sizeof(CAN_MSG_CAN__CWORD29_DATA), &st_delivery_msg);
- if (eFrameworkunifiedStatusMsgQFull == e_status) {
- /* eFrameworkunifiedStatusMsgQFull */
- g_map_handler[it->second].is_q_full = TRUE;
- }
- if (e_status != eFrameworkunifiedStatusOK) {
- ret = FALSE;
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedSendMsg Error(e_status:%d to:%s)", e_status, it->second.c_str()); // NOLINT (whitespace/line_length)
- }
- }
- }
- return (ret);
+static void CANTxMsgErrorLog(const char *reason, const char *func,
+ CANID id, uint16_t len, HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, func, "%s Frame(0x%x) length=%hu from %s is ignored.",
+ reason, id, len, FrameworkunifiedGetMsgSrc(h_app));
}
-/*******************************************************************************
- * MODULE : CANDeliverySndMsgToCANGW
- * ABSTRACT : CAN-data-delivery-messaging process to the CANGW
- * FUNCTION : CANDataSending Delivery Messages to a CANGW
- * ARGUMENT : h_app : HANDLE
- * cangw_data : CAN_MSG_CANGWDATA
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANDeliverySndMsgToCANGW(HANDLE h_app, CAN_MSG_CANGWDATA *cangw_data) {
- BOOL ret = TRUE;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
- BOOL q_full = FALSE;
- uint8_t data_count;
-
- // Memset unused space
- data_count = cangw_data->num;
- memset(reinterpret_cast<void *>(&cangw_data->data[data_count]), (int32_t)0,
- (size_t)sizeof(cangw_data->data[data_count]) * (CANGW_SND_NUM_MAX - data_count));
-
- if (g_map_handler.count(TN_CANGW_M_RCV) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, TN_CANGW_M_RCV);
- if (h_client == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- goto exit; // LCOV_EXCL_LINE 4: NSFW error case
- }
- g_map_handler[TN_CANGW_M_RCV].handle = h_client; // LCOV_EXCL_BR_LINE 200 unexpect branch
- g_map_handler[TN_CANGW_M_RCV].is_q_full = FALSE; // LCOV_EXCL_BR_LINE 200 unexpect branch
- } else {
- h_client = g_map_handler[TN_CANGW_M_RCV].handle; // LCOV_EXCL_BR_LINE 200 unexpect branch
- q_full = g_map_handler[TN_CANGW_M_RCV].is_q_full; // LCOV_EXCL_BR_LINE 200 unexpect branch
- }
+static EFrameworkunifiedStatus CANCommandResponse(HANDLE h_app, CAN_MSG_CANCMD *msg,
+ size_t len, char *notifyName) {
+ HANDLE h_client = NULL;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
- if (g_isaccoff && q_full) {
- /* Once queue full has occured during ACC OFF, do nothing */
- } else {
- e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CANGW_DELIVERY, sizeof(CAN_MSG_CANGWDATA), cangw_data);
- if (eFrameworkunifiedStatusMsgQFull == e_status) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- /* eFrameworkunifiedStatusMsgQFull */
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- g_map_handler[TN_CANGW_M_RCV].is_q_full = TRUE; // LCOV_EXCL_LINE 4: NSFW error case
- }
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "#CAN_thread# FrameworkunifiedSendMsg Error(e_status:%d to:%s)", e_status, TN_CANGW_M_RCV); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT (whitespace/line_length)
- }
+ h_client = CommonFindSender(h_app, notifyName);
+ if (!h_client) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Cannot open sender handle.");
+ return e_status;
}
-exit:
- return (ret);
+
+ msg->hdr.hdr.cid = (uint16_t)CID_CAN_CMD_DELIVERY;
+ e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CMD_DELIVERY, (uint32_t)len, msg);
+ if (e_status != eFrameworkunifiedStatusOK)
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg is failed.");
+
+ return e_status;
}
-/*******************************************************************************
- * MODULE : CANFreqTransStartTxMsg
- * ABSTRACT : CANDataPeriodic transmission start message transmission processing
- * FUNCTION : CANDataSending Periodic Send Data as a Send Message
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANFreqTransStartTxMsg(HANDLE h_app, uint8_t uc_index) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_FREQ_TRANSMISSION_DAT st_data; /* Periodic send data acquisition buffer */
-
- /****** Data acquisition ******/
- CANFreqTransDataGet(uc_index, &st_data); /* Periodic transmission data acquisition */
-
- /****** Messaging ******/
- if ((uint8_t)0 == st_data.uc_resp_num) {
- uc_index = (uint8_t)CAN_RID_NOTUSE_CODE;
+static EFrameworkunifiedStatus CANCommandVersionReq(HANDLE h_app, char *notifyName) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CANHAL_RET_API ret = CANHAL_RET_NORMAL;
+ std::string version_info;
+ CAN_MSG_CANCMD msg;
+
+ memset(&msg, 0, sizeof(msg));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "@@@ Call CanGetVersion for can_hal");
+ ret = CanGetVersion(h_app, &version_info);
+ if (ret != CANHAL_RET_NORMAL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Cannot get version from can_hal.");
+ return e_status;
}
- /* CANDataSend one transmission start message processing */
- if (FALSE == CAN1TimeTransStartTxMsg(h_app, uc_index, &st_data.st_can_data)) {
- ret = FALSE; /* Return value of this function */
+ if (CAN_TX_CMD_VERSION_SIZE != version_info.length()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid length of version.");
+ return e_status;
}
- return (ret);
+ msg.hdr.hdr.rid = 0;
+ msg.hdr.hdr.msgbodysize = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_VERSION_SIZE;
+ msg.data.cmd_id = CAN_CMDID_VERSION_RESP_RX;
+ strncpy((char *)msg.data.data, version_info.c_str(), CAN_TX_CMD_VERSION_SIZE);
+ return CANCommandResponse(h_app, &msg, sizeof(msg), notifyName);
}
-/*******************************************************************************
- * MODULE : CAN1TimeTransStartTxMsg
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief The transmission of CAN data transmission start message
- *
- * @~english
- * The transmission of CAN data transmission start message
- *
- * @~english
- * @note Details of process
- * -# Creating of data division
- * -# Message sending
- *
- * @~english
- * @return Message transmission success/failure
- * @retval <1> Message transmission success
- * @retval <0> Message transmission failure
- *
- * @~english
- * @param[in] <uc_can_rid> Index
- * @param[in] <*pst_data> Pointer of transmission data
- * @param[in] <uc_opc> Operation code
- * @param[in] <n_ta> Target address
- */
-BOOL CAN1TimeTransStartTxMsg(HANDLE h_app, uint8_t uc_can_rid, const CAN_DATA *pst_data) {
- BOOL b_ret = TRUE;
-// CanMessage st_can_data;
-//
-// if (pst_data != NULL) { // LCOV_EXCL_BR_LINE 200 (the caller always use the pointer of object)
-// st_can_data.can_id = pst_data->can_id;
-// st_can_data.dlc = pst_data->dlc;
-// st_can_data.rid = uc_can_rid;
-// if (pst_data->dlc < 8) {
-// memcpy(st_can_data.data, pst_data->data, pst_data->dlc);
-// }
-
-// if (CanSend(&st_can_data, CAN_HAL_TYPE_CAN) != CANHAL_RET_NORMAL) {
-// b_ret = FALSE;
-// }
-// }
- return b_ret;
-}
-
-/*******************************************************************************
- * MODULE : CANCommWatchSndMsg
- * ABSTRACT : CANDataTransmission of communication interruption detection/recovery message
- * FUNCTION : CANDataSend disconnection detection messages or recovery messages
- * ARGUMENT : uc_index : Indexed
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCommWatchSndMsg(HANDLE h_app, uint8_t uc_index) {
- DID ul_did; /* Data ID */
- uint8_t uc_comm_stop; /* Communication status */
- CAN_MSG_COMM_WATCHSTS st_comm_watch_sts; /* Communication Disruption Detection/Recovery Message Structures to the user */
- // int32_t ret_api; /* Return Values of System API Functions */
- char notify_name[MAX_NAME_SIZE_APP];
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
-
- /* Message structure initialization */
- memset(reinterpret_cast<void *>(&st_comm_watch_sts), (int32_t)0, (size_t)sizeof(st_comm_watch_sts));
- /* Buffer initialization */
-
- /* Acquisition of the communication status of the target index */
- CANCommWatchDataGet(uc_index, notify_name, &ul_did, &uc_comm_stop, CAN_PROTOCOL_TYPE_CAN);
-
- /* Message creation */
- /* Creation of header part (CAN -> Monitoring Requester)*/
-// if ((uint8_t)CAN_COMM_NORMAL == uc_comm_stop) { /* Command ID */
- /* During communication -> Send data communication recovery notification message */
-// st_comm_watch_sts.hdr.hdr.cid = (uint16_t)CID_CAN_COMM_RESTORE;
-// } else {
- /* When communication is interrupted -> Send data communication interruption notification message */
-// st_comm_watch_sts.hdr.hdr.cid = (uint16_t)CID_CAN_COMM_STOP;
-// }
-// st_comm_watch_sts.hdr.hdr.msgbodysize = sizeof(CAN_MSG_COMM_WATCHSTS_DAT); /* Message data size */
-// st_comm_watch_sts.hdr.hdr.rid = 0; /* Resource ID (not used) */
- st_comm_watch_sts.data.ulDid = ul_did; /* Creation of data section */
-
- if (g_map_handler.count(notify_name) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, notify_name);
- if (h_client == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- goto exit; // LCOV_EXCL_LINE 4: NSFW error case
- }
- g_map_handler[notify_name].handle = h_client; // LCOV_EXCL_BR_LINE 200 unexpect branch
- g_map_handler[notify_name].is_q_full = FALSE; // LCOV_EXCL_BR_LINE 200 unexpect branch
+static EFrameworkunifiedStatus CANCommandFuelcalcRstReq(HANDLE h_app, char *notifyName) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ if (CANCommandFuelCalcRstReqCheck()) {
+ // CAN_CMDID_FUELCALC_RST_REQ_RX is already received from can_hal.
+ // so response it in direct.
+ CAN_MSG_CANCMD msg;
+ memset(&msg, 0, sizeof(msg));
+ msg.hdr.hdr.rid = 0;
+ msg.hdr.hdr.msgbodysize = CAN_TX_CMD_DELIVERY_SIZE +
+ CAN_TX_CMD_FUELCALC_RST_SIZE;
+ msg.data.cmd_id = CAN_CMDID_FUELCALC_RST_REQ_RX;
+ e_status = CANCommandResponse(h_app, &msg, sizeof(msg), notifyName);
} else {
- h_client = g_map_handler[notify_name].handle; // LCOV_EXCL_BR_LINE 200 unexpect branch
- }
-// e_status = FrameworkunifiedSendMsg(h_client, st_comm_watch_sts.hdr.hdr.cid, sizeof(st_comm_watch_sts), &st_comm_watch_sts);
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- CANCommWatchDelete(uc_index, CAN_PROTOCOL_TYPE_CAN); // LCOV_EXCL_LINE 4: NSFW error case
- goto exit; // LCOV_EXCL_LINE 4: NSFW error case
+ CANDeliveryInsert(CAN_CMDID_FUELCALC_RST_REQ_RX, notifyName);
+ e_status = eFrameworkunifiedStatusOK;
}
-exit:
- return;
+ return e_status;
}
-/*******************************************************************************
- * MODULE : CANTxRsltSndMsg
- * ABSTRACT : CANDataTransmission result notification message transmission processing
- * FUNCTION : CANDataSend a transmission result notification message
- * ARGUMENT : uc_can_rid : Resource ID from CAN
- * uc_status : Transmission result status
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANTxRsltSndMsg(HANDLE h_app, uint8_t uc_can_rid, uint8_t uc_status) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_MSG_SENDSTS st_txrslt_msg; /* Transmission result notification message structure */
- CAN_1TIME_TXRSLT_DAT st_data; /* Transmission result data */
- int32_t ret_api = RET_NORMAL; /* Return Values of System API Functions */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
+static EFrameworkunifiedStatus CANCommandOther(HANDLE h_app, char *notifyName,
+ uint8_t cmd, uint8_t rid) {
+ CanMessage msg;
+ CANID wait = 0;
+ CANID can_id = (CANID)cmd;
+
+ memset(&msg, 0, sizeof(msg));
+ switch (cmd) {
+ case CAN_CMDID_STARTUP_FIN_REQ_TX:
+ wait = CAN_CMDID_STARTUP_FIN_RESP_RX;
+ break;
+ case CAN_CMDID_MRST_INFO_REQ_TX:
+ wait = CAN_CMDID_MRST_INFO_RESP_RX;
+ break;
+ case CAN_CMDID_CONNECTION_NODE_REQ_TX:
+ wait = CAN_CMDID_CONNECTION_NODE_RESP_RX;
+ break;
+ case CAN_CMDID_FUELCALC_REQ_TX:
+ wait = CAN_CMDID_FUELCALC_RST_REQ_RX;
+ break;
+ default:
+ CANTxMsgErrorLog("Unsupported cmd requested", __func__, cmd, 0, h_app);
+ return eFrameworkunifiedStatusFail;
+ }
- if (static_cast<const uint8_t>(CAN_TXRSLT_CANRID__CWORD29__START) <= uc_can_rid) {
- return (FALSE);
+ if (cmd != CAN_CMDID_FUELCALC_REQ_TX) {
+ CANDeliveryInsert(wait, notifyName);
}
- memset(reinterpret_cast<void *>(&st_txrslt_msg), 0, sizeof(CAN_MSG_SENDSTS));
- /* Message structure initialization */
- /****** Data acquisition ******/
- CANTxRsltDataGet(uc_can_rid, &st_data);
-
- /****** Creation of header section ******/
-// st_txrslt_msg.hdr.hdr.cid = static_cast<uint16_t>(CID_CAN_TX_RESULT); /* Command ID */
-// st_txrslt_msg.hdr.hdr.msgbodysize = static_cast<uint16_t>(sizeof(CAN_MSG_SENDSTS_DAT)); /* Message data size */
-
- /****** Creation of data section ******/
-// st_txrslt_msg.hdr.hdr.rid = st_data.uc_rid; /* Resources ID */
- st_txrslt_msg.data.ulCanid = st_data.ul_canid; /* CAN ID */
- st_txrslt_msg.data.ucStatus = uc_status; /* Transmission result status */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "Rid:%02x Canid:%08x Status:%02x", st_data.uc_rid, st_data.ul_canid, uc_status); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
- /****** Messaging ******/
- if (g_map_handler.count(st_data.notify_name) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, reinterpret_cast<const char *>(st_data.notify_name));
- if (h_client == reinterpret_cast<HANDLE>(NULL)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedMcOpenSender Error(name=%s)", st_data.notify_name);
- ret_api = RET_ERROR;
+ if (rid != CAN_RID_NOTUSE_CODE) {
+ // cmd can be assumed same as can_id.
+ if (0 < g_m_send_sts.count(can_id)) {
+ if (g_m_send_sts[can_id].notify_name[0] != 0x00) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "Not yet deliver SendSts but updated(SendID=%x, CAN ID=%x, Nane=%s)",
+ g_m_send_sts[can_id].rid, can_id, g_m_send_sts[can_id].notify_name);
+ }
}
- g_map_handler[st_data.notify_name].handle = h_client; // LCOV_EXCL_BR_LINE 200: unexpect branch
- g_map_handler[st_data.notify_name].is_q_full = FALSE; // LCOV_EXCL_BR_LINE 200: unexpect branch
- } else {
- h_client = g_map_handler[st_data.notify_name].handle; // LCOV_EXCL_BR_LINE 200: unexpect branch
+ g_m_send_sts[can_id].rid = rid;
+ memcpy(g_m_send_sts[can_id].notify_name, notifyName,
+ sizeof(g_m_send_sts[can_id].notify_name));
}
-// e_status = FrameworkunifiedSendMsg(h_client, st_txrslt_msg.hdr.hdr.cid,
-// static_cast<UI_32>(sizeof(CAN_MSG_SENDSTS)), reinterpret_cast<PCVOID>(&st_txrslt_msg));
- if (e_status != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error");
- ret_api = RET_ERROR;
- }
+ msg.can_id = (CANID)cmd;
+ msg.rid = rid;
+ msg.dlc = (uint8_t)CAN_CMDSND_DATA_SIZE;
- if (RET_NORMAL != ret_api) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(ret_api=%d)", ret_api);
- /* Check for message transmission and reception errors */
- CANMsgErrChk(ret_api, 0);
- ret = FALSE; /* Message transmission failure */
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "@@@ Call CanSend for can_hal");
+ if (CANHAL_RET_NORMAL != CanSend(h_app, &msg, CAN_HAL_TYPE_CAN)) {
+ CANTxMsgErrorLog("CAN CanSend failed", __func__, msg.can_id,
+ (uint16_t)msg.dlc, h_app);
+ return eFrameworkunifiedStatusFail;
}
- return (ret);
+ return eFrameworkunifiedStatusOK;
}
-/*******************************************************************************
- * MODULE : CAN_CWORD29_TxRsltSndMsg
- * ABSTRACT : _CWORD29_ data transmission result notification message transmission process
- * FUNCTION : Send _CWORD29_ transmission result notification messages
- * ARGUMENT : uc_can_rid : Resource ID from CAN
- * uc_status : Transmission result status
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CAN_CWORD29_TxRsltSndMsg(const HANDLE h_app, const uint8_t uc_can_rid, const uint8_t uc_status) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_MSG__CWORD29__SENDSTS st_txrslt_msg; /* _CWORD29_ send result notification messaging structures */
- CAN__CWORD29__TXRSLT_DAT st_data; /* _CWORD29_ transmission result data */
- int32_t ret_api = RET_NORMAL; /* Return Values of System API Functions */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
+EFrameworkunifiedStatus CANTxMsgCommand(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "@@@ Start communication CanCommandCtl");
- if (reinterpret_cast<HANDLE>(NULL) == h_app) {
- return (FALSE);
- }
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_CMD_CTRL_MSG_DAT rcv_msg;
- memset(reinterpret_cast<void *>(&st_txrslt_msg), 0, sizeof(CAN_MSG__CWORD29__SENDSTS));
- /* Message structure initialization */
- /****** Data acquisition ******/
- CAN_CWORD29_TxRsltDataGet(uc_can_rid, &st_data);
-
- /****** Creation of header section ******/
-// st_txrslt_msg.hdr.hdr.cid = CID_CAN__CWORD29__TX_RESULT; /* Command ID */
- /* Message data size */
-// st_txrslt_msg.hdr.hdr.msgbodysize = static_cast<uint16_t>(sizeof(CAN_MSG__CWORD29__SENDSTS_DAT));
-
- /****** Creation of data section ******/
-// st_txrslt_msg.hdr.hdr.rid = st_data.uc_rid; /* Resources ID */
- st_txrslt_msg.data.usOpc = st_data.opc; /* OPC */
- st_txrslt_msg.data.ucStatus = uc_status; /* Transmission result status */
-
- FRAMEWORKUNIFIEDLOG(ZONE_CAN_DEBUG, __func__, "Rid:%02x OPC:%08x Status:%02x", st_data.uc_rid, st_data.opc, uc_status);
- /****** Messaging ******/
- if (g_map_handler.count(reinterpret_cast<const char *>(st_data.notify_name)) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, st_data.notify_name);
- if (h_client == reinterpret_cast<HANDLE>(NULL)) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedMcOpenSender Error(name=%s)", st_data.notify_name);
- ret_api = RET_ERROR;
- }
- g_map_handler[st_data.notify_name].handle = h_client;
- g_map_handler[st_data.notify_name].is_q_full = FALSE;
- } else {
- h_client = g_map_handler[st_data.notify_name].handle;
- }
+ memset(&rcv_msg, 0, sizeof(rcv_msg));
-// e_status = FrameworkunifiedSendMsg(h_client, static_cast<UI_32>(st_txrslt_msg.hdr.hdr.cid), sizeof(CAN_MSG__CWORD29__SENDSTS),
-// &st_txrslt_msg);
+ e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease);
if (e_status != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error");
- ret_api = RET_ERROR;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
+ if (e_status == eFrameworkunifiedStatusInvldBufSize)
+ FrameworkunifiedClearMsgData(h_app);
+ return e_status;
}
- /****** NSFW error case ******/
- if (RET_NORMAL != ret_api) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(ret_api=%d)", ret_api);
- /* Check for message transmission and reception errors */
- CANMsgErrChk(ret_api, 0);
- /* Message transmission failure */
- ret = FALSE; // LCOV_EXCL_LINE 8:Due to dead code
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "notify_name=%s ulEvtId=%x ucRid=%x ucCmdid=%x",
+ rcv_msg.notifyName, rcv_msg.ulEvtId, rcv_msg.ucRid, rcv_msg.ucCmdid);
+
+ switch (rcv_msg.ucCmdid) {
+ case CAN_CMDID_VERSION_REQ_TX:
+ e_status = CANCommandVersionReq(h_app, rcv_msg.notifyName);
+ break;
+ case CAN_CMDID_FUELCALC_RST_REQ_DELIVERY:
+ e_status = CANCommandFuelcalcRstReq(h_app, rcv_msg.notifyName);
+ break;
+ default:
+ e_status = CANCommandOther(h_app,
+ rcv_msg.notifyName, rcv_msg.ucCmdid, rcv_msg.ucRid);
+ break;
}
+ return e_status;
+}
- return (ret);
+static CAN_TRANS_START_TABLE_VAL *CANTxMsgFindMap(CAN_TRANS_START_MSG_DAT *msg) {
+ std::map<CANID, CAN_TRANS_START_TABLE_VAL *>::iterator it;
+ it = g_map_trans_data.find(msg->id);
+ if (it == g_map_trans_data.end())
+ return NULL;
+ return it->second;
}
-/*******************************************************************************
- * MODULE : CANCanidUserToIfCvt
- * ABSTRACT : CAN ID Conversion Process 2
- * FUNCTION : Convert CAN ID for USER to CAN ID for interfaces
- * ARGUMENT : can_id : CAN ID
- * *puc_buf : CAN ID Array Pointers (Data-Out)
- * NOTE :
- * RETURN : None
- ******************************************************************************/
-void CANCanidUserToIfCvt(CANID can_id, uint8_t *puc_buf) {
- int32_t i; /* Generic counters */
- uint8_t *puc; /* Generic pointer */
- uint32_t ul1; /* General Variables */
- uint32_t ul2; /* General Variables */
- uint32_t ul3; /* General Variables */
-
- /* Concept of conversion
- Input data format (32-bit data)
- Bit assignment [31:29] [28:0]
- CAN ID free [2:0] CAN ID [28:0]
- Output data format (8-bit data with the following structure)
- Base Address +0 :ext_flag, CAN ID[10:4]
- +1 :CAN ID[3:0], Empty[1:0], CAN ID[28:27]
- +2 :CAN ID[26:19]
- +3 :CAN ID[18:11]
-*/
- ul1 = (uint32_t)can_id; /* Type conversion */
- ul2 = (ul1 << 20) & 0x7FF00000; /* Insert data of [10:0] */
- ul3 = (ul1 >> 11) & 0x0003FFFF; /* Populate [28:11] */
- ul2 |= ul3; /* Combine */
- /* Check of ext_flag */
- if (0 != ul3) {
- ul2 |= CAN_ID_EXT_FLAG; /* Add Extended Flag */
- } else {
- /* Do nothing */
- }
- puc = puc_buf; /* Get array pointers */
- for (i = 0; i < 4; i++) {
- ul3 = ul2 >> (uint32_t)((3 - i) * 8);
- *puc = (uint8_t)ul3; /* Data storage */
- puc++;
- }
- return;
+static CAN_TRANS_START_TABLE_VAL *CanSendFind(CAN_TRANS_START_MSG_DAT *msg) {
+ return CANTxMsgFindMap(msg);
}
-/*******************************************************************************
- * MODULE : CANCommandDeliverySndMsg
- * ABSTRACT : CAN command delivery message transmission processing
- * FUNCTION : CAN command delivery (CAN thread-> user)
- * ARGUMENT : uc_cmd_id : CAN command ID
- * puc_data : Receive data reference pointer
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANCommandDeliverySndMsg(HANDLE h_app, uint8_t uc_cmd_id, const uint8_t *puc_data) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_MSG_CANCMD st_snd_msg; /* CAN Command Delivery Notification Message Structure */
- int32_t l_cnt = 0; /* Counter */
- uint32_t ul = 0; /* General Variables */
- // int32_t ret_api; /* Return Values of System API Functions */
- CAN_COMMAND_DELIVERY_LIST_DAT list;
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
-
- /* Get Shipping ID List */
- (void)CANCommandDeliveryDataGet(uc_cmd_id, &list);
-
- /* Messaging */
- for (l_cnt = 0; l_cnt < (int32_t)list.notify_name_num; l_cnt++) {
- /* Data size setting */
- switch (uc_cmd_id) { // LCOV_EXCL_BR_LINE 6:Excluded because the value is not currently passed
- case CAN_CMDID_FUELCALC_RST_REQ_RX:
- ul = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_FUELCALC_RST_SIZE;
- break;
- case CAN_CMDID_STARTUP_FIN_RESP_RX:
- ul = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_STARTUP_FIN_SIZE;
- break;
- case CAN_CMDID_MRST_INFO_RESP_RX:
- ul = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_MRST_INFO_SIZE;
- break;
- case CAN_CMDID_VERSION_RESP_RX:
- ul = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_VERSION_SIZE;
- break;
- case CAN_CMDID_CONNECTION_NODE_RESP_RX:
- ul = CAN_TX_CMD_DELIVERY_SIZE + (uint32_t)puc_data[0] + 1;
- break;
- default:
- // LCOV_EXCL_START 6 Excluded because the value is not currently passed
- AGL_ASSERT_NOT_TESTED();
- ul = (uint32_t)sizeof(st_snd_msg.data);
- break;
- // LCOV_EXCL_STOP6 Excluded because the value is not currently passed
- }
+EFrameworkunifiedStatus CANTxMsgBit(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "@@@ Start communication CanSend(bit)");
- (void)memset(reinterpret_cast<void *>(&st_snd_msg), (int32_t)0, (size_t)sizeof(st_snd_msg));
- /* Message structure initialization */
- /****** Creation of header section ******/
-// st_snd_msg.hdr.hdr.rid = 0; /* Resource ID (not used) */
-// st_snd_msg.hdr.hdr.cid = (uint16_t)CID_CAN_CMD_DELIVERY; /* Command ID */
-// st_snd_msg.hdr.hdr.msgbodysize = (uint16_t)ul; /* Message data size */
-
- /****** Creation of data section ******/
- st_snd_msg.data.cmd_id = uc_cmd_id; /* CAN command ID */
- memcpy(&st_snd_msg.data.data[0], puc_data, (ul - CAN_TX_CMD_DELIVERY_SIZE)); /* Received data */
-
- /****** Messaging ******/
- if (g_map_handler.count(list.notify_name_list[l_cnt]) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, list.notify_name_list[l_cnt]);
- if (h_client == NULL) {
- ret = FALSE;
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedMcOpenSender Error(notify_name=%s)", list.notify_name_list[l_cnt]);
- break;
- }
- g_map_handler[list.notify_name_list[l_cnt]].handle = h_client;
- g_map_handler[list.notify_name_list[l_cnt]].is_q_full = FALSE;
- } else {
- h_client = g_map_handler[list.notify_name_list[l_cnt]].handle;
- }
- e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CMD_DELIVERY, sizeof(st_snd_msg), &st_snd_msg);
- if (e_status != eFrameworkunifiedStatusOK) {
- CANCommandDeliveryDeletesingle(uc_cmd_id, list.notify_name_list[l_cnt]);
- ret = FALSE;
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(e_status=%d)", e_status);
- break;
- }
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_TRANS_START_MSG_DAT rcv_msg;
+ CanMessage snd_msg;
+ CAN_TRANS_START_TABLE_VAL *store;
+ int32_t i = 0;
+ uint8_t *store_p;
+ uint8_t *data_p;
+ uint8_t *mask_p;
+
+ memset(&rcv_msg, 0, sizeof(rcv_msg));
+ memset(&snd_msg, 0, sizeof(snd_msg));
+
+ e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
+ if (e_status == eFrameworkunifiedStatusInvldBufSize)
+ FrameworkunifiedClearMsgData(h_app);
+ goto cleanup;
}
- return (ret);
-}
+ e_status = eFrameworkunifiedStatusFail;
-/*******************************************************************************
- * MODULE : CANCommandTxRsltSndMsg
- * ABSTRACT : CAN command transmission result notification message transmission processing
- * FUNCTION : Send CAN command send result notification (CAN thread-> user)
- * ARGUMENT : uc_can_rid : Resource ID from CAN
- * uc_status : Transmission result status
- * NOTE :
- * RETURN :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANCommandTxRsltSndMsg(HANDLE h_app, uint8_t uc_can_rid, uint8_t uc_status) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_CMD_MSG_SENDSTS st_snd_msg; /* CAN command transmission result notification message structure */
- uint8_t uc_rid; /* Resources ID */
- uint8_t uc_cmd_id; /* CAN command ID */
- // int32_t ret_api; /* Return Values of System API Functions */
- char notify_name[MAX_NAME_SIZE_APP];
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
-
- /* Data acquisition */
- CANCommandTxRsltDataGet(uc_can_rid, notify_name, &uc_rid, &uc_cmd_id);
-
- memset(reinterpret_cast<void *>(&st_snd_msg), (int32_t)0, (size_t)sizeof(st_snd_msg));
- /* Message structure initialization */
- /****** Creation of header section ******/
-// st_snd_msg.hdr.hdr.rid = uc_rid; /* Resources ID */
-// st_snd_msg.hdr.hdr.cid = (uint16_t)CID_CAN_CMD_TX_RESULT; /* Command ID */
-// st_snd_msg.hdr.hdr.msgbodysize = (size_t)sizeof(st_snd_msg.data); /* Message data size */
-
- /****** Creation of data section ******/
- st_snd_msg.data.cmd_id = (uint32_t)uc_cmd_id; /* CAN command ID */
- st_snd_msg.data.status = uc_status; /* Transmission result status */
-
- /****** Messaging ******/
- if (g_map_handler.count(notify_name) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, notify_name);
- if (h_client == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- return (ret); // LCOV_EXCL_LINE 4: NSFW error case
- }
- g_map_handler[notify_name].handle = h_client; // LCOV_EXCL_BR_LINE 200: unexpect branch
- g_map_handler[notify_name].is_q_full = FALSE; // LCOV_EXCL_BR_LINE 200: unexpect branch
- } else {
- h_client = g_map_handler[notify_name].handle; // LCOV_EXCL_BR_LINE 200: unexpect branch
+ if (TRUE != CommGetAvailabilityCurrent(CAN_AVAILABILITY)) {
+ CANTxMsgErrorLog("CAN is not ready", __func__, 0, 0, h_app);
+ goto cleanup;
}
- e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CMD_TX_RESULT, sizeof(st_snd_msg), &st_snd_msg);
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- CANCommandTxRsltDelete(uc_can_rid); // LCOV_EXCL_LINE 4: NSFW error case
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- return (ret); // LCOV_EXCL_LINE 4: NSFW error case
+
+ store = CanSendFind(&rcv_msg);
+ if (!store) {
+ CANTxMsgErrorLog("No initial value", __func__,
+ rcv_msg.id, sizeof(rcv_msg.dat), h_app);
+ goto cleanup;
}
- return (ret);
-}
-/*******************************************************************************
- * MODULE : CANCommandTransmissionSndMsg
- ******************************************************************************/
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Transmission of CAN command
- *
- * @~english
- * Transmission of CAN command (DISP Microcomputer -> SYS Microcomputer)
- *
- * @~english
- * @note Details of process
- * -# Creating of data division
- * -# Message sending
- *
- * @~english
- * @return Message transmission success/failure
- * @retval <1> Message transmission success
- * @retval <0> Message transmission failure
- *
- * @~english
- * @param[in] <uc_opc> Operation code
- * @param[in] <uc_can_rid> Resource ID
- */
-BOOL CANCommandTransmissionSndMsg(uint8_t uc_opc, uint8_t uc_can_rid) { // LCOV_EXCL_START 8: dead code
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- BOOL ret = TRUE; /* Return value of this function */
-// T_ICR_CMD st_tx_can_data; /* Transmit data structure */
-
-// (void)memset(reinterpret_cast<void *>(&st_tx_can_data), (int32_t)0, (size_t)sizeof(st_tx_can_data));
- /* Message structure initialization */
- /****** Creation of data section ******/
-// st_tx_can_data.cmd_data.phyadr_from = CAN_TX_PHYS_ADRS; /* Physical address */
-// st_tx_can_data.cmd_data.service_type = CAN_TX_COMM_KIND; /* Communication type 0x00: Individual */
-// st_tx_can_data.cmd_data.lgadr_from = CAN_TX_FROM_ADRS; /* Source Logical Address */
-// st_tx_can_data.cmd_data.lgadr_to = CAN_TX_TO_ADRS; /* Destination logical address */
-// st_tx_can_data.cmd_data.opc = uc_opc; /* Operation code */
-// st_tx_can_data.cmd_data.d_length = (uint16_t)CAN_CMDSND_DATA_SIZE; /* Data length (data section only) */
-
- /****** Messaging ******/
- return (ret);
-}
-// LCOV_EXCL_STOP
-
-/*******************************************************************************
- * MODULE : CANCommandFuelCalcRstReqSndMsg
- * ABSTRACT : CAN section flame reset request reception message transmission processing
- * FUNCTION : Send CAN interval flame reset request reception message (CAN thread-> user)
- * ARGUMENT : notifyId : Message Destination ID
- * NOTE :
- * RETURN : TRUE : Message transmission success
- * FALSE : Message transmission failure
- ******************************************************************************/
-BOOL CANCommandFuelCalcRstReqSndMsg(HANDLE h_app, PCSTR notify_name) {
- BOOL ret = TRUE; /* Return value of this function */
- CAN_MSG_CANCMD st_snd_msg; /* CAN Command Delivery Notification Message Structure */
- // int32_t ret_api = RET_NORMAL; /* Return Values of System API Functions */
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- HANDLE h_client;
-
- (void)memset(reinterpret_cast<void *>(&st_snd_msg), (int32_t)0, (size_t)sizeof(st_snd_msg));
- /* Message structure initialization */
- /****** Creation of header section ******/
-// st_snd_msg.hdr.hdr.rid = 0; /* Resource ID (not used) */
-// st_snd_msg.hdr.hdr.cid = (uint16_t)CID_CAN_CMD_DELIVERY; /* Command ID */
-// st_snd_msg.hdr.hdr.msgbodysize = CAN_TX_CMD_DELIVERY_SIZE + CAN_TX_CMD_FUELCALC_RST_SIZE; /* Message data size */
-
- /****** Creation of data section ******/
- st_snd_msg.data.cmd_id = CAN_CMDID_FUELCALC_RST_REQ_RX; /* CAN command ID */
-
- if (g_map_handler.count(notify_name) == 0) {
- h_client = FrameworkunifiedMcOpenSender(h_app, notify_name);
- if (h_client == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- return (ret); // LCOV_EXCL_LINE 4: NSFW error case
- }
- g_map_handler[notify_name].handle = h_client; // LCOV_EXCL_BR_LINE 11:except,C++ STL
- g_map_handler[notify_name].is_q_full = FALSE; // LCOV_EXCL_BR_LINE 11:except,C++ STL
- } else {
- h_client = g_map_handler[notify_name].handle; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ store_p = store->dat.dat;
+ data_p = rcv_msg.dat.dat;
+ mask_p = rcv_msg.mask.dat;
+ for (i = 0; i < store->dlc; i++) {
+ *store_p &= (uint8_t)(~(*mask_p));
+ *store_p |= ((*mask_p) & (*data_p));
+ ++store_p;
+ ++data_p;
+ ++mask_p;
}
- e_status = FrameworkunifiedSendMsg(h_client, CID_CAN_CMD_DELIVERY, sizeof(st_snd_msg), &st_snd_msg);
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- ret = FALSE; // LCOV_EXCL_LINE 4: NSFW error case
- return (ret); // LCOV_EXCL_LINE 4: NSFW error case
+
+ snd_msg.can_id = rcv_msg.id;
+ snd_msg.dlc = store->dlc;
+ snd_msg.rid = CAN_RID_NOTUSE_CODE;
+ memcpy(snd_msg.data, store->dat.dat, snd_msg.dlc);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "@@@ Call CanSend for can_hal : "
+ "can_id=%x dlc=%d rid=%x", snd_msg.can_id, snd_msg.dlc, snd_msg.rid);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(snd_msg.data, snd_msg.dlc).c_str());
+
+ if (CANHAL_RET_NORMAL != CanSend(h_app, &snd_msg, CAN_HAL_TYPE_CAN)) {
+ CANTxMsgErrorLog("CAN CanSend failed", __func__, snd_msg.can_id,
+ (uint16_t)snd_msg.dlc, h_app);
+ goto cleanup;
}
- return (ret);
+ // echoback
+ e_status = CANDeliverySndMsg(h_app, snd_msg.can_id, 0, (uint8_t)snd_msg.dlc,
+ (const uint8_t *)snd_msg.data,
+ CID_CAN_DATA_DELIVERY, CANIF_ECHOBACK);
+cleanup:
+ return e_status;
}
-/*******************************************************************************
- * MODULE : CANCommandidOpcToUserCvt
- * ABSTRACT : CAN Command ID Conversion Processing 1
- * FUNCTION : Convert the opcode to the corresponding CAN command ID
- * ARGUMENT : uc_opc : Opcode
- * puc_cmd_id : CAN command ID return pointer
- * NOTE :
- * RETURN : TRUE : Predefined opcodes
- * FALSE : Undefined opcode
- ******************************************************************************/
-BOOL CANCommandidOpcToUserCvt(uint8_t uc_opc, uint8_t *puc_cmd_id) {
- BOOL ret = TRUE; /* Return value of this function */
-
- switch (uc_opc) {
- case CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX: /* CAN startup completion notice received */
- *puc_cmd_id = CAN_CMDID_STARTUP_FIN_RESP_RX;
- break;
- case CAN_OPC_COMMAND_MRST_INFO_RESP_RX: /* CAN Master Reset Information Notification Reception */
- *puc_cmd_id = CAN_CMDID_MRST_INFO_RESP_RX;
- break;
- case CAN_OPC_COMMAND_VERSION_RESP_RX: /* CAN Version Response Reception */
- *puc_cmd_id = CAN_CMDID_VERSION_RESP_RX;
- break;
- case CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX: /* Receive CAN Connection Node Notification Response */
- *puc_cmd_id = CAN_CMDID_CONNECTION_NODE_RESP_RX;
- break;
- case CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX: /* RECEIVE REQUEST FREE OF CAN SECTION */
- *puc_cmd_id = CAN_CMDID_FUELCALC_RST_REQ_RX;
- break;
- default:
- ret = FALSE; /* Undefined opcode */
- break;
+EFrameworkunifiedStatus CANTxMsg(HANDLE h_app) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "@@@ Start communication CanSend");
+
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ CAN_TRANSMISSION_START_MSG_DAT rcv_msg;
+ CanMessage snd_msg;
+ memset(&rcv_msg, 0, sizeof(rcv_msg));
+ memset(&snd_msg, 0, sizeof(snd_msg));
+
+ e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &rcv_msg, sizeof(rcv_msg), eSMRRelease);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize Error(%d)", e_status);
+ if (e_status == eFrameworkunifiedStatusInvldBufSize)
+ FrameworkunifiedClearMsgData(h_app);
+ goto cleanup;
}
- return (ret);
-}
+ e_status = eFrameworkunifiedStatusFail;
-/*******************************************************************************
- * MODULE : CANCommandidUserToOpcCvt
- * ABSTRACT : CAN command ID conversion process 2
- * FUNCTION : Convert the CAN command ID to the corresponding opcode
- * ARGUMENT : uc_cmd_id : CAN command ID
- * puc_opc : Opcode return pointer
- * NOTE :
- * RETURN : TRUE : Predefined ID
- * FALSE : Undefined ID
- ******************************************************************************/
-BOOL CANCommandidUserToOpcCvt(uint8_t uc_cmd_id, uint8_t *puc_opc) {
- BOOL ret = TRUE; /* Return value of this function */
-
- switch (uc_cmd_id) {
- case CAN_CMDID_STARTUP_FIN_REQ_TX: /* CAN start completion notification request transmission */
- *puc_opc = CAN_OPC_COMMAND_STARTUP_FIN_REQ_TX;
- break;
- case CAN_CMDID_MRST_INFO_REQ_TX: /* CAN master reset information notification request transmission */
- *puc_opc = CAN_OPC_COMMAND_MRST_INFO_REQ_TX;
- break;
- case CAN_CMDID_VERSION_REQ_TX: /* CAN Version Request Send */
- *puc_opc = CAN_OPC_COMMAND_VERSION_REQ_TX;
- break;
- case CAN_CMDID_CONNECTION_NODE_REQ_TX: /* CAN connection node notification request transmission */
- *puc_opc = CAN_OPC_COMMAND_CONNECTION_NODE_REQ_TX;
- break;
- case CAN_CMDID_FUELCALC_REQ_TX: /* CAN section flame reset response transmission */
- *puc_opc = CAN_OPC_COMMAND_FUELCALC_REQ_TX;
- break;
- default:
- ret = FALSE; /* Undefined ID */
- break;
+ if (TRUE != CommGetAvailabilityCurrent(CAN_AVAILABILITY)) {
+ CANTxMsgErrorLog("CAN is not ready", __func__, 0, 0, h_app);
+ goto cleanup;
}
- return (ret);
+ snd_msg.can_id = rcv_msg.stCandata.can_id;
+ snd_msg.dlc = rcv_msg.stCandata.dlc;
+ snd_msg.rid = rcv_msg.ucRid;
+ memcpy(snd_msg.data, rcv_msg.stCandata.data, snd_msg.dlc);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "@@@ Call CanSend for can_hal : "
+ "can_id=%x dlc=%d rid=%x", snd_msg.can_id, snd_msg.dlc, snd_msg.rid);
+ FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "msg_data=%s",
+ MessageDataOutputLog(snd_msg.data, snd_msg.dlc).c_str());
+
+ if (CANHAL_RET_NORMAL != CanSend(h_app, &snd_msg, CAN_HAL_TYPE_CAN)) {
+ CANTxMsgErrorLog("CAN CanSend failed", __func__, snd_msg.can_id,
+ (uint16_t)snd_msg.dlc, h_app);
+ goto cleanup;
+ }
+
+ // echoback
+ e_status = CANDeliverySndMsg(h_app, snd_msg.can_id, 0, (uint8_t)snd_msg.dlc,
+ (const uint8_t *)snd_msg.data,
+ CID_CAN_DATA_DELIVERY, CANIF_ECHOBACK);
+ if (rcv_msg.ucRid == (uint8_t)CAN_RID_NOTUSE_CODE)
+ goto cleanup;
+
+ if (0 < g_m_send_sts.count(snd_msg.can_id)) {
+ if (g_m_send_sts[snd_msg.can_id].notify_name[0] != 0x00) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__,
+ "Not yet deliver SendSts but updated(SendID=%x, CAN ID=%x, Nane=%s)",
+ g_m_send_sts[snd_msg.can_id].rid, snd_msg.can_id,
+ g_m_send_sts[snd_msg.can_id].notify_name);
+ }
+ }
+
+ g_m_send_sts[snd_msg.can_id].rid = rcv_msg.ucRid;
+ memcpy(g_m_send_sts[snd_msg.can_id].notify_name,
+ rcv_msg.notifyName,
+ sizeof(g_m_send_sts[snd_msg.can_id].notify_name));
+cleanup:
+ return e_status;
}
-/*!-----------------------------------------------------------------------------
- * @~english
- * @brief Transmission CAN Command
- *
- * @~english
- * @return Return value
- * @retval <TRUE> Transmission success
- * @retval <FALSE> Transmission failed
- *
- * @~english
- * @param[in] <id> CAN ID
- * @param[in] <dlc> DLC
- * @param[in] <pst_data> CAN Data structure
- */
-BOOL CANTransStartTxMsgCore(HANDLE h_app, CANID id, uint8_t dlc, CAN_DATA_BIT *pst_data) {
- BOOL b_ret = FALSE;
-// CanMessage st_can_data;
-//
-// if (pst_data != NULL) { // LCOV_EXCL_BR_LINE 200: puc_data is a pointer of global variable
-// st_can_data.can_id = id;
-// st_can_data.rid = CAN_RID_NOTUSE_CODE;
-// st_can_data.dlc = dlc;
-// memcpy(st_can_data.data, pst_data->dat, dlc);
-
-// if (CanSend(&st_can_data, CAN_HAL_TYPE_CAN) != CANHAL_RET_NORMAL) {
-// b_ret = FALSE;
-// } else {
-// b_ret = TRUE;
-// }
-// }
-
- return b_ret;
-} // LCOV_EXCL_BR_LINE 10: end of line unknown branch
+EFrameworkunifiedStatus CANSndStsProcess(HANDLE h_app, CanSendResult *rcv_msg,
+ PS_CommunicationProtocol cid) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ CAN_MSG_SENDSTS snd_msg;
+ CANID can_id = rcv_msg->can_id;
+ HANDLE sender = NULL;
+ memset(&snd_msg, 0, sizeof(snd_msg));
+
+ if (0 == g_m_send_sts.count(can_id))
+ goto cleanup;
+
+ if (0x00 == (g_m_send_sts[can_id].notify_name[0]))
+ goto cleanup;
+
+ if (rcv_msg->rid != g_m_send_sts[can_id].rid)
+ goto cleanup;
+
+ snd_msg.hdr.hdr.cid = (uint16_t)cid;
+ snd_msg.hdr.hdr.msgbodysize = (uint16_t)(sizeof(snd_msg.data));
+ snd_msg.hdr.hdr.rid = rcv_msg->rid;
+ snd_msg.data.ulCanid = can_id;
+ snd_msg.data.ucStatus =
+ (CAN_SEND_RESULT_SUCCESS == rcv_msg->result) ? CAN_SUCCESS : CAN_RETRYOUT;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "cid=%x msgbodysize=%d rid=%x can_id=%x ucStatus=%x",
+ snd_msg.hdr.hdr.cid, snd_msg.hdr.hdr.msgbodysize, snd_msg.hdr.hdr.rid,
+ snd_msg.data.ulCanid, snd_msg.data.ucStatus);
+
+ sender = CommonFindSender(h_app, g_m_send_sts[can_id].notify_name);
+ if (!sender) {
+ CANTxMsgErrorLog("Could not open sender.", __func__, can_id,
+ sizeof(snd_msg), h_app);
+ goto cleanup;
+ }
+
+ e_status = FrameworkunifiedSendMsg(sender, cid, sizeof(snd_msg), &snd_msg);
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error(e_status:%d to:%s)",
+ e_status, g_m_send_sts[can_id].notify_name);
+ g_m_send_sts[can_id].notify_name[0] = 0x00;
+ g_m_send_sts[can_id].rid = 0x00;
+ goto cleanup;
+ }
+ g_m_send_sts[can_id].notify_name[0] = 0x00;
+ g_m_send_sts[can_id].rid = 0x00;
+
+ e_status = eFrameworkunifiedStatusOK;
+cleanup:
+ return e_status;
+}
diff --git a/communication/server/src/main/communication_application.cpp b/communication/server/src/main/communication_application.cpp
index 44049492..7240cdb9 100644
--- a/communication/server/src/main/communication_application.cpp
+++ b/communication/server/src/main/communication_application.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,15 +14,10 @@
* limitations under the License.
*/
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup tag_TE_Calculator
-/// \brief
-///
-///
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
+/*
+ * This file has been generated automatically.
+ * User hand written code entry is allowed only inside protected zones.
+ */
/*
* This file has been generated automatically.
@@ -37,94 +32,22 @@
#include <peripheral_service/Canif_API.h>
#include <stdio.h>
#include <signal.h>
+#include <string>
+#include <sstream>
+#include <iostream>
#include "communication_cid.h"
#include "communication_communicationlog.h"
-#include "ICR_Common.h"
#include "Thread_Common.h"
-#define NTFY_CommSH4A_Availability "CommSH4A/Availability"
-#define TIMER_SEM_NAME "TIMER_SEM"
-#define INT_SEM_NAME "INT_SEM"
-#define SENDRECV_SEM_NAME "SENDRECV_SEM"
-
-/*------------------------------------------------------------------------------
- * function declaration
- *----------------------------------------------------------------------------*/
-EFrameworkunifiedStatus CommSysCanReady(HANDLE h_app);
-EFrameworkunifiedStatus CallbackCommSH4AAvailability(HANDLE h_app);
-EFrameworkunifiedStatus CANThreadStart(HANDLE h_app);
-EFrameworkunifiedStatus CANThreadStop(HANDLE h_app);
-
-/*------------------------------------------------------------------------------
- * static variables
- *----------------------------------------------------------------------------*/
-HANDLE g_can_thread = NULL;
-
-BOOL g_can_ready = FALSE;
-BOOL g_commsh4a_ready = FALSE;
-
-BOOL g_isaccoff = FALSE; // CAN_TxMsg.cpp needs this
-
-static const FrameworkunifiedProtocolCallbackHandler kCommPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
- {CID_COMMSYS_CAN_READY, CommSysCanReady},
-};
-
-static const FrameworkunifiedNotificationCallbackHandler kCommsysNotificationHandlers[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT (whitespace/line_length)
- {NTFY_CommSH4A_Availability, CallbackCommSH4AAvailability},
-};
-
-EFrameworkunifiedStatus CommSysReadyCheck(HANDLE h_app) {
- EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- e_status = FrameworkunifiedPublishServiceAvailability(h_app, TRUE);
- if (eFrameworkunifiedStatusOK != e_status) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
- "Failed to Publish Service Availability Notification.");
- }
- return e_status;
-}
-
-EFrameworkunifiedStatus CallbackCommSH4AAvailability(HANDLE h_app) {
- EFrameworkunifiedStatus e_status;
- ServiceAvailability tServiceAvailability;
-
- // Read the data from the message
- e_status = FrameworkunifiedGetMsgDataOfSize(h_app, &tServiceAvailability, sizeof(tServiceAvailability), 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
- if (e_status == eFrameworkunifiedStatusInvldBufSize) {
- EFrameworkunifiedStatus e_statusClear = FrameworkunifiedClearMsgData(h_app);
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedClearMsgData (e_status = %d)", e_statusClear);
- }
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize Failed");
- return e_status;
- }
- // LCOV_EXCL_STOP 4: NSFW error case.
-
- // Service Availability
- if (eFrameworkunifiedServiceAvailable != tServiceAvailability.eServiceAvailability) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_DEBUG, __func__, "[%s] Availability is FALSE.", tServiceAvailability.cServiceName); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
- return e_status;
- } else {
- g_commsh4a_ready = TRUE;
- FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "[%s] Availability is TRUE.", tServiceAvailability.cServiceName); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT (whitespace/line_length)
- }
-
- CommSysReadyCheck(h_app);
- return eFrameworkunifiedStatusOK;
-}
+extern EFrameworkunifiedStatus CANThreadStart(HANDLE h_app);
+extern EFrameworkunifiedStatus CANThreadStop(HANDLE h_app);
-EFrameworkunifiedStatus CommSysCanReady(HANDLE h_app) {
- g_can_ready = TRUE;
- CommSysReadyCheck(h_app);
- return eFrameworkunifiedStatusOK;
-}
+HANDLE g_can_thread = NULL;
EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
- // Return Status
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- /*UserCodeStartCommunicationOnInitialization*/
+
+ CommonInit();
// API to Register Notification for Service Availability.
e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app,
@@ -147,81 +70,54 @@ EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
"Service Availability Notification published successfully.");
}
- // Attach callback api to dispatcher for to notify availability
- e_status = FrameworkunifiedAttachCallbacksToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE,
- kCommPcbhs, _countof(kCommPcbhs));
- if (e_status != eFrameworkunifiedStatusOK) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
- "FrameworkunifiedAttachCallbacksToDispatcher Error(%d)", e_status);
- exit(EXIT_FAILURE);
- }
-
- // FIXME : Following code is really needed?
- // Subscribe to service availability
- e_status = FrameworkunifiedSubscribeNotificationsWithCallback(h_app,
- kCommsysNotificationHandlers, _countof(kCommsysNotificationHandlers));
- if (eFrameworkunifiedStatusOK != e_status) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Failed to FrameworkunifiedSubscribeNotificationsWithCallback.");
- exit(EXIT_FAILURE);
- }
-
g_can_thread = FrameworkunifiedCreateChildThread(h_app, LAN_SERVICE_CAN,
CANThreadStart, CANThreadStop);
if (g_can_thread == NULL) {
FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to create CAN");
}
- /*UserCodeEndCommunicationOnInitialization*/
+ // API to Publish Service Availability Notification.
+ e_status = FrameworkunifiedPublishServiceAvailability(h_app, TRUE);
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to Publish Service Availability Notification.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Service Availability Notification published successfully.");
+ }
+
return e_status;
}
-// LCOV_EXCL_START 8: (dead code there is no function in wakeup)
EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 8: (dead code there is no function in wakeup)
-// LCOV_EXCL_START 14 Resident process, not called by NSFW
EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
-// LCOV_EXCL_START 14 Resident process, not called by NSFW
EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
-// LCOV_EXCL_START 14 Resident process, not called by NSFW
EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
-// LCOV_EXCL_START 7: Debug Code
EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 7: Debug Code
-// LCOV_EXCL_START 8:(dead code do not use StateMachine)
EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) {
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
return e_status;
}
-// LCOV_EXCL_STOP 8:(dead code do not use StateMachine)
static EFrameworkunifiedStatus CommThreadCheckAndStart(HANDLE p, HANDLE c,
UI_32 len, PCVOID data, BOOL current) {
@@ -245,15 +141,6 @@ EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) {
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[START]");
- e_status = FrameworkunifiedPublishServiceAvailability(h_app, FALSE);
- if (eFrameworkunifiedStatusOK != e_status) {
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
- "Failed to Publish Service Availability Notification.");
- } else {
- FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
- "Service Availability Notification published successfully.");
- }
-
e_status = CommThreadCheckAndStart(h_app, g_can_thread,
0, NULL, CommGetAvailabilityCurrent(CAN_AVAILABILITY));
if (eFrameworkunifiedStatusOK != e_status) {
@@ -267,7 +154,6 @@ EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) {
EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
- g_isaccoff = TRUE;
e_status = CommThreadCheckAndStop(h_app, g_can_thread,
0, NULL, CommGetAvailabilityCurrent(CAN_AVAILABILITY));
@@ -279,11 +165,10 @@ EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
}
return e_status;
-} // LCOV_EXCL_LINE 10: final line
+}
EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app) {
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
-
FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[START]");
e_status = CommThreadCheckAndStart(h_app, g_can_thread,
@@ -326,4 +211,16 @@ EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app) {
FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
return e_status;
-} // LCOV_EXCL_BR_LINE 10:Gcov constraints (last row)
+}
+
+std::string MessageDataOutputLog(uint8_t *msg_data, uint32_t len){
+ std::string data_log;
+ int data_buf;
+ for(uint32_t i = 0; i < len; i++){
+ std::ostringstream ss;
+ data_buf = (int)msg_data[i];
+ ss << std::hex << data_buf;
+ data_log = ss.str() + " " + data_log;
+ }
+ return data_log;
+}
diff --git a/communication/server/src/main/communication_main.cpp b/communication/server/src/main/communication_main.cpp
index 5fcb428a..39daae14 100644
--- a/communication/server/src/main/communication_main.cpp
+++ b/communication/server/src/main/communication_main.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,21 +14,6 @@
* limitations under the License.
*/
-///////////////////////////////////////////////////////////////////////////////
-/// \ingroup
-/// \brief
-///
-///
-///
-///
-///
-///////////////////////////////////////////////////////////////////////////////
-
-/*
- * This file has been generated automatically.
- * User hand written code entry is allowed only inside protected zones.
- */
-
#include <errno.h>
#include <sys/timerfd.h>
#include <unistd.h>
@@ -48,9 +33,9 @@
#include "CAN_Thread.h"
#include "Thread_Common.h"
-CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION); // NOLINT (readability/naming)
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
-FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT (readability/naming)
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
FRAMEWORKUNIFIEDLOGOPTIONS,
{ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
@@ -63,42 +48,71 @@ FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT (readability
FRAMEWORKUNIFIEDLOGZONES};
extern HANDLE g_can_thread;
+static bool capture_log_flg = FALSE;
#define COMMSYS_SND_ERR_CNT_MAX 10
-//////////////////////////////////////////
-// Function : main
-//////////////////////////////////////////
+static void MessageHandler(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ e_status = FrameworkunifiedDispatchProcessWithoutLoop(h_app);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ // Ignore Error. Logging only.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedDispatchProcessWithoutLoop: %d", e_status);
+ }
+}
+
+static void TimeoutHandlerCAN(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ uint32_t dummy = 0;
+ static uint32_t snd_err_cnt_can = 0;
+
+ if (CommGetAvailabilityCurrent(CAN_AVAILABILITY)) {
+ e_status = FrameworkunifiedSendChild(h_app, g_can_thread,
+ CID_COMMSYS_TIMEOUT, 0, &dummy);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ snd_err_cnt_can++;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__,
+ "FrameworkunifiedSendChild(timeout for can) faild: %d", e_status);
+
+ if (capture_log_flg)
+ return;
+
+ if (snd_err_cnt_can < COMMSYS_SND_ERR_CNT_MAX)
+ return;
+
+ SendUserInvokedLoggingRequestToSystemManager(
+ e_SS_SM_CAPTURE_DTC_LOGS, "Send CAN TimeoutNtfy Error");
+ capture_log_flg = true;
+ } else {
+ snd_err_cnt_can = 0;
+ }
+ }
+}
int main(int argc, char *argv[]) {
EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
FrameworkunifiedDefaultCallbackHandler cb_funcs;
- FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cb_funcs); // LCOV_EXCL_BR_LINE 15:marco defined in "system_service/ss_system_if.h"
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cb_funcs);
HANDLE h_app;
- FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIED_SET_ZONES();
struct pollfd fds[2];
int ret;
- uint32_t dummy = 0;
- uint32_t snd_err_cnt_can = 0;
- BOOL capture_log_flg = FALSE; // Log save flag(Saved:TRUE, Unsaved:FALSE)
- e_status = FrameworkunifiedCreateDispatcherWithoutLoop(LAN_SERVICE_MAIN, h_app, argc, argv, &cb_funcs, TRUE); // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT (whitespace/line_length)
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedCreateDispatcherWithoutLoop: %d", e_status); // LCOV_EXCL_LINE 4: NSFW error case.
+ e_status = FrameworkunifiedCreateDispatcherWithoutLoop(LAN_SERVICE_MAIN,
+ h_app, argc, argv, &cb_funcs, TRUE);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedCreateDispatcherWithoutLoop: %d", e_status);
return EXIT_FAILURE;
}
- e_status = FrameworkunifiedGetDispatcherFD(h_app, &fds[0].fd); // LCOV_EXCL_BR_LINE 11:Unexpected branch
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetDispatcherFD: %d", e_status); // LCOV_EXCL_LINE 4: NSFW error case.
+ e_status = FrameworkunifiedGetDispatcherFD(h_app, &fds[0].fd);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetDispatcherFD: %d", e_status);
return EXIT_FAILURE;
}
- if ((fds[1].fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)) == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case. // NOLINT (whitespace/line_length)
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_create: %d", errno); // LCOV_EXCL_LINE 5: timerfd_create's error case.
+ if ((fds[1].fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_create: %d", errno);
return EXIT_FAILURE;
}
@@ -107,53 +121,34 @@ int main(int argc, char *argv[]) {
tm.it_value.tv_nsec = 100 * 1000 * 1000;
tm.it_interval.tv_sec = 0;
tm.it_interval.tv_nsec = 100 * 1000 * 1000;
- if (timerfd_settime(fds[1].fd, 0, &tm, NULL) == -1) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime: %d", errno); // LCOV_EXCL_LINE 5: timerfd_create's error case.
+ if (timerfd_settime(fds[1].fd, 0, &tm, NULL) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime: %d", errno);
return EXIT_FAILURE;
}
fds[0].events = POLLIN;
fds[1].events = POLLIN;
while (1) {
- ret = poll(fds, sizeof(fds) / sizeof(struct pollfd), -1); // LCOV_EXCL_BR_LINE 5: poll's error case.
- if (ret < 0) { // LCOV_EXCL_BR_LINE 5: poll's error case.
- // LCOV_EXCL_START 5: poll's error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- if (errno == EINTR) { /* signal interrupt */
+ ret = poll(fds, sizeof(fds) / sizeof(struct pollfd), -1);
+ if (ret < 0) {
+ if (errno == EINTR) {
continue;
}
FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "poll errno:%d", errno);
- // LCOV_EXCL_STOP 5: poll's error case.
- } else {
- if ((fds[0].revents & POLLIN) != 0) {
- e_status = FrameworkunifiedDispatchProcessWithoutLoop(h_app); // LCOV_EXCL_BR_LINE 11:Unexpected branch
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedDispatchProcessWithoutLoop: %d", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
- }
- } else if ((fds[1].revents & POLLIN) != 0) { // LCOV_EXCL_BR_LINE 5: poll's error case.
- // Timeout
- uint64_t exp;
- read(fds[1].fd, &exp, sizeof(uint64_t)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
-
- // Timeout notification to the CAN thread
- if (CommGetAvailabilityCurrent(CAN_AVAILABILITY)) {
- e_status = FrameworkunifiedSendChild(h_app, g_can_thread, CID_COMMSYS_TIMEOUT, 0, &dummy); // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT (whitespace/line_length)
- if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
- AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
- snd_err_cnt_can++; // LCOV_EXCL_LINE 4: NSFW error case.
- FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendChild(timeout for can) faild: %d", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
- if (!capture_log_flg && (snd_err_cnt_can >= COMMSYS_SND_ERR_CNT_MAX)) { // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
- SendUserInvokedLoggingRequestToSystemManager(e_SS_SM_CAPTURE_DTC_LOGS, "Send CAN TimeoutNtfy Error"); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
- capture_log_flg = TRUE; // LCOV_EXCL_LINE 4: NSFW error case.
- }
- } else {
- snd_err_cnt_can = 0;
- }
- }
- }
+ continue;
+ }
+
+ if ((fds[0].revents & POLLIN) != 0) {
+ MessageHandler(h_app);
+ continue;
+ }
+
+ if ((fds[1].revents & POLLIN) != 0) {
+ uint64_t exp;
+ read(fds[1].fd, &exp, sizeof(uint64_t));
+ TimeoutHandlerCAN(h_app);
+ continue;
}
}
return EXIT_SUCCESS;
-} // LCOV_EXCL_LINE 10: final line
+} \ No newline at end of file
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 <poll.h> //NOLINT (build/include)
+#include <poll.h>
#include <sys/timerfd.h>
}
#include <native_service/frameworkunified_types.h>
@@ -40,126 +25,109 @@ extern "C" {
#include <native_service/frameworkunified_timer.h>
#include <peripheral_service/Canif_API.h>
#include <peripheral_service/communication_notifications.h>
-//#include <can_hal.h>
+#include <can_hal.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <agl_thread.h>
#include <string>
#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<T_ICR_CMD_DATA *>(&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<uint8_t>(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<T_ICR_CMD_DATA *>(&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<CAN_MSG_DATA *>(&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<CAN_MSG_DATA *>(&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<CAN_MSG_DATA *>(&rcv_msg));
-// } else {
- /* CANDataReceive message processing of transmission result */
-// l_ret = CANTxRsltReceiveMsg(h_app, reinterpret_cast<CAN_MSG_DATA *>(&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<CAN_MSG_DATA *>(msg_ptr);
- data_p = reinterpret_cast<uint8_t *>(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<char *>(&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 <stdint.h>
#include <boost/atomic.hpp>
+#include <pthread.h>
+
#include <native_service/frameworkunified_types.h>
#include <native_service/frameworkunified_framework_if.h>
#include <native_service/frameworkunified_timer.h>
#include <agl_thread.h>
-//#include <can_hal.h>
+#include <can_hal.h>
#include "communication_communicationlog.h"
#include "communication_cid.h"
#include "Thread_Common.h"
-static boost::atomic<int32_t> availabilityMask;
+static std::map<std::string, HANDLE> g_map_sender;
+static pthread_mutex_t g_sender_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
static boost::atomic<int32_t> 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<std::string, HANDLE>::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;
+}
diff --git a/peripheral_service.mk b/peripheral_service.mk
index e30aa90e..c0547221 100644
--- a/peripheral_service.mk
+++ b/peripheral_service.mk
@@ -1,7 +1,7 @@
#############################################################
#
# Common Makefile for peripheral_service
-# Copyright (C) 2017-2019 TOYOTA MOTOR CORPORATION
+# Copyright (C) 2017-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.