C# Class BrickPi.Brick

Show file Open project: Ellerbach/BrickPi Class Usage Examples

Public Methods

Method Description
Brick ( ) : System

Initialize the brick, create the structure and setup the serial port

Brick ( SerialDevice myserial ) : System

Initialize the brick, create the structure and setup the serial port

Brick ( SerialDevice myserial, bool autostart ) : System

Initialize the birck, create the structure and setup the serial port

GetBrickVersion ( ) : int

Don't use in normal code, this will errase the sensor type use only for debug purpose

SetTimeout ( int timeout ) : void

Set brick timeout for motor to stop

SetupSensors ( ) : Task

Setup sensors. Don't use this function if the brick is started, only when not started

Start ( ) : void

Start reading the brick, getting info from sensors, moving motors

Stop ( ) : void

Stop the brick, stop all reading, writing, motor movement

UpdateValues ( ) : void

Update values. Don't use this function if the brick is started, only when not started

Private Methods

Method Description
BrickPiChangeAddress ( byte OldAddr, byte NewAddr ) : Task

Used to change the address of the Ardunio WARNING: don't use it except if you really know what you are doing

BrickPiRx ( int timeout, int cancelAfter = CancelAfter ) : Task

Read data coming from the BrickPi

BrickPiSetTimeout ( ) : Task

Set a new timeout on the brick

BrickPiSetupSensors ( int idxArduino ) : Task

update the type of sensors. Needed to be able to change mode don't call directly this function, it will brak the running thread. Call it only thru the SetupSensros function.

BrickPiTx ( int dest, int byteCount, byte OutArray ) : void

Send data to the BrickPi

BrickPiUpdateValues ( ) : Task

Main function running in the main thread, checking all the time the status of sensors

CheckRetMessage ( byte InArray, byte msg, byte &OutArray, int OutArrayLength = 256 ) : bool

Check if the returned buffer is all correct

CloseDevice ( ) : void

CloseDevice: - Disposes SerialDevice object - Clears the enumerated device Id list

ContinuousUpdate ( IAsyncAction action ) : void

The main thread running all the time to check the sensor status

ReadAsync ( int timeout, CancellationToken cancellationToken ) : Task

ReadAsync: Task that waits on data and reads asynchronously from the serial device InputStream

SelectAndInitSerial ( SerialDevice myserial ) : Task

Initialize the Serial port, the BrickPi

SerialPort_ErrorReceived ( SerialDevice sender, ErrorReceivedEventArgs args ) : void

Used for debug only is any issue happen to the Serial port

UpdateButtons ( ) : void
sum ( int idxStart, int byteCount, byte arrayToCount ) : long

checksum calculator

Method Details

Brick() public method

Initialize the brick, create the structure and setup the serial port
public Brick ( ) : System
return System

Brick() public method

Initialize the brick, create the structure and setup the serial port
public Brick ( SerialDevice myserial ) : System
myserial SerialDevice serial port to use
return System

Brick() public method

Initialize the birck, create the structure and setup the serial port
public Brick ( SerialDevice myserial, bool autostart ) : System
myserial SerialDevice serial port to use
autostart bool starts automatically the reading thread
return System

GetBrickVersion() public method

Don't use in normal code, this will errase the sensor type use only for debug purpose
public GetBrickVersion ( ) : int
return int

SetTimeout() public method

Set brick timeout for motor to stop
public SetTimeout ( int timeout ) : void
timeout int timeout in milliseconds
return void

SetupSensors() public method

Setup sensors. Don't use this function if the brick is started, only when not started
public SetupSensors ( ) : Task
return Task

Start() public method

Start reading the brick, getting info from sensors, moving motors
public Start ( ) : void
return void

Stop() public method

Stop the brick, stop all reading, writing, motor movement
public Stop ( ) : void
return void

UpdateValues() public method

Update values. Don't use this function if the brick is started, only when not started
public UpdateValues ( ) : void
return void