NXT_GetOutputState

Requests and retrieves an output motor state reading

Contents

Syntax

data = NXT_GetOutputState(port)

data = NXT_GetOutputState(port, handle)

Description

data = NXT_GetOutputState(port) requests and retrieves an output motor state reading of the given motor port. The value port can be addressed by the symbolic constants MOTOR_A, MOTOR_B and MOTOR_C analog to the labeling on the NXT Brick. The return value data is a struct variable. It contains several motor settings and information.

data = NXT_GetOutputState(port, handle) uses the given Bluetooth connection handle. This should be a serial handle on a PC system and a file handle on a Linux system.

If no Bluetooth handle is specified the default one (COM_GetDefaultNXT) is used.

Output:

data.Port % current port number (0..3)

data.Power % current motor power

data.Mode % motor mode byte

data.ModeIsMOTORON % flag: "motor is on"

data.ModeIsBRAKE % flag: "motor uses the advanced brake mode (PVM)"

data.ModeIsREGULATED % flag: "motor uses a regulation"

data.RegModeByte % motor regulation byte

data.RegModeName % name of regulation mode

data.TurnRatio % turn ratio value

data.RunStateByte % motor run state byte

data.RunStateName % name of run state

data.TachoLimit % tacho / angle limit

data.TachoCount % current absolute tacho count

data.BlockTachoCount % current relative tacho count

data.RotationCount % current second relative tacho count

For more details see the official LEGO Mindstorms communication protocol.

Examples

   data = NXT_GetOutputState(MOTOR_B);
   handle = COM_OpenNXT('bluetooth.ini');
   data = NXT_GetOutputState(MOTOR_A, handle);

See also

ReadFromNXT, NXT_SetOutputState, DirectMotorCommand, MOTOR_A, MOTOR_B, MOTOR_C,

Signature