C# Class BrickPi.Brick

Afficher le fichier Open project: Ellerbach/BrickPi Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

Brick() public méthode

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

Brick() public méthode

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
Résultat System

GetBrickVersion() public méthode

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

SetTimeout() public méthode

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

SetupSensors() public méthode

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

Start() public méthode

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

Stop() public méthode

Stop the brick, stop all reading, writing, motor movement
public Stop ( ) : void
Résultat void

UpdateValues() public méthode

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