Merge branch 'master' into v0.3.0-dev

v0.3.0-dev
Paul Hollinsky 2021-08-22 13:15:54 -04:00
commit 5f44986c1b
4 changed files with 25 additions and 14 deletions

View File

@ -877,10 +877,12 @@ int LegacyDLLExport icsneoSetDeviceSettings(void *hObject, SDeviceSettings *pSet
neodevice_t* device = (neodevice_t*)hObject; neodevice_t* device = (neodevice_t*)hObject;
if (bSaveToEEPROM) const size_t offset = size_t(&pSettings->Settings) - size_t(pSettings);
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); if (bSaveToEEPROM)
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)
@ -890,7 +892,11 @@ int LegacyDLLExport icsneoGetDeviceSettings(void *hObject, SDeviceSettings *pSet
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) int LegacyDLLExport icsneoSetBitRateEx(void *hObject, unsigned long BitRate, int NetworkID, int iOptions)

View File

@ -115,7 +115,8 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
case Network::Type::Internal: { case Network::Type::Internal: {
switch(packet->network.getNetID()) { switch(packet->network.getNetID()) {
case Network::NetID::Reset_Status: { 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); report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
return false; return false;
} }
@ -124,8 +125,6 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
auto msg = std::make_shared<ResetStatusMessage>(); auto msg = std::make_shared<ResetStatusMessage>();
msg->mainLoopTime = data->main_loop_time_25ns * 25; msg->mainLoopTime = data->main_loop_time_25ns * 25;
msg->maxMainLoopTime = data->max_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->justReset = data->status.just_reset;
msg->comEnabled = data->status.com_enabled; msg->comEnabled = data->status.com_enabled;
msg->cmRunning = data->status.cm_is_running; msg->cmRunning = data->status.cm_is_running;
@ -139,6 +138,10 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
msg->cmTooBig = data->status.cm_too_big; msg->cmTooBig = data->status.cm_too_big;
msg->hidUsbState = data->status.hidUsbState; msg->hidUsbState = data->status.hidUsbState;
msg->fpgaUsbState = data->status.fpgaUsbState; msg->fpgaUsbState = data->status.fpgaUsbState;
if(packet->data.size() >= sizeof(HardwareResetStatusPacket)) {
msg->busVoltage = data->busVoltage;
msg->deviceTemperature = data->deviceTemperature;
}
result = msg; result = msg;
return true; return true;
} }

View File

@ -5,6 +5,7 @@
#include "icsneo/communication/message/main51message.h" #include "icsneo/communication/message/main51message.h"
#include "icsneo/communication/command.h" #include "icsneo/communication/command.h"
#include "icsneo/platform/optional.h"
#include <string> #include <string>
namespace icsneo { namespace icsneo {
@ -28,8 +29,8 @@ public:
bool cmTooBig; bool cmTooBig;
bool hidUsbState; bool hidUsbState;
bool fpgaUsbState; bool fpgaUsbState;
uint16_t busVoltage; icsneo::optional<uint16_t> busVoltage;
uint16_t deviceTemperature; icsneo::optional<uint16_t> deviceTemperature;
}; };
} }

View File

@ -5,6 +5,7 @@
#include "icsneo/platform/tchar.h" #include "icsneo/platform/tchar.h"
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
typedef uint8_t byte; // Typedef helper for the following include typedef uint8_t byte; // Typedef helper for the following include
#include "icsneo/icsnVC40.h" // Definitions for structs #include "icsneo/icsnVC40.h" // Definitions for structs