summaryrefslogtreecommitdiffstats
path: root/communication/server/src/CAN
diff options
context:
space:
mode:
Diffstat (limited to 'communication/server/src/CAN')
-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
10 files changed, 4813 insertions, 0 deletions
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