Init basesystem source codes.
[staging/basesystem.git] / peripheralservice / communication / server / include / CAN / Delivery / CAN_DeliveryData.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_
18 #define COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_
19 /******************************************************************************
20  * FILE  :CAN_DeliveryData.h
21  * SYSTEM  :_CWORD107_
22  * SUBSYSTEM :
23 -----------------------------------------------------------------------------*/
24 #include <native_service/frameworkunified_types.h>
25 #include <peripheral_service/Canif_API.h>
26
27 /************************************************************************
28 *   Macro definitions             *
29 ************************************************************************/
30 /* Data size relationship */
31 #define CAN_DELIVERY_LIST_NUM 400                                               /* Maximum number of delivery destination management tables */
32 #define CAN_DELIVERY_CANID_LIST_NUM 150 /* Delivery CAN ID control table max. */
33
34 #define CAN_EXRCV_DATA_NUM 22   /* CAN Extended Reception Notification CAN Maximum Number of Data */
35 #define CAN_EXRCV_DATA_SIZE 11  /* CAN Extended Reception Notification CAN Data Size */
36 #define CAN_EXRCV_CANNUM_SIZE 1 /* CAN Extended Reception Notification CAN Data Number Size */
37 #define CAN_EXRCV_DLC_MIN 1     /* CAN Extended Reception Notification DLC Minimum Value */
38 #define CAN_EXRCV_DLC_MAX 8     /* CAN Extended Reception Notification DLC Maximum Value */
39
40 /* Flag relationship */
41 #define CAN_DELIVERY_OFF 0 /* Stopping data delivery */
42 #define CAN_DELIVERY_ON 1  /* Data delivery in progress */
43
44 /* CANDataControl code relationship used in the delivery relationship */
45 #define CAN_DELIVERYLIST_STOP_CODE 0xFFFF /* Shipping Destination Management Table Stop Code */
46
47 #define CAN_CANIDLIST_EMPTY 0xFFFF /* Availability of CAN ID control table */
48 /************************************************************************
49 *   Struct definitions
50 ************************************************************************/
51 /***************************************************
52 * TAG       : CAN_DELIVERY_DAT
53 * ABSTRACT  : Destination management table structure (1 item)
54 *             (CAN internal data management table)
55 ****************************************************/
56 typedef struct {                      /* Type definition of delivery destination management data (1 item) */
57   CANID ul_canid;                      /* CAN ID */
58   char notify_name[MAX_NAME_SIZE_APP]; /* Destination thread name */
59                                       // uint32_t  notifyId;  /* Addresses for delivery ID */
60   uint8_t uc_delivery_on;               /* Delivery operation */
61   uint8_t reserve1;                   /* Reserved */
62   uint16_t us_link_id;                  /* Link ID */
63   uint8_t reserve2[2];                /* Reserved */
64 } CAN_DELIVERY_DAT;
65
66 /***************************************************
67 * TAG       : CAN_DELIVERY_LIST_DAT
68 * ABSTRACT  : Destination management table structure (all)
69 *             (CAN internal data management table)
70 ****************************************************/
71 typedef struct {                                  /* Type definition of the shipping management table */
72   uint16_t us_entry_num;                            /* Registered number */
73   uint8_t reserve[2];                             /* Reserved */
74   CAN_DELIVERY_DAT st_list[CAN_DELIVERY_LIST_NUM]; /* Delivery destination management data */
75 } CAN_DELIVERY_LIST_DAT;
76
77 /***************************************************
78 * TAG       : CAN_DELIVERY_SPACE_DAT
79 * ABSTRACT  : Free space management structure in the destination management table (all)
80 *             (CAN internal data management table free space management table)
81 ****************************************************/
82 typedef struct {                             /* Type definitions for free space management tables */
83   uint16_t space_num;                         /* Number of free spaces */
84   uint16_t index_list[CAN_DELIVERY_LIST_NUM]; /* Free space index list */
85 } CAN_DELIVERY_SPACE_DAT;
86
87 /***************************************************
88 * TAG       : CAN_CANID_DAT
89 * ABSTRACT  : Transport CAN ID control table structures (1 item)
90 *             (CAN internal data management table)
91 ****************************************************/
92 typedef struct {      /* Defining the type of delivery destination CAN ID (1 item) */
93   CANID ul_canid;      /* CAN ID */
94   uint16_t us_start_id; /* Start ID */
95   uint16_t us_end_id;   /* End ID */
96   uint16_t us_data_num; /* Number of data items */
97   uint8_t reserve[2]; /* Reserved */
98 } CAN_CANID_DAT;
99
100 /***************************************************
101 * TAG       : CAN_CANID_LIST_DAT
102 * ABSTRACT  : Delivery CAN ID control table structures (all)
103 *             (CAN internal data management table)
104 ****************************************************/
105 typedef struct {                                     /* Type definitions for the target CAN ID administration table */
106   uint16_t us_entry_num;                               /* Registered number */
107   uint8_t reserve[2];                                /* Reserved */
108   CAN_CANID_DAT st_list[CAN_DELIVERY_CANID_LIST_NUM]; /* Shipping CAN ID */
109 } CAN_CANID_LIST_DAT;
110
111 /***************************************************
112 * TAG       : CAN_DELIVERY_SND_DAT
113 * ABSTRACT  : Destination thread name for sending a message of delivery data
114 *             (CAN-internal Work)
115 ****************************************************/
116 /* Type definition of the target thread name list data to which the message is sent */
117 typedef struct {
118   int32_t i_num;                                              /* Number of messages sent */
119   char notify_name[CAN_DELIVERY_LIST_NUM][MAX_NAME_SIZE_APP]; /* Destination thread name */
120 } CAN_DELIVERY_SND_DAT;
121
122 typedef struct {
123   CAN_DELIVERY_LIST_DAT* p_dlvry_list;
124   CAN_DELIVERY_SPACE_DAT* p_dlvry_space;
125   CAN_CANID_LIST_DAT* p_canid_list;
126   CAN_DELIVERY_SND_DAT* p_dlvry_snd;
127 } CAN_STRUCT_PTR;
128
129 /************************************************************************
130 *   Function prototype             *
131 ************************************************************************/
132 void CANDeliveryDataInit(void);          /* CANDataDelivery Management Data Initialization Process */
133 EFrameworkunifiedStatus CANDeliveryEntry(HANDLE h_app); /* CANDataDelivery registration process */
134 void CANDeliveryBufferOut(FILE* fp_log);   /* CAN shipping table log output processing */
135 EFrameworkunifiedStatus CANClearEntry(HANDLE h_app);
136
137 #endif  // COMMUNICATION_SERVER_INCLUDE_CAN_DELIVERY_CAN_DELIVERYDATA_H_