Teoria
ECR17 is a request-response protocol between an Electronic Cash Register and an EFT-POS terminal. The cash register sends a command frame, the terminal acknowledges transport-level receipt, performs the requested operation, and returns an application result frame.
Frame families
STX, payload, ETX, then LRC.
SOH, 20-character display text, then EOT.
ACK or NAK response at the protocol handshake layer.
LRC
The implementation starts from base 0x7F and XOR-folds the configured bytes.
For a byte sequence (b_1, b_2, \ldots, b_n):
lrcMode controls whether STX and ETX participate in that fold:
stx:STX + payload + ETXstd:payloadnoext:payload + ETXstx_noext:STX + payload
Timing
The session uses distinct timeouts for connection, ACK, and final response. Separating them helps identify whether the failure is the LAN socket, terminal handshake, or host-side transaction wait.
Progress frames do not carry LRC. Treating SOH ... EOT as an application frame will corrupt decoding.