OpenSRX 0.1.0
C++ library for interfacing with Keyence SR series barcode readers
Loading...
Searching...
No Matches
OpenSRX::SocketInterface Class Reference

Communication interface using a TCP/IP socket. More...

#include <SocketInterface.hpp>

Inheritance diagram for OpenSRX::SocketInterface:
OpenSRX::AsioInterface< asio::ip::tcp::socket > OpenSRX::ICommInterface

Public Member Functions

 SocketInterface (const std::string &ip="192.168.100.100", int port=9004)
 Open a TCP socket connection to the scanner.
 
 ~SocketInterface () override
 
std::string describe () const override
 Return a human-readable description of this interface.
 
void startFtpServer (const std::string &address, int port, const std::string &mountPoint, int threadPoolSize=4)
 Start a local FTP server for receiving data from the scanner.
 
- Public Member Functions inherited from OpenSRX::AsioInterface< asio::ip::tcp::socket >
 ~AsioInterface () override=default
 
std::string sendCommand (const std::string &command) override
 Sends a command over the Asio stream and reads the response.
 
std::string sendCommandUnlocked (const std::string &command) override
 Sends a command without acquiring the communication mutex.
 
- Public Member Functions inherited from OpenSRX::ICommInterface
virtual ~ICommInterface ()=default
 
void setCommFormat (CommFormat format)
 Set the communication framing format.
 
CommFormat getCommFormat ()
 Get the current communication framing format.
 

Private Attributes

std::string ip
 Scanner IP address.
 
int port
 Scanner command port.
 
std::unique_ptr< fineftp::FtpServer > pFtpServer = nullptr
 FTP server instance (heap-allocated because FtpServer is non-copyable).
 

Additional Inherited Members

- Protected Member Functions inherited from OpenSRX::AsioInterface< asio::ip::tcp::socket >
 AsioInterface (Args &&... args)
 Construct an AsioInterface, forwarding arguments to the stream.
 
- Protected Attributes inherited from OpenSRX::AsioInterface< asio::ip::tcp::socket >
asio::io_context ioContext
 
asio::ip::tcp::socket stream
 
- Protected Attributes inherited from OpenSRX::ICommInterface
std::mutex commMutex
 Mutex to ensure thread-safe access to the communixcation interface.
 

Detailed Description

Communication interface using a TCP/IP socket.

Connects to the scanner's Ethernet command port via Asio TCP socket.

Constructor & Destructor Documentation

◆ SocketInterface()

OpenSRX::SocketInterface::SocketInterface ( const std::string & ip = "192.168.100.100",
int port = 9004 )

Open a TCP socket connection to the scanner.

Parameters
ipScanner IP address (e.g. "192.168.100.100").
portScanner command port (default 9004).

◆ ~SocketInterface()

OpenSRX::SocketInterface::~SocketInterface ( )
override

Member Function Documentation

◆ describe()

std::string OpenSRX::SocketInterface::describe ( ) const
inlineoverridevirtual

Return a human-readable description of this interface.

Returns
e.g. "/dev/ttyUSB0" or "192.168.1.100:9004".

Implements OpenSRX::ICommInterface.

◆ startFtpServer()

void OpenSRX::SocketInterface::startFtpServer ( const std::string & address,
int port,
const std::string & mountPoint,
int threadPoolSize = 4 )

Start a local FTP server for receiving data from the scanner.

Parameters
addressLocal address to bind to.
portFTP port to listen on.
mountPointLocal filesystem path to serve.
threadPoolSizeNumber of FTP server threads.

Member Data Documentation

◆ ip

std::string OpenSRX::SocketInterface::ip
private

Scanner IP address.

◆ pFtpServer

std::unique_ptr<fineftp::FtpServer> OpenSRX::SocketInterface::pFtpServer = nullptr
private

FTP server instance (heap-allocated because FtpServer is non-copyable).

◆ port

int OpenSRX::SocketInterface::port
private

Scanner command port.


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