summaryrefslogtreecommitdiffstats
path: root/communication
diff options
context:
space:
mode:
Diffstat (limited to 'communication')
-rw-r--r--communication/LICENSE177
-rw-r--r--communication/Makefile.client18
-rw-r--r--communication/Makefile.server18
-rw-r--r--communication/client_can/Makefile73
-rw-r--r--communication/client_can/include/Canif_API_Local.h103
-rw-r--r--communication/client_can/include/peripheral_service/Canif_API.h1509
-rw-r--r--communication/client_can/include/peripheral_service/communication_can.h28
-rw-r--r--communication/client_can/libCAN_API.ver38
-rw-r--r--communication/client_can/src/Canif_API.cpp852
-rw-r--r--communication/server/Makefile113
-rw-r--r--communication/server/include/CAN/CommWatch/CAN_CommWatch.h49
-rw-r--r--communication/server/include/CAN/CommWatch/CAN_CommWatchData.h125
-rw-r--r--communication/server/include/CAN/Command/CAN_Command.h42
-rw-r--r--communication/server/include/CAN/Command/CAN_CommandData.h96
-rw-r--r--communication/server/include/CAN/Delivery/CAN_Delivery.h48
-rw-r--r--communication/server/include/CAN/Delivery/CAN_DeliveryData.h140
-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.h116
-rw-r--r--communication/server/include/com_error_type.h35
-rw-r--r--communication/server/include/main/communication_cid.h47
-rw-r--r--communication/server/include/main/communication_communicationlog.h94
-rw-r--r--communication/server/include/main/communication_version.h45
-rw-r--r--communication/server/include/peripheral_service/communication.h29
-rw-r--r--communication/server/include/peripheral_service/communication_notifications.h28
-rw-r--r--communication/server/include/peripheral_service/ps_services.h94
-rw-r--r--communication/server/include/private/ICR_Common.h30
-rw-r--r--communication/server/include/threads/CAN_Thread.h158
-rw-r--r--communication/server/include/threads/Thread_Common.h32
-rw-r--r--communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp268
-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.cpp349
-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.cpp961
-rw-r--r--communication/server/src/main/communication_application.cpp329
-rw-r--r--communication/server/src/main/communication_main.cpp159
-rw-r--r--communication/server/src/threads/CAN_Thread.cpp551
-rw-r--r--communication/server/src/threads/Thread_Common.cpp170
44 files changed, 10459 insertions, 0 deletions
diff --git a/communication/LICENSE b/communication/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/communication/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/communication/Makefile.client b/communication/Makefile.client
new file mode 100644
index 00000000..8ba47d4b
--- /dev/null
+++ b/communication/Makefile.client
@@ -0,0 +1,18 @@
+#
+# @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.
+#
+SUBDIRS = client_can
+
+include ../peripheral_service.mk
diff --git a/communication/Makefile.server b/communication/Makefile.server
new file mode 100644
index 00000000..ca58ea62
--- /dev/null
+++ b/communication/Makefile.server
@@ -0,0 +1,18 @@
+#
+# @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.
+#
+SUBDIRS = server
+
+include ../peripheral_service.mk
diff --git a/communication/client_can/Makefile b/communication/client_can/Makefile
new file mode 100644
index 00000000..e94c5261
--- /dev/null
+++ b/communication/client_can/Makefile
@@ -0,0 +1,73 @@
+#
+# @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.
+#
+
+######### installed program #############
+#INST_PROGS =
+
+######### installed library(*.a) #############
+#INST_LIBS =
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libCAN_API
+
+######### install unit representative headers(*.h) #############
+VPATH += ../server/include/$(COMPONENT_NAME)
+INST_HEADERS += communication_notifications.h communication.h ps_services.h
+
+######### install headers(*.h) #############
+VPATH += ./include/$(COMPONENT_NAME)
+INST_HEADERS += Canif_API.h communication_can.h
+
+######### compiled sources #############
+libCAN_API_SRCS += Canif_API.cpp
+
+######### add source path #############
+VPATH += ./src
+
+######### add include path #############
+CPPFLAGS += -I./include
+CPPFLAGS += -I./../client_lan/include/
+CPPFLAGS += -I./../server/include
+CPPFLAGS += -I./../server/include/private
+CPPFLAGS += -I./../server/include/CAN/TxMsg
+CPPFLAGS += -I./../server/include/CAN/main
+CPPFLAGS += -I./../server/include/main
+CPPFLAGS += -I./../server/include/threads
+
+######### add compile option #############
+CPPFLAGS += -DLINUX -fPIC -fdata-sections -ffunction-sections -DFLG_CORE
+
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+######### add library path #############
+LDFLAGS += -Wl,-M -Wl,--gc-sections
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -Wl,--no-undefined
+
+######### linked library (static) #############
+
+######### 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/Canif_API_Local.h b/communication/client_can/include/Canif_API_Local.h
new file mode 100644
index 00000000..9ab205ad
--- /dev/null
+++ b/communication/client_can/include/Canif_API_Local.h
@@ -0,0 +1,103 @@
+/*
+ * @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 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
+
+/*********************************************************************
+* 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;
+
+/* 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 */
+
+#if defined(__cplusplus)
+}
+#endif
+#endif // COMMUNICATION_CLIENT_CAN_INCLUDE_CANIF_API_LOCAL_H_
diff --git a/communication/client_can/include/peripheral_service/Canif_API.h b/communication/client_can/include/peripheral_service/Canif_API.h
new file mode 100644
index 00000000..d522c5a1
--- /dev/null
+++ b/communication/client_can/include/peripheral_service/Canif_API.h
@@ -0,0 +1,1509 @@
+/*
+ * @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 Canif_API.h
+ * TITLE :Data header files needed to use the CAN I/F API
+ ****************************************************************************/
+
+#ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
+#define COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
+
+/**
+ * @file Canif_API.h
+ * @~english
+ * @brief Canif API header
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup peripheral_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup communication
+ * @ingroup peripheral_service
+ * @{
+ */
+/** @addtogroup CAN
+ * @ingroup communication
+ * @{
+ */
+
+#include <native_service/frameworkunified_types.h>
+#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
+
+/**
+ * \~english Defination of Service name
+ */
+#define LAN_SERVICE_CAN "CAN_COM_PROT"
+
+/**
+ * \~english Availability notification of CAN
+ */
+#define NTFY_Communication_CAN_ISAVAILABLE "Communication/CanIsAvailable"
+
+/*********************************************************************
+* Defining Return Values
+***********************************************************************/
+/* Normal system */
+/**
+ * \~english Suceess
+ */
+#define CANIF_RET_NORMAL 1
+/* Abnormal system */
+/**
+ * \~english Parameter error
+ */
+#define CANIF_RET_ERROR_PARAM 2
+/**
+ * \~english Buffer Full
+ */
+#define CANIF_RET_ERROR_BUFFULL 3
+/**
+ * \~english CAN ID FULL
+ */
+#define CANIF_RET_ERROR_CANIDFULL 4
+/**
+ * \~english ID unregister
+ */
+#define CANIF_RET_ERROR_UNDEF 5
+/**
+ * \~english Thread ID unmatched
+ */
+#define CANIF_RET_ERROR_PID 6
+/**
+ * \~english Timer error
+ */
+#define CANIF_RET_ERROR_TIMER 7
+/**
+ * \~english Event Creat Error
+ */
+#define CANIF_RET_ERROR_CREATE_EVENT 8
+/**
+ * \~english Error Cancel
+ */
+#define CANIF_RET_ERROR_CANCEL 9
+/**
+ * \~english Null Pointer
+ */
+#define CANIF_RET_ERROR_NULL 10
+
+/**
+ * \~english Defination of Command ID ( CAN -> user )
+ */
+typedef enum _PS_CommunicationProtocol {
+ /**
+ * \~english Delivery CAN Data
+ */
+ CID_CAN_DATA_DELIVERY = 0x0401,
+ /**
+ * \~english CAN communication stop
+ */
+ CID_CAN_COMM_STOP,
+ /**
+ * \~english CAN communication restore
+ */
+ CID_CAN_COMM_RESTORE,
+ /**
+ * \~english CAN transmission result
+ */
+ 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,
+ /**
+ * \~english CAN command transmission result
+ */
+ CID_CAN_CMD_TX_RESULT,
+ /**
+ * \~english Delivery CAN data to CANGW
+ */
+ CID_CAN_CANGW_DELIVERY,
+} PS_CommunicationProtocol;
+
+/**
+ * \~english Defination of Command ID ( CANIF -> CAN )
+ */
+typedef enum _PS_Communication_InternalProtocol {
+ /**
+ * \~english Delivery registration of CAN data
+ */
+ CID_CANIF_DELIVERY_ENTRY = 0x0501,
+ /**
+ * \~english Delivery registration of _CWORD29_data
+ */
+ CID_CANIF__CWORD29__DELIVERY_ENTRY,
+ /**
+ * \~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,
+ /**
+ * \~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
+***********************************************************************/
+/**
+* \~english Request CAN fuel calculator reset
+*/
+#define CAN_CMDID_FUELCALC_RST_REQ_DELIVERY 0x00
+/**
+* \~english Request CAN startup finished notification
+*/
+#define CAN_CMDID_STARTUP_FIN_REQ_TX 0x01
+/**
+* \~english Request CAN Master reset notification
+*/
+#define CAN_CMDID_MRST_INFO_REQ_TX 0x02
+/**
+* \~english Request CAN version
+*/
+#define CAN_CMDID_VERSION_REQ_TX 0x03
+/**
+* \~english Request CAN connected node notification
+*/
+#define CAN_CMDID_CONNECTION_NODE_REQ_TX 0x04
+/**
+* \~english Request CAN BUS status notification
+* ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
+*/
+#define CAN_CMDID_BUS_STATUS_REQ_TX 0x05
+/**
+* \~english Response of CAN fuel calculator reset
+*/
+#define CAN_CMDID_FUELCALC_REQ_TX 0x06
+/**
+* \~english Receive CAN fuel calculator reset request
+*/
+#define CAN_CMDID_FUELCALC_RST_REQ_RX 0x07
+/**
+* \~english Receive CAN startup finished notification
+*/
+#define CAN_CMDID_STARTUP_FIN_RESP_RX 0x08
+/**
+* \~english Receive CAN Master reset notification
+*/
+#define CAN_CMDID_MRST_INFO_RESP_RX 0x09
+/**
+* \~english Response of CAN version receive
+*/
+#define CAN_CMDID_VERSION_RESP_RX 0x0A
+/**
+* \~english Response of CAN connection node receive
+*/
+#define CAN_CMDID_CONNECTION_NODE_RESP_RX 0x0B
+/**
+* \~english Response of CAN bus status receive
+* ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
+*/
+#define CAN_CMDID_BUS_STATUS_RESP_RX 0x0C
+
+/*********************************************************************
+* Control Flag/Status Definition
+***********************************************************************/
+/* CANData Delivery control flag */
+/**
+* \~english Delivery stop
+*/
+#define CAN_DELIVERY_STOP 0
+/**
+* \~english Delivery restart
+*/
+#define CAN_DELIVARY_RESTART 1
+
+/* CANData Transmission result notification status */
+/**
+* \~english Success
+*/
+#define CAN_SUCCESS 0
+/**
+* \~english Retryout
+*/
+#define CAN_RETRYOUT 1
+/**
+* \~english Send buffer full
+*/
+#define CAN_BUFFERFUL 2
+
+/* IG linkage type */
+/**
+* \~english IG cooperation off
+*/
+#define CAN_IG_COOPERATION_OFF 0
+/**
+* \~english IG cooperation on
+*/
+#define CAN_IG_COOPERATION_ON 1
+
+/* N_TA */
+/**
+* \~english Invalid target address
+*/
+#define CAN_NTA_INVALID 0xFF
+
+/* Others */
+/**
+* \~english The code of resource ID which is not used
+*/
+#define CAN_RID_NOTUSE_CODE 0xFF
+
+/*********************************************************************
+* Data size definition
+***********************************************************************/
+/**
+* \~english MAX CAN data size used to send/receive message
+*/
+#define CAN_DATA_SIZE 63
+/**
+* \~english MAX CAN data size used to send message
+*/
+#define CAN_TXDATA_SIZE 8
+
+/* Data size relationship */
+/**
+* \~english MAX number of delivery entry
+* \~english ((528-16)-12)/4 = 125 12:event ID etc. , 4:size of CAN ID
+*/
+#define CAN_DELIVERY_CANID_ENTRY_MAX 125
+
+/**
+* \~english OPC MAX number of delivery entry
+*/
+#define CAN_DELIVERY_OPC_ENTRY_MAX 255
+
+/* Message size relationship */
+/**
+* \~english MAX size of message buffer
+*/
+#define CAN_MSGBUF_MAX_SIZE 528
+/**
+* \~english Size of message buffer header
+*/
+#define CAN_MSGBUF_HEADER_SIZE 16
+/**
+* \~english MAX size of message buffer header
+*/
+#define CAN_MSGBUF_DATAMAX_SIZE (CAN_MSGBUF_MAX_SIZE - CAN_MSGBUF_HEADER_SIZE)
+
+/**
+* \~english MAX size of CAN command data
+*/
+#define CANCMD_DAT_MAX 68
+
+/**
+* \~english MAX number of CANGW transmission data
+*/
+#define CANGW_SND_NUM_MAX 0x16
+/**
+* \~english MAX length of CANGW DLC
+*/
+#define CANGW_DLC_MAX_SIZE 0x08
+
+/**
+* \~english Memory size used for _CWORD29_ can data
+*/
+#define CAN__CWORD29__MEM_SZ (4100)
+
+/*********************************************************************
+* Type definition
+***********************************************************************/
+/**
+* \~english CAN I/F API return code
+*/
+typedef int32_t CANIF_RET_API;
+/**
+* \~english define of CAN ID type
+*/
+typedef uint32_t CANID;
+
+/**
+* \~english data ID
+*/
+typedef uint32_t DID;
+
+/**
+* \~english Data struct used to transfer CAN data
+* \~english (transfer data from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english CAN ID
+ */
+ CANID can_id;
+ /**
+ * \~english Data Length
+ */
+ uint8_t dlc;
+ /**
+ * \~english reserve
+ */
+ uint8_t reserve[3];
+ /**
+ * \~english DATA[0] ~ DATA[N]
+ */
+ uint8_t data[CAN_DATA_SIZE];
+ /**
+ * \~english reserve
+ */
+ uint8_t reserve2;
+} CAN_MSG_CANDATA_DAT;
+
+/**
+* \~english Data struct used to transfer CAN message
+* \~english (transfer message from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ /**
+ * \~english data
+ */
+ CAN_MSG_CANDATA_DAT data;
+} CAN_MSG_CANDATA;
+
+/**
+* \~english Data struct used to transfer CAN data to CANGW
+* \~english (transfer data from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english CAN ID (upper byte)
+ */
+ uint8_t can_id_high;
+ /**
+ * \~english CAN ID (lower byte)
+ */
+ uint8_t can_id_low;
+ /**
+ * \~english Data Length
+ */
+ uint8_t dlc;
+ /**
+ * \~english data
+ */
+ uint8_t data[CANGW_DLC_MAX_SIZE];
+} 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)
+*/
+typedef struct {
+ /**
+ * \~english CAN data
+ */
+ CAN_MSG_CANGWDATA_DAT data[CANGW_SND_NUM_MAX];
+ /**
+ * \~english Number of CAN data(max 22)
+ */
+ uint8_t num;
+} CAN_MSG_CANGWDATA;
+
+/**
+* \~english Data struct used to transfer CAN data
+* \~english (transfer data from user to CANIF API)
+*/
+typedef struct {
+ /**
+ * \~english CAN ID
+ */
+ CANID can_id;
+ /**
+ * \~english Data Length
+ */
+ uint8_t dlc;
+ /**
+ * \~english reserve
+ */
+ uint8_t reserve[3];
+ /**
+ * \~english DATA
+ */
+ uint8_t data[CAN_DATA_SIZE + 1];
+} CAN_DATA;
+
+/**
+* \~english Data struct used to transfer CAN data
+* \~english (transfer data from CANIF API to CAN)
+*/
+typedef struct {
+ /**
+ * \~english Delivery target thread name
+ */
+ char notifyName[MAX_NAME_SIZE_APP];
+ // uint32_t notifyId; /* Addresses for delivery ID */
+ /**
+ * \~english Thread ID used by _CWORD64_
+ */
+ uint32_t ulEventId;
+ /**
+ * \~english Resource ID
+ */
+ uint8_t ucRid; /* Resources ID */
+ /**
+ * \~english Cycle of send message(Unit of 100ms)
+ */
+ uint16_t usFreq;
+ /**
+ * \~english CAN DATA
+ */
+ CAN_DATA stCandata;
+} CAN_TRANSMISSION_START_MSG_DAT;
+
+/**
+* \~english Data struct used to notify transmission result
+* \~english (transfer data from CAN API to user)
+*/
+typedef struct {
+ /**
+ * \~english CAN ID
+ */
+ CANID ulCanid;
+ /**
+ * \~english Transmission result status
+ */
+ uint8_t ucStatus;
+ /**
+ * \~english Reserve
+ */
+ uint8_t reserve[3];
+} CAN_MSG_SENDSTS_DAT;
+
+/**
+* \~english Message struct used to notify transmission result
+* \~english (transfer message from CAN API to user)
+*/
+typedef struct {
+ /**
+ * \~english header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ /**
+ * \~english Data
+ */
+ CAN_MSG_SENDSTS_DAT data;
+} 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)
+*/
+typedef struct {
+ /**
+ * \~english Delivery target thread name
+ */
+ char notifyName[MAX_NAME_SIZE_APP];
+ // uint32_t notifyId; /* Addresses for delivery ID */
+ /**
+ * \~english Event ID that use for _CWORD64_
+ */
+ uint32_t ulEventId;
+ /**
+ * \~english CAN ID
+ */
+ CANID ulCanid;
+} CAN_FREQ_TRANS_STOP_MSG_DAT;
+
+/**
+* \~english Data struct used for communication stop/restore
+* \~english (transfer message from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english Data ID
+ */
+ DID ulDid;
+} CAN_MSG_COMM_WATCHSTS_DAT;
+
+/**
+* \~english Data struct used for communication stop/restore
+* \~english (transfer message from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english Header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ /**
+ * \~english Data
+ */
+ CAN_MSG_COMM_WATCHSTS_DAT data;
+} CAN_MSG_COMM_WATCHSTS;
+
+/**
+* \~english 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];
+ // uint32_t notifyId; /* Addresses for delivery ID */
+ /**
+ * \~english Event ID use for _CWORD64_
+ */
+ uint32_t ulEventId;
+ /**
+ * \~english Number of CAN ID entry
+ */
+ uint16_t usCanNum;
+ /**
+ * \~english CAN ID entry array
+ */
+ CANID ulCanid[CAN_DELIVERY_CANID_ENTRY_MAX];
+} 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)
+*/
+typedef struct {
+ /**
+ * \~english Delivery target thread name
+ */
+ char notifyName[MAX_NAME_SIZE_APP]; /* Destination thread name */
+ /**
+ * \~english Event ID
+ */
+ uint32_t ulEvtId;
+ /**
+ * \~english CAN ID
+ */
+ CANID ulCanid;
+ /**
+ * \~english Data ID
+ */
+ DID ulDid;
+ /**
+ * \~english Watch time for commuication stop (Unit of 100ms)
+ */
+ uint16_t usWatchTime;
+} CAN_COMM_WATCH_MSG_DAT;
+
+/**
+* \~english Data struct used for CAN command control
+* \~english (transfer data from CANIF API to CAN)
+*/
+typedef struct {
+ /**
+ * \~english Delivery target thread name
+ */
+ char notifyName[MAX_NAME_SIZE_APP];
+ // uint32_t notifyId; /* Transfer to: ID */
+ /**
+ * \~english Event ID
+ */
+ uint32_t ulEvtId;
+ /**
+ * \~english Resource ID
+ */
+ uint8_t ucRid;
+ /**
+ * \~english CAN command ID
+ */
+ uint8_t ucCmdid;
+} CAN_CMD_CTRL_MSG_DAT;
+
+/**
+* \~english Data struct used for CAN command delivery
+* \~english (transfer data from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english CAN command ID
+ */
+ uint8_t cmd_id;
+ /**
+ * \~english Reserve
+ */
+ uint8_t reserve[3];
+ /**
+ * \~english Data
+ */
+ uint8_t data[CANCMD_DAT_MAX];
+} CAN_MSG_CANCMD_DAT;
+
+/**
+* \~english Message struct used for CAN command delivery
+* \~english (transfer message from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english Header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ /**
+ * \~english Data
+ */
+ CAN_MSG_CANCMD_DAT data;
+} CAN_MSG_CANCMD;
+
+/**
+* \~english Data struct used for CAN command transmission result
+* \~english (transfer data from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english CAN command ID(same as delivery format)
+ */
+ uint32_t cmd_id;
+ /**
+ * \~english Delivery result status
+ */
+ uint8_t status;
+ /**
+ * \~english Reserve
+ */
+ uint8_t reserve[3];
+} CAN_CMD_MSG_SENDSTS_DAT;
+
+/**
+* \~english Data struct used for CAN command transmission result
+* \~english (transfer data from CAN to user)
+*/
+typedef struct {
+ /**
+ * \~english Header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM hdr;
+ /**
+ * \~english Data
+ */
+ CAN_CMD_MSG_SENDSTS_DAT data;
+} CAN_CMD_MSG_SENDSTS;
+
+/**
+* \~english Data struct for receiving message(work data)
+*/
+typedef struct {
+ /**
+ * \~english Header
+ */
+// T_APIMSG_MSGBUF_HEADER_COMM stHead;
+ /**
+ * \~english Data
+ */
+ uint8_t ucData[CAN_MSGBUF_DATAMAX_SIZE];
+} CAN_MSG_DATA;
+
+/**
+* \~english CAN data struct of communication stop registration
+* \~english (transfer data from CANIF API to CAN)
+*/
+typedef struct {
+ /**
+ * \~english Delivery target thread name
+ */
+ char notifyName[MAX_NAME_SIZE_APP];
+ /**
+ * \~english Event ID for _CWORD64_
+ */
+ uint32_t ulEvtId;
+ /**
+ * \~english CAN ID
+ */
+ CANID ulCanid;
+ /**
+ * \~english Data ID
+ */
+ DID ulDid;
+ /**
+ * \~english Watch time for communication stop(Unit of 100ms)
+ */
+ uint16_t usWatchTime;
+ /**
+ * \~english has IG coopration or not
+ */
+ uint8_t ucIg;
+} CAN_COMM_WATCHEXT_MSG_DAT;
+
+/**
+* \~english Mask data struct for CAN data
+*/
+typedef struct {
+ /**
+ * \~english Mask data
+ */
+ uint8_t dat[CAN_TXDATA_SIZE];
+} CAN_DATA_MASK;
+
+/**
+* \~english Data struct used for CAN data transmission
+*/
+typedef struct {
+ /**
+ * \~english Transmission data
+ */
+ uint8_t dat[CAN_TXDATA_SIZE];
+} CAN_DATA_BIT;
+
+/**
+* \~english Data struct used for CAN data transmission registration
+*/
+typedef struct {
+ /**
+ * \~english CAN ID
+ */
+ CANID id;
+ /**
+ * \~english Mask data
+ */
+ CAN_DATA_MASK mask;
+ /**
+ * \~english Transmission data
+ */
+ CAN_DATA_BIT dat;
+ /**
+ * \~english Cycle of regular transmission
+ */
+ uint32_t freq;
+} CAN_TRANS_START_MSG_DAT;
+
+/***********************************************************************
+* CANIF API Functions Prototypes *
+************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*******************************************************************************
+ * MODULE : Canif_DeliveryEntry
+ ******************************************************************************/
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Canif_DeliveryEntry
+/// \~english @par Brief
+/// Delivery registration of CAN data
+/// \~english @param [in] h_app
+/// HANDLE - Handle for application
+/// \~english @param [in] notify_name
+/// PCSTR - Delivery target thread name
+/// \~english @param [in] can_num
+/// uint8_t - Number of delivery registration CAN ID
+/// \~english @param [in] p_can_id
+/// CANID* - Pointer of delivery registration CAN ID 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]
+/// - can_num is 0 or bigger than 125.[CANIF_RET_ERROR_PARAM]
+/// - CAN ID pointer 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
+/// - Delivery registration of CAN data. \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////
+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
+ ******************************************************************************/
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Canif_TransmissionStart
+/// \~english @par Brief
+/// CAN data transmission starting
+/// \~english @param [in] h_app
+/// HANDLE - Handle for application
+/// \~english @param [in] notify_name
+/// PCSTR - Delivery target thread name
+/// \~english @param [in] rid
+/// uint8_t - Resource ID for CAN data transmission result notification
+/// \~english @param [in] freq
+/// uint16_t - Cycle of regular transmission
+/// \~english @param [in] p_data
+/// CAN_DATA* - 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]
+/// - 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
+/// - The transmission of the CAN data starts(Regular/One). \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////
+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
+ ******************************************************************************/
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Canif_CommandCtrl
+/// \~english @par Brief
+/// CAN command control
+/// \~english @param [in] h_app
+/// HANDLE - Handle for application
+/// \~english @param [in] notify_name
+/// PCSTR - Delivery target thread name
+/// \~english @param [in] rid
+/// uint8_t - Resource ID
+/// \~english @param [in] cmd_id
+/// uint32_t - CAN command ID(32bit)
+/// \~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]
+/// - CAN command ID is invalid.[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 control of CAN command. \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////
+CANIF_RET_API Canif_CommandCtrl(HANDLE h_app, PCSTR notify_name, uint8_t rid,
+ uint32_t cmd_id);
+
+/*******************************************************************************
+ * MODULE : Canif_CommWatch
+ ******************************************************************************/
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Canif_CommWatch
+/// \~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 @param [in] did
+/// DID - Data ID
+/// \~english @param [in] watch_time
+/// uint16_t - Communication watch suspension time(Unit of 100ms)
+/// \~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_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id,
+ DID did, uint16_t watch_time);
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Canif_TransStart
+/// \~english @par Brief
+/// Transmission CAN Command
+/// \~english @param [in] h_app
+/// HANDLE - Handle for application
+/// \~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 @param [in] freq
+/// uint32_t - Transmission Cycle
+/// \~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]
+/// - Transmission Cycle is bigger than 0xFFFF.[CANIF_RET_ERROR_PARAM]
+/// - CAN ID 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
+/// - Start Transmission CAN Command API. \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////
+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
+/// \~english @par Brief
+/// Delete all delivery entry
+/// \~english @param [in] h_app
+/// HANDLE - Handle for application
+/// \~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]
+/// - 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
+/// - Delete all delivery entry. \n
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////
+CANIF_RET_API Canif_Debug_Delete_AllDeliveryEntryList(HANDLE h_app);
+#endif
+
+/** @}*/ // end of CAN
+/** @}*/ // end of communication
+/** @}*/ // end of peripheral_service
+/** @}*/ // end of BaseSystem
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
diff --git a/communication/client_can/include/peripheral_service/communication_can.h b/communication/client_can/include/peripheral_service/communication_can.h
new file mode 100644
index 00000000..59cc1bd2
--- /dev/null
+++ b/communication/client_can/include/peripheral_service/communication_can.h
@@ -0,0 +1,28 @@
+//
+// @copyright Copyright (c) 2017-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 PERIPHERALSERVICE_COMMUNICATIONCAN_H_ // NOLINT(build/header_guard)
+#define PERIPHERALSERVICE_COMMUNICATIONCAN_H_ // NOLINT(build/header_guard)
+
+/**
+ * @file communication_can.h
+ * @~english
+ * @brief communication_can unit header
+ */
+
+#include <peripheral_service/Canif_API.h>
+
+#endif // PERIPHERALSERVICE_COMMUNICATIONCAN_H_
diff --git a/communication/client_can/libCAN_API.ver b/communication/client_can/libCAN_API.ver
new file mode 100644
index 00000000..ede5fcac
--- /dev/null
+++ b/communication/client_can/libCAN_API.ver
@@ -0,0 +1,38 @@
+/*
+ * @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.
+ */
+
+#########################
+# lib_CWORD83_ version script #
+#########################
+{
+ global:
+ ### .text section ###
+ Canif_DeliveryEntry;
+ 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
new file mode 100644
index 00000000..9adce907
--- /dev/null
+++ b/communication/client_can/src/Canif_API.cpp
@@ -0,0 +1,852 @@
+/*
+ * @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.
+ */
+
+/*******************************************************************************
+ * 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 "Canif_API_Local.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;
+ }
+ }
+
+ /* Initialization of transmission data */
+ memset(reinterpret_cast<void *>(&pst_delivery_entry), (int32_t)0x00, (size_t)sizeof(pst_delivery_entry));
+
+ /* 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 (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;
+ }
+ return l_ret;
+}
+
+/*******************************************************************************
+ * 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 */
+ }
+
+ 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 */
+ 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 */
+ }
+
+ copysize = sizeof(uint16_t) * static_cast<const size_t>(opc_num);
+
+ /* Initialization of transmission data */
+ memset(reinterpret_cast<void *>(&pst_delivery_entry), (int32_t)0x00,
+ static_cast<size_t>(sizeof(CAN__CWORD29__DELIVERY_ENTRY)));
+
+ /* 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 (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;
+}
+
+/*******************************************************************************
+ * 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 (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", "");
+ }
+
+ 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);
+ }
+
+ /* 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
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_ret = CANIF_RET_NORMAL;
+ }
+ 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 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 */
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ 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 (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 (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;
+ }
+ 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);
+}
+
+/*******************************************************************************
+ * 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;
+
+ /* 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 (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
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_ret = CANIF_RET_NORMAL;
+ }
+
+ 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 */
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ 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 */
+ }
+
+ /* 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 */
+ }
+
+ /* CANDataInitialization of communication disruption monitoring information */
+ memset(reinterpret_cast<void *>(&pst_comm_watch_msg), (int32_t)0x00, (size_t)sizeof(pst_comm_watch_msg));
+
+ /* 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) */
+
+ 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
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_ret = CANIF_RET_NORMAL;
+ }
+
+ 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_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 */
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ 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 */
+ }
+
+ /* Maximum Size Check */
+ if (CAN__CWORD29__MEM_SZ < data_size) {
+ return CANIF_RET_ERROR_PARAM;
+ }
+
+ /* CANDataInitialization of transmission start information */
+ memset(reinterpret_cast<void *>(&pst__CWORD29__trans), (int32_t)0x00, (size_t)sizeof(pst__CWORD29__trans));
+
+ /* 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", "");
+ }
+
+ 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);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ } else {
+ l_ret = CANIF_RET_NORMAL;
+ }
+ 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;
+ CAN_TRANS_START_MSG_DAT pst_trans_start;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ /* 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;
+ }
+
+ 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 = 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 (g_hdl == NULL) {
+ g_hdl = FrameworkunifiedMcOpenSender(h_app, LAN_SERVICE_CAN);
+ }
+
+ /* 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;
+}
+
+/*!-----------------------------------------------------------------------------
+ * @~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;
+
+ /* 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;
+ }
+
+ 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
+ l_ret = CANIF_RET_ERROR_CANCEL;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ l_ret = CANIF_RET_NORMAL;
+ }
+ 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;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ /* Check parameter */
+ if (can_id == (CANID)NULL || mask == NULL || dat == 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;
+ }
+
+ 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 (g_mchdl == NULL) {
+ g_mchdl = McOpenSender(LAN_SERVICE_CAN);
+ }
+
+ /* 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;
+ }
+ 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;
+ }
+
+ 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;
+ }
+ 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
new file mode 100644
index 00000000..aa0ddf3f
--- /dev/null
+++ b/communication/server/Makefile
@@ -0,0 +1,113 @@
+#
+# @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.
+#
+
+######### add source path #############
+
+######### installed program #############
+INST_PROGS = communication
+
+######### installed library(*.a) #############
+
+######### installed shared library(*.so) #############
+
+######### compiled sources #############
+
+## from ./src/main
+communication_SRCS += ./src/main/communication_main.cpp
+communication_SRCS += ./src/main/communication_application.cpp
+
+## from ./src/threads
+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
+
+######### add source path #############
+VPATH += \
+ ./src/CAN/Command \
+ ./src/CAN/CommWatch \
+ ./src/CAN/Delivery \
+ ./src/CAN/main \
+ ./src/CAN/TimerCtrl \
+ ./src/CAN/Transmission \
+ ./src/CAN/TxMsg \
+ ./src/main \
+
+
+######### add include path #############
+CPPFLAGS += \
+ -I./../client_can/include \
+ -I./include \
+ -I./include/CAN/Command \
+ -I./include/CAN/CommWatch \
+ -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 \
+ -I./include/private
+
+######### add compile option #############
+CPPFLAGS += -DLINUX -fdata-sections -ffunction-sections -DFLG_CORE
+
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+######### add library path #############
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -Wl,--no-undefined
+LDFLAGS += -Wl,--gc-sections
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+LDLIBS += -Wl,-Bdynamic -lrt
+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
+
+include ../../peripheral_service.mk
diff --git a/communication/server/include/CAN/CommWatch/CAN_CommWatch.h b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h
new file mode 100644
index 00000000..3b6c8840
--- /dev/null
+++ b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h
@@ -0,0 +1,49 @@
+/*
+ * @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_COMMWATCH_H_
+#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_
+/******************************************************************************
+ * FILE :CAN_CommWatch.h
+ * SYSTEM :_CWORD107_
+ * SUBSYSTEM :
+ ******************************************************************************/
+#include "CAN_CommWatchData.h"
+
+/************************************************************************
+* Macro definitions *
+************************************************************************/
+
+/* 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 */
+
+/************************************************************************
+* 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);
+#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
new file mode 100644
index 00000000..7a982e03
--- /dev/null
+++ b/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h
@@ -0,0 +1,125 @@
+/*
+ * @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/Command/CAN_Command.h b/communication/server/include/CAN/Command/CAN_Command.h
new file mode 100644
index 00000000..ca385b2d
--- /dev/null
+++ b/communication/server/include/CAN/Command/CAN_Command.h
@@ -0,0 +1,42 @@
+/*
+ * @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_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
new file mode 100644
index 00000000..3d476a68
--- /dev/null
+++ b/communication/server/include/CAN/Command/CAN_CommandData.h
@@ -0,0 +1,96 @@
+/*
+ * @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
new file mode 100644
index 00000000..74e226c1
--- /dev/null
+++ b/communication/server/include/CAN/Delivery/CAN_Delivery.h
@@ -0,0 +1,48 @@
+/*
+ * @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_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 "CAN_Thread.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 *
+************************************************************************/
+
+/************************************************************************
+* 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);
+#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
new file mode 100644
index 00000000..692b8216
--- /dev/null
+++ b/communication/server/include/CAN/Delivery/CAN_DeliveryData.h
@@ -0,0 +1,140 @@
+/*
+ * @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_DELIVERY_CAN_DELIVERYDATA_H_
+#define COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_
+/******************************************************************************
+ * FILE :CAN_DeliveryData.h
+ * SYSTEM :_CWORD107_
+ * SUBSYSTEM :
+-----------------------------------------------------------------------------*/
+#include <native_service/frameworkunified_types.h>
+#include <peripheral_service/Canif_API.h>
+
+/************************************************************************
+* Macro definitions *
+************************************************************************/
+/* Data size relationship */
+#define CAN_DELIVERY_LIST_NUM 400 /* Maximum number of delivery destination management tables */
+#define CAN_DELIVERY_CANID_LIST_NUM 150 /* Delivery CAN ID control table max. */
+
+#define CAN_EXRCV_DATA_NUM 22 /* CAN Extended Reception Notification CAN Maximum Number of Data */
+#define CAN_EXRCV_DATA_SIZE 11 /* CAN Extended Reception Notification CAN Data Size */
+#define CAN_EXRCV_CANNUM_SIZE 1 /* CAN Extended Reception Notification CAN Data Number Size */
+#define CAN_EXRCV_DLC_MIN 1 /* CAN Extended Reception Notification DLC Minimum Value */
+#define CAN_EXRCV_DLC_MAX 8 /* CAN Extended Reception Notification DLC Maximum Value */
+
+/* Flag relationship */
+#define CAN_DELIVERY_OFF 0 /* Stopping data delivery */
+#define CAN_DELIVERY_ON 1 /* Data delivery in progress */
+
+/* CANDataControl code relationship used in the delivery relationship */
+#define CAN_DELIVERYLIST_STOP_CODE 0xFFFF /* Shipping Destination Management Table Stop Code */
+
+#define CAN_CANIDLIST_EMPTY 0xFFFF /* Availability of CAN ID control table */
+/************************************************************************
+* Struct definitions
+************************************************************************/
+/***************************************************
+* TAG : CAN_DELIVERY_DAT
+* ABSTRACT : Destination management table structure (1 item)
+* (CAN internal data management table)
+****************************************************/
+typedef struct { /* Type definition of delivery destination management data (1 item) */
+ CANID ul_canid; /* CAN ID */
+ char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
+ // uint32_t notifyId; /* Addresses for delivery ID */
+ uint8_t uc_delivery_on; /* Delivery operation */
+ uint8_t reserve1; /* Reserved */
+ uint16_t us_link_id; /* Link ID */
+ uint8_t reserve2[2]; /* Reserved */
+} CAN_DELIVERY_DAT;
+
+/***************************************************
+* TAG : CAN_DELIVERY_LIST_DAT
+* ABSTRACT : Destination management table structure (all)
+* (CAN internal data management table)
+****************************************************/
+typedef struct { /* Type definition of the shipping management table */
+ uint16_t us_entry_num; /* Registered number */
+ uint8_t reserve[2]; /* Reserved */
+ CAN_DELIVERY_DAT st_list[CAN_DELIVERY_LIST_NUM]; /* Delivery destination management data */
+} CAN_DELIVERY_LIST_DAT;
+
+/***************************************************
+* TAG : CAN_DELIVERY_SPACE_DAT
+* ABSTRACT : Free space management structure in the destination management table (all)
+* (CAN internal data management table free space management table)
+****************************************************/
+typedef struct { /* Type definitions for free space management tables */
+ uint16_t space_num; /* Number of free spaces */
+ uint16_t index_list[CAN_DELIVERY_LIST_NUM]; /* Free space index list */
+} CAN_DELIVERY_SPACE_DAT;
+
+/***************************************************
+* TAG : CAN_CANID_DAT
+* ABSTRACT : Transport CAN ID control table structures (1 item)
+* (CAN internal data management table)
+****************************************************/
+typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */
+ CANID ul_canid; /* CAN ID */
+ uint16_t us_start_id; /* Start ID */
+ uint16_t us_end_id; /* End ID */
+ uint16_t us_data_num; /* Number of data items */
+ uint8_t reserve[2]; /* Reserved */
+} CAN_CANID_DAT;
+
+/***************************************************
+* TAG : CAN_CANID_LIST_DAT
+* ABSTRACT : Delivery CAN ID control table structures (all)
+* (CAN internal data management table)
+****************************************************/
+typedef struct { /* Type definitions for the target CAN ID administration table */
+ uint16_t us_entry_num; /* Registered number */
+ uint8_t reserve[2]; /* Reserved */
+ CAN_CANID_DAT st_list[CAN_DELIVERY_CANID_LIST_NUM]; /* Shipping CAN ID */
+} CAN_CANID_LIST_DAT;
+
+/***************************************************
+* TAG : CAN_DELIVERY_SND_DAT
+* ABSTRACT : Destination thread name for sending a message of delivery data
+* (CAN-internal Work)
+****************************************************/
+/* Type definition of the target thread name list data to which the message is sent */
+typedef struct {
+ int32_t i_num; /* Number of messages sent */
+ char notify_name[CAN_DELIVERY_LIST_NUM][MAX_NAME_SIZE_APP]; /* Destination thread name */
+} CAN_DELIVERY_SND_DAT;
+
+typedef struct {
+ CAN_DELIVERY_LIST_DAT* p_dlvry_list;
+ CAN_DELIVERY_SPACE_DAT* p_dlvry_space;
+ CAN_CANID_LIST_DAT* p_canid_list;
+ CAN_DELIVERY_SND_DAT* p_dlvry_snd;
+} CAN_STRUCT_PTR;
+
+/************************************************************************
+* Function prototype *
+************************************************************************/
+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
+
+#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
new file mode 100644
index 00000000..bf273dd7
--- /dev/null
+++ b/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h
@@ -0,0 +1,82 @@
+/*
+ * @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
new file mode 100644
index 00000000..bca233ea
--- /dev/null
+++ b/communication/server/include/CAN/Transmission/CAN_Transmission.h
@@ -0,0 +1,56 @@
+/*
+ * @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
new file mode 100644
index 00000000..0c389276
--- /dev/null
+++ b/communication/server/include/CAN/Transmission/CAN_TransmissionData.h
@@ -0,0 +1,162 @@
+/*
+ * @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
new file mode 100644
index 00000000..15fc56d1
--- /dev/null
+++ b/communication/server/include/CAN/TxMsg/CAN_TxMsg.h
@@ -0,0 +1,116 @@
+/*
+ * @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_TXMSG_CAN_TXMSG_H_
+#define COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_
+/******************************************************************************
+ * FILE :CAN_TxMsg.h
+ * SYSTEM :_CWORD107_
+ * SUBSYSTEM :
+ ******************************************************************************/
+
+#include "CAN_Thread.h"
+
+/************************************************************************
+* 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 *);
+
+#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
new file mode 100644
index 00000000..bfd96b3a
--- /dev/null
+++ b/communication/server/include/com_error_type.h
@@ -0,0 +1,35 @@
+/*
+ * @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_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 */
+
+#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
new file mode 100644
index 00000000..21882eea
--- /dev/null
+++ b/communication/server/include/main/communication_cid.h
@@ -0,0 +1,47 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+/// \brief
+///
+///
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+/*
+ * This file has been generated automatically.
+ * User hand written code entry is not allowed. Do not modify the file content.
+ *
+ */
+#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 {
+ CID_COMMSYS_MSG_BASE = PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD, // Base command id.
+ CID_COMMSYS_CAN_READY, // CAN_COM_PROT->Communication
+ CID_COMMSYS_TIMEOUT, // Communication->CAN
+} PS_CommunicationServiceProtocol;
+
+#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_
diff --git a/communication/server/include/main/communication_communicationlog.h b/communication/server/include/main/communication_communicationlog.h
new file mode 100644
index 00000000..c8a46e5f
--- /dev/null
+++ b/communication/server/include/main/communication_communicationlog.h
@@ -0,0 +1,94 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+/// \brief
+///
+///
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+/*
+ * This file has been generated automatically.
+ * User hand written code entry is not allowed. Do not modify the file content.
+ *
+ */
+#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_
+#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_APP ZONEMASK(13)
+#define ZONE__CWORD83__DEBUG ZONEMASK(14)
+#define ZONE_CAN_DEBUG ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_COMMSYS ZONEMASK(17)
+#define ZONE_ICR ZONEMASK(18)
+#define ZONE_ICR_TABLE ZONEMASK(19)
+#define ZONE_TRANSLOG ZONEMASK(20)
+#define ZONE_LOOPBACK ZONEMASK(22)
+#define ZONE_ENTRY ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_DEBUG ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ZONE_COMM_SYS_STS ZONEMASK(107)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 "StateMachine Example"
+#define ZONE_TEXT_14 "_CWORD83_"
+#define ZONE_TEXT_15 "CAN"
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 "COMSYS"
+#define ZONE_TEXT_18 "ICR"
+#define ZONE_TEXT_19 "ICR_TABLE"
+#define ZONE_TEXT_20 "TRANSLOG"
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 "Debug"
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_APP, ZONE_ERR, ZONE_WARN, ZONE_INFO, ZONE_COMM_SYS, ZONE_CAN_FILTER, ZONE_COMM_SYS_STS
+#endif
+
+#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_
diff --git a/communication/server/include/main/communication_version.h b/communication/server/include/main/communication_version.h
new file mode 100644
index 00000000..cdb83e66
--- /dev/null
+++ b/communication/server/include/main/communication_version.h
@@ -0,0 +1,45 @@
+/*
+ * @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 version.h
+/// \ingroup
+/// \version 0.1.0
+/// \brief
+///
+/// \todo
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// File name : version.h
+// Module : Communication
+// Description : TODO INSERT
+// Scope : < example:Legacy Architecture>
+// Platform : _CWORD3_002 Platform
+//
+// Customer :
+// System :
+// Reference :
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_
+#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_
+
+#define MAJORNO 0x01
+#define MINORNO 0x00
+#define REVISION 0x00
+
+#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_
diff --git a/communication/server/include/peripheral_service/communication.h b/communication/server/include/peripheral_service/communication.h
new file mode 100644
index 00000000..e99996ce
--- /dev/null
+++ b/communication/server/include/peripheral_service/communication.h
@@ -0,0 +1,29 @@
+//
+// @copyright Copyright (c) 2017-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 communication.h
+ * @~english
+ * @brief communication unit header
+ */
+
+#ifndef PERIPHERALSERVICE_COMMUNICATION_H_ // NOLINT(build/header_guard)
+#define PERIPHERALSERVICE_COMMUNICATION_H_ // NOLINT(build/header_guard)
+
+#include <peripheral_service/communication_notifications.h>
+#include <peripheral_service/communication_can.h>
+
+#endif // PERIPHERALSERVICE_COMMUNICATION_H_
diff --git a/communication/server/include/peripheral_service/communication_notifications.h b/communication/server/include/peripheral_service/communication_notifications.h
new file mode 100644
index 00000000..97817177
--- /dev/null
+++ b/communication/server/include/peripheral_service/communication_notifications.h
@@ -0,0 +1,28 @@
+/*
+ * @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 communication_notifications.h
+ * @~english
+ * @brief Defination of communication notification
+ */
+
+#ifndef COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_
+#define COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_
+
+/*! @~english Defination of communication notification */
+#define NTFY_Communication_Availability "Communication/Availability"
+
+#endif // COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_
diff --git a/communication/server/include/peripheral_service/ps_services.h b/communication/server/include/peripheral_service/ps_services.h
new file mode 100644
index 00000000..dbb823ee
--- /dev/null
+++ b/communication/server/include/peripheral_service/ps_services.h
@@ -0,0 +1,94 @@
+/*
+ * @copyright Copyright (c) 2017-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 ps_services.h
+ * @~english
+ * @brief Defines the names of the available peripheral services.
+ */
+
+#ifndef PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard)
+#define PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard)
+
+/**
+ * @file ps_services.h
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup peripheral_service
+ * @ingroup BaseSystem
+ * @{
+ */
+
+/*------------------------------------------------------------------------------
+ * define
+ *----------------------------------------------------------------------------*/
+#define SERVICE_PSMSHADOW "PS_PSMShadow"
+/*!< @~english Define the name of SERVICE_PSMSHADOW */
+
+#define SERVICE_IPC "PS_IPC_DISP"
+/*!< @~english Define the name of SERVICE_IPC */
+
+#define SERVICE_IPC_DISP "PS_IPC"
+/*!< @~english Define the name of SERVICE_IPC_DISP */
+
+#define SERVICE_IPCTESTAPP "PS_IPC_TestApp"
+/*!< @~english Define the name of SERVICE_IPCTESTAPP */
+
+#define SERVICE_HMIKEYHANDLER "PS_KeyHandler"
+/*!< @~english PS_KeyHandler name SERVICE_HMIKEYHANDLER */
+
+#define SERVICE_MP_SHADOW "PS_IPC_MP_Shadow"
+/*!< @~english Define the name of SERVICE_MP_SHADOW */
+
+#define SERVICE_SENSORSHADOW "PS_SensorShadow"
+/*!< @~english Define the name of SERVICE_SENSORSHADOW */
+
+#define SERVICE_COMMUNICATIONDEBUGDUMPTEST "PS_COMMUNICATIONDebugDumpTest"
+/*!< @~english Define the name of SERVICE_COMMUNICATIONDEBUGDUMPTEST */
+
+#define SERVICE_PSMSHADOWTEST "PS_TEST_PSMShadow"
+/*!< @~english Define the name of SERVICE_PSMSHADOWTEST */
+
+#define SERVICE_LOGGERSHADOW "PS_LoggerShadow"
+/*!< @~english Define the name of SERVICE_LOGGERSHADOW */
+
+#define SERVICE_SOFTWAREUPDATESHADOW "PS_SoftwareUpdateShadow"
+/*!< @~english Define the name of SERVICE_SOFTWAREUPDATESHADOW */
+
+// #define SERVICE_LINSHADOW "LINShadowService"
+///*!< @~english Define the name of SERVICE_LINSHADOW */
+
+// #define SERVICE_RTCSHADOW "RTCShadowService"
+///*!< @~english Define the name of SERVICE_RTCSHADOW */
+
+// #define SERVICE_HBSHADOW "HBShadowService"
+///*!< @~english Define the name of SERVICE_HBSHADOW */
+
+// #define SERVICE_HBDUMMY "HBDummyService"
+///*!< @~english Define the name of SERVICE_HBDUMMY */
+
+// #define SERVICE_DISPLAYSHADOW "DisplayShadowService"
+///*!< @~english Define the name of SERVICE_DISPLAYSHADOW */
+
+// #define SERVICE_HMIALDUMMY "HMIALDummyService"
+///*!< @~english Define the name of SERVICE_HMIALDUMMY */
+
+/** @}*/ // end of peripheral_service
+/** @}*/ // end of BaseSystem
+
+#endif // PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard)
diff --git a/communication/server/include/private/ICR_Common.h b/communication/server/include/private/ICR_Common.h
new file mode 100644
index 00000000..c9bae1c1
--- /dev/null
+++ b/communication/server/include/private/ICR_Common.h
@@ -0,0 +1,30 @@
+/*
+ * @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
new file mode 100644
index 00000000..67a814a0
--- /dev/null
+++ b/communication/server/include/threads/CAN_Thread.h
@@ -0,0 +1,158 @@
+/*
+ * @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_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 */
+
+#define CAN_RX_CANDATA_SIZE CAN_DATA_SIZE /* Reserve 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 */
+#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
+***********************************************************************/
+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_
diff --git a/communication/server/include/threads/Thread_Common.h b/communication/server/include/threads/Thread_Common.h
new file mode 100644
index 00000000..91b907d5
--- /dev/null
+++ b/communication/server/include/threads/Thread_Common.h
@@ -0,0 +1,32 @@
+/*
+ * @copyright Copyright (c) 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_THREADS_THREAD_COMMON_H_
+#define COMMUNICATION_SERVER_INCLUDE_THREADS_THREAD_COMMON_H_
+#include <stdint.h>
+//#include <can_hal.h>
+const int32_t CAN_AVAILABILITY = 0x1;
+
+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
diff --git a/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp b/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp
new file mode 100644
index 00000000..abb727bd
--- /dev/null
+++ b/communication/server/src/CAN/CommWatch/CAN_CommWatch.cpp
@@ -0,0 +1,268 @@
+/*
+ * @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_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_framework_if.h>
+
+#include <peripheral_service/Canif_API.h>
+#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
+ ******************************************************************************/
+void CANCommWatchInit(void) {
+ g_uc_comm_watch_ig_stat = CAN_COMM_IG_NORCV; /* Initialization of IG reception status */
+}
+
+/*******************************************************************************
+ * 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;
+ }
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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);
+}
+
+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;
+
+ 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);
+ }
+ ret = RET_CAN_ERROR_CANCEL;
+ goto exit;
+ }
+ // 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;
+ }
+
+ /* 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);
+ }
+
+ } 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;
+ }
+
+ /* 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;
+ }
+
+ /* 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);
+ }
+
+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;
+}
+
+/*******************************************************************************
+ * 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;
+ }
+ }
+
+ return;
+}
+
+/*******************************************************************************
+ * 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);
+}
+// LCOV_EXCL_STOP
diff --git a/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp b/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp
new file mode 100644
index 00000000..8b5a4681
--- /dev/null
+++ b/communication/server/src/CAN/CommWatch/CAN_CommWatchData.cpp
@@ -0,0 +1,447 @@
+/*
+ * @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
new file mode 100644
index 00000000..f7875362
--- /dev/null
+++ b/communication/server/src/CAN/Command/CAN_Command.cpp
@@ -0,0 +1,319 @@
+/*
+ * @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
new file mode 100644
index 00000000..fe85ebfd
--- /dev/null
+++ b/communication/server/src/CAN/Command/CAN_CommandData.cpp
@@ -0,0 +1,534 @@
+/*
+ * @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
new file mode 100644
index 00000000..f4ee1f82
--- /dev/null
+++ b/communication/server/src/CAN/Delivery/CAN_Delivery.cpp
@@ -0,0 +1,349 @@
+/*
+ * @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 :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_TxMsg.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));
+ 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);
+}
+
+/*!-----------------------------------------------------------------------------
+ * @~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
+ }
+
+ return ret;
+}
+
+/*!-----------------------------------------------------------------------------
+ * @~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;
+ }
+
+ return ret;
+}
+
+/*******************************************************************************
+ * 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);
+}
+
+/*******************************************************************************
+ * 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);
+}
diff --git a/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp b/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp
new file mode 100644
index 00000000..a0bc1f0f
--- /dev/null
+++ b/communication/server/src/CAN/Delivery/CAN_DeliveryData.cpp
@@ -0,0 +1,214 @@
+/*
+ * @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
new file mode 100644
index 00000000..9e3ac384
--- /dev/null
+++ b/communication/server/src/CAN/TimerCtrl/CAN_TimerCtrl.cpp
@@ -0,0 +1,405 @@
+/*
+ * @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
new file mode 100644
index 00000000..4be88578
--- /dev/null
+++ b/communication/server/src/CAN/Transmission/CAN_Transmission.cpp
@@ -0,0 +1,603 @@
+/*
+ * @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
new file mode 100644
index 00000000..2858c196
--- /dev/null
+++ b/communication/server/src/CAN/Transmission/CAN_TransmissionData.cpp
@@ -0,0 +1,713 @@
+/*
+ * @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
new file mode 100644
index 00000000..36ddc6d8
--- /dev/null
+++ b/communication/server/src/CAN/TxMsg/CAN_TxMsg.cpp
@@ -0,0 +1,961 @@
+/*
+ * @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.
+ */
+
+/*******************************************************************************
+ * 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 <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 <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);
+
+ 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)
+ }
+
+ /****** 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;
+ }
+
+ 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++;
+ }
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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);
+ }
+
+ /****** 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;
+ }
+
+ 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);
+}
+
+/*******************************************************************************
+ * 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
+ }
+
+ 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)
+ }
+ }
+exit:
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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;
+ }
+
+ /* 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 */
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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
+ } 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
+ }
+exit:
+ return;
+}
+
+/*******************************************************************************
+ * 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;
+
+ if (static_cast<const uint8_t>(CAN_TXRSLT_CANRID__CWORD29__START) <= uc_can_rid) {
+ return (FALSE);
+ }
+
+ 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;
+ }
+ 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
+ }
+
+// 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;
+ }
+
+ 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 */
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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;
+
+ if (reinterpret_cast<HANDLE>(NULL) == h_app) {
+ return (FALSE);
+ }
+
+ 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;
+ }
+
+// e_status = FrameworkunifiedSendMsg(h_client, static_cast<UI_32>(st_txrslt_msg.hdr.hdr.cid), sizeof(CAN_MSG__CWORD29__SENDSTS),
+// &st_txrslt_msg);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Error");
+ ret_api = RET_ERROR;
+ }
+
+ /****** 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
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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;
+}
+
+/*******************************************************************************
+ * 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
+ }
+
+ (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;
+ }
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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
+ }
+ 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
+ }
+ 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
+ }
+ 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
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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;
+ }
+
+ return (ret);
+}
+
+/*******************************************************************************
+ * 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;
+ }
+
+ return (ret);
+}
+
+/*!-----------------------------------------------------------------------------
+ * @~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
diff --git a/communication/server/src/main/communication_application.cpp b/communication/server/src/main/communication_application.cpp
new file mode 100644
index 00000000..44049492
--- /dev/null
+++ b/communication/server/src/main/communication_application.cpp
@@ -0,0 +1,329 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_TE_Calculator
+/// \brief
+///
+///
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+/*
+ * This file has been generated automatically.
+ * User hand written code entry is allowed only inside protected zones.
+ */
+
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <peripheral_service/communication_notifications.h>
+#include <peripheral_service/Canif_API.h>
+#include <stdio.h>
+#include <signal.h>
+#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;
+}
+
+EFrameworkunifiedStatus CommSysCanReady(HANDLE h_app) {
+ g_can_ready = TRUE;
+ CommSysReadyCheck(h_app);
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
+ // Return Status
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ /*UserCodeStartCommunicationOnInitialization*/
+
+ // API to Register Notification for Service Availability.
+ e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app,
+ NTFY_Communication_Availability);
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to Register Service Availability Notification.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Service Availability Notification registered successfully.");
+ }
+
+ // API to Publish Service Availability Notification.
+ 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.");
+ }
+
+ // 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*/
+ 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) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ if (TRUE != current) {
+ e_status = FrameworkunifiedStartChildThread(p, c, len, data);
+ }
+ return e_status;
+}
+
+static EFrameworkunifiedStatus CommThreadCheckAndStop(HANDLE p, HANDLE c,
+ UI_32 len, PCVOID data, BOOL current) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ if (TRUE == current) {
+ e_status = FrameworkunifiedStopChildThread(p, c, len, data);
+ }
+ return e_status;
+}
+
+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) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Fail to Start CAN Thread. Status:%#x", e_status);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
+ return e_status;
+}
+
+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));
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Fail to Stop CAN Thread. Status:%#x", e_status);
+ } else {
+ g_can_thread = NULL;
+ }
+
+ 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,
+ 0, NULL, CommGetAvailabilityCurrent(CAN_AVAILABILITY));
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Fail to Start CAN Thread. Status:%#x", e_status);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
+ return e_status;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[START]");
+
+ e_status = CommThreadCheckAndStart(h_app, g_can_thread,
+ 0, NULL, CommGetAvailabilityCurrent(CAN_AVAILABILITY));
+ if (eFrameworkunifiedStatusOK != e_status) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Fail to Start CAN Thread. Status:%#x", e_status);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
+ return e_status;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[START]");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
+ return e_status;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[START]");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "[END]");
+ return e_status;
+} // LCOV_EXCL_BR_LINE 10:Gcov constraints (last row)
diff --git a/communication/server/src/main/communication_main.cpp b/communication/server/src/main/communication_main.cpp
new file mode 100644
index 00000000..5fcb428a
--- /dev/null
+++ b/communication/server/src/main/communication_main.cpp
@@ -0,0 +1,159 @@
+/*
+ * @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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \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>
+#include <poll.h>
+
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_multithreading.h>
+
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_system_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include "communication_communicationlog.h"
+#include "communication_version.h"
+#include "communication_cid.h"
+
+#include "CAN_Thread.h"
+#include "Thread_Common.h"
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION); // NOLINT (readability/naming)
+
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT (readability/naming)
+ FRAMEWORKUNIFIEDLOGOPTIONS,
+ {ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31},
+ FRAMEWORKUNIFIEDLOGZONES};
+
+extern HANDLE g_can_thread;
+
+#define COMMSYS_SND_ERR_CNT_MAX 10
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+
+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"
+ HANDLE h_app;
+ FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ 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.
+ 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.
+ 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.
+ return EXIT_FAILURE;
+ }
+
+ struct itimerspec tm;
+ tm.it_value.tv_sec = 0;
+ 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.
+ 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 */
+ 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;
+ }
+ }
+ }
+ }
+ }
+ return EXIT_SUCCESS;
+} // LCOV_EXCL_LINE 10: final line
diff --git a/communication/server/src/threads/CAN_Thread.cpp b/communication/server/src/threads/CAN_Thread.cpp
new file mode 100644
index 00000000..3393e60f
--- /dev/null
+++ b/communication/server/src/threads/CAN_Thread.cpp
@@ -0,0 +1,551 @@
+/*
+ * @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.
+ */
+
+/*******************************************************************************
+ * 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 <sys/timerfd.h>
+}
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_timer.h>
+#include <peripheral_service/Canif_API.h>
+#include <peripheral_service/communication_notifications.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);
+
+/*************************************************/
+/* Global variable */
+/*************************************************/
+static const FrameworkunifiedProtocolCallbackHandler kCanPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
+// {CID_ICR_CMD_RCV, CANIcrCmdRcvProcess},
+// {CID_ICR_CMD_SND_CNF, CANIcrSndStsProcess},
+ {CID_CANIF_DELIVERY_ENTRY, CANDeliveryEntry},
+ {CID_CANIF__CWORD29__DELIVERY_ENTRY, CAN_CWORD29_DeliveryEntry},
+ {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_COMM_WATCH, CANCommWatch},
+ {CID_CANIF__CWORD29__TX_START, CAN_CWORD29_TxMsg},
+ {CID_CANIF_CMD_CTRL, CANCommandTransmission},
+};
+
+static UI_32 kCanPcbhsD[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
+// CID_ICR_CMD_RCV,
+// CID_ICR_CMD_SND_CNF,
+ CID_CANIF_DELIVERY_ENTRY,
+ CID_CANIF__CWORD29__DELIVERY_ENTRY,
+ 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
+};
+
+static const FrameworkunifiedProtocolCallbackHandler kCanDebugPcbhs[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
+ {CID_CANIF_COMMWATCH_CLEAR_FOR_DEBUG, CANCommWatchAllClearDebug},
+};
+
+static UI_32 kCanDebugPcbhsD[] = { // LCOV_EXCL_BR_LINE 11: unexpected branch
+ CID_CANIF_COMMWATCH_CLEAR_FOR_DEBUG,
+};
+
+//static CanHalParam canParam;
+
+//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);
+//}
+
+EFrameworkunifiedStatus CANThreadStart(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ CommClrAvailabilityCurrent(CAN_AVAILABILITY);
+ CANDeliveryDataInit();
+ CANTransmissionDataInit();
+ CANCommWatchDataInit();
+ CANCommandDataInit();
+ CANCommWatchInit();
+ CANTimerTblInit();
+
+// 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;
+ }
+
+ return e_status;
+}
+
+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;
+ }
+
+ 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 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;
+// }
+//}
+
+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;
+
+ 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 */
+ };
+
+// 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
+
+// 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;
+// }
+ }
+
+ 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
+ }
+
+// }
+exit:
+ if (l_ret == RET_CAN_NORMAL)
+ return eFrameworkunifiedStatusOK;
+ else
+ 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;
+
+// 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;
+ }
+
+// 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;
+}
+// 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);
+ 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
new file mode 100644
index 00000000..72d80eab
--- /dev/null
+++ b/communication/server/src/threads/Thread_Common.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#include <stdint.h>
+#include <boost/atomic.hpp>
+#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 "communication_communicationlog.h"
+#include "communication_cid.h"
+#include "Thread_Common.h"
+
+static boost::atomic<int32_t> availabilityMask;
+static boost::atomic<int32_t> availabilityCurrent;
+
+void CommSetAvailabilityMask(int32_t mask) {
+ availabilityMask |= mask;
+}
+
+void CommSetAvailabilityCurrent(int32_t current) {
+ availabilityCurrent |= current;
+}
+
+void CommClrAvailabilityCurrent(int32_t current) {
+ availabilityCurrent &= (~current);
+}
+
+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";
+ z = (e_status != eFrameworkunifiedStatusOK) ? ZONE_INFO : ZONE_ERR;
+ called = "FrameworkunifiedNPPublishNotification";
+ FRAMEWORKUNIFIEDLOG(z, __func__, "%s(%s) %s(%d)", called, cmd, result, e_status);
+ return e_status;
+}
+
+EFrameworkunifiedStatus CommonCanHalErrorNotify(const char *msg, void *ctxid) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "can_hal error : %s", msg);
+ return eFrameworkunifiedStatusOK;
+}
+
+//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;
+//}
+