OpenSRX is a C++ library that lets you control Keyence SR-X series barcode readers programmatically. It supports two communication backends:
- SocketInterface – TCP/IP over Ethernet (default port 9004)
- SerialInterface – RS-232 serial link
Prerequisites
- A C++17 compiler (GCC ≥ 9, Clang ≥ 10, MSVC ≥ 19.20)
- CMake ≥ 3.16
- An internet connection during the first build (dependencies are fetched automatically via CMake
FetchContent)
Quick Start
git clone https://github.com/jwlodek/OpenSRX.git
cd OpenSRX
cmake -S . -B build
cmake --build build
After building, example binaries are at build/examples/ (e.g. VersionInfo, ReadCode, ImageReadback). All examples accept --ip/--port or --serial arguments — run with --help for usage details.
Umbrella Header
Include a single header to get the entire public API:
Umbrella header for the OpenSRX library.
Connecting to a Scanner
std::cout << scanner.getModel() << std::endl;
std::cout << scanner.getFirmwareVersion() << std::endl;
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
Reading a Barcode
startReading() blocks until the scanner decodes a code (or throws on timeout):
std::cout <<
"Data: " << code.
data << std::endl;
Result of a barcode read operation.
Definition Code.hpp:42
std::string data
The decoded barcode string.
Definition Code.hpp:43
Enable appending options for extra metadata:
if (code.boundingBox) {
auto& bb = *code.boundingBox;
std::cout << "Top-left: (" << bb.topLeft.x << ", " << bb.topLeft.y << ")\n";
}
if (code.center) {
std::cout << "Center: (" << code.center->x << ", " << code.center->y << ")\n";
}
@ ENABLE
Definition ParamValues.hpp:10
@ CODE_VERTEX_APPENDING
Definition OperationParam.hpp:121
@ CODE_CENTER_APPENDING
Definition OperationParam.hpp:122
Getting and Setting Parameters
Parameters are accessed with compile-time-typed templates:
@ BMP
Definition ParamValues.hpp:232
@ EXPOSURE_TIME
Definition BankParam.hpp:24
@ IMAGE_FORMAT
Definition OperationParam.hpp:149
@ FTP_REMOTE_IP
Definition CommParam.hpp:91
Image Readback
Start an embedded FTP server, trigger a read, and receive the image:
scanner.startImageServer("192.168.100.50");
scanner.stopImageServer();
Raw decoded image data.
Definition Image.hpp:18
Using the Simulator
For development without hardware, use the Python simulator:
python scripts/simulator.py
# or: pixi run simulator
Then point examples at 127.0.0.1:9004:
./build/examples/ReadCode --ip 127.0.0.1 --port 9004