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

An LibUSB data transport class. More...

#include <libusbdatatransport.hpp>

Inheritance diagram for logicalaccess::LibUSBDataTransport:
logicalaccess::DataTransport logicalaccess::XmlSerializable logicalaccess::YubikeyDataTransport

Public Member Functions

 LibUSBDataTransport ()
 Constructor.
 
virtual ~LibUSBDataTransport ()
 Destructor.
 
std::string getTransportType () const override
 Get the transport type of this instance.
 
std::string getDefaultXmlNodeName () const override
 Get the default Xml Node name for this object.
 
void serialize (boost::property_tree::ptree &parentNode) override
 Serialize object to Xml Node.
 
void unSerialize (boost::property_tree::ptree &node) override
 UnSerialize object from a Xml Node.
 
bool connect () override
 Connect to the transport layer.
 
void disconnect () override
 Disconnect from the transport layer.
 
bool isConnected () override
 
std::shared_ptr< LibUSBReaderUnitgetLibUSBReaderUnit () const
 Get the LibUSB reader unit.
 
std::string getName () const override
 Get the data transport endpoint name.
 
virtual void send (const std::vector< unsigned char > &data) override
 Send the data using rpleth protocol computation.
 
virtual std::vector< unsigned char > receive (long int timeout=5000) override
 Receive data from reader.
 
std::vector< unsigned char > sendCommand (const std::vector< unsigned char > &command, long int timeout=2000) override
 Send a command to the reader.
 
void usb_write (const std::vector< unsigned char > &data, int report_type, int report_number)
 
std::vector< unsigned char > usb_read (int report_type, int report_number, int readlen, int timeout=1000)
 
void CheckLibUSBError (int errorFlag)
 
- 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_isConnected
 
- 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.
 
- Protected Member Functions inherited from logicalaccess::DataTransport
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

An LibUSB data transport class.

Constructor & Destructor Documentation

◆ LibUSBDataTransport()

logicalaccess::LibUSBDataTransport::LibUSBDataTransport ( )

Constructor.

◆ ~LibUSBDataTransport()

logicalaccess::LibUSBDataTransport::~LibUSBDataTransport ( )
virtual

Destructor.

Member Function Documentation

◆ CheckLibUSBError()

void logicalaccess::LibUSBDataTransport::CheckLibUSBError ( int  errorFlag)

◆ connect()

bool logicalaccess::LibUSBDataTransport::connect ( )
overridevirtual

Connect to the transport layer.

Returns
True on success, false otherwise.

Implements logicalaccess::DataTransport.

◆ disconnect()

void logicalaccess::LibUSBDataTransport::disconnect ( )
overridevirtual

Disconnect from the transport layer.

Implements logicalaccess::DataTransport.

◆ getDefaultXmlNodeName()

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

Get the default Xml Node name for this object.

Returns
The Xml node name.

Implements logicalaccess::XmlSerializable.

◆ getLibUSBReaderUnit()

std::shared_ptr< LibUSBReaderUnit > logicalaccess::LibUSBDataTransport::getLibUSBReaderUnit ( ) const
inline

Get the LibUSB reader unit.

Returns
The LibUSB reader unit.

◆ getName()

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

Get the data transport endpoint name.

Returns
The data transport endpoint name.

Implements logicalaccess::DataTransport.

◆ getTransportType()

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

Get the transport type of this instance.

Returns
The transport type.

Implements logicalaccess::DataTransport.

◆ isConnected()

bool logicalaccess::LibUSBDataTransport::isConnected ( )
overridevirtual

\briaf Get if connected to the transport layer.

Returns
True if connected, false otherwise.

Implements logicalaccess::DataTransport.

◆ receive()

std::vector< unsigned char > logicalaccess::LibUSBDataTransport::receive ( long int  timeout = 5000)
overridevirtual

Receive data from reader.

Parameters
timeoutThe time to wait data.
Returns
The data from reader.

Implements logicalaccess::DataTransport.

Reimplemented in logicalaccess::YubikeyDataTransport.

◆ send()

void logicalaccess::LibUSBDataTransport::send ( const std::vector< unsigned char > &  data)
overridevirtual

Send the data using rpleth protocol computation.

Parameters
dataThe data to send.

Reimplemented in logicalaccess::YubikeyDataTransport.

◆ sendCommand()

std::vector< unsigned char > logicalaccess::LibUSBDataTransport::sendCommand ( const std::vector< unsigned char > &  command,
long int  timeout = 2000 
)
override

Send a command to the reader.

Parameters
commandThe command buffer.
timeoutThe command timeout.
Returns
the result of the command.

◆ serialize()

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

Serialize object to Xml Node.

Parameters
parentNodeThe parent XML node.

Implements logicalaccess::XmlSerializable.

◆ unSerialize()

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

UnSerialize object from a Xml Node.

Parameters
nodeThe Xml node.

Implements logicalaccess::XmlSerializable.

◆ usb_read()

std::vector< unsigned char > logicalaccess::LibUSBDataTransport::usb_read ( int  report_type,
int  report_number,
int  readlen,
int  timeout = 1000 
)

◆ usb_write()

void logicalaccess::LibUSBDataTransport::usb_write ( const std::vector< unsigned char > &  data,
int  report_type,
int  report_number 
)

Member Data Documentation

◆ d_isConnected

bool logicalaccess::LibUSBDataTransport::d_isConnected
protected

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