Metratec devices library 3.1.1.0
Public Member Functions | Properties | List of all members
CommunicationInterfaces.EthernetInterface Class Reference

The Ethernet version of the interface used for communication. More...

Inheritance diagram for CommunicationInterfaces.EthernetInterface:
CommunicationInterfaces.ICommunicationInterface

Public Member Functions

 EthernetInterface (string address, int port)
 The constructor.
 
override string ToString ()
 Returns a string that represents the current object.
 
void Connect ()
 The method to connect the communication interface.
 
void Disconnect ()
 The method to close the communication interface.
 
void Send (byte[] data, int offset, int count)
 Method to write a byte-array to the device (e.g. a binary file)
 
void SendCommand (string outputBuffer)
 The method used to send data to the reader.
 
byte[] Read (int count)
 Method to read a stream of bytes from device.
 
string Read (string endLineString)
 The method used to synchronously read data from the reader.
 
string ReadResponse ()
 The method used to read a complete answer from the reader, check it for error messages and crc mismatch.
 
- Public Member Functions inherited from CommunicationInterfaces.ICommunicationInterface
void Connect ()
 The method to connect the communication interface.
 
void Disconnect ()
 The method to close the communication interface.
 
void Send (byte[] data, int offset, int count)
 Method to write a byte-array to the device (e.g. a binary file)
 
void Send (byte[] data)
 Method to write a byte-array to the device (e.g. a binary file)
 
void Send (string data)
 Method to write a string to the device.
 
void SendCommand (string command)
 The method used to send a command to the reader.
 
byte[] Read (int count)
 Method to read a stream of bytes from device.
 
string ReadResponse ()
 The method used to synchronously read a reader response.
 

Properties

int BaudRate [get, set]
 The communication baud rate.
 
int ReceiveTimeout [get, set]
 The communication receive timeout.
 
string NewlineString [get, set]
 The communication new line string.
 
bool DataAvailable [get]
 Indicates whether data is available for reading.
 
bool IsConnected [get]
 Returns if the connection is established.
 
- Properties inherited from CommunicationInterfaces.ICommunicationInterface
int ReceiveTimeout [get, set]
 The communication receive timeout.
 
int BaudRate [get, set]
 The communication baud rate.
 
string NewlineString [get, set]
 The communication new line string.
 
bool DataAvailable [get]
 Indicates whether data is available for reading.
 
bool IsConnected [get]
 Connection flag.
 

Detailed Description

The Ethernet version of the interface used for communication.

Constructor & Destructor Documentation

◆ EthernetInterface()

CommunicationInterfaces.EthernetInterface.EthernetInterface ( string  address,
int  port 
)

The constructor.

Parameters
addressThe IP address of the reader
portThe TCP port the reader is communicating on (default is 10,001)
Exceptions
T:System.ArgumentNullExceptionThrown when the specified address is null.
T:System.ArgumentExceptionThrown when the specified address cannot be parsed into an IP address.
T:System.ArgumentOutOfRangeExceptionThrown when the specified port is outside of the range of valid TCP ports (1-65535).
T:System.InvalidOperationExceptionThrown when the socket could not be connected to the IPEndpoint (socket closed or insufficient permissions).

Member Function Documentation

◆ Connect()

void CommunicationInterfaces.EthernetInterface.Connect ( )

The method to connect the communication interface.

Exceptions
T:System.InvalidOperationExceptionThrown when the serial port could not be set up (e.g. wrong parameters, insufficient permissions, invalid port state).

Implements CommunicationInterfaces.ICommunicationInterface.

◆ Disconnect()

void CommunicationInterfaces.EthernetInterface.Disconnect ( )

The method to close the communication interface.

Implements CommunicationInterfaces.ICommunicationInterface.

◆ Read() [1/2]

byte[] CommunicationInterfaces.EthernetInterface.Read ( int  count)

Method to read a stream of bytes from device.

Parameters
countNumber of bytes to read
Returns
The bytes read

Implements CommunicationInterfaces.ICommunicationInterface.

◆ Read() [2/2]

string CommunicationInterfaces.EthernetInterface.Read ( string  endLineString)

The method used to synchronously read data from the reader.

Returns
The string read - without the newline character
Exceptions
T:System.TimeoutExceptionThrown when no answer is received for more than 400ms.
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

◆ ReadResponse()

string CommunicationInterfaces.EthernetInterface.ReadResponse ( )

The method used to read a complete answer from the reader, check it for error messages and crc mismatch.

Returns
The answer read - nicely parsed
Exceptions
T:System.TimeoutExceptionThrown when no answer is received for more than 400ms.
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream
T:System.InvalidOperationExceptionThrown when the answer from the reader contained errors

Implements CommunicationInterfaces.ICommunicationInterface.

◆ Send()

void CommunicationInterfaces.EthernetInterface.Send ( byte[]  data,
int  offset,
int  count 
)

Method to write a byte-array to the device (e.g. a binary file)

Parameters
dataThe overall byte-array of data
offsetThe starting address in the array
countThe number of characters to write

Implements CommunicationInterfaces.ICommunicationInterface.

◆ SendCommand()

void CommunicationInterfaces.EthernetInterface.SendCommand ( string  outputBuffer)

The method used to send data to the reader.

Parameters
outputBufferThe data / command sent to the reader
Exceptions
T:System.ArgumentNullExceptionThrown when the specified outputBuffer is null.
T:System.InvalidOperationExceptionThrown when an exception occurs when trying to access the port (e.g. port closed, timeout).
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

Implements CommunicationInterfaces.ICommunicationInterface.

◆ ToString()

override string CommunicationInterfaces.EthernetInterface.ToString ( )

Returns a string that represents the current object.

Returns
A string that represents the current object.

Property Documentation

◆ BaudRate

int CommunicationInterfaces.EthernetInterface.BaudRate
getset

The communication baud rate.

Exceptions
T:System.InvalidOperationExceptionThrown in case baud rate setting did not work

Implements CommunicationInterfaces.ICommunicationInterface.

◆ DataAvailable

bool CommunicationInterfaces.EthernetInterface.DataAvailable
get

Indicates whether data is available for reading.

Exceptions
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

Implements CommunicationInterfaces.ICommunicationInterface.

◆ IsConnected

bool CommunicationInterfaces.EthernetInterface.IsConnected
get

Returns if the connection is established.

Returns
True if the connection is established

Implements CommunicationInterfaces.ICommunicationInterface.

◆ NewlineString

string CommunicationInterfaces.EthernetInterface.NewlineString
getset

The communication new line string.

Implements CommunicationInterfaces.ICommunicationInterface.

◆ ReceiveTimeout

int CommunicationInterfaces.EthernetInterface.ReceiveTimeout
getset

The communication receive timeout.

Exceptions
T:System.InvalidOperationExceptionThrown in case baud rate setting did not work

Implements CommunicationInterfaces.ICommunicationInterface.


The documentation for this class was generated from the following file: