A C++ library for interfacing with Keyence SR-X series barcode readers over Ethernet (TCP socket) or RS-232 serial connections.
- Scanner control – reading, tuning, I/O terminal control, status queries, settings management (save/load/factory reset/backup)
- Typed parameter access – template-based get/set for bank, tuning, operation, and communication parameters with automatic type conversion
- Structured read results –
Codestruct with optional bounding box, center, code type, bank number, and angle metadata - Image readback – embedded FTP server receives BMP images pushed by the scanner; decode, queue, and callback APIs
- Two comm backends –
SocketInterface(TCP/IP) andSerialInterface(RS-232), both implementingICommInterface - Simulator – Python-based scanner simulator for development without hardware
#include "OpenSRX/OpenSRX.hpp"
// Connect over Ethernet
OpenSRX::SocketInterface comm("192.168.100.100", 9004);
OpenSRX::Scanner scanner(comm);
// Read a barcode
OpenSRX::Code code = scanner.startReading();
std::cout << "Read: " << code.data << std::endl;
// Get/set parameters
auto exposure = scanner.getParam<OpenSRX::BankParam::EXPOSURE_TIME>(1);
scanner.setParam<OpenSRX::OperationParam::IMAGE_FORMAT>(OpenSRX::ImageFormat::BMP);cmake -S . -B build
cmake --build buildOr with pixi:
pixi run buildSix example programs are included under examples/:
| Example | Description |
|---|---|
VersionInfo |
Print library and scanner version information |
ReadCode |
Trigger a barcode read and print the result |
ReadCodeDetailed |
Read with bounding box, center, and code type metadata |
ImageReadback |
Start FTP server, trigger a read, save the received image as BMP |
ImageSnapshot |
Take a camera snapshot (no decode) and save as BMP |
AdjustParams |
Read and modify scanner parameters |
All examples accept --ip/--port or --serial arguments. Run with --help
for details.
| Option | Description | Default |
|---|---|---|
BUILD_STATIC_LIB |
Build a static library instead of shared | OFF |
BUILD_EXAMPLES |
Build example binaries | ON |
BUILD_TESTS |
Build the test suite (fetches GoogleTest) | ON |
cmake --build build
./build/tests/TestOpenSRXAll C++ dependencies are fetched automatically via CMake FetchContent:
- Asio 1.30.2 – standalone, header-only networking
- spdlog 1.15.3 – fast C++ logging
- fineftp-server 1.3.4 – lightweight FTP server for image readback
- GoogleTest 1.17.0 – unit-testing framework (tests only)
- argparse 3.2 – CLI argument parsing (examples only)
A Python-based scanner simulator is provided for development and testing:
python scripts/simulator.py
# or: pixi run simulatorThis opens a TCP server on port 9004 that emulates the SR-X command protocol, including simulated barcode reads with generated images pushed via FTP.
API documentation is generated with Doxygen from the C++ header comments and hand-written Markdown guides.
pixi run docs
# or: cd docs && doxygen DoxyfileThe generated site will be in docs/_build/html/.