Files
continuum-proxy/tests/fixtures/push_status_v1_p1p_idle.json
octoturge 9a314b2b9f Fix print.push_status parsing, and stop losing reports silently
Pointed at a real H2C that was 20% into a job, `print_status()` returned
nothing at all. The printer was in fact pushing a full status object every
second; every one was arriving, failing to deserialize, and being dropped
invisibly by an `if let Ok(report) = ..` with no `else`.

That silence produced two confidently-wrong claims in our own comments,
both corrected here:

- `pushall`'s doc said whether v2 emits `push_status` unprompted was "an
  open question". It is not: v2 pushes a full 97-field object roughly once
  a second from the moment you subscribe, no trigger needed. There is no
  missing "other trigger" to hunt for.
- The "sequence gap" warning blamed the network for dropped v1 updates.
  Those updates were not dropped in transit - they failed to parse, so
  they never reached the counter, making the next one that did look like a
  skip. Confirmed: seq 57, 62, 64 and 69 all arrived. After the fix, zero
  gaps and zero parse failures across a 25s run against both printers.

Two concrete causes, both found with captured payloads:

- v1 trays carry `tray_temp`/`tray_time`; v2 trays carry
  `drying_temp`/`drying_time`. All four were required, so *every* v1 push
  carrying AMS data failed.
- A third tray shape existed that nothing modelled: an empty v2 slot sends
  `{"id": "2", "state": 0}`, which matched neither `EmptyTray` (it denies
  unknown fields, deliberately) nor `LoadedTray` (16 fields short).

A parse failure now reports itself, naming the printer, the sequence id and
the serde error. A report this process cannot parse is a defect in
`PrintReport`, and the only way to fix it is to be told which field.

`PrintReport` itself modelled 9 of 97 top-level fields, and none of them
were progress or temperature - it was built from a truncated example. It
now carries gcode_state, percent, layer counts, remaining time, nozzle/bed
temperatures, fan gears, wifi and HMS entries. `merge_from`'s two dozen
four-line blocks collapse to `newer.x.or(self.x.take())` one-liners: the
old shape made adding a field a three-place edit, and forgetting the merge
half produced a field that silently never survived a partial update.

Two scale traps documented where they bite: reported fan speeds are 0-15
gears, not percent and not the 0-255 PWM we send (`set_fan_speed(50)`
reads back as "7"); and v2 pins `sequence_id` to one value for minutes
while contents change, so it orders and identifies nothing there.

Two examples, and the distinction between them is the point. `live_reports`
is read-only and safe against a printer mid-job. `bambu_idle_checks`
writes, so it requires an explicit printer id and refuses to run unless
that printer reports `gcode_state: "IDLE"`.

Regression fixtures are verbatim captures off both printers, hardware
identifiers scrubbed - the only way to keep this from regressing without a
printer plugged in.
2026-10-03 10:12:05 +00:00

220 lines
5.0 KiB
JSON

{
"upgrade_state": {
"sequence_id": 0,
"progress": "",
"status": "IDLE",
"consistency_request": false,
"dis_state": 0,
"err_code": 0,
"force_upgrade": false,
"message": "0%, 0B/s",
"module": "",
"new_version_state": 0,
"cur_state_code": 0,
"idx2": 4275297388,
"new_ver_list": []
},
"ipcam": {
"ipcam_dev": "1",
"ipcam_record": "enable",
"timelapse": "disable",
"resolution": "",
"tutk_server": "disable",
"mode_bits": 3
},
"upload": {
"status": "idle",
"progress": 0,
"message": ""
},
"net": {
"conf": 0,
"info": [
{
"ip": 0,
"mask": 0
}
]
},
"nozzle_temper": 22.125,
"nozzle_target_temper": 0,
"bed_temper": 21.34375,
"bed_target_temper": 0,
"chamber_temper": 5,
"mc_print_stage": "1",
"heatbreak_fan_speed": "15",
"cooling_fan_speed": "0",
"big_fan1_speed": "0",
"big_fan2_speed": "0",
"mc_percent": 0,
"mc_remaining_time": 0,
"ams_status": 0,
"ams_rfid_status": 0,
"hw_switch_state": 0,
"spd_mag": 100,
"spd_lvl": 2,
"print_error": 0,
"lifecycle": "product",
"wifi_signal": "-64dBm",
"gcode_state": "IDLE",
"gcode_file_prepare_percent": "0",
"queue_number": 0,
"queue_total": 0,
"queue_est": 0,
"queue_sts": 0,
"project_id": "0",
"profile_id": "0",
"task_id": "0",
"subtask_id": "0",
"subtask_name": "",
"gcode_file": "",
"stg": [],
"stg_cur": 0,
"print_type": "idle",
"home_flag": 158549400,
"mc_print_line_number": "0",
"mc_print_sub_stage": 0,
"sdcard": true,
"force_upgrade": false,
"mess_production_state": "active",
"layer_num": 0,
"total_layer_num": 0,
"s_obj": [],
"filam_bak": [],
"fan_gear": 0,
"nozzle_diameter": "0.4",
"nozzle_type": "stainless_steel",
"cali_version": 0,
"k": "0.0000",
"flag3": 655,
"hms": [],
"online": {
"ahb": false,
"rfid": false,
"version": 1849554829
},
"ams": {
"ams": [
{
"chip_id": "<scrubbed>",
"ams_id": "<scrubbed>",
"check": 1,
"id": "0",
"humidity": "2",
"humidity_raw": "41",
"temp": "23.0",
"dry_time": 0,
"info": "1001",
"tray": [
{
"id": "0"
},
{
"id": "1"
},
{
"id": "2",
"state": 3,
"remain": -1,
"k": 0.03999999910593033,
"n": 1,
"cali_idx": -1,
"total_len": 330000,
"tag_uid": "<scrubbed>",
"tray_id_name": "",
"tray_info_idx": "GFG99",
"tray_type": "PETG",
"tray_sub_brands": "",
"tray_color": "161616FF",
"tray_weight": "0",
"tray_diameter": "0.00",
"tray_temp": "0",
"tray_time": "0",
"bed_temp_type": "0",
"bed_temp": "0",
"nozzle_temp_max": "270",
"nozzle_temp_min": "220",
"xcam_info": "000000000000000000000000",
"tray_uuid": "<scrubbed>",
"ctype": 0,
"cols": [
"161616FF"
]
},
{
"id": "3",
"state": 3,
"remain": -1,
"k": 0.03999999910593033,
"n": 1,
"cali_idx": -1,
"total_len": 330000,
"tag_uid": "<scrubbed>",
"tray_id_name": "",
"tray_info_idx": "GFG99",
"tray_type": "PETG",
"tray_sub_brands": "",
"tray_color": "2850E0FF",
"tray_weight": "0",
"tray_diameter": "0.00",
"tray_temp": "0",
"tray_time": "0",
"bed_temp_type": "0",
"bed_temp": "0",
"nozzle_temp_max": "270",
"nozzle_temp_min": "220",
"xcam_info": "000000000000000000000000",
"tray_uuid": "<scrubbed>",
"ctype": 0,
"cols": [
"2850E0FF"
]
}
]
}
],
"ams_exist_bits": "1",
"tray_exist_bits": "c",
"tray_is_bbl_bits": "c",
"tray_tar": "255",
"tray_now": "255",
"tray_pre": "255",
"tray_read_done_bits": "c",
"tray_reading_bits": "0",
"version": 2,
"insert_flag": false,
"power_on_flag": false
},
"vt_tray": {
"id": "254",
"tag_uid": "<scrubbed>",
"tray_id_name": "",
"tray_info_idx": "P9599a25",
"tray_type": "PETG",
"tray_sub_brands": "",
"tray_color": "D3C5A3FF",
"tray_weight": "0",
"tray_diameter": "0.00",
"tray_temp": "0",
"tray_time": "0",
"bed_temp_type": "0",
"bed_temp": "0",
"nozzle_temp_max": "240",
"nozzle_temp_min": "225",
"xcam_info": "000000000000000000000000",
"tray_uuid": "<scrubbed>",
"remain": 0,
"k": 0.019999999552965164,
"n": 1,
"cali_idx": -1
},
"lights_report": [
{
"node": "chamber_light",
"mode": "off"
}
],
"command": "push_status",
"msg": 0,
"sequence_id": "53"
}