Skip to main content

Crate ocrl

Crate ocrl 

Source
Expand description

§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.

§API Compliance

This library implements the exact same C API as the official OCRL Linux library:

  • Function signatures match the official specification exactly
  • Parameter names use the same camelCase convention as the original API
  • Return codes follow the official error code specification
  • Buffer size requirements match the official minimum of 4096 bytes

§Usage

The library exports three main C functions:

  • Connect(char* com): Open serial port and setup security channel with R/W
  • CmdExchange(char* requestJSON, char* responseJSON, int maxResponseLen): Send requests and receive responses
  • Disconnect(): Close serial port

§Error Codes

  • 0: Success (communication succeeded)
  • -1: COM not opened
  • -2: Communication error with R/W
  • -3: responseJSON buffer size not enough
  • -6: Link busy

Functions§

CmdExchange
Blocking call to send out request and wait for response from R/W with 1sec timeout
Connect
Open serial port and setup security channel with R/W
Disconnect
Close serial port