WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
CANSessionMux.h
1 // CANSessionMux.h
2 //
3 // Defines the API for building a CAN Interface Plugin to support
4 // PWM-cable-free CAN motor control on FRC robots. This allows you
5 // to connect any CAN interface to the secure Jaguar CAN driver.
6 //
7 
8 #ifndef __CANSessionMux_h__
9 #define __CANSessionMux_h__
10 
11 #include <stdint.h>
12 
13 #define CAN_SEND_PERIOD_NO_REPEAT 0
14 #define CAN_SEND_PERIOD_STOP_REPEATING -1
15 
16 /* Flags in the upper bits of the messageID */
17 #define CAN_IS_FRAME_REMOTE 0x80000000
18 #define CAN_IS_FRAME_11BIT 0x40000000
19 
20 #define ERR_CANSessionMux_InvalidBuffer -44086
21 #define ERR_CANSessionMux_MessageNotFound -44087
22 #define WARN_CANSessionMux_NoToken 44087
23 #define ERR_CANSessionMux_NotAllowed -44088
24 #define ERR_CANSessionMux_NotInitialized -44089
25 #define ERR_CANSessionMux_SessionOverrun 44050
26 
28  uint32_t messageID;
29  uint32_t timeStamp;
30  uint8_t data[8];
31  uint8_t dataSize;
32 };
33 
34 namespace nCANSessionMux {
35 void sendMessage_wrapper(uint32_t messageID, const uint8_t *data,
36  uint8_t dataSize, int32_t periodMs, int32_t *status);
37 void receiveMessage_wrapper(uint32_t *messageID, uint32_t messageIDMask,
38  uint8_t *data, uint8_t *dataSize,
39  uint32_t *timeStamp, int32_t *status);
40 void openStreamSession(uint32_t *sessionHandle, uint32_t messageID,
41  uint32_t messageIDMask, uint32_t maxMessages,
42  int32_t *status);
43 void closeStreamSession(uint32_t sessionHandle);
44 void readStreamSession(uint32_t sessionHandle,
45  struct tCANStreamMessage *messages,
46  uint32_t messagesToRead, uint32_t *messagesRead,
47  int32_t *status);
48 void getCANStatus(float *percentBusUtilization, uint32_t *busOffCount,
49  uint32_t *txFullCount, uint32_t *receiveErrorCount,
50  uint32_t *transmitErrorCount, int32_t *status);
51 }
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 void FRC_NetworkCommunication_CANSessionMux_sendMessage(uint32_t messageID,
58  const uint8_t *data,
59  uint8_t dataSize,
60  int32_t periodMs,
61  int32_t *status);
62 void FRC_NetworkCommunication_CANSessionMux_receiveMessage(
63  uint32_t *messageID, uint32_t messageIDMask, uint8_t *data,
64  uint8_t *dataSize, uint32_t *timeStamp, int32_t *status);
65 void FRC_NetworkCommunication_CANSessionMux_openStreamSession(
66  uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask,
67  uint32_t maxMessages, int32_t *status);
68 void FRC_NetworkCommunication_CANSessionMux_closeStreamSession(
69  uint32_t sessionHandle);
70 void FRC_NetworkCommunication_CANSessionMux_readStreamSession(
71  uint32_t sessionHandle, struct tCANStreamMessage *messages,
72  uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status);
73 void FRC_NetworkCommunication_CANSessionMux_getCANStatus(
74  float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount,
75  uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif // __CANSessionMux_h__
Definition: CANSessionMux.h:27