Nedap.HandheldApi
Public Member Functions | Properties | Events
Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort Class Reference

This clas wraps SerialPort class and imelements IComunication interface. It is used as an apstraction for a serial port. More...

Inheritance diagram for Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort:
Nedap.HandheldApi.CommunicationQueue.ICommunicationPort

List of all members.

Public Member Functions

 SerialCommunicationPort (string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
 This is a constructor for serial port. It creates new instance of SerialPort class with required parameters.
void Dispose ()
 Disposes private members.
bool Connect ()
 Connect to port.
bool Disconnect ()
 Disconnect from port.
int WriteData (byte[] buffer, int offset, int length)
 Writes data to port.
int ReadData (byte[] buffer, int offset, int length)
 Reads data from port, if no data is available it should return with 0 result.

Properties

bool Connected [get, set]
 Defines if port is connected.

Events

EventHandler OnDataReceived
 This event is trigered when data are received on the serial port.

Detailed Description

This clas wraps SerialPort class and imelements IComunication interface. It is used as an apstraction for a serial port.


Constructor & Destructor Documentation

Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.SerialCommunicationPort ( string  portName,
int  baudRate,
Parity  parity,
int  dataBits,
StopBits  stopBits 
)

This is a constructor for serial port. It creates new instance of SerialPort class with required parameters.

Parameters:
portNameString that holds name of the serial port (e.g. COM7)
baudRateInteger number that represents port baud rate
parityPort parity checking protocol
dataBitsStandard length of data bits per byte.
stopBitsStandard number of stopbits per byte.

Member Function Documentation

bool Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.Connect ( )

Connect to port.

Returns:
True if success

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.

bool Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.Disconnect ( )

Disconnect from port.

Returns:
True if success

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.

void Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.Dispose ( )

Disposes private members.

int Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.ReadData ( byte[]  buffer,
int  offset,
int  length 
)

Reads data from port, if no data is available it should return with 0 result.

Parameters:
bufferBuffer to read into
offsetPosition where to start writing
lengthMaximum number of bytes to read
Returns:
Actual read bytes, which is possible to be 0 if no data is available

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.

int Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.WriteData ( byte[]  buffer,
int  offset,
int  length 
)

Writes data to port.

Parameters:
bufferData buffer
offsetPosition where to start writing
lengthNumber of bytes to write
Returns:

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.


Property Documentation

bool Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.Connected [get, set]

Defines if port is connected.

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.


Event Documentation

EventHandler Nedap.HandheldApi.CommunicationPort.SerialCommunicationPort.OnDataReceived

This event is trigered when data are received on the serial port.

Implements Nedap.HandheldApi.CommunicationQueue.ICommunicationPort.