nx_moonraker_telemetry_parse.nx
buildroot/runtime/nx_moonraker_telemetry_parse.nx
about
nx_moonraker_telemetry_parse.nx -- pure-substrate parser for
Moonraker /printer/objects/query responses; populates the
thermal section of NxPrintTelemetry.
Strategy: substring-window scan (no recursive descent). Moonraker
JSON shape is documented and stable enough that this approach
works without a full tree parser, but it IS brittle if Moonraker
changes the response layout -- a future arc can swap this for an
nx_json-based stateful parser without changing the API.
For /printer/objects/query?extruder&heater_bed the response is:
{"result":{"status":{
"extruder": {"temperature":209.8,"target":210.0,...},
"heater_bed": {"temperature":59.7, "target":60.0, ...}
},"eventtime":12345.678}}
We:
1. Find the scope window `"extruder":{...}` (matched braces).
2. Within that window, find `"temperature":` and read the next
number. Likewise `"target":`.
3. Same for heater_bed.
Numbers convert to whole °C (truncate fractional). 1°C precision
is acceptable given typical 2-5°C tolerances; operator can tighten
if needed. Sentinel -1 means "not found" for setpoints (lets
NxPrintTelemetry skip that axis cleanly).
license_tier: ORIGINAL
dependencies 2 imports · 3 importers
imports: nx_syscalls.nxnx_print_telemetry.nx
imported by: nx_moonraker_loop_e2e_test.nxnx_moonraker_motion_parse_test.nxnx_moonraker_telemetry_parse_test.nx
structs
| none |
consts
| 32 | const NX_MAGIC_32768: i64 = 32768 |
| 34 | const NX_MR_PARSE_OK: i64 = 0 |
| 35 | const NX_MR_PARSE_NO_OBJECT: i64 = 1 |
| 36 | const NX_MR_PARSE_BAD_INPUT: i64 = 2 |
| 246 | const MR_P_Q14_NOT_FOUND: i64 = -2147483647 |
| 247 | const MR_P_Q14_SCALE: i64 = 16384 |
functions
| 40 | func mr_p_byte_eq(body: *u8, off: i64, lit: *u8, n: i64) -> i64 called by 1: mr_p_find |
| 50 | func mr_p_cstr_len(s: *u8) -> i64 |
| 58 | func mr_p_find(body: *u8, body_len: i64, start: i64, needle: *u8) -> i64 |
| 75 | func mr_p_match_brace(body: *u8, body_len: i64, open_at: i64) -> i64 |
| 111 | func mr_p_parse_int_degrees(body: *u8, off: i64, end: i64) -> i64 called by 1: mr_p_extract_int_in_scope |
| 157 | func mr_p_extract_int_in_scope( |
| 176 | func nx_moonraker_parse_thermal( |
| 249 | func mr_p_parse_q14(body: *u8, off: i64, end: i64) -> i64 |
| 331 | func mr_p_extract_q14_in_scope( |
| 345 | func mr_p_extract_live_position( |
| 424 | func nx_moonraker_parse_motion( called by 2: mainmain calls 4: mr_p_findmr_p_match_bracemr_p_extract_live_positionmr_p_extract_q14_in_scope |