Event-Based Library for Arduino - .Net ClientAPI
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Events
ebl_arduino.SerialProtocol Class Reference

Protocol implementation for AdvancedSerial. More...

Inherited by ebl_arduino.AdvancedSerialClient.

List of all members.

Classes

class  AdvancedSerialMessage
 Message class. More...

Public Types

enum  MessageTypes {
  DEBUG = 0x01, MESSAGE = 0x02, MESSAGE_ACKNOWLEDGE = 0x03, DISCOVERY_REQUEST = 0x04,
  DISCOVERY_RESPONSE = 0x05
}
 Type of AdvancedSerial messages. More...
enum  ConnectionState { ReadingSTX, ReadingETX, ReadingHeader, ReadingPayload }
 Connection states. More...

Public Member Functions

delegate void MessageReceivedCallback (AdvancedSerialMessage Message)
 Delegate method for MessageReceived.
abstract bool IsConnected ()
 Verify transport connection.
abstract void Close ()
 Close transport connection.
void Send (AdvancedSerialMessage Message)
 Send message.
void Send (MessageTypes Type, byte ID, byte Size, byte[] Payload)
 Send message.
void Send (MessageTypes Type)
 Send simple message without payload.
void Flush ()
 Clear communication stream.

Public Attributes

const int MESSAGE_HEADER_SIZE = 3
 Size of message header.
const int MESSAGE_DELIMITER_SIZE = 1
 Size of message delimiter.
const int MESSAGE_MAX_PAYLOAD_SIZE = 32
 Maximum size of message payload.
const int MESSAGE_SIZE = MESSAGE_MAX_PAYLOAD_SIZE + MESSAGE_HEADER_SIZE
 Maximum size of message.
const byte STX = 0x02
 Start of message.
const byte ETX = 0x03
 End of message.
int MessageTimeout = 2000
 Timeout for message confirmation.

Protected Member Functions

void Receive ()
 Receive next amount of data.

Protected Attributes

Stream ConnectionStream
 Protocol stream.

Events

MessageReceivedCallback MessageReceived
 Occurs when the a message is received.

Detailed Description

Protocol implementation for AdvancedSerial.


Member Enumeration Documentation

Connection states.

Enumerator:
ReadingSTX 

Receiving start of text.

ReadingETX 

Receiving end of text.

ReadingHeader 

Receiving header.

ReadingPayload 

Receiving payload.

Type of AdvancedSerial messages.

Enumerator:
DEBUG 

Common message.

MESSAGE 

Common message.

MESSAGE_ACKNOWLEDGE 

Message acknowledge.

DISCOVERY_REQUEST 

Discovery request message.

DISCOVERY_RESPONSE 

Discovery response message.


Member Function Documentation

abstract void ebl_arduino.SerialProtocol.Close ( ) [pure virtual]

Close transport connection.

Implemented in ebl_arduino.AdvancedSerialClient.

void ebl_arduino.SerialProtocol.Flush ( )

Clear communication stream.

abstract bool ebl_arduino.SerialProtocol.IsConnected ( ) [pure virtual]

Verify transport connection.

Returns:
Return true if connected.

Implemented in ebl_arduino.AdvancedSerialClient.

delegate void ebl_arduino.SerialProtocol.MessageReceivedCallback ( AdvancedSerialMessage  Message)

Delegate method for MessageReceived.

void ebl_arduino.SerialProtocol.Receive ( ) [protected]

Receive next amount of data.

void ebl_arduino.SerialProtocol.Send ( MessageTypes  Type)

Send simple message without payload.

Parameters:
TypeMessage type.
void ebl_arduino.SerialProtocol.Send ( AdvancedSerialMessage  Message)

Send message.

Parameters:
MessageMessage to send.
void ebl_arduino.SerialProtocol.Send ( MessageTypes  Type,
byte  ID,
byte  Size,
byte[]  Payload 
)

Send message.

Parameters:
TypeMessage type.
IDMessage ID.
SizePayload size.
PayloadMessage payload

Member Data Documentation

Protocol stream.

const byte ebl_arduino.SerialProtocol.ETX = 0x03

End of message.

Size of message delimiter.

Size of message header.

Maximum size of message payload.

Maximum size of message.

Timeout for message confirmation.

const byte ebl_arduino.SerialProtocol.STX = 0x02

Start of message.


Event Documentation

MessageReceivedCallback ebl_arduino.SerialProtocol.MessageReceived

Occurs when the a message is received.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Events