code wiki / (root) / nx_moonraker_telemetry_parse.nx

nx_moonraker_telemetry_parse.nx

buildroot/runtime/nx_moonraker_telemetry_parse.nx

15747 B460 linesdepth 4pulls 4 transitivereach 3 importersview sourcekind librarytopic moonraker
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_print_telemetry.nx nx_moonraker_telemetry_parse.n nx_moonraker_loop_e2e_test.nx nx_moonraker_motion_parse_test.nx nx_moonraker_telemetry_parse_test.

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

32const NX_MAGIC_32768: i64 = 32768
34const NX_MR_PARSE_OK: i64 = 0
35const NX_MR_PARSE_NO_OBJECT: i64 = 1
36const NX_MR_PARSE_BAD_INPUT: i64 = 2
246const MR_P_Q14_NOT_FOUND: i64 = -2147483647
247const MR_P_Q14_SCALE: i64 = 16384

functions

40func mr_p_byte_eq(body: *u8, off: i64, lit: *u8, n: i64) -> i64
called by 1: mr_p_find
50func mr_p_cstr_len(s: *u8) -> i64
58func mr_p_find(body: *u8, body_len: i64, start: i64, needle: *u8) -> i64
75func mr_p_match_brace(body: *u8, body_len: i64, open_at: i64) -> i64
111func mr_p_parse_int_degrees(body: *u8, off: i64, end: i64) -> i64
157func mr_p_extract_int_in_scope(
176func nx_moonraker_parse_thermal(
249func mr_p_parse_q14(body: *u8, off: i64, end: i64) -> i64
331func mr_p_extract_q14_in_scope(
345func mr_p_extract_live_position(
424func nx_moonraker_parse_motion(