WPILibC++  2018.4.1-20180729123227-1139-ga11fcb6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
CAN.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/Types.h"
13 
14 // These are copies of defines located in CANSessionMux.h prepended with HAL_
15 
16 #define HAL_CAN_SEND_PERIOD_NO_REPEAT 0
17 #define HAL_CAN_SEND_PERIOD_STOP_REPEATING -1
18 
19 /* Flags in the upper bits of the messageID */
20 #define HAL_CAN_IS_FRAME_REMOTE 0x80000000
21 #define HAL_CAN_IS_FRAME_11BIT 0x40000000
22 
23 #define HAL_ERR_CANSessionMux_InvalidBuffer -44086
24 #define HAL_ERR_CANSessionMux_MessageNotFound -44087
25 #define HAL_WARN_CANSessionMux_NoToken 44087
26 #define HAL_ERR_CANSessionMux_NotAllowed -44088
27 #define HAL_ERR_CANSessionMux_NotInitialized -44089
28 #define HAL_ERR_CANSessionMux_SessionOverrun 44050
29 
34  uint32_t messageID;
35  uint32_t timeStamp;
36  uint8_t data[8];
37  uint8_t dataSize;
38 };
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
53 void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data,
54  uint8_t dataSize, int32_t periodMs, int32_t* status);
55 
66 void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask,
67  uint8_t* data, uint8_t* dataSize,
68  uint32_t* timeStamp, int32_t* status);
69 
78 void HAL_CAN_OpenStreamSession(uint32_t* sessionHandle, uint32_t messageID,
79  uint32_t messageIDMask, uint32_t maxMessages,
80  int32_t* status);
81 
87 void HAL_CAN_CloseStreamSession(uint32_t sessionHandle);
88 
97 void HAL_CAN_ReadStreamSession(uint32_t sessionHandle,
98  struct HAL_CANStreamMessage* messages,
99  uint32_t messagesToRead, uint32_t* messagesRead,
100  int32_t* status);
101 
111 void HAL_CAN_GetCANStatus(float* percentBusUtilization, uint32_t* busOffCount,
112  uint32_t* txFullCount, uint32_t* receiveErrorCount,
113  uint32_t* transmitErrorCount, int32_t* status);
114 
115 #ifdef __cplusplus
116 } // extern "C"
117 #endif
Storage for CAN Stream Messages.
Definition: CAN.h:33