OpenSRX 0.1.0
C++ library for interfacing with Keyence SR series barcode readers
Loading...
Searching...
No Matches
Serial vs. Socket Communication

OpenSRX provides two concrete communication backends, both implementing the OpenSRX::ICommInterface abstract class.

SocketInterface

Use OpenSRX::SocketInterface for Ethernet (TCP/IP) connections. This is the most common setup for the SR-X series.

OpenSRX::SocketInterface comm("192.168.100.100", 9004);
OpenSRX::Scanner scanner(comm);
OpenSRX::Code code = scanner.startReading();
std::cout << code.data << std::endl;
Umbrella header for the OpenSRX library.
High-level interface to a KEYENCE SR-X series barcode scanner.
Definition Scanner.hpp:90
Communication interface using a TCP/IP socket.
Definition SocketInterface.hpp:17
Result of a barcode read operation.
Definition Code.hpp:42
std::string data
The decoded barcode string.
Definition Code.hpp:43

SerialInterface

Use OpenSRX::SerialInterface for RS-232 serial connections.

OpenSRX::SerialInterface comm("/dev/ttyUSB0", 115200);
OpenSRX::Scanner scanner(comm);
OpenSRX::Code code = scanner.startReading();
std::cout << code.data << std::endl;
Communication interface using an RS-232 serial port.
Definition SerialInterface.hpp:42

You can configure parity, data bits, stop bits, and flow control through the constructor parameters. See the OpenSRX::SerialInterface class reference for details.

Communication Format

Both backends support switching between different command framing modes via OpenSRX::ICommInterface::setCommFormat. The available modes are defined in OpenSRX::CommFormat.