WPILibC++  2019.1.1-beta-1-26-g8be693f
 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 
20 // These are copies of defines located in CANSessionMux.h prepended with HAL_
21 
22 #define HAL_CAN_SEND_PERIOD_NO_REPEAT 0
23 #define HAL_CAN_SEND_PERIOD_STOP_REPEATING -1
24 
25 /* Flags in the upper bits of the messageID */
26 #define HAL_CAN_IS_FRAME_REMOTE 0x80000000
27 #define HAL_CAN_IS_FRAME_11BIT 0x40000000
28 
29 #define HAL_ERR_CANSessionMux_InvalidBuffer -44086
30 #define HAL_ERR_CANSessionMux_MessageNotFound -44087
31 #define HAL_WARN_CANSessionMux_NoToken 44087
32 #define HAL_ERR_CANSessionMux_NotAllowed -44088
33 #define HAL_ERR_CANSessionMux_NotInitialized -44089
34 #define HAL_ERR_CANSessionMux_SessionOverrun 44050
35 
40  uint32_t messageID;
41  uint32_t timeStamp;
42  uint8_t data[8];
43  uint8_t dataSize;
44 };
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
59 void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data,
60  uint8_t dataSize, int32_t periodMs, int32_t* status);
61 
72 void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask,
73  uint8_t* data, uint8_t* dataSize,
74  uint32_t* timeStamp, int32_t* status);
75 
84 void HAL_CAN_OpenStreamSession(uint32_t* sessionHandle, uint32_t messageID,
85  uint32_t messageIDMask, uint32_t maxMessages,
86  int32_t* status);
87 
93 void HAL_CAN_CloseStreamSession(uint32_t sessionHandle);
94 
103 void HAL_CAN_ReadStreamSession(uint32_t sessionHandle,
104  struct HAL_CANStreamMessage* messages,
105  uint32_t messagesToRead, uint32_t* messagesRead,
106  int32_t* status);
107 
117 void HAL_CAN_GetCANStatus(float* percentBusUtilization, uint32_t* busOffCount,
118  uint32_t* txFullCount, uint32_t* receiveErrorCount,
119  uint32_t* transmitErrorCount, int32_t* status);
120 
121 #ifdef __cplusplus
122 } // extern "C"
123 #endif
124 
void HAL_CAN_CloseStreamSession(uint32_t sessionHandle)
Closes a CAN stream.
Storage for CAN Stream Messages.
Definition: CAN.h:39
void HAL_CAN_GetCANStatus(float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status)
Gets CAN status information.
void HAL_CAN_ReceiveMessage(uint32_t *messageID, uint32_t messageIDMask, uint8_t *data, uint8_t *dataSize, uint32_t *timeStamp, int32_t *status)
Receives a CAN message.
void HAL_CAN_OpenStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status)
Opens a CAN stream.
void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t periodMs, int32_t *status)
Sends a CAN message.
void HAL_CAN_ReadStreamSession(uint32_t sessionHandle, struct HAL_CANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status)
Reads a CAN stream message.