pt.citar.diablu.nxt.protocol
Class NXTResponse

java.lang.Object
  extended by pt.citar.diablu.nxt.protocol.NXTResponse
Direct Known Subclasses:
NXTResponseGetBatteryLevel, NXTResponseGetOutputState, NXTResponseInputValues, NXTResponseLSRead, NXTResponseReceiveMsg, NXTResponseStatus

public abstract class NXTResponse
extends Object

Represents a Response to a Command that can be received from the NXTBrick. This class cannot be instantiated. Only subclasses which represent concrete Responses should be used. Subclasses should implement the receiveResponse() method and any specific parameter getter methods.

Author:
Jorge Cardoso

Field Summary
static byte ATTEMPTED_TO_ACCESS_INVALID_FIELD_OF_A_STRUCTURE
           
static byte BAD_ARGUMENTS
           
static byte BAD_INPUT_OR_OUTPUT_SPECIFIED
           
static byte COMMUNICATION_BUS_ERROR
           
static byte DATA_CONTAINS_OUT_OF_RANGE_VALUES
           
static byte ILLEGAL_MAILBOX_QUEUE_ID_SPECIFIED
           
static byte ILLEGAL_SIZE_SPECIFIED
           
static byte INSANE_PACKET
           
static byte INSUFFICIENT_MEMORY_AVAILABLE
           
static byte NO_ACTIVE_PROGRAM
           
static byte NO_FREE_MEMORY_IN_COMMUNICATION_BUFFER
           
static byte PENDING_COMMUNICATION_TRANSACTION_IN_PROGRESS
          PENDING_COMMUNICATION_TRANSACTION_IN_PROGRESS status code.
static byte REQUEST_FAILED
           
static byte SPECIFIED_CHANNEL_CONNECTION_IS_NOT_VALID
           
static byte SPECIFIED_CHANNEL_CONNECTION_NOT_CONFIGURED_OR_BUSY
           
static byte SPECIFIED_MAILBOX_QUEUE_IS_EMPTY
           
static byte SUCCESS
          Success status code.
static byte UNKNOWN_COMMAND_OPCODE
           
 
Constructor Summary
NXTResponse()
          Constructs a new response object.
 
Method Summary
 int getStatus()
          Returns the status of the response.
 String getStatusDescription()
          Returns a textual representation of the status code.
 void receiveResponse(NXTCommChannel channel)
          Receives a response from the NXTBrick.
 String toString()
          Formats the command packet in hex form.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUCCESS

public static final byte SUCCESS
Success status code.

See Also:
Constant Field Values

PENDING_COMMUNICATION_TRANSACTION_IN_PROGRESS

public static final byte PENDING_COMMUNICATION_TRANSACTION_IN_PROGRESS
PENDING_COMMUNICATION_TRANSACTION_IN_PROGRESS status code.

See Also:
Constant Field Values

SPECIFIED_MAILBOX_QUEUE_IS_EMPTY

public static final byte SPECIFIED_MAILBOX_QUEUE_IS_EMPTY
See Also:
Constant Field Values

REQUEST_FAILED

public static final byte REQUEST_FAILED
See Also:
Constant Field Values

UNKNOWN_COMMAND_OPCODE

public static final byte UNKNOWN_COMMAND_OPCODE
See Also:
Constant Field Values

INSANE_PACKET

public static final byte INSANE_PACKET
See Also:
Constant Field Values

DATA_CONTAINS_OUT_OF_RANGE_VALUES

public static final byte DATA_CONTAINS_OUT_OF_RANGE_VALUES
See Also:
Constant Field Values

COMMUNICATION_BUS_ERROR

public static final byte COMMUNICATION_BUS_ERROR
See Also:
Constant Field Values

NO_FREE_MEMORY_IN_COMMUNICATION_BUFFER

public static final byte NO_FREE_MEMORY_IN_COMMUNICATION_BUFFER
See Also:
Constant Field Values

SPECIFIED_CHANNEL_CONNECTION_IS_NOT_VALID

public static final byte SPECIFIED_CHANNEL_CONNECTION_IS_NOT_VALID
See Also:
Constant Field Values

SPECIFIED_CHANNEL_CONNECTION_NOT_CONFIGURED_OR_BUSY

public static final byte SPECIFIED_CHANNEL_CONNECTION_NOT_CONFIGURED_OR_BUSY
See Also:
Constant Field Values

NO_ACTIVE_PROGRAM

public static final byte NO_ACTIVE_PROGRAM
See Also:
Constant Field Values

ILLEGAL_SIZE_SPECIFIED

public static final byte ILLEGAL_SIZE_SPECIFIED
See Also:
Constant Field Values

ILLEGAL_MAILBOX_QUEUE_ID_SPECIFIED

public static final byte ILLEGAL_MAILBOX_QUEUE_ID_SPECIFIED
See Also:
Constant Field Values

ATTEMPTED_TO_ACCESS_INVALID_FIELD_OF_A_STRUCTURE

public static final byte ATTEMPTED_TO_ACCESS_INVALID_FIELD_OF_A_STRUCTURE
See Also:
Constant Field Values

BAD_INPUT_OR_OUTPUT_SPECIFIED

public static final byte BAD_INPUT_OR_OUTPUT_SPECIFIED
See Also:
Constant Field Values

INSUFFICIENT_MEMORY_AVAILABLE

public static final byte INSUFFICIENT_MEMORY_AVAILABLE
See Also:
Constant Field Values

BAD_ARGUMENTS

public static final byte BAD_ARGUMENTS
See Also:
Constant Field Values
Constructor Detail

NXTResponse

public NXTResponse()
Constructs a new response object.

Method Detail

receiveResponse

public void receiveResponse(NXTCommChannel channel)
                     throws IOException
Receives a response from the NXTBrick. Subclasses should verify the packet.

Throws:
IOException

getStatus

public int getStatus()
Returns the status of the response. A text message describing the status can be obtained by invoking the toString() method.

Returns:
The status code of the response.

getStatusDescription

public String getStatusDescription()
Returns a textual representation of the status code.

Returns:
The text describing the status code.

toString

public String toString()
Formats the command packet in hex form.

Overrides:
toString in class Object
Returns:
The command packet in hex form.


Processing library NXTComm by Jorge C. S. Cardoso. (c) 2014