LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
logicalaccess::SerialPortDataTransport Class Reference

A serial port data transport class. More...

#include <serialportdatatransport.hpp>

Inheritance diagram for logicalaccess::SerialPortDataTransport:
logicalaccess::DataTransport logicalaccess::XmlSerializable logicalaccess::DeisterSerialPortDataTransport logicalaccess::ElatecSerialPortDataTransport logicalaccess::GunneboSerialPortDataTransport logicalaccess::OSDPSerialPortDataTransport logicalaccess::STidSTRSerialPortDataTransport

Public Member Functions

 SerialPortDataTransport (const std::string &portname="")
 Constructor.
 
virtual ~SerialPortDataTransport ()
 Destructor.
 
std::string getTransportType () const override
 Get the transport type of this instance.
 
void configure () const
 Configure the current serial port.
 
void configure (std::shared_ptr< SerialPortXml > port, bool retryConfiguring) const
 Configure the given serial port.
 
bool connect () override
 
void disconnect () override
 
bool isConnected () override
 
std::string getName () const override
 Get the data transport endpoint name.
 
virtual void startAutoDetect ()
 Start to auto-detect the first serial port with a reader. Update serial port when found.
 
void serialize (boost::property_tree::ptree &parentNode) override
 Serialize the current object to XML.
 
void unSerialize (boost::property_tree::ptree &node) override
 UnSerialize a XML node to the current object.
 
std::string getDefaultXmlNodeName () const override
 Get the default Xml Node name for this object.
 
unsigned long getPortBaudRate () const
 Get the serial port baudrate.
 
void setPortBaudRate (unsigned long baudRate)
 Set the serial port baudrate.
 
std::shared_ptr< SerialPortXmlgetSerialPort () const
 
virtual void setSerialPort (std::shared_ptr< SerialPortXml > port)
 
void send (const ByteVector &data) override
 
ByteVector receive (long int timeout) override
 
- Public Member Functions inherited from logicalaccess::DataTransport
virtual ~DataTransport ()=default
 
virtual std::shared_ptr< ReaderUnitgetReaderUnit () const
 Get the reader unit.
 
virtual void setReaderUnit (std::weak_ptr< ReaderUnit > unit)
 Set the reader unit.
 
virtual std::string getTransportType () const =0
 Get the transport type of this instance.
 
virtual bool connect ()=0
 Connect to the transport layer.
 
virtual void disconnect ()=0
 Disconnect from the transport layer.
 
virtual bool isConnected ()=0
 
virtual std::string getName () const =0
 Get the data transport endpoint name.
 
virtual ByteVector sendCommand (const ByteVector &command, long int timeout=-1)
 Send a command to the reader.
 
virtual ByteVector getLastCommand ()
 Get the last command.
 
virtual ByteVector getLastResult ()
 Get the last command result.
 
- Public Member Functions inherited from logicalaccess::XmlSerializable
virtual ~XmlSerializable ()=default
 
virtual std::string serialize ()
 Serialize object to Xml Node string.
 
virtual std::string serializeWithHeaders ()
 Serialize object to Xml Node string, with xml headers.
 
virtual void serialize (boost::property_tree::ptree &parentNode)=0
 Serialize object to Xml Node.
 
virtual void serializeToFile (const std::string &filename)
 Serialize object to a Xml file.
 
virtual void unSerialize (boost::property_tree::ptree &node)=0
 UnSerialize object from a Xml Node.
 
virtual void unSerialize (const std::string &xmlstring, const std::string &rootNode)
 UnSerialize object from a Xml Node string.
 
virtual void unSerialize (std::istream &is, const std::string &rootNode)
 UnSerialize object from a Xml node.
 
virtual void unSerialize (boost::property_tree::ptree &node, const std::string &rootNode)
 UnSerialize object from a Xml node.
 
virtual void unSerializeFromFile (const std::string &filename)
 UnSerialize object from a Xml file.
 
virtual std::string getDefaultXmlNodeName () const =0
 Get the default Xml Node name for this object.
 

Protected Attributes

bool d_isAutoDetected
 The auto-detected status.
 
std::shared_ptr< SerialPortXmld_port
 The serial port.
 
unsigned long d_portBaudRate
 The baudrate to use when configuring the serial port.
 
- Protected Attributes inherited from logicalaccess::DataTransport
std::weak_ptr< ReaderUnitd_ReaderUnit
 The reader unit.
 
ByteVector d_lastResult
 The last result.
 
ByteVector d_lastCommand
 The last command.
 

Additional Inherited Members

- Static Public Member Functions inherited from logicalaccess::XmlSerializable
static std::string removeXmlDeclaration (const std::string &xmlstring)
 Remove Xml declaration from a xml string.
 
static ByteVector formatHexString (std::string hexstr)
 Format hex string to hex string with space.
 
virtual void send (const ByteVector &data)=0
 
virtual ByteVector receive (long int timeout)=0
 
- Static Protected Member Functions inherited from logicalaccess::XmlSerializable
static unsigned long long atoull (const std::string &str)
 

Detailed Description

A serial port data transport class.

Constructor & Destructor Documentation

◆ SerialPortDataTransport()

logicalaccess::SerialPortDataTransport::SerialPortDataTransport ( const std::string &  portname = "")
explicit

Constructor.

Parameters
portnameThe serial port name.

◆ ~SerialPortDataTransport()

logicalaccess::SerialPortDataTransport::~SerialPortDataTransport ( )
virtual

Destructor.

Member Function Documentation

◆ configure() [1/2]

void logicalaccess::SerialPortDataTransport::configure ( ) const

Configure the current serial port.

◆ configure() [2/2]

void logicalaccess::SerialPortDataTransport::configure ( std::shared_ptr< SerialPortXml port,
bool  retryConfiguring 
) const

Configure the given serial port.

Parameters
portThe COM port to configure.
retryConfiguringOn error, the function wait some milliseconds and retry another time to configure the serial port.

◆ connect()

bool logicalaccess::SerialPortDataTransport::connect ( )
overridevirtual
Parameters
Connectto the transport layer.
Returns
True on success, false otherwise.

Implements logicalaccess::DataTransport.

◆ disconnect()

void logicalaccess::SerialPortDataTransport::disconnect ( )
overridevirtual
Parameters
Disconnectfrom the transport layer.

Implements logicalaccess::DataTransport.

◆ getDefaultXmlNodeName()

std::string logicalaccess::SerialPortDataTransport::getDefaultXmlNodeName ( ) const
overridevirtual

◆ getName()

std::string logicalaccess::SerialPortDataTransport::getName ( ) const
overridevirtual

Get the data transport endpoint name.

Returns
The data transport endpoint name.

Implements logicalaccess::DataTransport.

◆ getPortBaudRate()

unsigned long logicalaccess::SerialPortDataTransport::getPortBaudRate ( ) const
inline

Get the serial port baudrate.

Returns
The Baudrate.

◆ getSerialPort()

std::shared_ptr< SerialPortXml > logicalaccess::SerialPortDataTransport::getSerialPort ( ) const
inline

◆ getTransportType()

std::string logicalaccess::SerialPortDataTransport::getTransportType ( ) const
inlineoverridevirtual

◆ isConnected()

bool logicalaccess::SerialPortDataTransport::isConnected ( )
overridevirtual

\briaf Get if connected to the transport layer.

Returns
True if connected, false otherwise.

Implements logicalaccess::DataTransport.

◆ receive()

ByteVector logicalaccess::SerialPortDataTransport::receive ( long int  timeout)
overridevirtual

◆ send()

void logicalaccess::SerialPortDataTransport::send ( const ByteVector data)
overridevirtual

◆ serialize()

void logicalaccess::SerialPortDataTransport::serialize ( boost::property_tree::ptree &  parentNode)
overridevirtual

◆ setPortBaudRate()

void logicalaccess::SerialPortDataTransport::setPortBaudRate ( unsigned long  baudRate)
inline

Set the serial port baudrate.

Parameters
baudRateThe Baudrate (9600, 19200, 38400, 57600, 115200).

◆ setSerialPort()

virtual void logicalaccess::SerialPortDataTransport::setSerialPort ( std::shared_ptr< SerialPortXml port)
inlinevirtual

◆ startAutoDetect()

void logicalaccess::SerialPortDataTransport::startAutoDetect ( )
virtual

Start to auto-detect the first serial port with a reader. Update serial port when found.

◆ unSerialize()

void logicalaccess::SerialPortDataTransport::unSerialize ( boost::property_tree::ptree &  node)
overridevirtual

Member Data Documentation

◆ d_isAutoDetected

bool logicalaccess::SerialPortDataTransport::d_isAutoDetected
protected

The auto-detected status.

◆ d_port

std::shared_ptr<SerialPortXml> logicalaccess::SerialPortDataTransport::d_port
protected

The serial port.

◆ d_portBaudRate

unsigned long logicalaccess::SerialPortDataTransport::d_portBaudRate
protected

The baudrate to use when configuring the serial port.


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