common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / peripheralservice / communication / client_can / include / peripheral_service / Canif_API.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 /****************************************************************************
18  * FILE    Canif_API.h
19  * TITLE   :Data header files needed to use the CAN I/F API
20  ****************************************************************************/
21
22 #ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
23 #define COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
24
25 /**
26  * @file Canif_API.h
27  * @~english
28  * @brief Canif API header
29  */
30
31 /** @addtogroup BaseSystem
32  *  @{
33  */
34 /** @addtogroup peripheral_service
35  *  @ingroup BaseSystem
36  *  @{
37  */
38 /** @addtogroup communication
39  *  @ingroup peripheral_service
40  *  @{
41  */
42 /** @addtogroup CAN
43  *  @ingroup communication
44  *  @{
45  */
46
47 #include <native_service/frameworkunified_types.h>
48 #include <stdio.h>
49 #include <unistd.h>
50 #include <asm/unistd.h>
51 #include <stub/com_message_header.h>
52
53 /**
54  * \~english  Defination of Service name
55  */
56 #define LAN_SERVICE_CAN "CAN_COM_PROT"
57
58 /**
59  * \~english  Availability notification of CAN
60  */
61 #define NTFY_Communication_CAN_ISAVAILABLE "Communication/CanIsAvailable"
62
63 /*********************************************************************
64 *                       Defining Return Values
65 ***********************************************************************/
66 /* Normal system */
67 /**
68  * \~english  Suceess
69  */
70 #define CANIF_RET_NORMAL 1
71 /* Abnormal system */
72 /**
73  * \~english  Parameter error
74  */
75 #define CANIF_RET_ERROR_PARAM 2
76 /**
77  * \~english  Buffer Full
78  */
79 #define CANIF_RET_ERROR_BUFFULL 3
80 /**
81  * \~english  CAN ID FULL
82  */
83 #define CANIF_RET_ERROR_CANIDFULL 4
84 /**
85  * \~english  ID unregister
86  */
87 #define CANIF_RET_ERROR_UNDEF 5
88 /**
89  * \~english  Thread ID unmatched
90  */
91 #define CANIF_RET_ERROR_PID 6
92 /**
93  * \~english  Timer error
94  */
95 #define CANIF_RET_ERROR_TIMER 7
96 /**
97  * \~english  Event Creat Error
98  */
99 #define CANIF_RET_ERROR_CREATE_EVENT 8
100 /**
101  * \~english  Error Cancel
102  */
103 #define CANIF_RET_ERROR_CANCEL 9
104 /**
105  * \~english  Null Pointer
106  */
107 #define CANIF_RET_ERROR_NULL 10
108
109 /**
110  * \~english  Flags for specifiy Delivery is echoback or not.
111  */
112 enum CanIfEchoBackFlags {
113   /**
114   * \~english  Delivery is recv data
115   */
116   CANIF_PURERECV = 0,
117   /**
118   * \~english  Delivery is echo data
119   */
120   CANIF_ECHOBACK = 1
121 };
122
123 /**
124  * \~english  Defination of Command ID ( CAN -> user )
125  */
126 typedef enum _PS_CommunicationProtocol {
127   /**
128   * \~english  Delivery CAN Data
129   */
130   CID_CAN_DATA_DELIVERY = 0x0401,
131   /**
132   * \~english  CAN communication stop
133   */
134   CID_CAN_COMM_STOP,
135   /**
136   * \~english  CAN communication restore
137   */
138   CID_CAN_COMM_RESTORE,
139   /**
140   * \~english  CAN transmission result
141   */
142   CID_CAN_TX_RESULT,
143   /**
144   * \~english  Delivery CAN command
145   */
146   CID_CAN_CMD_DELIVERY,
147   /**
148   * \~english  CAN command transmission result
149   */
150   CID_CAN_CMD_TX_RESULT,
151   /**
152   * \~english  Delivery CAN data to CANGW
153   */
154   CID_CAN_CANGW_DELIVERY,
155 } PS_CommunicationProtocol;
156
157 /**
158  * \~english  Defination of Command ID ( CANIF -> CAN )
159  */
160 typedef enum _PS_Communication_InternalProtocol {
161   /**
162   * \~english  Delivery registration of CAN data 
163   */
164   CID_CANIF_DELIVERY_ENTRY = 0x0501,
165   /**
166   * \~english  Delivery deregistration of CAN data
167   */
168   CID_CANIF_DELIVERY_ERASE,
169   /**
170   * \~english  CAN data transmission start
171   */
172   CID_CANIF_TX_START,
173   /**
174   * \~english  CAN data communication stop watching 
175   */
176   CID_CANIF_COMM_WATCH,
177   /**
178   * \~english  CAN command control
179   */
180   CID_CANIF_CMD_CTRL,
181   /**
182   * \~english  CAN data transmission start
183   */
184   CID_CANIF_TX_BIT_START,
185 } PS_Communication_InternalProtocol;
186
187 /*********************************************************************
188 *                     Definitions of CAN command IDs
189 ***********************************************************************/
190 /**
191 * \~english  Request CAN fuel calculator reset 
192 */
193 #define CAN_CMDID_FUELCALC_RST_REQ_DELIVERY 0x00
194 /**
195 * \~english  Request CAN startup finished notification  
196 */
197 #define CAN_CMDID_STARTUP_FIN_REQ_TX 0x01
198 /**
199 * \~english  Request CAN Master reset notification
200 */
201 #define CAN_CMDID_MRST_INFO_REQ_TX 0x02
202 /**
203 * \~english  Request CAN version
204 */
205 #define CAN_CMDID_VERSION_REQ_TX 0x03
206 /**
207 * \~english  Request CAN connected node notification
208 */
209 #define CAN_CMDID_CONNECTION_NODE_REQ_TX 0x04
210 /**
211 * \~english  Request CAN BUS status notification
212 *   ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
213 */
214 #define CAN_CMDID_BUS_STATUS_REQ_TX 0x05
215 /**
216 * \~english  Response of CAN fuel calculator reset
217 */
218 #define CAN_CMDID_FUELCALC_REQ_TX 0x06
219 /**
220 * \~english  Receive CAN fuel calculator reset request
221 */
222 #define CAN_CMDID_FUELCALC_RST_REQ_RX 0x07
223 /**
224 * \~english  Receive CAN startup finished notification
225 */
226 #define CAN_CMDID_STARTUP_FIN_RESP_RX 0x08
227 /**
228 * \~english  Receive CAN Master reset notification
229 */
230 #define CAN_CMDID_MRST_INFO_RESP_RX 0x09
231 /**
232 * \~english  Response of CAN version receive
233 */
234 #define CAN_CMDID_VERSION_RESP_RX 0x0A
235 /**
236 * \~english  Response of CAN connection node receive
237 */
238 #define CAN_CMDID_CONNECTION_NODE_RESP_RX 0x0B
239 /**
240 * \~english  Response of CAN bus status receive
241 *   ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
242 */
243 #define CAN_CMDID_BUS_STATUS_RESP_RX 0x0C
244
245 /*********************************************************************
246 *                     Control Flag/Status Definition
247 ***********************************************************************/
248 /* CANData Delivery control flag */
249 /**
250 * \~english  Delivery stop
251 */
252 #define CAN_DELIVERY_STOP 0
253 /**
254 * \~english  Delivery restart
255 */
256 #define CAN_DELIVARY_RESTART 1
257
258 /* CANData Transmission result notification status */
259 /**
260 * \~english  Success
261 */
262 #define CAN_SUCCESS 0
263 /**
264 * \~english  Retryout
265 */
266 #define CAN_RETRYOUT 1
267 /**
268 * \~english  Send buffer full
269 */
270 #define CAN_BUFFERFUL 2
271
272 /* IG linkage type  */
273 /**
274 * \~english  IG cooperation off
275 */
276 #define CAN_IG_COOPERATION_OFF 0
277 /**
278 * \~english  IG cooperation on
279 */
280 #define CAN_IG_COOPERATION_ON 1
281
282 /* N_TA */
283 /**
284 * \~english  Invalid target address
285 */
286 #define CAN_NTA_INVALID 0xFF
287
288 /* Others */
289 /**
290 * \~english  The code of resource ID which is not used 
291 */
292 #define CAN_RID_NOTUSE_CODE 0xFF
293
294 /*********************************************************************
295 *                     Data size definition
296 ***********************************************************************/
297 /**
298 * \~english  MAX CAN data size used to send/receive message
299 */
300 #define CAN_DATA_SIZE 63
301 /**
302 * \~english  MAX CAN data size used to send message
303 */
304 #define CAN_TXDATA_SIZE 8
305
306 /* Data size relationship */
307 /**
308 * \~english  MAX number of delivery entry
309 * \~english  ((528-16)-12)/4 = 125     12:event ID etc. , 4:size of CAN ID
310 */
311 #define CAN_DELIVERY_CANID_ENTRY_MAX 125
312
313 /**
314 * \~english  OPC MAX number of delivery entry
315 */
316 #define CAN_DELIVERY_OPC_ENTRY_MAX 255
317
318 /* Message size relationship */
319 /**
320 * \~english  MAX size of message buffer
321 */
322 #define CAN_MSGBUF_MAX_SIZE 528
323 /**
324 * \~english  Size of message buffer header
325 */
326 #define CAN_MSGBUF_HEADER_SIZE 16
327 /**
328 * \~english  MAX size of message buffer header
329 */
330 #define CAN_MSGBUF_DATAMAX_SIZE (CAN_MSGBUF_MAX_SIZE - CAN_MSGBUF_HEADER_SIZE)
331
332 /**
333 * \~english  MAX size of CAN command data
334 */
335 #define CANCMD_DAT_MAX 68
336
337 /**
338 * \~english  MAX number of CANGW transmission data
339 */
340 #define CANGW_SND_NUM_MAX 0x16
341 /**
342 * \~english  MAX length of CANGW DLC
343 */
344 #define CANGW_DLC_MAX_SIZE 0x08
345
346 /*********************************************************************
347 *                       Type definition
348 ***********************************************************************/
349 /**
350 * \~english  CAN I/F API return code
351 */
352 typedef int32_t CANIF_RET_API;
353 /**
354 * \~english  define of CAN ID type
355 */
356 typedef uint32_t CANID;
357
358 /**
359 * \~english  data ID
360 */
361 typedef uint32_t DID;
362
363 /**
364 * \~english  Data struct used to transfer CAN data
365 * \~english  (transfer data from CAN to user)
366 */
367 typedef struct {
368   /**
369   * \~english  CAN ID
370   */
371   CANID can_id;
372   /**
373   * \~english  Data Length
374   */
375   uint8_t dlc;
376   /**
377   * \~english  reserve
378   */
379   uint8_t reserve[3];
380   /**
381   * \~english  DATA[0] ~ DATA[N]
382   */
383   uint8_t data[CAN_DATA_SIZE];
384   /**
385   * \~english  reserve
386   */
387   uint8_t reserve2;
388 } CAN_MSG_CANDATA_DAT;
389
390 /**
391 * \~english  Data struct used to transfer CAN message
392 * \~english  (transfer message from CAN to user)
393 */
394 typedef struct {
395   /**
396   * \~english  header
397   */
398   T_APIMSG_MSGBUF_HEADER_COMM hdr;
399   /**
400   * \~english  data
401   */
402   CAN_MSG_CANDATA_DAT data;
403   /**
404   * \~english  echoback flag
405   */
406   enum CanIfEchoBackFlags echoback;
407 } CAN_MSG_CANDATA;
408
409 /**
410 * \~english  Data struct used to transfer CAN data to CANGW 
411 * \~english  (transfer data from CAN to user)
412 */
413 typedef struct {
414   /**
415   * \~english  CAN ID (upper byte)
416   */
417   uint8_t can_id_high;
418   /**
419   * \~english  CAN ID (lower byte)
420   */
421   uint8_t can_id_low;
422   /**
423   * \~english  Data Length
424   */
425   uint8_t dlc;
426   /**
427   * \~english  data
428   */
429   uint8_t data[CANGW_DLC_MAX_SIZE];
430 } CAN_MSG_CANGWDATA_DAT;
431
432 /**
433 * \~english  Message struct used to transfer CAN data to CANGW
434 * \~english  (transfer message from CAN to user)
435 */
436 typedef struct {
437   /**
438   * \~english  CAN data
439   */
440   CAN_MSG_CANGWDATA_DAT data[CANGW_SND_NUM_MAX];
441   /**
442   * \~english  Number of CAN data(max 22)
443   */
444   uint8_t num;
445 } CAN_MSG_CANGWDATA;
446
447 /**
448 * \~english  Data struct used to transfer CAN data
449 * \~english  (transfer data from user to CANIF API)
450 */
451 typedef struct {
452   /**
453   * \~english  CAN ID
454   */
455   CANID can_id;
456   /**
457   * \~english  Data Length
458   */
459   uint8_t dlc;
460   /**
461   * \~english  reserve
462   */
463   uint8_t reserve[3];
464   /**
465   * \~english  DATA
466   */
467   uint8_t data[CAN_DATA_SIZE + 1];
468 } CAN_DATA;
469
470 /**
471 * \~english  Data struct used to transfer CAN data
472 * \~english  (transfer data from CANIF API to CAN)
473 */
474 typedef struct {
475   /**
476   * \~english  Delivery target thread name
477   */
478   char notifyName[MAX_NAME_SIZE_APP];
479   //  uint32_t  notifyId;    /* Addresses for delivery ID */
480   /**
481   * \~english  Thread ID used by _CWORD64_ 
482   */
483   uint32_t ulEventId;
484   /**
485   * \~english  Resource ID
486   */
487   uint8_t ucRid; /* Resources ID */
488   /**
489   * \~english  Cycle of send message(Unit of 100ms)
490   */
491   uint16_t usFreq;
492   /**
493   * \~english  CAN DATA
494   */
495   CAN_DATA stCandata;
496 } CAN_TRANSMISSION_START_MSG_DAT;
497
498 /**
499 * \~english  Data struct used to notify transmission result
500 * \~english  (transfer data from CAN API to user)
501 */
502 typedef struct {
503   /**
504   * \~english  CAN ID
505   */
506   CANID ulCanid;
507   /**
508   * \~english  Transmission result status
509   */
510   uint8_t ucStatus;
511   /**
512   * \~english  Reserve
513   */
514   uint8_t reserve[3];
515 } CAN_MSG_SENDSTS_DAT;
516
517 /**
518 * \~english  Message struct used to notify transmission result
519 * \~english  (transfer message from CAN API to user)
520 */
521 typedef struct {
522   /**
523   * \~english  header
524   */
525   T_APIMSG_MSGBUF_HEADER_COMM hdr;
526   /**
527   * \~english  Data
528   */
529   CAN_MSG_SENDSTS_DAT data;
530 } CAN_MSG_SENDSTS;
531
532 /**
533 * \~english  Data struct used for regular transmission stop
534 * \~english  (transfer data from CANIF API to CAN)
535 */
536 typedef struct {
537   /**
538   * \~english  Delivery target thread name
539   */
540   char notifyName[MAX_NAME_SIZE_APP];
541   //  uint32_t    notifyId;  /* Addresses for delivery ID */
542   /**
543   * \~english  Event ID that use for _CWORD64_
544   */
545   uint32_t ulEventId;
546   /**
547   * \~english  CAN ID
548   */
549   CANID ulCanid;
550 } CAN_FREQ_TRANS_STOP_MSG_DAT;
551
552 /**
553 * \~english  Data struct used for communication stop/restore
554 * \~english  (transfer message from CAN to user)
555 */
556 typedef struct {
557   /**
558   * \~english  Data ID
559   */
560   DID ulDid;
561 } CAN_MSG_COMM_WATCHSTS_DAT;
562
563 /**
564 * \~english  Data struct used for communication stop/restore
565 * \~english  (transfer message from CAN to user)
566 */
567 typedef struct {
568   /**
569   * \~english  Header
570   */
571   T_APIMSG_MSGBUF_HEADER_COMM hdr;
572   /**
573   * \~english  Data
574   */
575   CAN_MSG_COMM_WATCHSTS_DAT data;
576 } CAN_MSG_COMM_WATCHSTS;
577
578 /**
579 * \~english  Data struct used for delivery entry
580 * \~english  (transfer data from CANIF API to CAN)
581 */
582 typedef struct {
583   /**
584   * \~english  Delivery target thread name
585   */
586   char notifyName[MAX_NAME_SIZE_APP];
587   //  uint32_t    notifyId;        /* Addresses for delivery ID */
588   /**
589   * \~english  Event ID use for _CWORD64_
590   */
591   uint32_t ulEventId;
592   /**
593   * \~english  Number of CAN ID entry
594   */
595   uint16_t usCanNum;
596   /**
597   * \~english  CAN ID entry array
598   */
599   CANID ulCanid[CAN_DELIVERY_CANID_ENTRY_MAX];
600 } CAN_DELIVERY_ENTRY;
601
602 /**
603 * \~english  Data struct used for communication stop
604 * \~english  (transfer data from CANIF API to CAN)
605 */
606 typedef struct {
607   /**
608   * \~english  Delivery target thread name
609   */
610   char notifyName[MAX_NAME_SIZE_APP]; /* Destination thread name */
611   /**
612   * \~english  Event ID
613   */
614   uint32_t ulEvtId;
615   /**
616   * \~english  CAN ID
617   */
618   CANID ulCanid;
619   /**
620   * \~english  Data ID
621   */
622   DID ulDid;
623   /**
624   * \~english  Watch time for commuication stop (Unit of 100ms)
625   */
626   uint16_t usWatchTime;
627 } CAN_COMM_WATCH_MSG_DAT;
628
629 /**
630 * \~english  Data struct used for CAN command control
631 * \~english  (transfer data from CANIF API to CAN)
632 */
633 typedef struct {
634   /**
635   * \~english  Delivery target thread name
636   */
637   char notifyName[MAX_NAME_SIZE_APP];
638   //  uint32_t  notifyId;  /* Transfer to: ID */
639   /**
640   * \~english  Event ID
641   */
642   uint32_t ulEvtId;
643   /**
644   * \~english  Resource ID
645   */
646   uint8_t ucRid;
647   /**
648   * \~english  CAN command ID
649   */
650   uint8_t ucCmdid;
651 } CAN_CMD_CTRL_MSG_DAT;
652
653 /**
654 * \~english  Data struct used for CAN command delivery
655 * \~english  (transfer data from CAN to user)
656 */
657 typedef struct {
658   /**
659   * \~english  CAN command ID
660   */
661   uint8_t cmd_id;
662   /**
663   * \~english  Reserve
664   */
665   uint8_t reserve[3];
666   /**
667   * \~english  Data
668   */
669   uint8_t data[CANCMD_DAT_MAX];
670 } CAN_MSG_CANCMD_DAT;
671
672 /**
673 * \~english  Message struct used for CAN command delivery
674 * \~english  (transfer message from CAN to user)
675 */
676 typedef struct {
677   /**
678   * \~english  Header
679   */
680   T_APIMSG_MSGBUF_HEADER_COMM hdr;
681   /**
682   * \~english  Data
683   */
684   CAN_MSG_CANCMD_DAT data;
685 } CAN_MSG_CANCMD;
686
687 /**
688 * \~english  Data struct used for CAN command transmission result
689 * \~english  (transfer data from CAN to user)
690 */
691 typedef struct {
692   /**
693   * \~english  CAN command ID(same as delivery format)
694   */
695   uint32_t cmd_id;
696   /**
697   * \~english  Delivery result status
698   */
699   uint8_t status;
700   /**
701   * \~english  Reserve
702   */
703   uint8_t reserve[3];
704 } CAN_CMD_MSG_SENDSTS_DAT;
705
706 /**
707 * \~english  Data struct used for CAN command transmission result
708 * \~english  (transfer data from CAN to user)
709 */
710 typedef struct {
711   /**
712   * \~english  Header
713   */
714   T_APIMSG_MSGBUF_HEADER_COMM hdr;
715   /**
716   * \~english  Data
717   */
718   CAN_CMD_MSG_SENDSTS_DAT data;
719 } CAN_CMD_MSG_SENDSTS;
720
721 /**
722 * \~english  Data struct for receiving message(work data)
723 */
724 typedef struct {
725   /**
726   * \~english  Header
727   */
728   T_APIMSG_MSGBUF_HEADER_COMM stHead;
729   /**
730   * \~english  Data
731   */
732   uint8_t ucData[CAN_MSGBUF_DATAMAX_SIZE];
733 } CAN_MSG_DATA;
734
735 /**
736 * \~english  CAN data struct of communication stop registration
737 * \~english  (transfer data from CANIF API to CAN)
738 */
739 typedef struct {
740   /**
741   * \~english  Delivery target thread name
742   */
743   char notifyName[MAX_NAME_SIZE_APP];
744   /**
745   * \~english  Event ID for _CWORD64_
746   */
747   uint32_t ulEvtId;
748   /**
749   * \~english  CAN ID
750   */
751   CANID ulCanid;
752   /**
753   * \~english  Data ID
754   */
755   DID ulDid;
756   /**
757   * \~english  Watch time for communication stop(Unit of 100ms)
758   */
759   uint16_t usWatchTime;
760   /**
761   * \~english  has IG coopration or not
762   */
763   uint8_t ucIg;
764 } CAN_COMM_WATCHEXT_MSG_DAT;
765
766 /**
767 * \~english  Mask data struct for CAN data
768 */
769 typedef struct {
770   /**
771   * \~english  Mask data
772   */
773   uint8_t dat[CAN_TXDATA_SIZE];
774 } CAN_DATA_MASK;
775
776 /**
777 * \~english  Data struct used for CAN data transmission
778 */
779 typedef struct {
780   /**
781   * \~english  Transmission data
782   */
783   uint8_t dat[CAN_TXDATA_SIZE];
784 } CAN_DATA_BIT;
785
786 /**
787 * \~english  Data struct used for CAN data transmission registration
788 */
789 typedef struct {
790   /**
791   * \~english  CAN ID
792   */
793   CANID id;
794   /**
795   * \~english  Mask data
796   */
797   CAN_DATA_MASK mask;
798   /**
799   * \~english  Transmission data
800   */
801   CAN_DATA_BIT dat;
802   /**
803   * \~english  Cycle of regular transmission
804   */
805   uint32_t freq;
806 } CAN_TRANS_START_MSG_DAT;
807
808 /***********************************************************************
809 *                       CANIF API Functions Prototypes                        *
810 ************************************************************************/
811 #if defined(__cplusplus)
812 extern "C" {
813 #endif
814
815 /*******************************************************************************
816  * MODULE    : Canif_DeliveryEntry
817  ******************************************************************************/
818 ////////////////////////////////////////////////////////////////////////////////
819 /// \ingroup Canif_DeliveryEntry
820 /// \~english @par Brief
821 ///     Delivery registration of CAN data
822 /// \~english @param [in] h_app
823 ///     HANDLE - Handle for application
824 /// \~english @param [in] notify_name
825 ///     PCSTR - Delivery target thread name
826 /// \~english @param [in] can_num
827 ///     uint8_t - Number of delivery registration CAN ID
828 /// \~english @param [in] p_can_id
829 ///     CANID* - Pointer of delivery registration CAN ID array
830 /// \~english @retval CANIF_RET_NORMAL          Normality
831 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
832 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
833 /// \~english @par Prerequisite
834 ///     None
835 /// \~english @par Change of internal state
836 ///     - Change of internal state according to the API does not occur
837 /// \~english @par Conditions of processing failure
838 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
839 ///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
840 ///       [CANIF_RET_ERROR_PARAM]
841 ///     - can_num is 0 or bigger than 125.[CANIF_RET_ERROR_PARAM]
842 ///     - CAN ID pointer is null.[CANIF_RET_ERROR_PARAM]
843 ///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
844 ///     - malloc failed to get the message queue management information area
845 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
846 ///     - malloc failed to get the message queue name storage area for
847 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
848 ///     - mq_open failed to open the message queue for transmission
849 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
850 ///     - The session message queue to communication service is full.
851 ///       [CANIF_RET_ERROR_CANCEL]
852 ///     - The transmission file descriptor of the session
853 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
854 ///     - The interruption by the system call (signal) occurred while
855 ///       transmitting the session message to communication service.
856 ///       [CANIF_RET_ERROR_CANCEL]
857 ///     - Any error occurred in the transmission of the session message
858 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
859 ///     - It failed to access to the shared memory for the transmission of
860 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
861 /// \~english @par Classification
862 ///     Public
863 /// \~english @par Type
864 ///     Sync
865 /// \~english @par Detail
866 ///     - Delivery registration of CAN data. \n
867 /// \~english @see None
868 ////////////////////////////////////////////////////////////////////////////////
869 CANIF_RET_API Canif_DeliveryEntry(HANDLE h_app, PCSTR notify_name,
870                                   uint8_t can_num, CANID *p_can_id);
871
872 /*******************************************************************************
873  * MODULE    : Canif_TransmissionStart
874  ******************************************************************************/
875 ////////////////////////////////////////////////////////////////////////////////
876 /// \ingroup Canif_TransmissionStart
877 /// \~english @par Brief
878 ///     CAN data transmission starting
879 /// \~english @param [in] h_app
880 ///     HANDLE - Handle for application
881 /// \~english @param [in] notify_name
882 ///     PCSTR - Delivery target thread name
883 /// \~english @param [in] rid
884 ///     uint8_t - Resource ID for CAN data transmission result notification
885 /// \~english @param [in] freq
886 ///     uint16_t - Cycle of regular transmission
887 /// \~english @param [in] p_data
888 ///     CAN_DATA* - Pointer of transmission data
889 /// \~english @retval CANIF_RET_NORMAL          Normality
890 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
891 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
892 /// \~english @par Prerequisite
893 ///     None
894 /// \~english @par Change of internal state
895 ///     - Change of internal state according to the API does not occur
896 /// \~english @par Conditions of processing failure
897 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
898 ///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
899 ///       [CANIF_RET_ERROR_PARAM]
900 ///     - Transmission data pointer is null.[CANIF_RET_ERROR_PARAM]
901 ///     - DLC size is bigger than 8 bytes.[CANIF_RET_ERROR_PARAM]
902 ///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
903 ///     - CAN ID is not defined in the _CWORD108_ bit asignment table
904 ///       [CANIF_RET_ERROR_PARAM]
905 ///     - malloc failed to get the message queue management information area
906 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
907 ///     - malloc failed to get the message queue name storage area for
908 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
909 ///     - mq_open failed to open the message queue for transmission
910 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
911 ///     - The session message queue to communication service is full.
912 ///       [CANIF_RET_ERROR_CANCEL]
913 ///     - The transmission file descriptor of the session
914 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
915 ///     - The interruption by the system call (signal) occurred while
916 ///       transmitting the session message to communication service.
917 ///       [CANIF_RET_ERROR_CANCEL]
918 ///     - Any error occurred in the transmission of the session message
919 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
920 ///     - It failed to access to the shared memory for the transmission of
921 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
922 /// \~english @par Classification
923 ///     Public
924 /// \~english @par Type
925 ///     ASync
926 /// \~english @par Detail
927 ///     - The transmission of the CAN data starts(Regular/One). \n
928 /// \~english @see None
929 ////////////////////////////////////////////////////////////////////////////////
930 CANIF_RET_API Canif_TransmissionStart(HANDLE h_app, PCSTR notify_name,
931                                       uint8_t rid, uint16_t freq, CAN_DATA *p_data);
932
933 /*******************************************************************************
934  * MODULE    : Canif_CommandCtrl
935  ******************************************************************************/
936 ////////////////////////////////////////////////////////////////////////////////
937 /// \ingroup Canif_CommandCtrl
938 /// \~english @par Brief
939 ///     CAN command control
940 /// \~english @param [in] h_app
941 ///     HANDLE - Handle for application
942 /// \~english @param [in] notify_name
943 ///     PCSTR - Delivery target thread name
944 /// \~english @param [in] rid
945 ///     uint8_t - Resource ID
946 /// \~english @param [in] cmd_id
947 ///     uint32_t - CAN command ID(32bit)
948 /// \~english @retval CANIF_RET_NORMAL          Normality
949 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
950 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
951 /// \~english @par Prerequisite
952 ///     None
953 /// \~english @par Change of internal state
954 ///     - Change of internal state according to the API does not occur
955 /// \~english @par Conditions of processing failure
956 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
957 ///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
958 ///       [CANIF_RET_ERROR_PARAM]
959 ///     - CAN command ID is invalid.[CANIF_RET_ERROR_PARAM]
960 ///     - malloc failed to get the message queue management information area
961 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
962 ///     - malloc failed to get the message queue name storage area for
963 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
964 ///     - mq_open failed to open the message queue for transmission
965 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
966 ///     - The session message queue to communication service is full.
967 ///       [CANIF_RET_ERROR_CANCEL]
968 ///     - The transmission file descriptor of the session
969 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
970 ///     - The interruption by the system call (signal) occurred while
971 ///       transmitting the session message to communication service.
972 ///       [CANIF_RET_ERROR_CANCEL]
973 ///     - Any error occurred in the transmission of the session message
974 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
975 ///     - It failed to access to the shared memory for the transmission of
976 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
977 /// \~english @par Classification
978 ///     Public
979 /// \~english @par Type
980 ///     ASync
981 /// \~english @par Detail
982 ///     - Transmission control of CAN command. \n
983 /// \~english @see None
984 ////////////////////////////////////////////////////////////////////////////////
985 CANIF_RET_API Canif_CommandCtrl(HANDLE h_app, PCSTR notify_name, uint8_t rid,
986                                 uint32_t cmd_id);
987
988 /*******************************************************************************
989  * MODULE    : Canif_CommWatch
990  ******************************************************************************/
991 ////////////////////////////////////////////////////////////////////////////////
992 /// \ingroup Canif_CommWatch
993 /// \~english @par Brief
994 ///     CAN data regular transmission stop
995 /// \~english @param [in] h_app
996 ///     HANDLE - Handle for application
997 /// \~english @param [in] notify_name
998 ///     PCSTR - Delivery target thread name
999 /// \~english @param [in] can_id
1000 ///     CANID - CAN ID
1001 /// \~english @param [in] did
1002 ///     DID - Data ID
1003 /// \~english @param [in] watch_time
1004 ///     uint16_t - Communication watch suspension time(Unit of 100ms)
1005 /// \~english @retval CANIF_RET_NORMAL          Normality
1006 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
1007 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
1008 /// \~english @par Prerequisite
1009 ///     None
1010 /// \~english @par Change of internal state
1011 ///     - Change of internal state according to the API does not occur
1012 /// \~english @par Conditions of processing failure
1013 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
1014 ///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
1015 ///       [CANIF_RET_ERROR_PARAM]
1016 ///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
1017 ///     - malloc failed to get the message queue management information area
1018 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
1019 ///     - malloc failed to get the message queue name storage area for
1020 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
1021 ///     - mq_open failed to open the message queue for transmission
1022 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1023 ///     - The session message queue to communication service is full.
1024 ///       [CANIF_RET_ERROR_CANCEL]
1025 ///     - The transmission file descriptor of the session
1026 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
1027 ///     - The interruption by the system call (signal) occurred while
1028 ///       transmitting the session message to communication service.
1029 ///       [CANIF_RET_ERROR_CANCEL]
1030 ///     - Any error occurred in the transmission of the session message
1031 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1032 ///     - It failed to access to the shared memory for the transmission of
1033 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
1034 /// \~english @par Classification
1035 ///     Public
1036 /// \~english @par Type
1037 ///     Sync
1038 /// \~english @par Detail
1039 ///     - CAN data regular transmission stop. \n
1040 /// \~english @see None
1041 ////////////////////////////////////////////////////////////////////////////////
1042 CANIF_RET_API Canif_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id,
1043                               DID did, uint16_t watch_time);
1044
1045 ////////////////////////////////////////////////////////////////////////////////
1046 /// \ingroup Canif_TransStart
1047 /// \~english @par Brief
1048 ///     Transmission CAN Command
1049 /// \~english @param [in] h_app
1050 ///     HANDLE - Handle for application
1051 /// \~english @param [in] can_id
1052 ///     CANID - CAN ID
1053 /// \~english @param [in] mask
1054 ///     CAN_DATA_MASK* - Mask Data
1055 /// \~english @param [in] dat
1056 ///     CAN_DATA_BIT* - Transmission Data
1057 /// \~english @param [in] freq
1058 ///     uint32_t - Transmission Cycle
1059 /// \~english @retval CANIF_RET_NORMAL          Normality
1060 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
1061 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
1062 /// \~english @par Prerequisite
1063 ///     None
1064 /// \~english @par Change of internal state
1065 ///     - Change of internal state according to the API does not occur
1066 /// \~english @par Conditions of processing failure
1067 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
1068 ///     - Transmission Cycle is bigger than 0xFFFF.[CANIF_RET_ERROR_PARAM]
1069 ///     - CAN ID is NULL.[CANIF_RET_ERROR_PARAM]
1070 ///     - Mask Data is NULL.[CANIF_RET_ERROR_PARAM]
1071 ///     - Transmission Data is NULL.[CANIF_RET_ERROR_PARAM]
1072 ///     - CAN ID is not defined in the _CWORD108_ bit asignment table
1073 ///       [CANIF_RET_ERROR_PARAM]
1074 ///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
1075 ///     - malloc failed to get the message queue management information area
1076 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
1077 ///     - malloc failed to get the message queue name storage area for
1078 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
1079 ///     - mq_open failed to open the message queue for transmission
1080 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1081 ///     - The session message queue to communication service is full.
1082 ///       [CANIF_RET_ERROR_CANCEL]
1083 ///     - The transmission file descriptor of the session
1084 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
1085 ///     - The interruption by the system call (signal) occurred while
1086 ///       transmitting the session message to communication service.
1087 ///       [CANIF_RET_ERROR_CANCEL]
1088 ///     - Any error occurred in the transmission of the session message
1089 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1090 ///     - It failed to access to the shared memory for the transmission of
1091 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
1092 /// \~english @par Classification
1093 ///     Public
1094 /// \~english @par Type
1095 ///     ASync
1096 /// \~english @par Detail
1097 ///     - Start Transmission CAN Command API. \n
1098 /// \~english @see None
1099 ////////////////////////////////////////////////////////////////////////////////
1100 CANIF_RET_API Canif_TransStart(HANDLE h_app, CANID can_id, CAN_DATA_MASK *mask,
1101                                CAN_DATA_BIT *dat, uint32_t freq);
1102
1103 ////////////////////////////////////////////////////////////////////////////////
1104 /// \ingroup Canif_DeliveryEraseAll
1105 /// \~english @par Brief
1106 ///     Delete all delivery entry
1107 /// \~english @param [in] h_app
1108 ///     HANDLE - Handle for application
1109 /// \~english @param [in] notify_name
1110 ///     PCSTR - Delivery target thread name
1111 /// \~english @retval CANIF_RET_NORMAL          Normality
1112 /// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
1113 /// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
1114 /// \~english @par Prerequisite
1115 ///     None
1116 /// \~english @par Change of internal state
1117 ///     - Change of internal state according to the API does not occur
1118 /// \~english @par Conditions of processing failure
1119 ///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
1120 ///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
1121 ///       [CANIF_RET_ERROR_PARAM]
1122 ///     - malloc failed to get the message queue management information area
1123 ///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
1124 ///     - malloc failed to get the message queue name storage area for
1125 ///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
1126 ///     - mq_open failed to open the message queue for transmission
1127 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1128 ///     - The session message queue to communication service is full.
1129 ///       [CANIF_RET_ERROR_CANCEL]
1130 ///     - The transmission file descriptor of the session
1131 ///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
1132 ///     - The interruption by the system call (signal) occurred while
1133 ///       transmitting the session message to communication service.
1134 ///       [CANIF_RET_ERROR_CANCEL]
1135 ///     - Any error occurred in the transmission of the session message
1136 ///       to communication service. [CANIF_RET_ERROR_CANCEL]
1137 ///     - It failed to access to the shared memory for the transmission of
1138 ///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
1139 /// \~english @par Classification
1140 ///     Public
1141 /// \~english @par Type
1142 ///     Sync
1143 /// \~english @par Detail
1144 ///     - Delete all delivery entry. \n
1145 /// \~english @see None
1146 ////////////////////////////////////////////////////////////////////////////////
1147 CANIF_RET_API Canif_DeliveryEraseAll(HANDLE h_app, PCSTR notify_name);
1148
1149 /** @}*/  // end of CAN
1150 /** @}*/  // end of communication
1151 /** @}*/  // end of peripheral_service
1152 /** @}*/  // end of BaseSystem
1153
1154 #if defined(__cplusplus)
1155 }
1156 #endif
1157
1158 #endif  // COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_