优化消息代码

This commit is contained in:
zjk
2025-05-14 15:12:26 +08:00
parent 476be20025
commit 18f00d70d4
27 changed files with 245 additions and 88 deletions
-4
View File
@@ -800,13 +800,9 @@ vector<DriverCommand> Driver::loadDriverIdFromJson(const std::string &strJson) {
{"launchControler", 37}, {"sideSonar", 35}, {"buoyage", 56}
};
// 检查每个字段,如果存在且值发生变化,则添加到返回向量中
for (const auto& [field, id] : fieldToId) {
if (root.isMember(field)) {
unsigned char newValue = root[field].asUInt();
// unsigned char& currentValue = *((unsigned char*)&table + offsetof(DriverTable, depth1) +
// (fieldToId.at(field) - 18) * sizeof(unsigned char));
DriverCommand cmd;
cmd.id = id;
cmd.cmd = newValue;