nxtlib/src/Protocol.cs
/// <summary> 
/// [Native] Get the state of an NXT motor port.
/// </summary>
/// <param name="port">The port of the selected motor.</param>
/// <returns>Returns a MotorStateOut package.</returns>
[Native] Get the state of an NXT motor port.
[ Native ] Get the state of an NXT motor port .
public MotorStateOut GetMotorState(MotorPortSingle port)
        {
            byte[] request = new byte[] {
            0x00,
            (byte) DirectCommand.GetOutputState,
            (byte) port
            };
            byte[] reply = CompleteRequest(request);
            byte motorportout = reply[3];
            if (reply[3] != (byte)port)
            {
                throw new NXTReplyIncorrect();
            }
            MotorStateOut result = new MotorStateOut();
            result.power = reply[4];
            result.tachocount = GetInt32(reply, 13);
            result.blocktachocount = GetInt32(reply, 17);
            result.rotationcount = GetInt32(reply, 21);
            return result;
        }
public MotorStateOut GetMotorState ( MotorPortSingle port ) { byte [ ] request = new byte [ ] { 0x00 , ( byte ) DirectCommand . GetOutputState , ( byte ) port } ; byte [ ] reply = CompleteRequest ( request ) ; byte motorportout = reply [ 3 ] ; if ( reply [ 3 ] != ( byte ) port ) { throw new NXTReplyIncorrect ( ) ; } MotorStateOut result = new MotorStateOut ( ) ; result . power = reply [ 4 ] ; result . tachocount = GetInt32 ( reply , 13 ) ; result . blocktachocount = GetInt32 ( reply , 17 ) ; result . rotationcount = GetInt32 ( reply , 21 ) ; return result ; }
[Native] Get the state of an NXT motor port.
[ Native ] Get the state of an NXT motor port .
/*
            NxtGetOutputStateReply result;
            result.power = (sbyte)reply[4];
            result.mode = (NxtMotorMode)reply[5];
            result.regulationMode = (NxtMotorRegulationMode)reply[6];
            result.turnRatio = (sbyte)reply[7];
            result.runState = (NxtMotorRunState)reply[8];
            result.tachoLimit = Util.GetUInt32(reply, 9);
            result.tachoCount = Util.GetInt32(reply, 13);
            result.blockTachoCount = Util.GetInt32(reply, 17);
            result.rotationCount = Util.GetInt32(reply, 21);

            return result;*/
Returns a MotorStateOut package.
Returns a MotorStateOut package .
port
MotorPortSingle
The port of the selected motor.
The port of the selected motor .