From a2020632874cf997bae70ea8e8ab3a6553880def Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 8 Jan 2019 17:42:17 -0600 Subject: [PATCH] Truncate the config packet for firmware that doesn't need all of it. --- sdk/Windows/SMXDevice.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sdk/Windows/SMXDevice.cpp b/sdk/Windows/SMXDevice.cpp index c4ebf6a..990d5a5 100644 --- a/sdk/Windows/SMXDevice.cpp +++ b/sdk/Windows/SMXDevice.cpp @@ -313,6 +313,15 @@ void SMX::SMXDevice::SendConfig() // Write configuration command: string sData = ssprintf("w"); int8_t iSize = sizeof(SMXConfig); + + // Firmware through version 3 allowed config packets up to 128 bytes. Additions + // to the packet later on brought it up to 126, so the maximum was raised to 250. + // Older firmware won't use the extra fields, but will ignore the packet if it's + // larger than it supports, so just truncate the packet for these devices to make + // sure this doesn't happen. + if(config.masterVersion <= 3) + iSize = min(iSize, offsetof(SMXConfig, flags)); + sData.append((char *) &iSize, sizeof(iSize)); sData.append((char *) &wanted_config, sizeof(wanted_config));