|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Layer: L7 Application ยท Build flags: PC_ENABLE_LSV2
Heidenhain TNC controls (iTNC 530, TNC 320 / 620 / 640, ...) speak LSV/2 for DNC and data access - file transfer, program upload/download, and run/status inspection - over a serial link or, as here, LSV/2-over-TCP (default port 19000). It is the CNC-native way to pull live machine state from the common European control with no vendor middleware. services/lsv2 is a pure codec for the telegram framing; the sketch owns the socket.
Every LSV/2 telegram is a 4-byte big-endian payload-length prefix, a 4-character mnemonic, then the payload. The length counts the payload only, so a bare acknowledgement is exactly 8 bytes:
The codec frames each request and slices each reply off the byte stream:
Access is privilege-gated: log in to a group (INSPECT to read, FILE for the file system, DNC for DNC functions, ...) with A_LG, then issue commands; the control answers T_OK / T_FD, a S_* data reply, or T_ER / T_BD carrying a two-byte error-class + error-code.
Point TNC_IP at a TNC with the LSV/2 / DNC Ethernet interface enabled (the control's network / DNC settings). No machine handy? The pyLSV2 project ships a small LSV/2 server stub, or a socket server that answers each request with the 00 00 00 00 T_OK / S_RI frames above works for a dry run.
Flash and watch Serial @ 115200:
The complete sketch is HeidenhainLsv2.ino. The codec itself is in src/services/machine_tool/lsv2/lsv2.h; the telegram framing, the command / response mnemonic set, and the login / filename / run-info payload layouts are cross-checked byte-for-byte against the pyLSV2 reference. Pairs with the HaasMdc and Fanuc FOCAS machine-tool examples.