Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /************************************************************* |
| 2 | * NOTICE |
| 3 | * |
| 4 | * These are the only externally exposed functions to the |
| 5 | * NetworkCommunication library |
| 6 | * |
| 7 | * This is an implementation of FRC Spec for Comm Protocol |
| 8 | * Revision 4.5, June 30, 2008 |
| 9 | * |
| 10 | * Copyright (c) National Instruments 2008. All Rights Reserved. |
| 11 | * |
| 12 | *************************************************************/ |
| 13 | |
| 14 | #ifndef __FRC_COMM_H__ |
| 15 | #define __FRC_COMM_H__ |
| 16 | |
| 17 | #ifdef SIMULATION |
| 18 | #include <vxWorks_compat.h> |
| 19 | #ifdef USE_THRIFT |
| 20 | #define EXPORT_FUNC |
| 21 | #else |
| 22 | #define EXPORT_FUNC __declspec(dllexport) __cdecl |
| 23 | #endif |
| 24 | #else |
| 25 | #include <stdint.h> |
| 26 | #include <pthread.h> |
| 27 | #define EXPORT_FUNC |
| 28 | #endif |
| 29 | |
| 30 | #define ERR_FRCSystem_NetCommNotResponding -44049 |
| 31 | #define ERR_FRCSystem_NoDSConnection -44018 |
| 32 | |
| 33 | enum AllianceStationID_t { |
| 34 | kAllianceStationID_red1, |
| 35 | kAllianceStationID_red2, |
| 36 | kAllianceStationID_red3, |
| 37 | kAllianceStationID_blue1, |
| 38 | kAllianceStationID_blue2, |
| 39 | kAllianceStationID_blue3, |
| 40 | }; |
| 41 | |
| 42 | enum MatchType_t { |
| 43 | kMatchType_none, |
| 44 | kMatchType_practice, |
| 45 | kMatchType_qualification, |
| 46 | kMatchType_elimination, |
| 47 | }; |
| 48 | |
| 49 | struct ControlWord_t { |
| 50 | uint32_t enabled : 1; |
| 51 | uint32_t autonomous : 1; |
| 52 | uint32_t test : 1; |
| 53 | uint32_t eStop : 1; |
| 54 | uint32_t fmsAttached : 1; |
| 55 | uint32_t dsAttached : 1; |
| 56 | uint32_t control_reserved : 26; |
| 57 | }; |
| 58 | |
| 59 | struct JoystickAxes_t { |
| 60 | uint16_t count; |
| 61 | int16_t axes[1]; |
| 62 | }; |
| 63 | |
| 64 | struct JoystickPOV_t { |
| 65 | uint16_t count; |
| 66 | int16_t povs[1]; |
| 67 | }; |
| 68 | |
| 69 | #ifdef __cplusplus |
| 70 | extern "C" { |
| 71 | #endif |
| 72 | int EXPORT_FUNC FRC_NetworkCommunication_Reserve(void *instance); |
| 73 | #ifndef SIMULATION |
| 74 | void EXPORT_FUNC |
| 75 | getFPGAHardwareVersion(uint16_t *fpgaVersion, uint32_t *fpgaRevision); |
| 76 | #endif |
| 77 | int EXPORT_FUNC setStatusData(float battery, uint8_t dsDigitalOut, |
| 78 | uint8_t updateNumber, const char *userDataHigh, |
| 79 | int userDataHighLength, const char *userDataLow, |
| 80 | int userDataLowLength, int wait_ms); |
| 81 | int EXPORT_FUNC setErrorData(const char *errors, int errorsLength, int wait_ms); |
| 82 | |
| 83 | #ifdef SIMULATION |
| 84 | void EXPORT_FUNC setNewDataSem(HANDLE); |
| 85 | #else |
| 86 | void EXPORT_FUNC setNewDataSem(pthread_cond_t *); |
| 87 | #endif |
| 88 | |
| 89 | // this uint32_t is really a LVRefNum |
| 90 | int EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); |
| 91 | |
| 92 | int EXPORT_FUNC |
| 93 | FRC_NetworkCommunication_getControlWord(struct ControlWord_t *controlWord); |
| 94 | int EXPORT_FUNC FRC_NetworkCommunication_getAllianceStation( |
| 95 | enum AllianceStationID_t *allianceStation); |
| 96 | int EXPORT_FUNC FRC_NetworkCommunication_getMatchTime(float *matchTime); |
| 97 | int EXPORT_FUNC |
| 98 | FRC_NetworkCommunication_getJoystickAxes(uint8_t joystickNum, |
| 99 | struct JoystickAxes_t *axes, |
| 100 | uint8_t maxAxes); |
| 101 | int EXPORT_FUNC FRC_NetworkCommunication_getJoystickButtons(uint8_t joystickNum, |
| 102 | uint32_t *buttons, |
| 103 | uint8_t *count); |
| 104 | int EXPORT_FUNC |
| 105 | FRC_NetworkCommunication_getJoystickPOVs(uint8_t joystickNum, |
| 106 | struct JoystickPOV_t *povs, |
| 107 | uint8_t maxPOVs); |
| 108 | int EXPORT_FUNC |
| 109 | FRC_NetworkCommunication_setJoystickOutputs(uint8_t joystickNum, |
| 110 | uint32_t hidOutputs, |
| 111 | uint16_t leftRumble, |
| 112 | uint16_t rightRumble); |
| 113 | int EXPORT_FUNC |
| 114 | FRC_NetworkCommunication_getJoystickDesc(uint8_t joystickNum, uint8_t *isXBox, |
| 115 | uint8_t *type, char *name, |
| 116 | uint8_t *axisCount, uint8_t *axisTypes, |
| 117 | uint8_t *buttonCount, |
| 118 | uint8_t *povCount); |
| 119 | |
| 120 | void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version); |
| 121 | int EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); |
| 122 | void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramDisabled(void); |
| 123 | void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramAutonomous(void); |
| 124 | void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTeleop(void); |
| 125 | void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTest(void); |
| 126 | #ifdef __cplusplus |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | #endif |