Re: Detecting secondary controller (transmitter) in ROBOTC

(Reposted from the ROBOTC Techincal Support Q&A forum)
https://vexforum.com/t/is-the-second-transmitter-connected/20853/1

You could try using vexRT[AccelXXmtr2], vexRT[AccelYXmtr2], or vexRT[AccelZXmtr2] to detect movement (or any value at all) from the secondary joystick to see if it’s connected.

It also appears that in the RobotCIntrinsics.c file, located in the Includes Directory, there is an Enumeration, with these Intrincs, nVexRCReceiveState, opcdSourceSystem, kSystemVEXRCReceiveState.

If you Mask OFF the top 5 Bits, the result will be:
Zero for no Controllers
One for One Controller, or
Two for Two Controllers

I don’t know without compiling some Code, if One or All Three have the same Values…

This test requires no Inputs at all, from any of the Joysticks…




#elif defined(VEX2)

  typedef enum
  {
    vrNoXmiters           = 0,        // No transmitters connected
    vrXmit1               = 0x01,     //                          1 == Transmitter 1 connected
    vrXmit2               = 0x02,     //                          1 == Transmitter 2 connected
    vrBit2                = 0x04,     // Unused
    vrCompetitionSwitch   = 0x08,     // 0 == No Comp Switch      1 == Competition Switch attached.
    vrResetSlave          = 0x10,     // Unused
    vrGameController      = 0x20,     // 0 == Legacy75MHz,        1 == Game Controller
    vrAutonomousMode      = 0x40,     // 0 == Driver Control,     1 == Autonomous Mode
    vrDisabled            = 0x80,     // 0 == Enabled             1 == Disabled.
  } TVexReceiverState;
  intrinsic const TVexReceiverState variableIndex(nVexRCReceiveState,
opcdSourceSystem, kSystemVEXRCReceiveState);
#endif


Yes, it’s very simple, just check the variable

nVexRCReceiveState

for example


if( nVexRCReceiveState & 0x01 )
    {
    // first joystick is connected
    }
if( nVexRCReceiveState & 0x02 )
    {
    // second joystick is connected
    }

Hmm… There is a Conflict, seen here

Some how I don’t think Everyone is on the Same Sheet of Music…

I saw Jesse’s answer, however, I did test the variable with a partner joystick and it works as I described (under ROBOTC 3.04). You can also observe this under the system parameters debug window where the variable is also displayed.