capabilities: report device frame size so the client can adapt

PM3_CMD_DATA_SIZE went 512 -> 624 without a capabilities bump, so a new
client connects to old firmware and every oversized command dies at the
device's length check with no message.

Append max_cmd_data_size, bump to v9. The client now accepts an older
capabilities struct - it only ever grows by appending, so an older layout
is a prefix - and defaults the frame size for pre-v9 firmware.
SendCommandNG bounds by the device value instead of the compile time one.

Also zero init capabilities_t on the device, it leaked stack bytes.
This commit is contained in:
iceman1001 committed 2026-08-30 20:13:38 +02:00
1 parent 6d2c35b05b
commit 9e2092fc66
4 files changed
+60 -8

No files matched your search

+8 -1
View File
@@ -261,8 +261,15 @@ typedef struct {
bool hw_available_i2c_eeprom : 1;
bool is_pm5 : 1;
bool is_pm5_std_ant : 1;
// Appended in version 9. Fields must only ever be APPENDED here:
// the client accepts a shorter struct from older firmware
// PM5 can use this to inform which size they support oo.
uint16_t max_cmd_data_size; // device side PM3_CMD_DATA_SIZE
} PACKED capabilities_t;
#define CAPABILITIES_VERSION 8
#define CAPABILITIES_VERSION 9
// what a pre-v9 device would have used, it could not tell us
#define CAPABILITIES_LEGACY_CMD_DATA_SIZE 512
extern capabilities_t g_pm3_capabilities;
typedef struct {