From 0c67cdf07830fcc93173d48549afaef32ec9d65a Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Mon, 5 Jul 2021 23:54:15 -0400 Subject: [PATCH 1/5] macOS: PCAP: Fix typo --- platform/posix/pcap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/posix/pcap.cpp b/platform/posix/pcap.cpp index bdd4cee..969b57a 100644 --- a/platform/posix/pcap.cpp +++ b/platform/posix/pcap.cpp @@ -105,7 +105,7 @@ std::vector PCAP::FindAll() { #ifdef __linux__ // -1 is required for instant reporting of new packets -1, // to_ms #else // macOS gives BIOCSRTIMEOUT for -1 and no packets for 0 - 0, + 1, #endif errbuf); // TODO Handle warnings From 84c6b202c7918b32601b1d22d40038721a83e73b Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 6 Jul 2021 19:31:44 -0400 Subject: [PATCH 2/5] RAD-Star 2: Fix invalid serial numbers being reported --- include/icsneo/device/tree/radstar2/radstar2eth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/icsneo/device/tree/radstar2/radstar2eth.h b/include/icsneo/device/tree/radstar2/radstar2eth.h index dce6e12..5fed772 100644 --- a/include/icsneo/device/tree/radstar2/radstar2eth.h +++ b/include/icsneo/device/tree/radstar2/radstar2eth.h @@ -38,7 +38,7 @@ public: auto device = foundDev.device; device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0'; - found.push_back(std::make_shared(foundDev.device)); + found.push_back(std::make_shared(device)); break; } } From c7e72221409b3df0c3f8473bbf5ecd8f08d3757f Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 5 Aug 2021 15:07:02 -0700 Subject: [PATCH 3/5] Legacy: Ensure stddef.h is present for size_t Many compilers won't need this, but better to have it so it's correct. --- include/icsneo/icsneolegacy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/icsneo/icsneolegacy.h b/include/icsneo/icsneolegacy.h index 3988382..e71173d 100644 --- a/include/icsneo/icsneolegacy.h +++ b/include/icsneo/icsneolegacy.h @@ -5,6 +5,7 @@ #include "icsneo/platform/tchar.h" #include +#include typedef uint8_t byte; // Typedef helper for the following include #include "icsneo/icsnVC40.h" // Definitions for structs @@ -166,4 +167,4 @@ extern int LegacyDLLExport icsneoDisableBitSmash(void* hObject, unsigned int res } // extern "C" #endif -#endif \ No newline at end of file +#endif From 27184a203f200a4eb07c0b5cda73c0419abd263d Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 20 Aug 2021 10:36:55 -0400 Subject: [PATCH 4/5] Legacy: Use new layout for SDeviceSettings This fixes issues where the settings values would be shifted. --- api/icsneolegacy/icsneolegacy.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 75542d9..3d96e78 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -870,27 +870,33 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void *hObject, EPlasmaIonVnetCha return 1; } -int LegacyDLLExport icsneoSetDeviceSettings(void *hObject, SDeviceSettings *pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot) +int LegacyDLLExport icsneoSetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot) { if (!icsneoValidateHObject(hObject)) return false; - neodevice_t *device = (neodevice_t *)hObject; + neodevice_t* device = (neodevice_t*)hObject; + + const size_t offset = size_t(&pSettings->Settings) - size_t(pSettings); if (bSaveToEEPROM) - return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); - - return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); + return icsneo_settingsApplyStructure(device, &pSettings->Settings, iNumBytes - offset); + else + return icsneo_settingsApplyStructureTemporary(device, &pSettings->Settings, iNumBytes - offset); } -int LegacyDLLExport icsneoGetDeviceSettings(void *hObject, SDeviceSettings *pSettings, int iNumBytes, EPlasmaIonVnetChannel_t vnetSlot) +int LegacyDLLExport icsneoGetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, EPlasmaIonVnetChannel_t vnetSlot) { if (!icsneoValidateHObject(hObject)) return false; - neodevice_t *device = (neodevice_t *)hObject; + neodevice_t* device = (neodevice_t*)hObject; - return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes); + if (icsneoGetDeviceSettingsType(hObject, vnetSlot, &pSettings->DeviceSettingType) == 0) + return false; + + const size_t offset = size_t(&pSettings->Settings) - size_t(pSettings); + return !!icsneo_settingsReadStructure(device, &pSettings->Settings, iNumBytes - offset); } int LegacyDLLExport icsneoSetBitRateEx(void *hObject, unsigned long BitRate, int NetworkID, int iOptions) From 68715d515d382a8b02596718bc469c2f20cddf9a Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 22 Aug 2021 13:09:48 -0400 Subject: [PATCH 5/5] Decoder: Allow older ResetStatus packets without voltage or temperature --- communication/decoder.cpp | 9 ++++++--- .../icsneo/communication/message/resetstatusmessage.h | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/communication/decoder.cpp b/communication/decoder.cpp index 4cbe7b3..cc655e2 100644 --- a/communication/decoder.cpp +++ b/communication/decoder.cpp @@ -91,7 +91,8 @@ bool Decoder::decode(std::shared_ptr& result, const std::shared_ptrnetwork.getNetID()) { case Network::NetID::Reset_Status: { - if(packet->data.size() < sizeof(HardwareResetStatusPacket)) { + // We can deal with not having the last two fields (voltage and temperature) + if(packet->data.size() < (sizeof(HardwareResetStatusPacket) - (sizeof(uint16_t) * 2))) { report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error); return false; } @@ -101,8 +102,6 @@ bool Decoder::decode(std::shared_ptr& result, const std::shared_ptrnetwork = packet->network; msg->mainLoopTime = data->main_loop_time_25ns * 25; msg->maxMainLoopTime = data->max_main_loop_time_25ns * 25; - msg->busVoltage = data->busVoltage; - msg->deviceTemperature = data->deviceTemperature; msg->justReset = data->status.just_reset; msg->comEnabled = data->status.com_enabled; msg->cmRunning = data->status.cm_is_running; @@ -116,6 +115,10 @@ bool Decoder::decode(std::shared_ptr& result, const std::shared_ptrcmTooBig = data->status.cm_too_big; msg->hidUsbState = data->status.hidUsbState; msg->fpgaUsbState = data->status.fpgaUsbState; + if(packet->data.size() >= sizeof(HardwareResetStatusPacket)) { + msg->busVoltage = data->busVoltage; + msg->deviceTemperature = data->deviceTemperature; + } result = msg; return true; } diff --git a/include/icsneo/communication/message/resetstatusmessage.h b/include/icsneo/communication/message/resetstatusmessage.h index 2784cba..c83c848 100644 --- a/include/icsneo/communication/message/resetstatusmessage.h +++ b/include/icsneo/communication/message/resetstatusmessage.h @@ -5,6 +5,7 @@ #include "icsneo/communication/message/main51message.h" #include "icsneo/communication/command.h" +#include "icsneo/platform/optional.h" #include namespace icsneo { @@ -28,8 +29,8 @@ public: bool cmTooBig; bool hidUsbState; bool fpgaUsbState; - uint16_t busVoltage; - uint16_t deviceTemperature; + icsneo::optional busVoltage; + icsneo::optional deviceTemperature; }; }