Getting motor name and port number?

Hi, I am trying to create a function that will print out information about a motor to the brain screen. I would like to simply call the function with a single


object and have it get the name (the one defined in robot-config.h) and which port it is plugged into. Is there any way to do this?

There’s no way to get the name of the motor, and the index is protected.

However you can make a derived class of


to get the port

class Motor : public vex::motor{
        int32_t getPort(){
            //add one becasue index is zero based
            return this->_index+1;

if youre looking for the port the motor is in, my method was unplugging it from the brain, then seeing which motor light turned off. for example, if my puncher is in port 20, and i unplug 20 and my puncher turns off, i know that port 20 is my puncher motor

Or, you could check the motor screen on your brain and in the code itself.