OCRL Mock Library
A mock implementation of the OCRL (Octopus Card Reader Library) C ABI for testing purposes. This library provides a test-friendly simulation of payment terminal operations including card enquiry, deduction, and settlement functions.
Installation
From Crates.io
From Source
Usage
As a Dependency
Add this to your Cargo.toml:
[]
= "0.1.0"
If you have the actual OCRL library (libocrl.a) for Linux x86_64 but need to develop and test on macOS or other systems:
[]
= "0.1.0"
build.rs file in your project root:
Supported Commands
config.get- Get device configurationdisplay.img- Display image (resId 1-8)scheme.enquiry- Get available promotion schemestrans.request- Request transaction (card.enquiry, deduct, settle)trans.perform- Perform requested transactiontrans.cancel- Cancel transaction
Environment Variables
You can control the mock behavior using environment variables:
CARD=1- Simulates invalid card errorCARD=2- Simulates card with transaction history- Default - Normal card with balance
Error Codes
| Code | Description |
|---|---|
0 |
Success (communication succeeded) |
-1 |
COM not opened |
-2 |
Communication error with R/W |
-3 |
responseJSON buffer size not enough |
-6 |
Link busy |
License
MIT
Disclaimer
This is a mock library for testing purposes only. It does not connect to real hardware and should not be used in production environments where actual payment processing is required.