Fixed multiple bugs and errors.
- Added WARNING handler - put voltage calculations to dedicated module fixed last errors. Updated menu repair screen without ERROR from PID This is version 0.9.0.3, which is used for the first duration test Will also be tagged git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@272 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
#include "Error.h"
|
||||
#include "RepairPresets.h"
|
||||
|
||||
#include "CachedStorage.h"
|
||||
@@ -72,7 +73,7 @@ struct RepairPresets* const self = &_self;
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus RepairPresets_verifyCRCs(void);
|
||||
static void RepairPresets_verifyCRCs(void);
|
||||
static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass* repairPreset);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -193,7 +194,7 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID)
|
||||
// Check the CRC on the loaded presets
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = RepairPresets_verifyCRCs();
|
||||
RepairPresets_verifyCRCs();
|
||||
}
|
||||
|
||||
// CRCs are verified
|
||||
@@ -225,7 +226,7 @@ struct RepairPreset* RepairPresets_getPreset(unsigned int index)
|
||||
if ((index > 0) || (index <= REPAIR_PRESETS_NUMBER_OF_PRESETS))
|
||||
{
|
||||
struct RepairPresetStorageClass* tempPreset;
|
||||
tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4);
|
||||
tempPreset = (struct RepairPresetStorageClass*)CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4);
|
||||
returnValue = (struct RepairPreset*)&tempPreset->preset;
|
||||
}
|
||||
}
|
||||
@@ -241,7 +242,7 @@ void RepairPresets_savePresets(void)
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus RepairPresets_verifyCRCs(void)
|
||||
static void RepairPresets_verifyCRCs(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (self->initialized)
|
||||
@@ -249,15 +250,17 @@ static ErrorStatus RepairPresets_verifyCRCs(void)
|
||||
int loopCounter;
|
||||
struct RepairPresetStorageClass _tempPresetStorage;
|
||||
struct RepairPresetStorageClass* tempPresetStorage = &_tempPresetStorage;
|
||||
bool crcErrorFound = false;
|
||||
for (loopCounter = 0; loopCounter < REPAIR_PRESETS_NUMBER_OF_PRESETS; loopCounter++)
|
||||
{
|
||||
// Load next preset from cache
|
||||
tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4);
|
||||
tempPresetStorage = (struct RepairPresetStorageClass*)CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4);
|
||||
// Verify CRC
|
||||
returnValue = RepairPresets_verifyPresetCRC(tempPresetStorage);
|
||||
// Check CRC verification
|
||||
if (returnValue != SUCCESS)
|
||||
{
|
||||
crcErrorFound = true;
|
||||
// CRC was not correct - replace corrupted preset with a DEFAULT preset
|
||||
RepairPreset_generateDefaultPreset(&tempPresetStorage->preset, loopCounter + 1);
|
||||
LOGGER_DEBUG(mainLog, "PRESET %d: Softstart: %d, Duration: %d, Voltage: %d", tempPresetStorage->preset.presetNumber, tempPresetStorage->preset.preset[0].softstartDuration, tempPresetStorage->preset.preset[0].duration, tempPresetStorage->preset.preset[0].voltage);
|
||||
@@ -265,14 +268,13 @@ static ErrorStatus RepairPresets_verifyCRCs(void)
|
||||
RepairPresets_writePreset(&tempPresetStorage->preset);
|
||||
}
|
||||
}
|
||||
if (crcErrorFound)
|
||||
{
|
||||
Error_postError(ERROR_CRC_PRESETS);
|
||||
}
|
||||
// Commit cache to memory - will not write if no changes have been made
|
||||
CachedStorage_commit(self->presetStorage);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user