Fix potential crash during calib

This commit is contained in:
Noisyfox
2025-06-02 19:18:11 +08:00
parent 57e5f5c4c4
commit aac6e2a3d0

View File

@@ -4481,10 +4481,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) { } else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) {
if (jj.contains("result") && jj.contains("reason")) { if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") { if (jj["result"].get<std::string>() == "fail") {
if (jj.contains("err_code")) {
auto err_code = jj["err_code"].get<int>(); auto err_code = jj["err_code"].get<int>();
print_error = err_code; print_error = err_code;
} }
} }
}
// BBS trigger ams UI update // BBS trigger ams UI update
@@ -4622,10 +4624,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} else if (jj["command"].get<std::string>() == "extrusion_cali_set") { } else if (jj["command"].get<std::string>() == "extrusion_cali_set") {
if (jj.contains("result") && jj.contains("reason")) { if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") { if (jj["result"].get<std::string>() == "fail") {
if (jj.contains("err_code")) {
auto err_code = jj["err_code"].get<int>(); auto err_code = jj["err_code"].get<int>();
print_error = err_code; print_error = err_code;
} }
} }
}
#ifdef CALI_DEBUG #ifdef CALI_DEBUG
std::string str = jj.dump(); std::string str = jj.dump();
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << str; BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << str;
@@ -4672,10 +4676,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
else if (jj["command"].get<std::string>() == "extrusion_cali_sel") { else if (jj["command"].get<std::string>() == "extrusion_cali_sel") {
if (jj.contains("result") && jj.contains("reason")) { if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") { if (jj["result"].get<std::string>() == "fail") {
if (jj.contains("err_code")) {
auto err_code = jj["err_code"].get<int>(); auto err_code = jj["err_code"].get<int>();
print_error = err_code; print_error = err_code;
} }
} }
}
#ifdef CALI_DEBUG #ifdef CALI_DEBUG
std::string str = jj.dump(); std::string str = jj.dump();