WPILib 2012
WPILibRoboticsLibraryforFRC
NetworkCommunication/FRCComm.h
00001 /*************************************************************
00002  *                                      NOTICE
00003  * 
00004  *      These are the only externally exposed functions to the
00005  *   NetworkCommunication library
00006  * 
00007  * This is an implementation of FRC Spec for Comm Protocol
00008  * Revision 4.5, June 30, 2008
00009  *
00010  * Copyright (c) National Instruments 2008.  All Rights Reserved.
00011  * 
00012  *************************************************************/
00013 
00014 #ifndef __FRC_COMM_H__
00015 #define __FRC_COMM_H__
00016 
00017 #include <vxWorks.h>
00018 
00019 // Commandeer some bytes at the end for advanced I/O feedback.
00020 #define IO_CONFIG_DATA_SIZE 32
00021 #define SYS_STATUS_DATA_SIZE 44
00022 #define USER_STATUS_DATA_SIZE (984 - IO_CONFIG_DATA_SIZE - SYS_STATUS_DATA_SIZE)
00023 #define USER_DS_LCD_DATA_SIZE 128
00024 
00025 struct FRCCommonControlData{
00026         UINT16 packetIndex;
00027         union {
00028                 UINT8 control;
00029                 struct {
00030                         UINT8 reset : 1;
00031                         UINT8 notEStop : 1;
00032                         UINT8 enabled : 1;
00033                         UINT8 autonomous : 1;
00034                         UINT8 fmsAttached:1;
00035                         UINT8 resync : 1;
00036                         UINT8 cRIOChkSum :1;
00037                         UINT8 fpgaChkSum :1;
00038                 };
00039         };
00040         UINT8 dsDigitalIn;
00041         UINT16 teamID;
00042 
00043         char dsID_Alliance;
00044         char dsID_Position;
00045 
00046         union {
00047                 INT8 stick0Axes[6];
00048                 struct {
00049                         INT8 stick0Axis1;
00050                         INT8 stick0Axis2;
00051                         INT8 stick0Axis3;
00052                         INT8 stick0Axis4;
00053                         INT8 stick0Axis5;
00054                         INT8 stick0Axis6;
00055                 };
00056         };
00057         UINT16 stick0Buttons;           // Left-most 4 bits are unused
00058 
00059         union {
00060                 INT8 stick1Axes[6];
00061                 struct {
00062                         INT8 stick1Axis1;
00063                         INT8 stick1Axis2;
00064                         INT8 stick1Axis3;
00065                         INT8 stick1Axis4;
00066                         INT8 stick1Axis5;
00067                         INT8 stick1Axis6;
00068                 };
00069         };
00070         UINT16 stick1Buttons;           // Left-most 4 bits are unused
00071 
00072         union {
00073                 INT8 stick2Axes[6];
00074                 struct {
00075                         INT8 stick2Axis1;
00076                         INT8 stick2Axis2;
00077                         INT8 stick2Axis3;
00078                         INT8 stick2Axis4;
00079                         INT8 stick2Axis5;
00080                         INT8 stick2Axis6;
00081                 };
00082         };
00083         UINT16 stick2Buttons;           // Left-most 4 bits are unused
00084 
00085         union {
00086                 INT8 stick3Axes[6];
00087                 struct {
00088                         INT8 stick3Axis1;
00089                         INT8 stick3Axis2;
00090                         INT8 stick3Axis3;
00091                         INT8 stick3Axis4;
00092                         INT8 stick3Axis5;
00093                         INT8 stick3Axis6;
00094                 };
00095         };
00096         UINT16 stick3Buttons;           // Left-most 4 bits are unused
00097 
00098         //Analog inputs are 10 bit right-justified
00099         UINT16 analog1;
00100         UINT16 analog2;
00101         UINT16 analog3;
00102         UINT16 analog4;
00103 
00104         UINT64 cRIOChecksum;
00105         UINT32 FPGAChecksum0;
00106         UINT32 FPGAChecksum1;
00107         UINT32 FPGAChecksum2;
00108         UINT32 FPGAChecksum3;
00109 
00110         char versionData[8];
00111 };
00112 
00113 #define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17
00114 #define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18
00115 #define kFRC_NetworkCommunication_DynamicType_Kinect_Header 19
00116 #define kFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20
00117 #define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21
00118 #define kFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22
00119 #define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23
00120 #define kFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24
00121 #define kFRC_NetworkCommunication_DynamicType_Kinect_Custom 25
00122 
00123 extern "C" {
00124         void getFPGAHardwareVersion(UINT16 *fpgaVersion, UINT32 *fpgaRevision);
00125         int getCommonControlData(FRCCommonControlData *data, int wait_ms);
00126         int getRecentCommonControlData(FRCCommonControlData *commonData, int wait_ms);
00127         int getRecentStatusData(UINT8 *batteryInt, UINT8 *batteryDec, UINT8 *dsDigitalOut, int wait_ms);
00128         int getDynamicControlData(UINT8 type, char *dynamicData, INT32 maxLength, int wait_ms);
00129         int setStatusData(float battery, UINT8 dsDigitalOut, UINT8 updateNumber,
00130                         const char *userDataHigh, int userDataHighLength,
00131                         const char *userDataLow, int userDataLowLength, int wait_ms);
00132         int setStatusDataFloatAsInt(int battery, UINT8 dsDigitalOut, UINT8 updateNumber,
00133                         const char *userDataHigh, int userDataHighLength,
00134                         const char *userDataLow, int userDataLowLength, int wait_ms);
00135         int setErrorData(const char *errors, int errorsLength, int wait_ms);
00136         int setUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms);
00137         int overrideIOConfig(const char *ioConfig, int wait_ms);
00138 
00139         void setNewDataSem(SEM_ID);
00140         void setResyncSem(SEM_ID);
00141         void signalResyncActionDone(void);
00142 
00143         // this UINT32 is really a LVRefNum
00144         void setNewDataOccurRef(UINT32 refnum);
00145         void setResyncOccurRef(UINT32 refnum);
00146 
00147         void FRC_NetworkCommunication_getVersionString(char *version);
00148         void FRC_NetworkCommunication_observeUserProgramStarting(void);
00149         void FRC_NetworkCommunication_observeUserProgramDisabled(void);
00150         void FRC_NetworkCommunication_observeUserProgramAutonomous(void);
00151         void FRC_NetworkCommunication_observeUserProgramTeleop(void);
00152 };
00153 
00154 #endif
 All Classes Functions Variables