summaryrefslogtreecommitdiffstats
path: root/peripheralservice/communication/client_can/include/peripheral_service/Canif_API.h
blob: a68783cab529c9e3905cde1ba7ceecb623587093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/****************************************************************************
 * FILE    Canif_API.h
 * TITLE   :Data header files needed to use the CAN I/F API
 ****************************************************************************/

#ifndef COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_
#define COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_

/**
 * @file Canif_API.h
 * @~english
 * @brief Canif API header
 */

/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup peripheral_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup communication
 *  @ingroup peripheral_service
 *  @{
 */
/** @addtogroup CAN
 *  @ingroup communication
 *  @{
 */

#include <native_service/frameworkunified_types.h>
#include <stdio.h>
#include <unistd.h>
#include <asm/unistd.h>
#include <stub/com_message_header.h>

/**
 * \~english  Defination of Service name
 */
#define LAN_SERVICE_CAN "CAN_COM_PROT"

/**
 * \~english  Availability notification of CAN
 */
#define NTFY_Communication_CAN_ISAVAILABLE "Communication/CanIsAvailable"

/*********************************************************************
*                       Defining Return Values
***********************************************************************/
/* Normal system */
/**
 * \~english  Suceess
 */
#define CANIF_RET_NORMAL 1
/* Abnormal system */
/**
 * \~english  Parameter error
 */
#define CANIF_RET_ERROR_PARAM 2
/**
 * \~english  Buffer Full
 */
#define CANIF_RET_ERROR_BUFFULL 3
/**
 * \~english  CAN ID FULL
 */
#define CANIF_RET_ERROR_CANIDFULL 4
/**
 * \~english  ID unregister
 */
#define CANIF_RET_ERROR_UNDEF 5
/**
 * \~english  Thread ID unmatched
 */
#define CANIF_RET_ERROR_PID 6
/**
 * \~english  Timer error
 */
#define CANIF_RET_ERROR_TIMER 7
/**
 * \~english  Event Creat Error
 */
#define CANIF_RET_ERROR_CREATE_EVENT 8
/**
 * \~english  Error Cancel
 */
#define CANIF_RET_ERROR_CANCEL 9
/**
 * \~english  Null Pointer
 */
#define CANIF_RET_ERROR_NULL 10

/**
 * \~english  Flags for specifiy Delivery is echoback or not.
 */
enum CanIfEchoBackFlags {
  /**
  * \~english  Delivery is recv data
  */
  CANIF_PURERECV = 0,
  /**
  * \~english  Delivery is echo data
  */
  CANIF_ECHOBACK = 1
};

/**
 * \~english  Defination of Command ID ( CAN -> user )
 */
typedef enum _PS_CommunicationProtocol {
  /**
  * \~english  Delivery CAN Data
  */
  CID_CAN_DATA_DELIVERY = 0x0401,
  /**
  * \~english  CAN communication stop
  */
  CID_CAN_COMM_STOP,
  /**
  * \~english  CAN communication restore
  */
  CID_CAN_COMM_RESTORE,
  /**
  * \~english  CAN transmission result
  */
  CID_CAN_TX_RESULT,
  /**
  * \~english  Delivery CAN command
  */
  CID_CAN_CMD_DELIVERY,
  /**
  * \~english  CAN command transmission result
  */
  CID_CAN_CMD_TX_RESULT,
  /**
  * \~english  Delivery CAN data to CANGW
  */
  CID_CAN_CANGW_DELIVERY,
} PS_CommunicationProtocol;

/**
 * \~english  Defination of Command ID ( CANIF -> CAN )
 */
typedef enum _PS_Communication_InternalProtocol {
  /**
  * \~english  Delivery registration of CAN data 
  */
  CID_CANIF_DELIVERY_ENTRY = 0x0501,
  /**
  * \~english  Delivery deregistration of CAN data
  */
  CID_CANIF_DELIVERY_ERASE,
  /**
  * \~english  CAN data transmission start
  */
  CID_CANIF_TX_START,
  /**
  * \~english  CAN data communication stop watching 
  */
  CID_CANIF_COMM_WATCH,
  /**
  * \~english  CAN command control
  */
  CID_CANIF_CMD_CTRL,
  /**
  * \~english  CAN data transmission start
  */
  CID_CANIF_TX_BIT_START,
} PS_Communication_InternalProtocol;

/*********************************************************************
*                     Definitions of CAN command IDs
***********************************************************************/
/**
* \~english  Request CAN fuel calculator reset 
*/
#define CAN_CMDID_FUELCALC_RST_REQ_DELIVERY 0x00
/**
* \~english  Request CAN startup finished notification  
*/
#define CAN_CMDID_STARTUP_FIN_REQ_TX 0x01
/**
* \~english  Request CAN Master reset notification
*/
#define CAN_CMDID_MRST_INFO_REQ_TX 0x02
/**
* \~english  Request CAN version
*/
#define CAN_CMDID_VERSION_REQ_TX 0x03
/**
* \~english  Request CAN connected node notification
*/
#define CAN_CMDID_CONNECTION_NODE_REQ_TX 0x04
/**
* \~english  Request CAN BUS status notification
*   ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
*/
#define CAN_CMDID_BUS_STATUS_REQ_TX 0x05
/**
* \~english  Response of CAN fuel calculator reset
*/
#define CAN_CMDID_FUELCALC_REQ_TX 0x06
/**
* \~english  Receive CAN fuel calculator reset request
*/
#define CAN_CMDID_FUELCALC_RST_REQ_RX 0x07
/**
* \~english  Receive CAN startup finished notification
*/
#define CAN_CMDID_STARTUP_FIN_RESP_RX 0x08
/**
* \~english  Receive CAN Master reset notification
*/
#define CAN_CMDID_MRST_INFO_RESP_RX 0x09
/**
* \~english  Response of CAN version receive
*/
#define CAN_CMDID_VERSION_RESP_RX 0x0A
/**
* \~english  Response of CAN connection node receive
*/
#define CAN_CMDID_CONNECTION_NODE_RESP_RX 0x0B
/**
* \~english  Response of CAN bus status receive
*   ToDo@Bus error I/F is not required when CanGetBusStatus() is deleted, so it is scheduled to be deleted.
*/
#define CAN_CMDID_BUS_STATUS_RESP_RX 0x0C

/*********************************************************************
*                     Control Flag/Status Definition
***********************************************************************/
/* CANData Delivery control flag */
/**
* \~english  Delivery stop
*/
#define CAN_DELIVERY_STOP 0
/**
* \~english  Delivery restart
*/
#define CAN_DELIVARY_RESTART 1

/* CANData Transmission result notification status */
/**
* \~english  Success
*/
#define CAN_SUCCESS 0
/**
* \~english  Retryout
*/
#define CAN_RETRYOUT 1
/**
* \~english  Send buffer full
*/
#define CAN_BUFFERFUL 2

/* IG linkage type  */
/**
* \~english  IG cooperation off
*/
#define CAN_IG_COOPERATION_OFF 0
/**
* \~english  IG cooperation on
*/
#define CAN_IG_COOPERATION_ON 1

/* N_TA */
/**
* \~english  Invalid target address
*/
#define CAN_NTA_INVALID 0xFF

/* Others */
/**
* \~english  The code of resource ID which is not used 
*/
#define CAN_RID_NOTUSE_CODE 0xFF

/*********************************************************************
*                     Data size definition
***********************************************************************/
/**
* \~english  MAX CAN data size used to send/receive message
*/
#define CAN_DATA_SIZE 63
/**
* \~english  MAX CAN data size used to send message
*/
#define CAN_TXDATA_SIZE 8

/* Data size relationship */
/**
* \~english  MAX number of delivery entry
* \~english  ((528-16)-12)/4 = 125     12:event ID etc. , 4:size of CAN ID
*/
#define CAN_DELIVERY_CANID_ENTRY_MAX 125

/**
* \~english  OPC MAX number of delivery entry
*/
#define CAN_DELIVERY_OPC_ENTRY_MAX 255

/* Message size relationship */
/**
* \~english  MAX size of message buffer
*/
#define CAN_MSGBUF_MAX_SIZE 528
/**
* \~english  Size of message buffer header
*/
#define CAN_MSGBUF_HEADER_SIZE 16
/**
* \~english  MAX size of message buffer header
*/
#define CAN_MSGBUF_DATAMAX_SIZE (CAN_MSGBUF_MAX_SIZE - CAN_MSGBUF_HEADER_SIZE)

/**
* \~english  MAX size of CAN command data
*/
#define CANCMD_DAT_MAX 68

/**
* \~english  MAX number of CANGW transmission data
*/
#define CANGW_SND_NUM_MAX 0x16
/**
* \~english  MAX length of CANGW DLC
*/
#define CANGW_DLC_MAX_SIZE 0x08

/*********************************************************************
*                       Type definition
***********************************************************************/
/**
* \~english  CAN I/F API return code
*/
typedef int32_t CANIF_RET_API;
/**
* \~english  define of CAN ID type
*/
typedef uint32_t CANID;

/**
* \~english  data ID
*/
typedef uint32_t DID;

/**
* \~english  Data struct used to transfer CAN data
* \~english  (transfer data from CAN to user)
*/
typedef struct {
  /**
  * \~english  CAN ID
  */
  CANID can_id;
  /**
  * \~english  Data Length
  */
  uint8_t dlc;
  /**
  * \~english  reserve
  */
  uint8_t reserve[3];
  /**
  * \~english  DATA[0] ~ DATA[N]
  */
  uint8_t data[CAN_DATA_SIZE];
  /**
  * \~english  reserve
  */
  uint8_t reserve2;
} CAN_MSG_CANDATA_DAT;

/**
* \~english  Data struct used to transfer CAN message
* \~english  (transfer message from CAN to user)
*/
typedef struct {
  /**
  * \~english  header
  */
  T_APIMSG_MSGBUF_HEADER_COMM hdr;
  /**
  * \~english  data
  */
  CAN_MSG_CANDATA_DAT data;
  /**
  * \~english  echoback flag
  */
  enum CanIfEchoBackFlags echoback;
} CAN_MSG_CANDATA;

/**
* \~english  Data struct used to transfer CAN data to CANGW 
* \~english  (transfer data from CAN to user)
*/
typedef struct {
  /**
  * \~english  CAN ID (upper byte)
  */
  uint8_t can_id_high;
  /**
  * \~english  CAN ID (lower byte)
  */
  uint8_t can_id_low;
  /**
  * \~english  Data Length
  */
  uint8_t dlc;
  /**
  * \~english  data
  */
  uint8_t data[CANGW_DLC_MAX_SIZE];
} CAN_MSG_CANGWDATA_DAT;

/**
* \~english  Message struct used to transfer CAN data to CANGW
* \~english  (transfer message from CAN to user)
*/
typedef struct {
  /**
  * \~english  CAN data
  */
  CAN_MSG_CANGWDATA_DAT data[CANGW_SND_NUM_MAX];
  /**
  * \~english  Number of CAN data(max 22)
  */
  uint8_t num;
} CAN_MSG_CANGWDATA;

/**
* \~english  Data struct used to transfer CAN data
* \~english  (transfer data from user to CANIF API)
*/
typedef struct {
  /**
  * \~english  CAN ID
  */
  CANID can_id;
  /**
  * \~english  Data Length
  */
  uint8_t dlc;
  /**
  * \~english  reserve
  */
  uint8_t reserve[3];
  /**
  * \~english  DATA
  */
  uint8_t data[CAN_DATA_SIZE + 1];
} CAN_DATA;

/**
* \~english  Data struct used to transfer CAN data
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP];
  //  uint32_t  notifyId;    /* Addresses for delivery ID */
  /**
  * \~english  Thread ID used by _CWORD64_ 
  */
  uint32_t ulEventId;
  /**
  * \~english  Resource ID
  */
  uint8_t ucRid; /* Resources ID */
  /**
  * \~english  Cycle of send message(Unit of 100ms)
  */
  uint16_t usFreq;
  /**
  * \~english  CAN DATA
  */
  CAN_DATA stCandata;
} CAN_TRANSMISSION_START_MSG_DAT;

/**
* \~english  Data struct used to notify transmission result
* \~english  (transfer data from CAN API to user)
*/
typedef struct {
  /**
  * \~english  CAN ID
  */
  CANID ulCanid;
  /**
  * \~english  Transmission result status
  */
  uint8_t ucStatus;
  /**
  * \~english  Reserve
  */
  uint8_t reserve[3];
} CAN_MSG_SENDSTS_DAT;

/**
* \~english  Message struct used to notify transmission result
* \~english  (transfer message from CAN API to user)
*/
typedef struct {
  /**
  * \~english  header
  */
  T_APIMSG_MSGBUF_HEADER_COMM hdr;
  /**
  * \~english  Data
  */
  CAN_MSG_SENDSTS_DAT data;
} CAN_MSG_SENDSTS;

/**
* \~english  Data struct used for regular transmission stop
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP];
  //  uint32_t    notifyId;  /* Addresses for delivery ID */
  /**
  * \~english  Event ID that use for _CWORD64_
  */
  uint32_t ulEventId;
  /**
  * \~english  CAN ID
  */
  CANID ulCanid;
} CAN_FREQ_TRANS_STOP_MSG_DAT;

/**
* \~english  Data struct used for communication stop/restore
* \~english  (transfer message from CAN to user)
*/
typedef struct {
  /**
  * \~english  Data ID
  */
  DID ulDid;
} CAN_MSG_COMM_WATCHSTS_DAT;

/**
* \~english  Data struct used for communication stop/restore
* \~english  (transfer message from CAN to user)
*/
typedef struct {
  /**
  * \~english  Header
  */
  T_APIMSG_MSGBUF_HEADER_COMM hdr;
  /**
  * \~english  Data
  */
  CAN_MSG_COMM_WATCHSTS_DAT data;
} CAN_MSG_COMM_WATCHSTS;

/**
* \~english  Data struct used for delivery entry
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP];
  //  uint32_t    notifyId;        /* Addresses for delivery ID */
  /**
  * \~english  Event ID use for _CWORD64_
  */
  uint32_t ulEventId;
  /**
  * \~english  Number of CAN ID entry
  */
  uint16_t usCanNum;
  /**
  * \~english  CAN ID entry array
  */
  CANID ulCanid[CAN_DELIVERY_CANID_ENTRY_MAX];
} CAN_DELIVERY_ENTRY;

/**
* \~english  Data struct used for communication stop
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP]; /* Destination thread name */
  /**
  * \~english  Event ID
  */
  uint32_t ulEvtId;
  /**
  * \~english  CAN ID
  */
  CANID ulCanid;
  /**
  * \~english  Data ID
  */
  DID ulDid;
  /**
  * \~english  Watch time for commuication stop (Unit of 100ms)
  */
  uint16_t usWatchTime;
} CAN_COMM_WATCH_MSG_DAT;

/**
* \~english  Data struct used for CAN command control
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP];
  //  uint32_t  notifyId;  /* Transfer to: ID */
  /**
  * \~english  Event ID
  */
  uint32_t ulEvtId;
  /**
  * \~english  Resource ID
  */
  uint8_t ucRid;
  /**
  * \~english  CAN command ID
  */
  uint8_t ucCmdid;
} CAN_CMD_CTRL_MSG_DAT;

/**
* \~english  Data struct used for CAN command delivery
* \~english  (transfer data from CAN to user)
*/
typedef struct {
  /**
  * \~english  CAN command ID
  */
  uint8_t cmd_id;
  /**
  * \~english  Reserve
  */
  uint8_t reserve[3];
  /**
  * \~english  Data
  */
  uint8_t data[CANCMD_DAT_MAX];
} CAN_MSG_CANCMD_DAT;

/**
* \~english  Message struct used for CAN command delivery
* \~english  (transfer message from CAN to user)
*/
typedef struct {
  /**
  * \~english  Header
  */
  T_APIMSG_MSGBUF_HEADER_COMM hdr;
  /**
  * \~english  Data
  */
  CAN_MSG_CANCMD_DAT data;
} CAN_MSG_CANCMD;

/**
* \~english  Data struct used for CAN command transmission result
* \~english  (transfer data from CAN to user)
*/
typedef struct {
  /**
  * \~english  CAN command ID(same as delivery format)
  */
  uint32_t cmd_id;
  /**
  * \~english  Delivery result status
  */
  uint8_t status;
  /**
  * \~english  Reserve
  */
  uint8_t reserve[3];
} CAN_CMD_MSG_SENDSTS_DAT;

/**
* \~english  Data struct used for CAN command transmission result
* \~english  (transfer data from CAN to user)
*/
typedef struct {
  /**
  * \~english  Header
  */
  T_APIMSG_MSGBUF_HEADER_COMM hdr;
  /**
  * \~english  Data
  */
  CAN_CMD_MSG_SENDSTS_DAT data;
} CAN_CMD_MSG_SENDSTS;

/**
* \~english  Data struct for receiving message(work data)
*/
typedef struct {
  /**
  * \~english  Header
  */
  T_APIMSG_MSGBUF_HEADER_COMM stHead;
  /**
  * \~english  Data
  */
  uint8_t ucData[CAN_MSGBUF_DATAMAX_SIZE];
} CAN_MSG_DATA;

/**
* \~english  CAN data struct of communication stop registration
* \~english  (transfer data from CANIF API to CAN)
*/
typedef struct {
  /**
  * \~english  Delivery target thread name
  */
  char notifyName[MAX_NAME_SIZE_APP];
  /**
  * \~english  Event ID for _CWORD64_
  */
  uint32_t ulEvtId;
  /**
  * \~english  CAN ID
  */
  CANID ulCanid;
  /**
  * \~english  Data ID
  */
  DID ulDid;
  /**
  * \~english  Watch time for communication stop(Unit of 100ms)
  */
  uint16_t usWatchTime;
  /**
  * \~english  has IG coopration or not
  */
  uint8_t ucIg;
} CAN_COMM_WATCHEXT_MSG_DAT;

/**
* \~english  Mask data struct for CAN data
*/
typedef struct {
  /**
  * \~english  Mask data
  */
  uint8_t dat[CAN_TXDATA_SIZE];
} CAN_DATA_MASK;

/**
* \~english  Data struct used for CAN data transmission
*/
typedef struct {
  /**
  * \~english  Transmission data
  */
  uint8_t dat[CAN_TXDATA_SIZE];
} CAN_DATA_BIT;

/**
* \~english  Data struct used for CAN data transmission registration
*/
typedef struct {
  /**
  * \~english  CAN ID
  */
  CANID id;
  /**
  * \~english  Mask data
  */
  CAN_DATA_MASK mask;
  /**
  * \~english  Transmission data
  */
  CAN_DATA_BIT dat;
  /**
  * \~english  Cycle of regular transmission
  */
  uint32_t freq;
} CAN_TRANS_START_MSG_DAT;

/***********************************************************************
*                       CANIF API Functions Prototypes                        *
************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif

/*******************************************************************************
 * MODULE    : Canif_DeliveryEntry
 ******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_DeliveryEntry
/// \~english @par Brief
///     Delivery registration of CAN data
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] notify_name
///     PCSTR - Delivery target thread name
/// \~english @param [in] can_num
///     uint8_t - Number of delivery registration CAN ID
/// \~english @param [in] p_can_id
///     CANID* - Pointer of delivery registration CAN ID array
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
///       [CANIF_RET_ERROR_PARAM]
///     - can_num is 0 or bigger than 125.[CANIF_RET_ERROR_PARAM]
///     - CAN ID pointer is null.[CANIF_RET_ERROR_PARAM]
///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync
/// \~english @par Detail
///     - Delivery registration of CAN data. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_DeliveryEntry(HANDLE h_app, PCSTR notify_name,
                                  uint8_t can_num, CANID *p_can_id);

/*******************************************************************************
 * MODULE    : Canif_TransmissionStart
 ******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_TransmissionStart
/// \~english @par Brief
///     CAN data transmission starting
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] notify_name
///     PCSTR - Delivery target thread name
/// \~english @param [in] rid
///     uint8_t - Resource ID for CAN data transmission result notification
/// \~english @param [in] freq
///     uint16_t - Cycle of regular transmission
/// \~english @param [in] p_data
///     CAN_DATA* - Pointer of transmission data
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
///       [CANIF_RET_ERROR_PARAM]
///     - Transmission data pointer is null.[CANIF_RET_ERROR_PARAM]
///     - DLC size is bigger than 8 bytes.[CANIF_RET_ERROR_PARAM]
///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
///     - CAN ID is not defined in the _CWORD108_ bit asignment table
///       [CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     ASync
/// \~english @par Detail
///     - The transmission of the CAN data starts(Regular/One). \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_TransmissionStart(HANDLE h_app, PCSTR notify_name,
                                      uint8_t rid, uint16_t freq, CAN_DATA *p_data);

/*******************************************************************************
 * MODULE    : Canif_CommandCtrl
 ******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_CommandCtrl
/// \~english @par Brief
///     CAN command control
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] notify_name
///     PCSTR - Delivery target thread name
/// \~english @param [in] rid
///     uint8_t - Resource ID
/// \~english @param [in] cmd_id
///     uint32_t - CAN command ID(32bit)
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
///       [CANIF_RET_ERROR_PARAM]
///     - CAN command ID is invalid.[CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     ASync
/// \~english @par Detail
///     - Transmission control of CAN command. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_CommandCtrl(HANDLE h_app, PCSTR notify_name, uint8_t rid,
                                uint32_t cmd_id);

/*******************************************************************************
 * MODULE    : Canif_CommWatch
 ******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_CommWatch
/// \~english @par Brief
///     CAN data regular transmission stop
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] notify_name
///     PCSTR - Delivery target thread name
/// \~english @param [in] can_id
///     CANID - CAN ID
/// \~english @param [in] did
///     DID - Data ID
/// \~english @param [in] watch_time
///     uint16_t - Communication watch suspension time(Unit of 100ms)
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
///       [CANIF_RET_ERROR_PARAM]
///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync
/// \~english @par Detail
///     - CAN data regular transmission stop. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_CommWatch(HANDLE h_app, PCSTR notify_name, CANID can_id,
                              DID did, uint16_t watch_time);

////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_TransStart
/// \~english @par Brief
///     Transmission CAN Command
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] can_id
///     CANID - CAN ID
/// \~english @param [in] mask
///     CAN_DATA_MASK* - Mask Data
/// \~english @param [in] dat
///     CAN_DATA_BIT* - Transmission Data
/// \~english @param [in] freq
///     uint32_t - Transmission Cycle
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     - Transmission Cycle is bigger than 0xFFFF.[CANIF_RET_ERROR_PARAM]
///     - CAN ID is NULL.[CANIF_RET_ERROR_PARAM]
///     - Mask Data is NULL.[CANIF_RET_ERROR_PARAM]
///     - Transmission Data is NULL.[CANIF_RET_ERROR_PARAM]
///     - CAN ID is not defined in the _CWORD108_ bit asignment table
///       [CANIF_RET_ERROR_PARAM]
///     - The upper 3bits of CAN ID are not 0.[CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     ASync
/// \~english @par Detail
///     - Start Transmission CAN Command API. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_TransStart(HANDLE h_app, CANID can_id, CAN_DATA_MASK *mask,
                               CAN_DATA_BIT *dat, uint32_t freq);

////////////////////////////////////////////////////////////////////////////////
/// \ingroup Canif_DeliveryEraseAll
/// \~english @par Brief
///     Delete all delivery entry
/// \~english @param [in] h_app
///     HANDLE - Handle for application
/// \~english @param [in] notify_name
///     PCSTR - Delivery target thread name
/// \~english @retval CANIF_RET_NORMAL          Normality
/// \~english @retval CANIF_RET_ERROR_PARAM     Abnormality of parameter
/// \~english @retval CANIF_RET_ERROR_CANCEL    Abnormal termination
/// \~english @par Prerequisite
///     None
/// \~english @par Change of internal state
///     - Change of internal state according to the API does not occur
/// \~english @par Conditions of processing failure
///     - h_app is NULL.[CANIF_RET_ERROR_PARAM]
///     -notify_nameis NULL or the length ofnotify_nameis longer than 15 bytes.
///       [CANIF_RET_ERROR_PARAM]
///     - malloc failed to get the message queue management information area
///       for transmission to communication service.  [CANIF_RET_ERROR_CANCEL]
///     - malloc failed to get the message queue name storage area for
///       transmission to communication service. [CANIF_RET_ERROR_CANCEL]
///     - mq_open failed to open the message queue for transmission
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - The session message queue to communication service is full.
///       [CANIF_RET_ERROR_CANCEL]
///     - The transmission file descriptor of the session
///       message to communication service is invalid. [CANIF_RET_ERROR_CANCEL]
///     - The interruption by the system call (signal) occurred while
///       transmitting the session message to communication service.
///       [CANIF_RET_ERROR_CANCEL]
///     - Any error occurred in the transmission of the session message
///       to communication service. [CANIF_RET_ERROR_CANCEL]
///     - It failed to access to the shared memory for the transmission of
///       session message to communication service. [CANIF_RET_ERROR_CANCEL]
/// \~english @par Classification
///     Public
/// \~english @par Type
///     Sync
/// \~english @par Detail
///     - Delete all delivery entry. \n
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////
CANIF_RET_API Canif_DeliveryEraseAll(HANDLE h_app, PCSTR notify_name);

/** @}*/  // end of CAN
/** @}*/  // end of communication
/** @}*/  // end of peripheral_service
/** @}*/  // end of BaseSystem

#if defined(__cplusplus)
}
#endif

#endif  // COMMUNICATION_CLIENT_CAN_INCLUDE_PERIPHERAL_SERVICE_CANIF_API_H_