|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Haas Machine Data Collection (MDC) Q-command codec (PC_ENABLE_HAAS_MDC) - a zero-heap codec for the documented Haas Automation MDC protocol, the ?Q query set a Haas CNC mill / lathe control answers over RS-232 (7-E-1, XON/XOFF) or a raw TCP socket (Setting 143, default port 5051). A small, fully-documented CNC read source that fans machine status into HTTP / MQTT.
More...
#include "protocore_config.h"Go to the source code of this file.
Haas Machine Data Collection (MDC) Q-command codec (PC_ENABLE_HAAS_MDC) - a zero-heap codec for the documented Haas Automation MDC protocol, the ?Q query set a Haas CNC mill / lathe control answers over RS-232 (7-E-1, XON/XOFF) or a raw TCP socket (Setting 143, default port 5051). A small, fully-documented CNC read source that fans machine status into HTTP / MQTT.
The device is the collector: it sends ?Q### queries and the control replies with a framed, comma-delimited payload. This codec builds the queries (pc_haas_mdc_build_q for the numbered commands and pc_haas_mdc_build_var for the ?Q600 <var> macro/system-variable read) and parses the responses (pc_haas_mdc_parse extracts the CSV payload framed between STX and ETB, then pc_haas_mdc_value / pc_haas_mdc_parse_status / pc_haas_mdc_parse_macro read the typed forms). It also de-multiplexes the unprompted DPRNT(...) lines a running G-code program pushes on the same link (pc_haas_mdc_dprnt_line - raw text, no STX/ETB).
Wire framing (byte-exact): a request is ?Q### + CR (\r), UPPERCASE. A response payload lives strictly between STX (0x02) and ETB (0x17), followed by CR LF and a > (0x3E) prompt byte, e.g. ?Q100\r -> \x02SERIAL NUMBER, 1234567\x17\r\n>. Parse defensively by scanning for the STX/ETB delimiters, not fixed offsets. Q500 has two branches (PROGRAM, Oxxxxx, <status>, PARTS, n when idle/running vs STATUS, BUSY mid-operation); an unsupported command returns UNKNOWN.
Reference: Haas Automation service manual "Machine Data Collection" (Setting 143) + the Q-command table and DPRNT how-to; framing cross-checked byte-for-byte against a production Haas serial adapter.
Definition in file haas_mdc.h.