View Full Version : cRio to DS packet spec.

10-21-2009, 03:06 PM
Hello all,

I'm working on a personal project where I'm hooking a Gumstix mini computer to an iCreate. The Gumstix has 802.11 on it and I was thinking of using a FIRST drivers station as the thing on my end to control it.

In order to do this I will need to learn the packet communication between the two so I can implement the code that the cRio has on it onto the Gumstix. I was thinking of sniffing the packets on our practice robot which is at my house currently, but then I thought someone else may already have this info and can share it with me. So….

Does anyone have the packet communication between the DS and the cRio that they can share with me?


10-21-2009, 05:46 PM
I was working on somthing similar, but I never finished coding it.

You can view the source code and documentation I was working on on Codeplex (http://frc1103dashboard.codeplex.com/SourceControl/changeset/view/14428#), but the documentation is really more of note for myself than usable documentation.

The data from the DS to robot is defined as:

#define USER_CONTROL_DATA_SIZE 984 //This number is from memory, it wasn't in this chuck of code from my docs.

struct FRCControlData{
UINT16 packetIndex;
union {
UINT8 control;
struct {
UINT8 reset : 1;
UINT8 notEStop : 1;
UINT8 enabled : 1;
UINT8 autonomous : 1;
UINT8 :1;
UINT8 resync : 1;
UINT8 cRIOChkSum :1;
UINT8 fpgaChkSum :1;
UINT8 dsDigitalIn;
UINT16 teamID;

char dsID_Alliance;
char dsID_Position;

union {
INT8 stick0Axes[6];
struct {
INT8 stick0Axis1;
INT8 stick0Axis2;
INT8 stick0Axis3;
INT8 stick0Axis4;
INT8 stick0Axis5;
INT8 stick0Axis6;
UINT16 stick0Buttons; // Left-most 4 bits are unused

union {
INT8 stick1Axes[6];
struct {
INT8 stick1Axis1;
INT8 stick1Axis2;
INT8 stick1Axis3;
INT8 stick1Axis4;
INT8 stick1Axis5;
INT8 stick1Axis6;
UINT16 stick1Buttons; // Left-most 4 bits are unused

union {
INT8 stick2Axes[6];
struct {
INT8 stick2Axis1;
INT8 stick2Axis2;
INT8 stick2Axis3;
INT8 stick2Axis4;
INT8 stick2Axis5;
INT8 stick2Axis6;
UINT16 stick2Buttons; // Left-most 4 bits are unused

union {
INT8 stick3Axes[6];
struct {
INT8 stick3Axis1;
INT8 stick3Axis2;
INT8 stick3Axis3;
INT8 stick3Axis4;
INT8 stick3Axis5;
INT8 stick3Axis6;
UINT16 stick3Buttons; // Left-most 4 bits are unused

//Analog inputs are 10 bit right-justified
UINT16 analog1;
UINT16 analog2;
UINT16 analog3;
UINT16 analog4;

UINT64 cRIOChecksum;
UINT32 FPGAChecksum0;
UINT32 FPGAChecksum1;
UINT32 FPGAChecksum2;
UINT32 FPGAChecksum3;

char versionData[8];

* Structure for DS to robot control packets
typedef struct {
FRCControlData commonData;
char userDefined[USER_CONTROL_DATA_SIZE];
INT32 crcPad;
INT32 crcChecksum;
} ControlData;

I never finished decyphering the robot to DS data, but here is what I think I know.

1 byte - ?
2 bytes - battery voltage
5 bytes -?
6 bytes - robot MAC address
14 bytes - ?
2 bytes - reply ID(ID of previous packet sent from DS)
936 bytes - user configureable data
4 bytes - crc pad
4 bytes - crc32

They use some weird data formating for some data. If it isn't simpy encoded data here are the conversions I have recorded.

Battery voltage (vb.net)

Dim batteryBytes = reader.ReadBytes(2)
BatteryVoltage = Convert.ToDecimal(batteryBytes(0).ToString("x")) + (Convert.ToDecimal(batteryBytes(1).ToString("x")) / 100.0)

Team number (vb.net)

Public Function ReadTeamNumber(ByVal reader As BinaryReader) As Integer
Dim temp1 = reader.ReadByte()
Dim temp2 = reader.ReadByte()
Return temp1 * 100 + temp2
End Function

DS/Comm version: ASCII enocded text

Alliance, 0x52 = 1, 0x42 = 2

Control byte - see DS to robot data structure


If I remember correctly, the DS sends the full data structure even if the robot isn't replying. It just sets the disabled bit to 1. This could mean you don't have to implement the reply logic, but you would some saftey features.

10-22-2009, 11:49 AM

Thanks this is what I needed.