From aacd1728939f2b6f4c811cd93502966265cd8203 Mon Sep 17 00:00:00 2001 From: ToshikazuOhiwa Date: Mon, 30 Mar 2020 09:37:19 +0900 Subject: ps-communication branch --- .../server/include/CAN/CommWatch/CAN_CommWatch.h | 49 +++++++ .../include/CAN/CommWatch/CAN_CommWatchData.h | 125 ++++++++++++++++ .../server/include/CAN/Command/CAN_Command.h | 42 ++++++ .../server/include/CAN/Command/CAN_CommandData.h | 96 ++++++++++++ .../server/include/CAN/Delivery/CAN_Delivery.h | 48 ++++++ .../server/include/CAN/Delivery/CAN_DeliveryData.h | 140 ++++++++++++++++++ .../server/include/CAN/TimerCtrl/CAN_TimerCtrl.h | 82 +++++++++++ .../include/CAN/Transmission/CAN_Transmission.h | 56 +++++++ .../CAN/Transmission/CAN_TransmissionData.h | 162 +++++++++++++++++++++ communication/server/include/CAN/TxMsg/CAN_TxMsg.h | 116 +++++++++++++++ communication/server/include/com_error_type.h | 35 +++++ .../server/include/main/communication_cid.h | 47 ++++++ .../include/main/communication_communicationlog.h | 94 ++++++++++++ .../server/include/main/communication_version.h | 45 ++++++ .../include/peripheral_service/communication.h | 29 ++++ .../communication_notifications.h | 28 ++++ .../include/peripheral_service/ps_services.h | 94 ++++++++++++ communication/server/include/private/ICR_Common.h | 30 ++++ communication/server/include/threads/CAN_Thread.h | 158 ++++++++++++++++++++ .../server/include/threads/Thread_Common.h | 32 ++++ 20 files changed, 1508 insertions(+) create mode 100644 communication/server/include/CAN/CommWatch/CAN_CommWatch.h create mode 100644 communication/server/include/CAN/CommWatch/CAN_CommWatchData.h create mode 100644 communication/server/include/CAN/Command/CAN_Command.h create mode 100644 communication/server/include/CAN/Command/CAN_CommandData.h create mode 100644 communication/server/include/CAN/Delivery/CAN_Delivery.h create mode 100644 communication/server/include/CAN/Delivery/CAN_DeliveryData.h create mode 100644 communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h create mode 100644 communication/server/include/CAN/Transmission/CAN_Transmission.h create mode 100644 communication/server/include/CAN/Transmission/CAN_TransmissionData.h create mode 100644 communication/server/include/CAN/TxMsg/CAN_TxMsg.h create mode 100644 communication/server/include/com_error_type.h create mode 100644 communication/server/include/main/communication_cid.h create mode 100644 communication/server/include/main/communication_communicationlog.h create mode 100644 communication/server/include/main/communication_version.h create mode 100644 communication/server/include/peripheral_service/communication.h create mode 100644 communication/server/include/peripheral_service/communication_notifications.h create mode 100644 communication/server/include/peripheral_service/ps_services.h create mode 100644 communication/server/include/private/ICR_Common.h create mode 100644 communication/server/include/threads/CAN_Thread.h create mode 100644 communication/server/include/threads/Thread_Common.h (limited to 'communication/server/include') diff --git a/communication/server/include/CAN/CommWatch/CAN_CommWatch.h b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h new file mode 100644 index 00000000..3b6c8840 --- /dev/null +++ b/communication/server/include/CAN/CommWatch/CAN_CommWatch.h @@ -0,0 +1,49 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_ +/****************************************************************************** + * FILE :CAN_CommWatch.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ +#include "CAN_CommWatchData.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ + +/* Flag relationship */ +#define CAN_COMM_IG_OFF 0x00 /* IG OFF */ +#define CAN_COMM_IG_ON 0x01 /* IG ON */ +#define CAN_COMM_IG_NORCV 0xFF /* IG not yet */ + +/************************************************************************ +* Struct definitions * +************************************************************************/ + +/************************************************************************ +* Function prototype * +************************************************************************/ +void CANCommWatchInit(void); +RET_CAN CANCommWatchTimeoutMsg(HANDLE h_app, uint16_t); +EFrameworkunifiedStatus CANCommWatch(HANDLE h_app); +EFrameworkunifiedStatus CANCommWatchCore(HANDLE h_app, CAN_PROTOCOL_TYPE type); +void CANCommWatchClear(HANDLE h_app, CANID); +EFrameworkunifiedStatus CANVehicleInfoMsg(HANDLE h_app); +uint8_t CANIgStatGet(void); +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCH_H_ diff --git a/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h b/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h new file mode 100644 index 00000000..7a982e03 --- /dev/null +++ b/communication/server/include/CAN/CommWatch/CAN_CommWatchData.h @@ -0,0 +1,125 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_ +/****************************************************************************** + * FILE :CAN_CommWatchData.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include +#include "CAN_Thread.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ +/* #001 start */ +#define COMM_WATICH_TIMER_SEQ_NO_MIN 0x0001 /* Minimum value of timer sequence number */ +/* #100 start */ +#define COMM_WATICH_TIMER_SEQ_NO_MAX 0x0FFF /* Maximum value of timer sequence number */ +/* #001 end */ +/* #100 end */ + +/* Flag Relationship */ +#define CAN_COMM_OFF 0x00 /* Monitoring OFF */ +#define CAN_COMM_NORMAL 0x01 /* Communicating */ +#define CAN_COMM_STOP 0x02 /* Interruption of communication */ + +/************************************************************************ +* Struct definitions * +************************************************************************/ +/*************************************************** +* TAG : CAN_COMM_WATCH_DAT +* ABSTRACT : Communication interruption monitoring management table structure (1 item) +* Use in arrays when used +* (CAN internal data management table) Not used because API is used in the TBD_Z first game +****************************************************/ +typedef struct { /* Type definition of communication disconnection monitoring management table (1 case) */ + CANID ul_can_id; /* CAN ID */ + DID ul_did; /* Data ID */ + uint16_t us_watch_time; /* Communication interruption monitoring time (in units of 100ms) */ + // uint32_t notifyId; /* Addresses for delivery ID */ + uint8_t uc_comm_stop; /* Communication status */ + uint8_t uc_ig; /* IG linkage */ + uint16_t us_timer_seq_no; /* Timer Sequence Number*/ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_COMM_WATCH_DAT; + +/************************************************************************ +* Variable prototype * +************************************************************************/ +/* Communication disruption monitoring management table */ +extern CAN_COMM_WATCH_DAT g_st_comm_watch_dat[CAN_PROTOCOL_TYPE_TERMINATE][COMM_WATCH_LIST_NUM]; +/* Number of effective registrations of communication disruption monitoring management table */ +extern uint16_t g_us_comm_watch_dat_cnt[CAN_PROTOCOL_TYPE_TERMINATE]; + +/************************************************************************ +* Function prototype * +************************************************************************/ +void CANCommWatchDataInit(void); +BOOL CANCommWatchCanidDidEntryCheck(uint8_t, CANID canid, DID did, CAN_PROTOCOL_TYPE); +BOOL CANCommWatchTimerSeqNoEntryCheck(uint16_t, uint8_t *, uint8_t *, CAN_PROTOCOL_TYPE); +BOOL CANCommWatchEntryCheck(CANID canid, DID did, PCSTR namel, uint8_t *, CAN_PROTOCOL_TYPE); +void CANCommWatchEntry(uint8_t uc_index, const CAN_COMM_WATCHEXT_MSG_DAT *pst_msg_data, + uint16_t us_timer_seq_no, uint8_t uc_comm_stop, CAN_PROTOCOL_TYPE); +void CANCommWatchDelete(uint8_t, CAN_PROTOCOL_TYPE); +void CANCommWatchCtrl(uint8_t, uint8_t, CAN_PROTOCOL_TYPE); +void CANCommWatchDataGet(uint8_t, char *, DID *, uint8_t *, CAN_PROTOCOL_TYPE); +uint16_t CANCommWatchTimerSeqNoGet(uint8_t, CAN_PROTOCOL_TYPE); +uint16_t CANCommWatchTimerSeqNoRenwal(uint8_t, uint16_t *, CAN_PROTOCOL_TYPE); +BOOL CANCommWatchSndCheck(uint8_t, PCSTR name, CAN_PROTOCOL_TYPE); +uint8_t CANCommWatchIgcoopGet(uint8_t uc_index, CAN_PROTOCOL_TYPE); +void CANCommWatchBufferOut(FILE *fp_log, CAN_PROTOCOL_TYPE); +inline BOOL CANCommWatchCanidEntryCheck(uint8_t uc_index, CANID ul_can_id, uint8_t *puc_comm_stop, + uint16_t *pus_chk_cnt, CAN_PROTOCOL_TYPE); + +/* for debug */ +EFrameworkunifiedStatus CANCommWatchAllClearDebug(HANDLE h_app); +/******************************************************************************* + * MODULE : CANCommWatchCanidEntryCheck + * ABSTRACT : CANDataCommunication Disruption Monitoring Control Table Registration Status Checking Process (CAN ID Search) + * FUNCTION : Compare the communication discontinuity monitoring control data indicated by the index with the specified CAN ID. + * ARGUMENT : uc_index :Indexed + * can_id :CAN ID + * puc_comm_stop :Communication status return pointer + * pusChkCnt :Pointer to number of valid data checks for table registration + * NOTE : + * RETURN : TRUE :Data consistency + * FALSE :Data mismatch + ******************************************************************************/ + +inline BOOL CANCommWatchCanidEntryCheck(uint8_t uc_index, CANID can_id, uint8_t *puc_comm_stop, + uint16_t *pusChkCnt, CAN_PROTOCOL_TYPE mode) { + BOOL ret = FALSE; + CAN_COMM_WATCH_DAT *ptr = &g_st_comm_watch_dat[mode][uc_index]; + + /* Is the specified index monitoring interrupted? */ + if ((uint16_t)0 != ptr->us_watch_time) { + /* Specified index-data CANID matches the arguments? */ + if (can_id == ptr->ul_can_id) { + ret = TRUE; + *puc_comm_stop = ptr->uc_comm_stop; + } + /* Updating the number of effective data checks for table registration */ + *pusChkCnt = (uint16_t)(*pusChkCnt + (uint16_t)1); + } + + return (ret); +} + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMWATCH_CAN_COMMWATCHDATA_H_ diff --git a/communication/server/include/CAN/Command/CAN_Command.h b/communication/server/include/CAN/Command/CAN_Command.h new file mode 100644 index 00000000..ca385b2d --- /dev/null +++ b/communication/server/include/CAN/Command/CAN_Command.h @@ -0,0 +1,42 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_ +/****************************************************************************** + * FILE :CAN_Command.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include "CAN_Thread.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ + +/************************************************************************ +* Struct definitions * +************************************************************************/ + +/************************************************************************ +* Function prototype * +************************************************************************/ +EFrameworkunifiedStatus CANCommandTransmission(HANDLE h_app); +RET_CAN CANCommandTxRslt(HANDLE h_app, CAN_MSG_DATA*); +RET_CAN CANCommandDelivery(HANDLE h_app, CAN_MSG_DATA*); + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMAND_H_ diff --git a/communication/server/include/CAN/Command/CAN_CommandData.h b/communication/server/include/CAN/Command/CAN_CommandData.h new file mode 100644 index 00000000..3d476a68 --- /dev/null +++ b/communication/server/include/CAN/Command/CAN_CommandData.h @@ -0,0 +1,96 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_ +/****************************************************************************** + * FILE :CAN_CommandData.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include + +/************************************************************************ +* Macro definitions * +************************************************************************/ +/* Number of table elements */ +#define CAN_COMMAND_DELIVERY_SNDID_NUM 16 /* CAN Command Delivery Registered Delivery Destination ID Max. */ +#define CAN_COMMAND_DELIVERY_NUM 6 /* Max. number of CAN command delivery control tables (6 for CAN command) */ +#define CAN_COMMAND_TXRSLT_SNDID_NUM 16 /* Maximum number of registered delivery destination IDs for CAN command transmission results */ +#define CAN_COMMAND_TXRSLT_NUM (6 * CAN_COMMAND_TXRSLT_SNDID_NUM) /* Maximum number of CAN command transmission result management tables */ + +/* Control method */ +#define CAN_CMD_DELIVERY_CTRL 0 /* Delivery control type */ +#define CAN_CMD_1TIME_TRANCE 1 /* One-time communication */ +#define CAN_CMD_TRANCE 2 /* Continuous communication type */ + +/* Controlling flag */ +#define CAN_CMD_RST_NOT_RCV 0 /* Not received */ +#define CAN_CMD_RST_RCV 1 /* Received */ + +/* Resource ID Mask */ +#define CAN_CMD_RID_MASK 0x80 + +/************************************************************************ +* Struct definitions * +************************************************************************/ +/*************************************************** +* TAG : CAN_COMMAND_DELIVERY_LIST_DAT +* ABSTRACT : CAN command delivery management table structure (1 item) +* Use in arrays when used +* (CAN internal data management table) +****************************************************/ +typedef struct { + uint8_t uc_ctrl; /* Control method */ + uint8_t uc_flag; /* Controlling flag */ + uint8_t notify_name_num; /* Number of registered shipping destinations */ + uint8_t reserve; /* ----- */ + // uint32_t notifyIdList[CAN_COMMAND_DELIVERY_SNDID_NUM]; /* Addresses for delivery ID */ + char notify_name_list[CAN_COMMAND_DELIVERY_SNDID_NUM][MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_COMMAND_DELIVERY_LIST_DAT; + +/*************************************************** +* TAG : CAN_COMMAND_TXRSLT_LIST_DAT +* ABSTRACT : CAN command transmission result management table structure (1 item) +* Use in arrays when used +* (CAN internal data management table) +****************************************************/ +typedef struct { + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ + // uint32_t notifyId; /* Addresses for delivery ID */ + uint8_t uc_rid; /* Resources ID */ + uint8_t uc_cmd_id; /* CAN command ID */ +} CAN_COMMAND_TXRSLT_LIST_DAT; + +/************************************************************************ +* Function prototype * +************************************************************************/ +BOOL CANCommandDeliveryEntryCheck(PCSTR name, uint8_t); +void CANCommandDeliveryEntry(PCSTR name, uint8_t); +void CANCommandDeliveryDataGet(uint8_t, CAN_COMMAND_DELIVERY_LIST_DAT *); +void CANCommandDeliveryDelete(uint8_t); +void CANCommandDeliveryDeletesingle(uint8_t, PCSTR); +BOOL CANCommandTxRsltEntryCheck(uint8_t, uint8_t *); +void CANCommandTxRsltEntry(uint8_t, PCSTR name, uint8_t); +void CANCommandTxRsltDataGet(uint8_t, char *, uint8_t *, uint8_t *); +void CANCommandTxRsltDelete(uint8_t); +BOOL CANCommandTxRsltCheck(uint8_t); +BOOL CANCommandFuelCalcRstReqCheck(void); +void CANCommandFuelCalcRstReq(void); +void CANCommandDataInit(void); + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_COMMAND_CAN_COMMANDDATA_H_ diff --git a/communication/server/include/CAN/Delivery/CAN_Delivery.h b/communication/server/include/CAN/Delivery/CAN_Delivery.h new file mode 100644 index 00000000..74e226c1 --- /dev/null +++ b/communication/server/include/CAN/Delivery/CAN_Delivery.h @@ -0,0 +1,48 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_ +/****************************************************************************** + * FILE :CAN_Delivery.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include +#include "CAN_Thread.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ +#define CAN_CSUM_CHECKTBL_STOP_CODE 0xFFFFFFFFUL +/* CANDataStop code of the table for which checksum checksumming is to be performed */ + +/************************************************************************ +* Struct definitions * +************************************************************************/ + +/************************************************************************ +* Function prototype * +************************************************************************/ +RET_CAN CANDataReceiveMsg(HANDLE h_app, CAN_MSG_DATA*); /* CANDataProcess of Received Messages */ +//RET_CAN CANDlcCheck(const T_ICR_CMD_DATA*); /* DLC check process */ +CANID CANCanidIfToUserCvt(uint8_t*); /* CAN ID Conversion Process 1 */ +CANID CANPacCanidIfToUserCvt(uint8_t*); +RET_CAN CANDeliveryRcvData(HANDLE h_app, CANID ul_canid, uint8_t n_ta, + uint8_t uc_dlc, uint8_t* puc_data_pos, uint8_t opc); +RET_CAN CANDeliveryRcv_CWORD29_Data(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, uint8_t *puc_data_pos); +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERY_H_ diff --git a/communication/server/include/CAN/Delivery/CAN_DeliveryData.h b/communication/server/include/CAN/Delivery/CAN_DeliveryData.h new file mode 100644 index 00000000..692b8216 --- /dev/null +++ b/communication/server/include/CAN/Delivery/CAN_DeliveryData.h @@ -0,0 +1,140 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_ +/****************************************************************************** + * FILE :CAN_DeliveryData.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : +-----------------------------------------------------------------------------*/ +#include +#include + +/************************************************************************ +* Macro definitions * +************************************************************************/ +/* Data size relationship */ +#define CAN_DELIVERY_LIST_NUM 400 /* Maximum number of delivery destination management tables */ +#define CAN_DELIVERY_CANID_LIST_NUM 150 /* Delivery CAN ID control table max. */ + +#define CAN_EXRCV_DATA_NUM 22 /* CAN Extended Reception Notification CAN Maximum Number of Data */ +#define CAN_EXRCV_DATA_SIZE 11 /* CAN Extended Reception Notification CAN Data Size */ +#define CAN_EXRCV_CANNUM_SIZE 1 /* CAN Extended Reception Notification CAN Data Number Size */ +#define CAN_EXRCV_DLC_MIN 1 /* CAN Extended Reception Notification DLC Minimum Value */ +#define CAN_EXRCV_DLC_MAX 8 /* CAN Extended Reception Notification DLC Maximum Value */ + +/* Flag relationship */ +#define CAN_DELIVERY_OFF 0 /* Stopping data delivery */ +#define CAN_DELIVERY_ON 1 /* Data delivery in progress */ + +/* CANDataControl code relationship used in the delivery relationship */ +#define CAN_DELIVERYLIST_STOP_CODE 0xFFFF /* Shipping Destination Management Table Stop Code */ + +#define CAN_CANIDLIST_EMPTY 0xFFFF /* Availability of CAN ID control table */ +/************************************************************************ +* Struct definitions +************************************************************************/ +/*************************************************** +* TAG : CAN_DELIVERY_DAT +* ABSTRACT : Destination management table structure (1 item) +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Type definition of delivery destination management data (1 item) */ + CANID ul_canid; /* CAN ID */ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ + // uint32_t notifyId; /* Addresses for delivery ID */ + uint8_t uc_delivery_on; /* Delivery operation */ + uint8_t reserve1; /* Reserved */ + uint16_t us_link_id; /* Link ID */ + uint8_t reserve2[2]; /* Reserved */ +} CAN_DELIVERY_DAT; + +/*************************************************** +* TAG : CAN_DELIVERY_LIST_DAT +* ABSTRACT : Destination management table structure (all) +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Type definition of the shipping management table */ + uint16_t us_entry_num; /* Registered number */ + uint8_t reserve[2]; /* Reserved */ + CAN_DELIVERY_DAT st_list[CAN_DELIVERY_LIST_NUM]; /* Delivery destination management data */ +} CAN_DELIVERY_LIST_DAT; + +/*************************************************** +* TAG : CAN_DELIVERY_SPACE_DAT +* ABSTRACT : Free space management structure in the destination management table (all) +* (CAN internal data management table free space management table) +****************************************************/ +typedef struct { /* Type definitions for free space management tables */ + uint16_t space_num; /* Number of free spaces */ + uint16_t index_list[CAN_DELIVERY_LIST_NUM]; /* Free space index list */ +} CAN_DELIVERY_SPACE_DAT; + +/*************************************************** +* TAG : CAN_CANID_DAT +* ABSTRACT : Transport CAN ID control table structures (1 item) +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */ + CANID ul_canid; /* CAN ID */ + uint16_t us_start_id; /* Start ID */ + uint16_t us_end_id; /* End ID */ + uint16_t us_data_num; /* Number of data items */ + uint8_t reserve[2]; /* Reserved */ +} CAN_CANID_DAT; + +/*************************************************** +* TAG : CAN_CANID_LIST_DAT +* ABSTRACT : Delivery CAN ID control table structures (all) +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Type definitions for the target CAN ID administration table */ + uint16_t us_entry_num; /* Registered number */ + uint8_t reserve[2]; /* Reserved */ + CAN_CANID_DAT st_list[CAN_DELIVERY_CANID_LIST_NUM]; /* Shipping CAN ID */ +} CAN_CANID_LIST_DAT; + +/*************************************************** +* TAG : CAN_DELIVERY_SND_DAT +* ABSTRACT : Destination thread name for sending a message of delivery data +* (CAN-internal Work) +****************************************************/ +/* Type definition of the target thread name list data to which the message is sent */ +typedef struct { + int32_t i_num; /* Number of messages sent */ + char notify_name[CAN_DELIVERY_LIST_NUM][MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_DELIVERY_SND_DAT; + +typedef struct { + CAN_DELIVERY_LIST_DAT* p_dlvry_list; + CAN_DELIVERY_SPACE_DAT* p_dlvry_space; + CAN_CANID_LIST_DAT* p_canid_list; + CAN_DELIVERY_SND_DAT* p_dlvry_snd; +} CAN_STRUCT_PTR; + +/************************************************************************ +* Function prototype * +************************************************************************/ +void CANDeliveryDataInit(void); /* CANDataDelivery Management Data Initialization Process */ +EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app); /* CANDataDelivery registration process */ +EFrameworkunifiedStatus CAN_CWORD29_DeliveryEntry(HANDLE h_app); /* Process of registering the delivery of _CWORD29_ data */ +void CANDeliveryBufferOut(FILE* fp_log); /* CAN shipping table log output processing */ +#ifdef CAN_DEBUG +EFrameworkunifiedStatus CANAllDeleteDeliveryEntry(HANDLE h_app); +#endif + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_ diff --git a/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h b/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h new file mode 100644 index 00000000..bf273dd7 --- /dev/null +++ b/communication/server/include/CAN/TimerCtrl/CAN_TimerCtrl.h @@ -0,0 +1,82 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_ +/****************************************************************************** + * FILE :CAN_TimerCtrl.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include "CAN_Thread.h" + +/************************************************************************ +* Macro Definitions * +************************************************************************/ +#define CAN_TIM_RETRY_NUM 3 /* Number of retries for alarm API errors */ +/************************************************************************ +* Struct Definitions * +************************************************************************/ + +/*************************************************** +* TAG : CAN_TIMER_CTRL_DATA +* ABSTRACT : Timer management data section structure +****************************************************/ +typedef struct { + uint16_t us_set_tim; /* Timeout value */ + uint16_t us_tim_cnt; /* Measured value of timer */ +} CAN_TIMER_CTRL_DATA; + +/*************************************************** +* TAG : CAN_FREQTRANS_TIMER +* ABSTRACT : Periodic transmission timer management table structure +****************************************************/ +typedef struct { + uint16_t us_num; /* Number of timer registrations */ + uint8_t reserve[2]; /* Reserve */ + CAN_TIMER_CTRL_DATA data[CAN_FREQTRANS_TIMER_DATA]; /* Timer management data */ +} CAN_FREQTRANS_TIMER; + +/*************************************************** +* TAG : CAN_COMMWATCH_TIMER +* ABSTRACT : Disruption monitoring timer management table structure +****************************************************/ +typedef struct { + uint16_t us_num; /* Number of timer registrations */ + uint8_t reserve[2]; /* Reserve */ + CAN_TIMER_CTRL_DATA data[CAN_COMMWATCH_TIMER_DATA]; /* Timer management data */ +} CAN_COMMWATCH_TIMER; + +/************************************************************************ +* Function Prototype * +************************************************************************/ +RET_CAN CANFreqTransTimerStart(uint8_t, uint16_t, CAN_PROTOCOL_TYPE); /* Periodic transmission timer start processing */ +RET_CAN CANFreqTransTimerStop(uint8_t, CAN_PROTOCOL_TYPE); /* Periodic transmission timer start processing */ +RET_CAN CANCommWatchTimerStart(uint8_t, uint16_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer start processing */ +RET_CAN CANCommWatchTimerStop(uint8_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer stop processing */ +RET_CAN CANCommWatchTimerRenewal(uint8_t, CAN_PROTOCOL_TYPE); /* Communication interruption monitoring timer update processing */ +void CANFreqTransTimeOut(HANDLE h_app, uint16_t, CAN_PROTOCOL_TYPE); /* CAN periodic transmission timeout confirmation processing */ +void CANCommWatchTimeOut(HANDLE h_app, CAN_PROTOCOL_TYPE); /* CAN Communication Disruption Monitoring Timeout Confirmation Process */ +void CANTimerStart(uint16_t, CAN_TIMER_CTRL_DATA*); /* CAN Timer Master Processing */ +void CANTimerTblInit(void); /* CAN timer table initialization processing */ + +void CANFreqTimerEntry(CANID canid, uint32_t); +void CANFreqTransTimeOutMap(HANDLE h_app); +RET_CAN CANFreqTransTimerStopMap(CANID); +void CANFreqTimerResetMap(CANID); + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TIMERCTRL_CAN_TIMERCTRL_H_ diff --git a/communication/server/include/CAN/Transmission/CAN_Transmission.h b/communication/server/include/CAN/Transmission/CAN_Transmission.h new file mode 100644 index 00000000..bca233ea --- /dev/null +++ b/communication/server/include/CAN/Transmission/CAN_Transmission.h @@ -0,0 +1,56 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_ +/****************************************************************************** + * FILE :CAN_Transmission.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ +#include +#include "CAN_Thread.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ +#define TIMER_SEQNO_MASK_CODE (uint16_t)(0x00FF) /* Mask code for acquiring timer sequence number */ + +/************************************************************************ +* Struct definitions * +************************************************************************/ + +/************************************************************************ +* Function prototype * +************************************************************************/ +/* CANDataTransmission start message processing */ +EFrameworkunifiedStatus CANTxStart(HANDLE); +/* CANDataSend start message check processing */ +RET_CAN CANTxStartMsgCheck(const CAN_TRANSMISSION_START_MSG_DAT *, uint8_t *); +/* CANDataPeriodic transmission stop message processing */ +EFrameworkunifiedStatus CANFreqTxStop(HANDLE); +/* CANDataPeriodic transmission time-up message processing */ +RET_CAN CANFreqTxTimeupMsg(HANDLE h_app, uint16_t); +/* CANDataReceive message processing of transmission result */ +RET_CAN CANTxRsltReceiveMsg(HANDLE h_app, CAN_MSG_DATA *); +/* CANDataSend result received message check processing */ +RET_CAN CANTxRsltReceiveMsgCheck(CAN_MSG_DATA *); +/* CANData(_CWORD29_) outgoing message processing */ +EFrameworkunifiedStatus CAN_CWORD29_TxMsg(HANDLE h_app); +EFrameworkunifiedStatus CANTxBitStart(HANDLE); /* CANDataTransmission start message processing */ +EFrameworkunifiedStatus CANTxBitStop(HANDLE); /* CANDataPeriodic transmission stop message processing */ + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSION_H_ diff --git a/communication/server/include/CAN/Transmission/CAN_TransmissionData.h b/communication/server/include/CAN/Transmission/CAN_TransmissionData.h new file mode 100644 index 00000000..0c389276 --- /dev/null +++ b/communication/server/include/CAN/Transmission/CAN_TransmissionData.h @@ -0,0 +1,162 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_ +/****************************************************************************** + * FILE :CAN_TransmissionData.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ +#include +#include +#include "Canif_API_Local.h" +/************************************************************************ +* Macro definitions * +************************************************************************/ +/* Data size relationship */ +/* Maximum number of transmission results management tables */ +#define CAN_1TIME_TRSNSMISSION_RSLT_NUM 16 +#define CAN__CWORD29__TRSNSMISSION_RSLT_NUM 16 + +/* Regular transmission, one transmission result management table relationship */ +#define CAN_TXRSLT_CANRID_START 0x00 /* Send result CANRID starting No. */ +/* Transmission result (1 transmission) CANRID starting number */ +#define CAN_TXRSLT_CANRID_1TIME_START CAN_FREQ_TRSNSMISSION_LIST_NUM +/* Send result (_CWORD29_) CANRID starting number) */ +#define CAN_TXRSLT_CANRID__CWORD29__START (CAN_FREQ_TRSNSMISSION_LIST_NUM + CAN_1TIME_TRSNSMISSION_RSLT_NUM) // NOLINT(whitespace/line_length) +/* Send result CANRID end No. */ +#define CAN_TXRSLT_CANRID_END (CAN_FREQ_TRSNSMISSION_LIST_NUM + CAN_1TIME_TRSNSMISSION_RSLT_NUM + CAN__CWORD29__TRSNSMISSION_RSLT_NUM - 1) // NOLINT(whitespace/line_length) + +/* Others */ +#define CAN_FREQ_TXRSLT_NUM 1 /* Number of notifications of periodic transmission results */ + +#define LAN_TYPE_19PF "CAN_19PF" +/************************************************************************ +* Struct definitions * +************************************************************************/ +/*************************************************** +* TAG : CAN_FREQ_TRANSMISSION_DAT +* ABSTRACT : Periodic transmission management table structure (1 item) +* Use in arrays when used +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Type definitions for the periodic transmission management table (1 item) */ + uint16_t us_freq; /* Periodic transmission period (in 100ms) */ + // uint32_t notifyId; /* Thread ID */ + uint8_t uc_rid; /* Resources ID */ + uint8_t uc_resp_num; /* Number of transmission result notifications (number of remaining notifications) */ + uint8_t reserve[2]; /* Reserved */ + CAN_DATA st_can_data; /* Transmitted data */ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_FREQ_TRANSMISSION_DAT; + +/*************************************************** +* TAG : CAN_1TIME_TXRSLT_DAT +* ABSTRACT : One transmission result management table structure (1 item) +* (CAN internal data management table) +****************************************************/ +typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */ + CANID ul_canid; /* CAN ID */ + // uint32_t notifyId; /* Addresses for delivery ID */ + uint8_t uc_rid; /* Resources ID */ + uint8_t reserve; /* Reserved */ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_1TIME_TXRSLT_DAT; + +/*************************************************** +* TAG : CAN_1TIME_TXRSLT_MSG_DAT +* ABSTRACT : List of Messages Sent Once (1 item) +* (CAN-internal Work) +****************************************************/ +typedef struct { /* Defining the type of delivery destination CAN ID (1 item) */ + CANID ul_canid; /* CAN ID */ + // uint32_t notifyId; /* Addresses for delivery ID */ + uint8_t uc_rid; /* Resources ID */ + uint8_t uc_sts; /* Transmission result status */ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN_1TIME_TXRSLT_MSG_DAT; + +/*************************************************** +* TAG : CAN_1TIME_TXRSLT_MSG_LIST_DAT +* ABSTRACT : List of Messages Sent Once (All Messages) +* (CAN-internal Work) +****************************************************/ +typedef struct { /* Type definition of the delivery destination ID data to which the message is sent */ + int32_t i_num; /* Number of messages sent */ + CAN_1TIME_TXRSLT_MSG_DAT st_list[CAN_1TIME_TRSNSMISSION_RSLT_NUM]; /* List */ +} CAN_1TIME_TXRSLT_MSG_LIST_DAT; + +/*************************************************** +* TAG : CAN__CWORD29__TXRSLT_DAT +* ABSTRACT : _CWORD29_ send result control table structure (1 item) +* (CAN internal data management table) +****************************************************/ +typedef struct { + uint16_t opc; /* OPC */ + uint8_t uc_rid; /* Resources ID */ + char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */ +} CAN__CWORD29__TXRSLT_DAT; + +/*************************************************** +* TAG : CAN_TRANS_START_TABLE_VAL +* ABSTRACT : Transmit data management table structure (1 item) +* (CAN internal data management table) +****************************************************/ +typedef struct { + uint8_t dlc; + CAN_DATA_BIT dat; +} CAN_TRANS_START_TABLE_VAL; + +/*************************************************** +* TAG : CAN_INIT_TABLE +* ABSTRACT : Transmission data initial value management table structure +****************************************************/ +typedef struct { + CANID canid; + CAN_TRANS_START_TABLE_VAL val; +} CAN_INIT_TABLE; + +/************************************************************************ +* Function prototype * +************************************************************************/ +void CANTransmissionDataInit(void); +BOOL CANFreqTransEntryCheck(CANID canid, uint8_t *); +void CANFreqTransEntry(uint8_t, const CAN_TRANSMISSION_START_MSG_DAT *); +void CANFreqTransDataGet(uint8_t uc_index, CAN_FREQ_TRANSMISSION_DAT *pst_data); +BOOL CANFreqTransCanidEntryCheck(uint8_t, CANID); +BOOL CANFreqTransIdEntryCheck(uint8_t, PCSTR); +void CANFreqTransStop(uint8_t); +BOOL CANFreqTransIndexEntryCheck(uint8_t); +BOOL CAN1TimeTransEntryCheck(uint8_t *); +BOOL CAN_CWORD29_TransEntryCheck(uint8_t *); +EFrameworkunifiedStatus CAN1TimeTransEntry(uint8_t, const CAN_TRANSMISSION_START_MSG_DAT *); +EFrameworkunifiedStatus CAN_CWORD29_TransEntry(uint8_t, const CAN__CWORD29__TRANS_MSG *); +BOOL CANTxRsltEntryCheck(uint8_t); +void CANTxRsltDataGet(uint8_t, CAN_1TIME_TXRSLT_DAT *); +void CAN_CWORD29_TxRsltDataGet(const uint8_t, CAN__CWORD29__TXRSLT_DAT* const); +void CANTxRsltFin(uint8_t); +void CAN_CWORD29_TxRsltFin(const uint8_t); +BOOL CANTxRsltSndCheck(uint8_t, uint32_t); +void CANCycleTransBufferOut(FILE *fp_log); + +BOOL CANTransDataEntry(CAN_TRANS_START_MSG_DAT *); +BOOL CANTransStartTxMsg(HANDLE h_app, CANID); +BOOL CANEntryTransCanidCheck(CANID); + +BOOL CAN_SubIDTransStartTxMsg(HANDLE h_app, CAN_TRANS_START_MSG_DAT *); + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TRANSMISSION_CAN_TRANSMISSIONDATA_H_ diff --git a/communication/server/include/CAN/TxMsg/CAN_TxMsg.h b/communication/server/include/CAN/TxMsg/CAN_TxMsg.h new file mode 100644 index 00000000..15fc56d1 --- /dev/null +++ b/communication/server/include/CAN/TxMsg/CAN_TxMsg.h @@ -0,0 +1,116 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_ +#define COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_ +/****************************************************************************** + * FILE :CAN_TxMsg.h + * SYSTEM :_CWORD107_ + * SUBSYSTEM : + ******************************************************************************/ + +#include "CAN_Thread.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ +#define CAN_TX_COMM_KIND 0x00 /* CANDataCommunication type for transmission */ +#define CAN_TX_PHYS_ADRS 0x0000 /* CANDataPhysical address for transmission */ +#define CAN_TX_FROM_ADRS 0x00 /* CANDataSource address for sending (wildcard) */ +#define CAN_TX_TO_ADRS 0x00 /* CANDataDestination address for sending (wildcard) */ + +/****** OPC ******/ +#define CAN_OPC_RX 0x00 /* CANData reception notice */ +#define CAN_OPC_PAC_RX 0x00 /* CAN Packaging Data Reception Notification */ +#define CAN_OPC_TX 0x00 /* CANDataReport request */ + +#define CAN_OPC_COMMAND_STARTUP_FIN_REQ_TX 0x00 /* CAN start completion notification request transmission */ +#define CAN_OPC_COMMAND_MRST_INFO_REQ_TX 0x01 /* CAN master reset information notification request transmission */ +#define CAN_OPC_COMMAND_VERSION_REQ_TX 0x02 /* CAN Version Request Send */ +#define CAN_OPC_COMMAND_CONNECTION_NODE_REQ_TX 0x03 /* CAN connection node notification request transmission */ +#define CAN_OPC_COMMAND_BUS_STATUS_REQ_TX 0x04 /* CAN bus status notification request transmission */ +#define CAN_OPC_COMMAND_FUELCALC_REQ_TX 0x05 /* CAN section flame reset response transmission */ +#define CAN_OPC_COMMAND_STARTUP_FIN_RESP_RX 0x06 /* CAN startup completion notice received */ +#define CAN_OPC_COMMAND_MRST_INFO_RESP_RX 0x07 /* CAN Master Reset Information Notification Reception */ +#define CAN_OPC_COMMAND_VERSION_RESP_RX 0x08 /* CAN Version Response Reception */ +#define CAN_OPC_COMMAND_CONNECTION_NODE_RESP_RX 0x09 /* Receive CAN Connection Node Notification Response */ +#define CAN_OPC_COMMAND_BUS_STATUS_RESP_RX 0x10 /* CAN Bus Status Notification Response Reception */ +#define CAN_OPC_COMMAND_FUELCALC_RST_REQ_RX 0x11 /* RECEIVE REQUEST FREE OF CAN SECTION */ + +/************************************************************************ +* Struct definitions * +************************************************************************/ +/*************************************************** +* TAG : CAN_TXMSG_DAT +* ABSTRACT : CANDataTransmission data section structure +* (Data structure passed from tha CAN to router) +****************************************************/ +typedef struct { /* Type definition of send command */ + uint8_t reserve; /* Reserved */ + uint8_t uc_length; /* Data length */ + uint8_t uc_kind_padrs; /* Data type/Physical address */ + uint8_t uc_p_adrs; /* Physical address */ + uint8_t uc_from_adrs; /* Source address */ + uint8_t uc_to_adrs; /* Forwarding address */ + uint8_t uc_opc; /* OPC */ + uint8_t uc_operand[CAN_TX_OPERAND_SIZE]; /* Operand*/ +} CAN_TXMSG_DAT; + +/*************************************************** +* TAG : CAN_TXMSG +* ABSTRACT : CANDataTransmission data section structure +* (Data structure passed from tha CAN to router) +****************************************************/ +typedef struct { /* For main processing */ +// T_APIMSG_MSGBUF_HEADER_COMM st_head; /* Header */ + CAN_TXMSG_DAT st_data; /* Data portion */ +} CAN_TXMSG; + +/*************************************************** +* TAG : HANDLE_DAT +* ABSTRACT : MapHandler data-section structures +****************************************************/ +typedef struct { + HANDLE handle; + BOOL is_q_full; /* Queue full judgment flag */ +} HANDLE_DAT; + +/************************************************************************ +* Function prototype * +************************************************************************/ +BOOL CANDeliverySndMsg(HANDLE h_app, CANID canid, uint8_t, const uint8_t *, uint8_t, uint8_t); +BOOL CANDelivery_CWORD29_SndMsg(HANDLE h_app, const uint16_t us_opc, uint32_t uc_dlc, const uint8_t *puc_data); +/* CANDataDelivery Messages Sending Process (Except for CANGW) */ +BOOL CANDeliverySndMsgToCANGW(HANDLE h_app, CAN_MSG_CANGWDATA *cangw_data); +/* CAN-data-delivery-messaging process to the CANGW */ +BOOL CANFreqTransStartTxMsg(HANDLE h_app, uint8_t); /* CANDataPeriodic transmission start message transmission processing */ +BOOL CAN1TimeTransStartTxMsg(HANDLE h_app, uint8_t, const CAN_DATA *); /* CANDataSend one transmission start message processing */ +void CANCommWatchSndMsg(HANDLE h_app, uint8_t); /* CANDataTransmission of communication interruption detection/recovery message */ +BOOL CANTxRsltSndMsg(HANDLE h_app, uint8_t, uint8_t); /* CANDataTransmission result notification message transmission processing */ +/* _CWORD29_ data transmission result notification message transmission process */ +BOOL CAN_CWORD29_TxRsltSndMsg(const HANDLE h_app, const uint8_t uc_can_rid, const uint8_t uc_status); +void CANCanidUserToIfCvt(CANID canid, uint8_t *); /* CAN ID Conversion Process 2 */ + +BOOL CANCommandDeliverySndMsg(HANDLE h_app, uint8_t, const uint8_t *); /* CAN command delivery message transmission processing */ +BOOL CANCommandTxRsltSndMsg(HANDLE h_app, uint8_t, uint8_t); /* CAN command transmission result notification message transmission processing */ +BOOL CANCommandTransmissionSndMsg(uint8_t, uint8_t); /* CAN command message transmission processing */ +BOOL CANCommandFuelCalcRstReqSndMsg(HANDLE h_app, PCSTR name); /* CAN section flame reset request reception message transmission processing */ +BOOL CANCommandidOpcToUserCvt(uint8_t, uint8_t *); /* CAN Command ID Conversion Processing 1 */ +BOOL CANCommandidUserToOpcCvt(uint8_t, uint8_t *); /* CAN command ID conversion process 2 */ + +BOOL CANTransStartTxMsgCore(HANDLE h_app, CANID canid, uint8_t, CAN_DATA_BIT *); + +#endif // COMMUNICATION_SERVER_INCLUDE_CAN_TXMSG_CAN_TXMSG_H_ diff --git a/communication/server/include/com_error_type.h b/communication/server/include/com_error_type.h new file mode 100644 index 00000000..bfd96b3a --- /dev/null +++ b/communication/server/include/com_error_type.h @@ -0,0 +1,35 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_ +#define COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_ + +/************************************************************************* + * RET_API define + *************************************************************************/ + +#define RET_NORMAL 0 /* Normal completion */ + +/* Function code (normal termination) system */ +#define RET_RCVMSG 1 /* Receive only message */ + +/* Error code system */ +#define RET_OSERROR -127 /* OS System call error*/ +#define RET_ERROR -1 /* Error termination (content is unspecified) */ +#define RET_ERRPARAM -2 /* Parameter error */ +#define RET_ERRTIMEOUT -5 /* Timeout with Processing Not Complete */ + +#endif // COMMUNICATION_SERVER_INCLUDE_COM_ERROR_TYPE_H_ diff --git a/communication/server/include/main/communication_cid.h b/communication/server/include/main/communication_cid.h new file mode 100644 index 00000000..21882eea --- /dev/null +++ b/communication/server/include/main/communication_cid.h @@ -0,0 +1,47 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup +/// \brief +/// +/// +/// +/// +/// +/////////////////////////////////////////////////////////////////////////////// + +/* + * This file has been generated automatically. + * User hand written code entry is not allowed. Do not modify the file content. + * + */ +#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_ +#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Include Files +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#define LAN_SERVICE_MAIN "Communication" + +typedef enum PSCommunicationServiceProtocol { + CID_COMMSYS_MSG_BASE = PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD, // Base command id. + CID_COMMSYS_CAN_READY, // CAN_COM_PROT->Communication + CID_COMMSYS_TIMEOUT, // Communication->CAN +} PS_CommunicationServiceProtocol; + +#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_CID_H_ diff --git a/communication/server/include/main/communication_communicationlog.h b/communication/server/include/main/communication_communicationlog.h new file mode 100644 index 00000000..c8a46e5f --- /dev/null +++ b/communication/server/include/main/communication_communicationlog.h @@ -0,0 +1,94 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup +/// \brief +/// +/// +/// +/// +/// +/////////////////////////////////////////////////////////////////////////////// + +/* + * This file has been generated automatically. + * User hand written code entry is not allowed. Do not modify the file content. + * + */ +#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_ +#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Include Files +//////////////////////////////////////////////////////////////////////////////////////////////////// +#include + +#define ZONE_INIT ZONEMASK(10) +#define ZONE_FUNC ZONEMASK(11) +#define ZONE_MEM ZONEMASK(12) +#define ZONE_APP ZONEMASK(13) +#define ZONE__CWORD83__DEBUG ZONEMASK(14) +#define ZONE_CAN_DEBUG ZONEMASK(15) +#define ZONE_16 ZONEMASK(16) +#define ZONE_COMMSYS ZONEMASK(17) +#define ZONE_ICR ZONEMASK(18) +#define ZONE_ICR_TABLE ZONEMASK(19) +#define ZONE_TRANSLOG ZONEMASK(20) +#define ZONE_LOOPBACK ZONEMASK(22) +#define ZONE_ENTRY ZONEMASK(23) +#define ZONE_24 ZONEMASK(24) +#define ZONE_25 ZONEMASK(25) +#define ZONE_26 ZONEMASK(26) +#define ZONE_27 ZONEMASK(27) +#define ZONE_DEBUG ZONEMASK(28) +#define ZONE_INFO ZONEMASK(29) +#define ZONE_WARN ZONEMASK(30) +#define ZONE_ERR ZONEMASK(31) +#define ZONE_COMM_SYS_STS ZONEMASK(107) + +#define ZONE_TEXT_10 "Init" +#define ZONE_TEXT_11 "Function" +#define ZONE_TEXT_12 "Memory" +#define ZONE_TEXT_13 "StateMachine Example" +#define ZONE_TEXT_14 "_CWORD83_" +#define ZONE_TEXT_15 "CAN" +#define ZONE_TEXT_16 "" +#define ZONE_TEXT_17 "COMSYS" +#define ZONE_TEXT_18 "ICR" +#define ZONE_TEXT_19 "ICR_TABLE" +#define ZONE_TEXT_20 "TRANSLOG" +#define ZONE_TEXT_21 "" +#define ZONE_TEXT_22 "" +#define ZONE_TEXT_23 "" +#define ZONE_TEXT_24 "" +#define ZONE_TEXT_25 "" +#define ZONE_TEXT_26 "" +#define ZONE_TEXT_27 "" +#define ZONE_TEXT_28 "Debug" +#define ZONE_TEXT_29 "Info" +#define ZONE_TEXT_30 "Warning" +#define ZONE_TEXT_31 "Error" + +#ifndef FRAMEWORKUNIFIEDLOGOPTIONS +#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER +#endif + +#ifndef FRAMEWORKUNIFIEDLOGAPPZONES +#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_APP, ZONE_ERR, ZONE_WARN, ZONE_INFO, ZONE_COMM_SYS, ZONE_CAN_FILTER, ZONE_COMM_SYS_STS +#endif + +#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_COMMUNICATIONLOG_H_ diff --git a/communication/server/include/main/communication_version.h b/communication/server/include/main/communication_version.h new file mode 100644 index 00000000..cdb83e66 --- /dev/null +++ b/communication/server/include/main/communication_version.h @@ -0,0 +1,45 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +////////////////////////////////////////////////////////////////////////////////////////////////// +/// \file version.h +/// \ingroup +/// \version 0.1.0 +/// \brief +/// +/// \todo +////////////////////////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////////////////// +// File name : version.h +// Module : Communication +// Description : TODO INSERT +// Scope : < example:Legacy Architecture> +// Platform : _CWORD3_002 Platform +// +// Customer : +// System : +// Reference : +////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_ +#define COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_ + +#define MAJORNO 0x01 +#define MINORNO 0x00 +#define REVISION 0x00 + +#endif // COMMUNICATION_SERVER_INCLUDE_MAIN_COMMUNICATION_VERSION_H_ diff --git a/communication/server/include/peripheral_service/communication.h b/communication/server/include/peripheral_service/communication.h new file mode 100644 index 00000000..e99996ce --- /dev/null +++ b/communication/server/include/peripheral_service/communication.h @@ -0,0 +1,29 @@ +// +// @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file communication.h + * @~english + * @brief communication unit header + */ + +#ifndef PERIPHERALSERVICE_COMMUNICATION_H_ // NOLINT(build/header_guard) +#define PERIPHERALSERVICE_COMMUNICATION_H_ // NOLINT(build/header_guard) + +#include +#include + +#endif // PERIPHERALSERVICE_COMMUNICATION_H_ diff --git a/communication/server/include/peripheral_service/communication_notifications.h b/communication/server/include/peripheral_service/communication_notifications.h new file mode 100644 index 00000000..97817177 --- /dev/null +++ b/communication/server/include/peripheral_service/communication_notifications.h @@ -0,0 +1,28 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file communication_notifications.h + * @~english + * @brief Defination of communication notification + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_ +#define COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_ + +/*! @~english Defination of communication notification */ +#define NTFY_Communication_Availability "Communication/Availability" + +#endif // COMMUNICATION_SERVER_INCLUDE_PERIPHERAL_SERVICE_COMMUNICATION_NOTIFICATIONS_H_ diff --git a/communication/server/include/peripheral_service/ps_services.h b/communication/server/include/peripheral_service/ps_services.h new file mode 100644 index 00000000..dbb823ee --- /dev/null +++ b/communication/server/include/peripheral_service/ps_services.h @@ -0,0 +1,94 @@ +/* + * @copyright Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*!------------------------------------------------------------------------------------------------ + * @file ps_services.h + * @~english + * @brief Defines the names of the available peripheral services. + */ + +#ifndef PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard) +#define PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard) + +/** + * @file ps_services.h + */ +/** @addtogroup BaseSystem + * @{ + */ +/** @addtogroup peripheral_service + * @ingroup BaseSystem + * @{ + */ + +/*------------------------------------------------------------------------------ + * define + *----------------------------------------------------------------------------*/ +#define SERVICE_PSMSHADOW "PS_PSMShadow" +/*!< @~english Define the name of SERVICE_PSMSHADOW */ + +#define SERVICE_IPC "PS_IPC_DISP" +/*!< @~english Define the name of SERVICE_IPC */ + +#define SERVICE_IPC_DISP "PS_IPC" +/*!< @~english Define the name of SERVICE_IPC_DISP */ + +#define SERVICE_IPCTESTAPP "PS_IPC_TestApp" +/*!< @~english Define the name of SERVICE_IPCTESTAPP */ + +#define SERVICE_HMIKEYHANDLER "PS_KeyHandler" +/*!< @~english PS_KeyHandler name SERVICE_HMIKEYHANDLER */ + +#define SERVICE_MP_SHADOW "PS_IPC_MP_Shadow" +/*!< @~english Define the name of SERVICE_MP_SHADOW */ + +#define SERVICE_SENSORSHADOW "PS_SensorShadow" +/*!< @~english Define the name of SERVICE_SENSORSHADOW */ + +#define SERVICE_COMMUNICATIONDEBUGDUMPTEST "PS_COMMUNICATIONDebugDumpTest" +/*!< @~english Define the name of SERVICE_COMMUNICATIONDEBUGDUMPTEST */ + +#define SERVICE_PSMSHADOWTEST "PS_TEST_PSMShadow" +/*!< @~english Define the name of SERVICE_PSMSHADOWTEST */ + +#define SERVICE_LOGGERSHADOW "PS_LoggerShadow" +/*!< @~english Define the name of SERVICE_LOGGERSHADOW */ + +#define SERVICE_SOFTWAREUPDATESHADOW "PS_SoftwareUpdateShadow" +/*!< @~english Define the name of SERVICE_SOFTWAREUPDATESHADOW */ + +// #define SERVICE_LINSHADOW "LINShadowService" +///*!< @~english Define the name of SERVICE_LINSHADOW */ + +// #define SERVICE_RTCSHADOW "RTCShadowService" +///*!< @~english Define the name of SERVICE_RTCSHADOW */ + +// #define SERVICE_HBSHADOW "HBShadowService" +///*!< @~english Define the name of SERVICE_HBSHADOW */ + +// #define SERVICE_HBDUMMY "HBDummyService" +///*!< @~english Define the name of SERVICE_HBDUMMY */ + +// #define SERVICE_DISPLAYSHADOW "DisplayShadowService" +///*!< @~english Define the name of SERVICE_DISPLAYSHADOW */ + +// #define SERVICE_HMIALDUMMY "HMIALDummyService" +///*!< @~english Define the name of SERVICE_HMIALDUMMY */ + +/** @}*/ // end of peripheral_service +/** @}*/ // end of BaseSystem + +#endif // PERIPHERALSERVICE__CWORD121_SHADOW_CLIENT_INCLUDE_PERIPHERAL_SERVICE_PS_SERVICES_H_ // NOLINT(build/header_guard) diff --git a/communication/server/include/private/ICR_Common.h b/communication/server/include/private/ICR_Common.h new file mode 100644 index 00000000..c9bae1c1 --- /dev/null +++ b/communication/server/include/private/ICR_Common.h @@ -0,0 +1,30 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*!----------------------------------------------------------------------------- + * @file ICR_Common.h + * @~english + * @brief ICR common definitions + *----------------------------------------------------------------------------*/ +#ifndef COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_ +#define COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_ + +#include +//#include + +//#include + +#endif // COMMUNICATION_SERVER_INCLUDE_PRIVATE_ICR_COMMON_H_ diff --git a/communication/server/include/threads/CAN_Thread.h b/communication/server/include/threads/CAN_Thread.h new file mode 100644 index 00000000..67a814a0 --- /dev/null +++ b/communication/server/include/threads/CAN_Thread.h @@ -0,0 +1,158 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_ +#define COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_ +/*!----------------------------------------------------------------------------- + * @file CAN_Thread.h + * @~english + * @brief CAN Thread main block header file + *----------------------------------------------------------------------------*/ +#include +#include + +#include "com_error_type.h" +#include "ICR_Common.h" +#include "communication_communicationlog.h" + +/************************************************************************ +* Macro definitions * +************************************************************************/ +/* Data size relationship */ + +#define CAN_TRX_HEADER_SIZE 7 /* Size of send/receive header section (data length excluding operands) */ +#define CAN_TRX_HEADER_LEN_SIZE 5 /* Size included in the data length calculation of the send/receive header section */ + +#define CAN_TRX_CANID_SIZE 4 /* Transmit/Receive CAN ID Size */ +#define CAN_TRX_DLC_SIZE 1 /* Transmit/Receive DLC Data Size */ +#define CAN_TRX_DLC_RESERVE_SIZE 3 /* Reserved data size after transmit/receive DLC */ + +#define CAN_RX_CANDATA_SIZE CAN_DATA_SIZE /* Reserve CANData(DATA#1 ~ #x)size */ +/* Reserve the structure if it is not a multiple of 4. */ +#define CAN_TX_CANDATA_SIZE CAN_DATA_SIZE /* Send CANData(DATA#1 ~ #x)size */ +/* Reserve the structure if it is not a multiple of 4. */ +#define CAN_RX_OPERAND_SIZE (CAN_TRX_CANID_SIZE + CAN_TRX_DLC_SIZE + CAN_RX_CANDATA_SIZE) +/* Receive operand size */ +#define CAN_RX_COMMAND_SIZE (CAN_TRX_HEADER_SIZE + CAN_RX_OPERAND_SIZE) +/* Receive command size */ +#define CAN_TX_OPERAND_SIZE (CAN_TRX_CANID_SIZE + CAN_TRX_DLC_SIZE + CAN_TX_CANDATA_SIZE) // NOLINT(whitespace/line_length) +/* Send operand size */ +#define CAN_TX_COMMAND_SIZE (CAN_TRX_HEADER_SIZE + CAN_TX_OPERAND_SIZE) +/* Send command size */ +#define CAN_TX_CMD_DELIVERY_SIZE 4 /* Transmitting CAN Command Delivery Data Size Common Block */ +#define CAN_TX_CMD_FUELCALC_RST_SIZE 0 /* Transmit CAN Command Delivery Data Size CAN Section Burn Cost Reset Request Receive Data */ +#define CAN_TX_CMD_STARTUP_FIN_SIZE 3 /* Transmit CAN Command Delivery Data Size CAN Startup Completion Notification Data */ +#define CAN_TX_CMD_MRST_INFO_SIZE 33 /* Transmit CAN Command Delivery Data Size CAN Master Reset Information Notification Receive Data */ +#define CAN_TX_CMD_VERSION_SIZE 4 /* Transmit CAN Command Delivery Data Size CAN Version Response Receive Data */ +#define CAN_TX_CMD_BUS_STATUS_SIZE 1 /* Transmit CAN Command Delivery Data Size Receive CAN Bus Status Notification Response */ + +#define CAN_CMDSND_DATA_SIZE 0 /* Command transmission data section size (CAN command control) */ + +/* Data location relationship */ +#define CAN_MSGBUF_CANID_POS 0 /* How many operands the CAN ID contains? */ +#define CAN_MSGBUF_DLC_POS 4 /* No. of operand from which DLC contains data? */ +#define CAN_MSGBUF_DATA_POS 5 /* How many operands does the DATA contain? */ + +#define CAN_MSGBUF_PAC_CANID_POS 1 /* How many operands the CAN ID contains? */ +#define CAN_MSGBUF_PAC_DLC_POS 3 /* No. of operand from which DLC contains data? */ +#define CAN_MSGBUF_PAC_DATA_POS 4 /* How many operands does the DATA contain? */ + +/* Error definitions */ +#define RET_CAN_INIT_SUCCESS RET_NORMAL /* Success in initialization */ +#define RET_CAN_INIT_ERROR RET_ERROR /* Master Clear failed */ + +#define RET_CAN_NORMAL CANIF_RET_NORMAL /* Normal completion */ +#define RET_CAN_ERROR_CREATE_EVENT CANIF_RET_ERROR_CREATE_EVENT /* Event generation failure */ +#define RET_CAN_ERROR_PARAM CANIF_RET_ERROR_PARAM /* Specified parameter is invalid */ +#define RET_CAN_ERROR_UNDEF CANIF_RET_ERROR_UNDEF /* Unregistered ID */ +#define RET_CAN_ERROR_SNDID CANIF_RET_ERROR_PID /* Discrepancy of Destination ID */ +#define RET_CAN_ERROR_BUFFULL CANIF_RET_ERROR_BUFFULL /* Registered FULL (Delivery/Periodic Transmission/Communication Disruption Monitor) */ +#define RET_CAN_ERROR_CANIDFULL CANIF_RET_ERROR_CANIDFULL /* CAN ID type is FULL */ +#define RET_CAN_ERROR_TIMER CANIF_RET_ERROR_TIMER /* Timer acquisition failed */ +#define RET_CAN_ERROR_CANCEL CANIF_RET_ERROR_CANCEL /* Abnormal termination (discard/cancel data) */ + +/* CANDataControl code used in the transmission/reception relationship */ +#define CAN_ID_EXT_FLAG 0x80000000UL /* CAN ID Extended Identity Codes */ + +/* Timer Relationship */ +#define CAN_TIMER_SEQNO_CODE 0x0001 /* CAN thread timer sequence number */ +#define CAN_TIMER_SEQNO_BUFFLOGOUT 0x0002 /* Buffer log output timer No. */ + +#define COMM_WATCH_SEQNO_CODE 0x0000 /* Timer Sequence Number Identification Flag of Communication Disruption */ +#define FREQ_TRANS_SEQNO_CODE 0x8000 /* Timer Sequence Number Identification Flag for Periodic Transmission */ +#define CAN_TIMER_DISTINCTION_CODE 0xF000 /* Timer Sequence Number Identification Flag */ + +#define CAN_COMTIM_OFF 0x00 /* Timer not started */ +#define CAN_COMTIM_ON 0x01 /* Timer activation state */ + +#define CAN_FREQ_TRSNSMISSION_LIST_NUM 32 /* Maximum number of periodic transmission management tables */ +#define COMM_WATCH_LIST_NUM 64 /* Maximum number of communication disruption monitoring management tables */ + + +/* Maximum number of CAN periodic transmission timer management data */ +#define CAN_FREQTRANS_TIMER_DATA CAN_FREQ_TRSNSMISSION_LIST_NUM +/* Maximum number of CAN disruption monitoring timer management data */ +#define CAN_COMMWATCH_TIMER_DATA COMM_WATCH_LIST_NUM + +#define CAN_BUFFER_LOGOUT_NAME "/fs/U0/can_buffer_log.txt" /* */ + +#define CAN_USAGE_RATE_THRESHOLD 80 /* Buffer Utilization Threshold (80%) */ + +#define CAN_DELIVERY_DLCERR 0xfeff /* CAN delivery error (DLC) */ +#define CAN_DELIVERY_CSUMERR 0xfefe /* CAN delivery errors (CSUM) */ +#define CAN_DELIVERY_ERR 0xfefd /* CAN delivery error (delivery unregistered) */ +#define CAN_TRANCE_ICR_ERR 0xfefc /* CAN transmission error (ICR) */ +#define CAN_TRANCE_SYSCOM_ERR 0xfefb /* CAN transmission errors (SYSCOM) */ + +/********************************************************************* +* Type definition +***********************************************************************/ +typedef CANIF_RET_API RET_CAN; + +typedef enum { + CAN_PROTOCOL_TYPE_CAN = 0, /* CAN */ + /* -------------------------------------------------------------------- */ + CAN_PROTOCOL_TYPE_TERMINATE /* Mode termination */ +} CAN_PROTOCOL_TYPE; + +/************************************************************************ +* Function prototype * +************************************************************************/ +RET_CAN CANMainThreadInit(void); +EFrameworkunifiedStatus CANCallbackForTimeOut(HANDLE); +void CANTimeOutMsg(HANDLE h_app, uint16_t); +void CANCommonTimerStart(void); +void CANBufferLogOut(void); +void CANDebugLogOut(uint16_t, void*); +void CANFreqTransTimeOutMap(void); + +/******************************************************************************* + * MODULE : CANMsgErrChk + * ABSTRACT : Message Send/Receive Error Check Processing + * FUNCTION : Check for message transmission and reception errors and perform error processing. + * ARGUMENT : RET_API ret_api Message send/receive return value + * : u_int16 communication_code Registration code + * NOTE : + * RETURN : + ******************************************************************************/ + +inline void CANMsgErrChk(int32_t ret_api, uint16_t communication_code) { + if (RET_ERROR == ret_api) { /* In case of an error */ + FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CANMsgErrChk Called."); + exit(EXIT_FAILURE); + } +} +#endif // COMMUNICATION_SERVER_INCLUDE_THREADS_CAN_THREAD_H_ diff --git a/communication/server/include/threads/Thread_Common.h b/communication/server/include/threads/Thread_Common.h new file mode 100644 index 00000000..91b907d5 --- /dev/null +++ b/communication/server/include/threads/Thread_Common.h @@ -0,0 +1,32 @@ +/* + * @copyright Copyright (c) 2019 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef COMMUNICATION_SERVER_INCLUDE_THREADS_THREAD_COMMON_H_ +#define COMMUNICATION_SERVER_INCLUDE_THREADS_THREAD_COMMON_H_ +#include +//#include +const int32_t CAN_AVAILABILITY = 0x1; + +BOOL CommGetAvailabilityCurrent(int32_t current); +void CommSetAvailabilityCurrent(int32_t current); +void CommClrAvailabilityCurrent(int32_t current); +EFrameworkunifiedStatus CommonStartNotify(HANDLE h_app, PCSTR cmd); +//EFrameworkunifiedStatus CommonCanHalThreadStart(HANDLE h_app, +// const FrameworkunifiedProtocolCallbackHandler *cb, +// UI_32 count, PCSTR cmd, CanHalParam *p); +//EFrameworkunifiedStatus CommonCanHalThreadStop(HANDLE h_app, const PUI_32 cb, +// UI_32 count, PCSTR cmd, CanHalType type); +EFrameworkunifiedStatus CommonCanHalErrorNotify(const char *msg, void *ctxid); +#endif -- cgit 1.2.3-korg