C# Class AForge.Robotics.Lego.Internals.SerialCommunication

Implementation of serial communication interface with LEGO Mindstorm NXT brick.
Inheritance: INXTCommunicationInterface
Show file Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
Connect ( ) : bool

Connect to NXT brick.

If communication interface was connected before the call, existing connection will be reused. If it is required to force reconnection, then Disconnect method should be called before.

Disconnect ( ) : void

Disconnect from NXT brick.

ReadMessage ( byte buffer, int &length ) : bool

Read message from NXT brick over the communication interface.

ReadMessage ( byte buffer, int offset, int &length ) : bool

Read message from NXT brick over the communication interface.

SendMessage ( byte message ) : bool

Send message to NXT brick over the communication interface.

This method assumes that message starts from the start of the specified buffer and occupies entire buffer.

SendMessage ( byte message, int length ) : bool

Send message to NXT brick over the communication interface.

This method assumes that message starts from the start of the specified buffer.

SendMessage ( byte message, int offset, int length ) : bool

Send message to NXT brick over the communication interface.

SerialCommunication ( string portName ) : System

Initializes a new instance of the SerialCommunication class.

This constructor initializes serial port with default write and read timeout values, which are 1000 milliseconds.

SerialCommunication ( string portName, int writeTimeout, int readTimeout ) : System

Initializes a new instance of the SerialCommunication class.

Method Details

Connect() public method

Connect to NXT brick.
If communication interface was connected before the call, existing connection will be reused. If it is required to force reconnection, then Disconnect method should be called before.
public Connect ( ) : bool
return bool

Disconnect() public method

Disconnect from NXT brick.
public Disconnect ( ) : void
return void

ReadMessage() public method

Read message from NXT brick over the communication interface.
public ReadMessage ( byte buffer, int &length ) : bool
buffer byte Buffer to use for message reading.
length int On successful return the variable keeps message length.
return bool

ReadMessage() public method

Read message from NXT brick over the communication interface.
public ReadMessage ( byte buffer, int offset, int &length ) : bool
buffer byte Buffer to use for message reading.
offset int Offset in the buffer for message.
length int On successful return the variable keeps message length.
return bool

SendMessage() public method

Send message to NXT brick over the communication interface.
This method assumes that message starts from the start of the specified buffer and occupies entire buffer.
public SendMessage ( byte message ) : bool
message byte Buffer containing the message to send.
return bool

SendMessage() public method

Send message to NXT brick over the communication interface.
This method assumes that message starts from the start of the specified buffer.
public SendMessage ( byte message, int length ) : bool
message byte Buffer containing the message to send.
length int Length of the message to send.
return bool

SendMessage() public method

Send message to NXT brick over the communication interface.
public SendMessage ( byte message, int offset, int length ) : bool
message byte Buffer containing the message to send.
offset int Offset of the message in the buffer.
length int Length of the message to send.
return bool

SerialCommunication() public method

Initializes a new instance of the SerialCommunication class.
This constructor initializes serial port with default write and read timeout values, which are 1000 milliseconds.
public SerialCommunication ( string portName ) : System
portName string Serial port name to use for communication.
return System

SerialCommunication() public method

Initializes a new instance of the SerialCommunication class.
public SerialCommunication ( string portName, int writeTimeout, int readTimeout ) : System
portName string Serial port name to use for communication.
writeTimeout int Timeout value used for write operations.
readTimeout int Timeout value used for read operations.
return System