Detecting connection to FMS

Is it possible to determine if we are connected to the FMS or running locally? I am trying to help a team control their off-board compressor.

R80 - Compressed air on the ROBOT must be provided by one and only one compressor. Compressor specifications may not exceed nominal 12VDC, 1.05 cfm flow rate. Off-board compressors must be controlled and powered by the ROBOT.

My thought is that if we can determine if (at startup) we are connected to the FMS, then any code related to the compressor would not be run (Open & Control Loop), thus avoid generating and reference errors during a match. I have searched the WPI palettes and only find the alliance color and position.

They have implemented a manual approach to this problem for now, check for the existence of a file in begin.vi and use that to run the compressor code. This method requires a file to be copied to the cRIO, then reboot it, let it fill the air tanks, then delete it from the cRIO, reboot it again, before placing the robot on the field.

To many possibilities for mistakes and causing errors during a match.

The Compressor Open VI has no way of knowing whether the relay and Digital Input are plugged in. You will see no errors from WPILib when they are unplugged that do not appear when they are plugged in. I highly recommend not adding unnecessary complexity to the code.

When the Pressure Switch is not plugged in the Compressor Relay will never be turned on.

You can detect attachment to the FMS by checking the RawControlByte output of the driver station Get Mode vi. It’s called in Robot Main and the control byte is discarded. It’d probably be most efficient to have it set to a global variable in Robot Main, rather than calling Get Mode just for the control byte.

The Get Mode vi itself uses the 1st, 4th, and 5th bits in order to determine the current mode, and outputs the appropriate enum value.

The relevant bits of the RawControlByte are as follows:

 Bit | Contents
-----+----------
   0 | 
   1 | Test Mode
   2 |
   3 | FMS Attached
   4 | Telop(0) / Autonomous(1)
   5 | Enabled
   6 | Emergency Stopped(0) / Okay(1)
   7 |

I’ve tested all of those except for FMS Attached, but I’m extremely confident it’ll work properly. Also, WPIlib (C++ at least) has supposed definitions for the other bits… but it also has Test Mode called cRIOChkSum, so I don’t think it’s really up to date… Nothing actually uses FMS Attached and the other ones anywhere, except for the firmware.

I pulled it together into a vi which outputs a named cluster with the bits you want. It should work. Haven’t tested it yet.

Driver Station Control Data.vi https://dl.dropbox.com/s/kwnjl4wti1poufp/driver_station_control_data_icon.png