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.
This commit is contained in:
+220
@@ -0,0 +1,220 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
+846
@@ -0,0 +1,846 @@
|
||||
{
|
||||
"2D": {
|
||||
"bs": {
|
||||
"bi": [
|
||||
{
|
||||
"clock_in": false,
|
||||
"est_time": 0,
|
||||
"idx": 0,
|
||||
"print_then": false,
|
||||
"proc_list": [],
|
||||
"step_type": 1,
|
||||
"tool_info": {
|
||||
"color": "",
|
||||
"diameter": 0.4000000059604645,
|
||||
"id": 8978432
|
||||
},
|
||||
"type": 137
|
||||
}
|
||||
],
|
||||
"total_time": 0
|
||||
},
|
||||
"cond": 14,
|
||||
"cur_stage": {
|
||||
"clock_in_time": 0,
|
||||
"idx": 0,
|
||||
"left_time": 0,
|
||||
"process": 0,
|
||||
"state": 0
|
||||
},
|
||||
"first_confirm": false,
|
||||
"makeable": false,
|
||||
"material": {
|
||||
"cur_id_list": [],
|
||||
"state": 0,
|
||||
"tar_id": "",
|
||||
"tar_name": ""
|
||||
},
|
||||
"pm": 0
|
||||
},
|
||||
"3D": {
|
||||
"layer_num": 2,
|
||||
"print_cali_option": 2,
|
||||
"total_layer_num": 50
|
||||
},
|
||||
"ams": {
|
||||
"ams": [
|
||||
{
|
||||
"dry_time": 0,
|
||||
"humidity": "2",
|
||||
"humidity_raw": "34",
|
||||
"id": "0",
|
||||
"info": "1003",
|
||||
"temp": "30.6",
|
||||
"tray": [
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"2850E0FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "0",
|
||||
"nozzle_temp_max": "280",
|
||||
"nozzle_temp_min": "240",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "2850E0FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFN99",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PA",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"7C4B00FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "1",
|
||||
"nozzle_temp_max": "300",
|
||||
"nozzle_temp_min": "260",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "7C4B00FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFN08",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PA-GF",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"898989FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "2",
|
||||
"nozzle_temp_max": "290",
|
||||
"nozzle_temp_min": "260",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "898989FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFC99",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PC",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"161616FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "3",
|
||||
"nozzle_temp_max": "290",
|
||||
"nozzle_temp_min": "260",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "161616FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFC99",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PC",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dry_time": 0,
|
||||
"humidity": "1",
|
||||
"humidity_raw": "47",
|
||||
"id": "1",
|
||||
"info": "1003",
|
||||
"temp": "27.1",
|
||||
"tray": [
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"FFFFFF00"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "0",
|
||||
"nozzle_temp_max": "280",
|
||||
"nozzle_temp_min": "240",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "FFFFFF00",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFB00",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "ABS",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"FFF144FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "1",
|
||||
"nozzle_temp_max": "270",
|
||||
"nozzle_temp_min": "220",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "FFF144FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFG99",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PETG",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"state": 10
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"898989FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "3",
|
||||
"nozzle_temp_max": "240",
|
||||
"nozzle_temp_min": "190",
|
||||
"remain": 0,
|
||||
"state": 11,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "898989FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFL95",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "PLA",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dry_time": 0,
|
||||
"humidity": "0",
|
||||
"humidity_raw": "16",
|
||||
"id": "128",
|
||||
"info": "2104",
|
||||
"temp": "41.5",
|
||||
"tray": [
|
||||
{
|
||||
"id": "0",
|
||||
"state": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ams_exist_bits": "13",
|
||||
"ams_exist_bits_raw": "13",
|
||||
"cali_id": 255,
|
||||
"cali_stat": 0,
|
||||
"insert_flag": false,
|
||||
"power_on_flag": false,
|
||||
"tray_exist_bits": "bf",
|
||||
"tray_is_bbl_bits": "bf",
|
||||
"tray_now": "0",
|
||||
"tray_pre": "0",
|
||||
"tray_read_done_bits": "bf",
|
||||
"tray_reading_bits": "0",
|
||||
"tray_tar": "0",
|
||||
"unbind_ams_stat": 0,
|
||||
"version": 169763
|
||||
},
|
||||
"ams_rfid_status": 0,
|
||||
"ams_status": 768,
|
||||
"ap_err": 0,
|
||||
"aux": "2001004",
|
||||
"aux_part_fan": false,
|
||||
"batch_id": 0,
|
||||
"bed_target_temper": 35.0,
|
||||
"bed_temper": 35.0,
|
||||
"big_fan1_speed": "14",
|
||||
"big_fan2_speed": "4",
|
||||
"cali_version": 0,
|
||||
"canvas_id": 0,
|
||||
"care": [
|
||||
{
|
||||
"id": "ls",
|
||||
"info": "1A00"
|
||||
},
|
||||
{
|
||||
"id": "ld",
|
||||
"info": "641864"
|
||||
},
|
||||
{
|
||||
"id": "lr",
|
||||
"info": "1A00"
|
||||
},
|
||||
{
|
||||
"id": "hr",
|
||||
"info": "5E185E"
|
||||
}
|
||||
],
|
||||
"cfg": "685DDAB8",
|
||||
"command": "push_status",
|
||||
"cooling_fan_speed": "14",
|
||||
"design_id": "",
|
||||
"device": {
|
||||
"airduct": {
|
||||
"modeCur": 0,
|
||||
"modeFunc": 0,
|
||||
"modeList": [
|
||||
{
|
||||
"ctrl": [
|
||||
16,
|
||||
32,
|
||||
48
|
||||
],
|
||||
"modeId": 0,
|
||||
"off": [
|
||||
96
|
||||
]
|
||||
},
|
||||
{
|
||||
"ctrl": [
|
||||
16
|
||||
],
|
||||
"modeId": 1,
|
||||
"off": [
|
||||
32,
|
||||
48
|
||||
]
|
||||
},
|
||||
{
|
||||
"ctrl": [
|
||||
48
|
||||
],
|
||||
"modeId": 2,
|
||||
"off": []
|
||||
}
|
||||
],
|
||||
"modeVisable": 7,
|
||||
"parts": [
|
||||
{
|
||||
"func": 0,
|
||||
"id": 16,
|
||||
"range": 6553600,
|
||||
"state": 100,
|
||||
"tar_state": 100
|
||||
},
|
||||
{
|
||||
"func": 1,
|
||||
"id": 32,
|
||||
"range": 6553600,
|
||||
"state": 100,
|
||||
"tar_state": 100
|
||||
},
|
||||
{
|
||||
"func": 2,
|
||||
"id": 48,
|
||||
"range": 6553600,
|
||||
"state": 30,
|
||||
"tar_state": 30
|
||||
},
|
||||
{
|
||||
"func": 4,
|
||||
"id": 96,
|
||||
"range": 6553600,
|
||||
"state": 0,
|
||||
"tar_state": 0
|
||||
}
|
||||
],
|
||||
"subFunc": 0,
|
||||
"subMode": 0,
|
||||
"subVisable": 7,
|
||||
"version": 1
|
||||
},
|
||||
"bed": {
|
||||
"info": {
|
||||
"temp": 2293795
|
||||
},
|
||||
"state": 2
|
||||
},
|
||||
"bed_temp": 2293795,
|
||||
"cam": {
|
||||
"laser": {
|
||||
"cond": 252,
|
||||
"state": 0
|
||||
},
|
||||
"timelapse_path": ""
|
||||
},
|
||||
"ctc": {
|
||||
"info": {
|
||||
"temp": 27
|
||||
},
|
||||
"state": 0
|
||||
},
|
||||
"ext_tool": {
|
||||
"calib": 2,
|
||||
"low_prec": true,
|
||||
"mount": 0,
|
||||
"mount_3d": 1,
|
||||
"th_temp": 0,
|
||||
"type": "F000"
|
||||
},
|
||||
"extruder": {
|
||||
"info": [
|
||||
{
|
||||
"filam_bak": [],
|
||||
"hnow": 0,
|
||||
"hpre": 0,
|
||||
"htar": 0,
|
||||
"id": 0,
|
||||
"info": 1611,
|
||||
"snow": 65280,
|
||||
"spre": 65280,
|
||||
"star": 65280,
|
||||
"stat": 197376,
|
||||
"temp": 15073510
|
||||
},
|
||||
{
|
||||
"filam_bak": [],
|
||||
"hnow": 1,
|
||||
"hpre": 1,
|
||||
"htar": 1,
|
||||
"id": 1,
|
||||
"info": 1048,
|
||||
"snow": 65279,
|
||||
"spre": 65279,
|
||||
"star": 65279,
|
||||
"stat": 0,
|
||||
"temp": 34
|
||||
}
|
||||
],
|
||||
"state": 2
|
||||
},
|
||||
"fan": 419300,
|
||||
"fire_ext": {
|
||||
"bot_err": 0,
|
||||
"cd": 0,
|
||||
"cd_init": 15,
|
||||
"connect_flag": 0,
|
||||
"drill_flag": 0,
|
||||
"history": [],
|
||||
"remain_time": 0,
|
||||
"rm_init": 33,
|
||||
"state": 0
|
||||
},
|
||||
"holder": {
|
||||
"info": 1,
|
||||
"job": 0,
|
||||
"pos": 3,
|
||||
"stat": 0,
|
||||
"step": [
|
||||
0
|
||||
]
|
||||
},
|
||||
"laser": {
|
||||
"power": 0
|
||||
},
|
||||
"nozzle": {
|
||||
"exist": 3604483,
|
||||
"info": [
|
||||
{
|
||||
"color_m": "00000000",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "GFB99",
|
||||
"id": 18,
|
||||
"sn": "20D06A5A1512964",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "00000000",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "",
|
||||
"id": 1,
|
||||
"sn": "N/A",
|
||||
"stat": 0,
|
||||
"tm": 0,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "F95D73FF",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "Pf3dbd0c",
|
||||
"id": 0,
|
||||
"sn": "20D06A5A1507129",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "7C4B00FF",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "GFN08",
|
||||
"id": 16,
|
||||
"sn": "20D06A5A1507166",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "FFF144FF",
|
||||
"diameter": 0.6,
|
||||
"fila_id": "GFG99",
|
||||
"id": 21,
|
||||
"sn": "20D06A592727617",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "2850E0FF",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "GFN99",
|
||||
"id": 17,
|
||||
"sn": "20D06A5A1215962",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
},
|
||||
{
|
||||
"color_m": "161616FF",
|
||||
"diameter": 0.4,
|
||||
"fila_id": "GFC99",
|
||||
"id": 20,
|
||||
"sn": "20D06A592725573",
|
||||
"stat": 0,
|
||||
"tm": 350,
|
||||
"type": "HS01",
|
||||
"wear": 0.0
|
||||
}
|
||||
],
|
||||
"src_id": 19,
|
||||
"state": 0,
|
||||
"tar_id": 19
|
||||
},
|
||||
"plate": {
|
||||
"base": 6,
|
||||
"cali2d_id": "",
|
||||
"cur_id": "P0102",
|
||||
"mat": 1,
|
||||
"tar_id": ""
|
||||
},
|
||||
"type": 1
|
||||
},
|
||||
"err": "0",
|
||||
"fail_reason": "0",
|
||||
"fan_gear": 5046271,
|
||||
"file": "/data/Metadata/plate_1.gcode",
|
||||
"force_upgrade": false,
|
||||
"fun": "10023FF18FFF9CB7",
|
||||
"fun2": "E",
|
||||
"gcode_file": "/data/Metadata/plate_1.gcode",
|
||||
"gcode_file_prepare_percent": "100",
|
||||
"gcode_state": "RUNNING",
|
||||
"heatbreak_fan_speed": "14",
|
||||
"hms": [
|
||||
{
|
||||
"attr": 83952640,
|
||||
"code": 196610
|
||||
},
|
||||
{
|
||||
"attr": 83952640,
|
||||
"code": 196612
|
||||
},
|
||||
{
|
||||
"attr": 83887616,
|
||||
"code": 131156
|
||||
}
|
||||
],
|
||||
"home_flag": -1066967745,
|
||||
"hw_switch_state": 1,
|
||||
"info": {
|
||||
"temp": 27
|
||||
},
|
||||
"ipcam": {
|
||||
"agora_service": "disable",
|
||||
"brtc_service": "enable",
|
||||
"bs_state": 0,
|
||||
"cap_pic_enable": "invalid",
|
||||
"ipcam_dev": "1",
|
||||
"ipcam_record": "enable",
|
||||
"laser_preview_res": 6,
|
||||
"mode_bits": 2,
|
||||
"resolution": "1080p",
|
||||
"rtsp_url": "rtsps://192.168.0.21:322/streaming/live/1",
|
||||
"timelapse": "enable",
|
||||
"tl_store_hpd_type": 2,
|
||||
"tl_store_path_type": 2,
|
||||
"tutk_server": "disable"
|
||||
},
|
||||
"job": {
|
||||
"cur_stage": {
|
||||
"idx": 0,
|
||||
"state": 2
|
||||
},
|
||||
"stage": [
|
||||
{
|
||||
"clock_in": false,
|
||||
"color": [
|
||||
"",
|
||||
""
|
||||
],
|
||||
"diameter": [
|
||||
0.4000000059604645,
|
||||
0.4000000059604645
|
||||
],
|
||||
"est_time": 0,
|
||||
"heigh": 0.0,
|
||||
"idx": 0,
|
||||
"platform": "",
|
||||
"print_then": false,
|
||||
"proc_list": [],
|
||||
"tool": [
|
||||
"HS01",
|
||||
"HS01"
|
||||
],
|
||||
"type": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"job_attr": 18,
|
||||
"job_id": "0",
|
||||
"lan_task_id": "0",
|
||||
"layer_num": 2,
|
||||
"lights_report": [
|
||||
{
|
||||
"mode": "on",
|
||||
"node": "chamber_light"
|
||||
},
|
||||
{
|
||||
"mode": "flashing",
|
||||
"node": "work_light"
|
||||
},
|
||||
{
|
||||
"mode": "on",
|
||||
"node": "chamber_light2"
|
||||
}
|
||||
],
|
||||
"mapping": [
|
||||
65280
|
||||
],
|
||||
"mc_action": 0,
|
||||
"mc_err": 0,
|
||||
"mc_percent": 13,
|
||||
"mc_print_error_code": "0",
|
||||
"mc_print_stage": "2",
|
||||
"mc_print_sub_stage": 0,
|
||||
"mc_remaining_time": 102,
|
||||
"mc_stage": 2,
|
||||
"model_id": "",
|
||||
"msg": 0,
|
||||
"net": {
|
||||
"conf": 16,
|
||||
"info": [
|
||||
{
|
||||
"ip": 352364736,
|
||||
"mask": 16777215
|
||||
},
|
||||
{
|
||||
"ip": 0,
|
||||
"mask": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"nozzle_diameter": "0.4",
|
||||
"nozzle_target_temper": 230.0,
|
||||
"nozzle_temper": 230.0,
|
||||
"nozzle_type": "HS01-0.4",
|
||||
"online": {
|
||||
"ahb": true,
|
||||
"ext": true,
|
||||
"version": 16
|
||||
},
|
||||
"percent": 13,
|
||||
"plate_cnt": 1,
|
||||
"plate_id": 1,
|
||||
"plate_idx": 1,
|
||||
"prepare_per": 100,
|
||||
"print_error": 0,
|
||||
"print_gcode_action": 0,
|
||||
"print_real_action": 0,
|
||||
"print_type": "local",
|
||||
"profile_id": "0",
|
||||
"project_id": "0",
|
||||
"queue": 0,
|
||||
"queue_est": 0,
|
||||
"queue_number": 0,
|
||||
"queue_sts": 0,
|
||||
"queue_total": 0,
|
||||
"remain_time": 102,
|
||||
"s_obj": [],
|
||||
"sdcard": true,
|
||||
"sequence_id": "2021",
|
||||
"spd_lvl": 2,
|
||||
"spd_mag": 100,
|
||||
"stat": "16782180F0",
|
||||
"state": 4,
|
||||
"stg": [
|
||||
64,
|
||||
29,
|
||||
13,
|
||||
74,
|
||||
72,
|
||||
4,
|
||||
54,
|
||||
39,
|
||||
8,
|
||||
14,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"stg_cur": 0,
|
||||
"subtask_id": "0",
|
||||
"subtask_name": "świeczka-24.stl",
|
||||
"task_id": "5101",
|
||||
"total_layer_num": 50,
|
||||
"upgrade_state": {
|
||||
"ahb_new_version_number": "",
|
||||
"ams_new_version_number": "",
|
||||
"consistency_request": false,
|
||||
"dis_state": 0,
|
||||
"err_code": 0,
|
||||
"ext_new_version_number": "",
|
||||
"force_upgrade": false,
|
||||
"idx": 16,
|
||||
"idx2": 1393374092,
|
||||
"lower_limit": "00.00.00.00",
|
||||
"message": "",
|
||||
"module": "",
|
||||
"new_version_state": 0,
|
||||
"ota_new_version_number": "",
|
||||
"progress": "0",
|
||||
"sequence_id": 0,
|
||||
"sn": "31B8BP5A1800585",
|
||||
"status": "IDLE",
|
||||
"upgrade_fail_list": [],
|
||||
"upgrade_type": "unknown"
|
||||
},
|
||||
"upload": {
|
||||
"file_size": 0,
|
||||
"finish_size": 0,
|
||||
"message": "Good",
|
||||
"oss_url": "",
|
||||
"progress": 0,
|
||||
"sequence_id": "0903",
|
||||
"speed": 0,
|
||||
"status": "idle",
|
||||
"task_id": "",
|
||||
"time_remaining": 0,
|
||||
"trouble_id": ""
|
||||
},
|
||||
"ver": "20000",
|
||||
"vir_slot": [
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"0ACC38FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "254",
|
||||
"nozzle_temp_max": "250",
|
||||
"nozzle_temp_min": "200",
|
||||
"remain": 0,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "0ACC38FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "GFU98",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "TPU-AMS",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
},
|
||||
{
|
||||
"bed_temp": "0",
|
||||
"bed_temp_type": "0",
|
||||
"cali_idx": -1,
|
||||
"cols": [
|
||||
"F95D73FF"
|
||||
],
|
||||
"ctype": 0,
|
||||
"drying_temp": "0",
|
||||
"drying_time": "0",
|
||||
"id": "255",
|
||||
"nozzle_temp_max": "240",
|
||||
"nozzle_temp_min": "230",
|
||||
"remain": 0,
|
||||
"tag_uid": "<scrubbed>",
|
||||
"total_len": 330000,
|
||||
"tray_color": "F95D73FF",
|
||||
"tray_diameter": "1.75",
|
||||
"tray_id_name": "",
|
||||
"tray_info_idx": "Pf3dbd0c",
|
||||
"tray_sub_brands": "",
|
||||
"tray_type": "TPU",
|
||||
"tray_uuid": "<scrubbed>",
|
||||
"tray_weight": "0",
|
||||
"xcam_info": "000000000000000000000000"
|
||||
}
|
||||
],
|
||||
"wifi_signal": "-66dBm",
|
||||
"xcam": {
|
||||
"allow_skip_parts": false,
|
||||
"buildplate_marker_detector": true,
|
||||
"cfg": 1797559,
|
||||
"first_layer_inspector": true,
|
||||
"halt_print_sensitivity": "medium",
|
||||
"print_halt": true,
|
||||
"printing_monitor": true,
|
||||
"spaghetti_detector": true
|
||||
},
|
||||
"xcam_status": "0"
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//! Does `PrintReport` actually parse what real printers really send?
|
||||
//!
|
||||
//! The fixtures in `tests/fixtures/` are verbatim `print.push_status`
|
||||
//! payloads captured off real hardware on 2026-10-03 via
|
||||
//! `cargo run --example live_reports` (hardware identifiers scrubbed):
|
||||
//!
|
||||
//! - `push_status_v1_p1p_idle.json` - a P1P on BambuMQTT v1, idle.
|
||||
//! - `push_status_v2_h2c_printing.json` - an H2C on BambuMQTT v2, 13% into
|
||||
//! a real job.
|
||||
//!
|
||||
//! These exist because the struct was originally built from a *truncated*
|
||||
//! example payload, and the gap between that and reality turned out to be
|
||||
//! the cause of two live misbehaviours (silently empty `print_status()`, and
|
||||
//! bogus "sequence gap" warnings). A fixture is the only way to keep that
|
||||
//! from regressing without a printer plugged in.
|
||||
|
||||
use continuum_proxy::printer::PrintReport;
|
||||
|
||||
fn load(name: &str) -> serde_json::Value {
|
||||
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/");
|
||||
let text = std::fs::read_to_string(format!("{path}{name}")).expect("fixture should exist");
|
||||
serde_json::from_str(&text).expect("fixture should be valid JSON")
|
||||
}
|
||||
|
||||
/// The failure mode that mattered: `handle_incoming_report` does
|
||||
/// `if let Ok(report) = serde_json::from_value::<PrintReport>(..)`, so a
|
||||
/// parse error doesn't just lose that one update - it's invisible. Assert on
|
||||
/// the error text, not just `is_ok()`, so a regression says *what* broke.
|
||||
fn assert_parses(name: &str) {
|
||||
let value = load(name);
|
||||
match serde_json::from_value::<PrintReport>(value) {
|
||||
Ok(_) => {}
|
||||
Err(err) => panic!("{name} failed to parse as PrintReport: {err}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_v1_idle_push_status() {
|
||||
assert_parses("push_status_v1_p1p_idle.json");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_v2_printing_push_status() {
|
||||
assert_parses("push_status_v2_h2c_printing.json");
|
||||
}
|
||||
|
||||
/// The whole point of consuming these at all: a print farm needs progress
|
||||
/// and temperatures. If the struct parses but drops these, it's no more
|
||||
/// useful than not parsing.
|
||||
#[test]
|
||||
fn v2_printing_report_carries_progress_and_temperatures() {
|
||||
let value = load("push_status_v2_h2c_printing.json");
|
||||
let report: PrintReport = serde_json::from_value(value).expect("should parse");
|
||||
|
||||
assert_eq!(report.gcode_state.as_deref(), Some("RUNNING"));
|
||||
assert_eq!(report.mc_percent, Some(13));
|
||||
assert_eq!(report.layer_num, Some(2));
|
||||
assert_eq!(report.total_layer_num, Some(50));
|
||||
assert_eq!(report.mc_remaining_time, Some(102));
|
||||
assert_eq!(report.nozzle_temper, Some(230.0));
|
||||
assert_eq!(report.subtask_name.as_deref(), Some("\u{15b}wieczka-24.stl"));
|
||||
}
|
||||
|
||||
/// An idle printer still has to produce a coherent report - just with
|
||||
/// nothing printing.
|
||||
#[test]
|
||||
fn v1_idle_report_reads_as_idle() {
|
||||
let value = load("push_status_v1_p1p_idle.json");
|
||||
let report: PrintReport = serde_json::from_value(value).expect("should parse");
|
||||
|
||||
assert_eq!(report.gcode_state.as_deref(), Some("IDLE"));
|
||||
assert_eq!(report.mc_percent, Some(0));
|
||||
}
|
||||
|
||||
/// v1 and v2 disagree about tray field names (`tray_temp`/`tray_time` vs
|
||||
/// `drying_temp`/`drying_time`) - this is the specific mismatch that made
|
||||
/// every v1 push carrying AMS data fail. Both spellings have to work.
|
||||
#[test]
|
||||
fn both_protocol_generations_parse_their_ams_trays() {
|
||||
for name in ["push_status_v1_p1p_idle.json", "push_status_v2_h2c_printing.json"] {
|
||||
let value = load(name);
|
||||
let report: PrintReport = serde_json::from_value(value).unwrap_or_else(|err| {
|
||||
panic!("{name}: {err}");
|
||||
});
|
||||
let ams = report.ams.expect("fixture should carry AMS state");
|
||||
assert!(!ams.ams.is_empty(), "{name}: expected at least one AMS unit");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user