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:
@@ -0,0 +1,142 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file PIN.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file PIN.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "PIN.h"
|
||||
|
||||
#include "Logger.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus PIN_verifyInsertedPins(struct PIN* self);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void PIN_generateDefaultPIN(struct PIN* self)
|
||||
{
|
||||
self->firstDigit = 0;
|
||||
self->secondDigit = 1;
|
||||
self->thirdDigit = 2;
|
||||
self->fourthDigit = 3;
|
||||
}
|
||||
|
||||
|
||||
bool PIN_isOK(struct PIN* self, char* const pin)
|
||||
{
|
||||
bool returnValue = false;
|
||||
|
||||
if (pin[0] == self->firstDigit)
|
||||
{
|
||||
if (pin[1] == self->secondDigit)
|
||||
{
|
||||
if (pin[2] == self->thirdDigit)
|
||||
{
|
||||
if (pin[3] == self->fourthDigit)
|
||||
{
|
||||
returnValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void PIN_changePinFirstInsert(struct PIN* self, char* const firstPinInsert)
|
||||
{
|
||||
int loopCounter;
|
||||
if (firstPinInsert != NULL)
|
||||
{
|
||||
for (loopCounter = 0; loopCounter < PIN_NUMBER_OF_DIGITS; loopCounter++)
|
||||
{
|
||||
self->pinchangeFirstInsert[loopCounter] = firstPinInsert[loopCounter];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus PIN_changePinSecondInsert(struct PIN* self, char* const secondPinInsert)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
int loopCounter;
|
||||
if (secondPinInsert != NULL)
|
||||
{
|
||||
for (loopCounter = 0; loopCounter < PIN_NUMBER_OF_DIGITS; loopCounter++)
|
||||
{
|
||||
self->pinchangeSecondInsert[loopCounter] = secondPinInsert[loopCounter];
|
||||
}
|
||||
}
|
||||
|
||||
returnValue = PIN_verifyInsertedPins(self);
|
||||
// Verify both PINs
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
self->firstDigit = self->pinchangeFirstInsert[0];
|
||||
self->secondDigit = self->pinchangeFirstInsert[1];
|
||||
self->thirdDigit = self->pinchangeFirstInsert[2];
|
||||
self->fourthDigit = self->pinchangeFirstInsert[3];
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus PIN_verifyInsertedPins(struct PIN* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if(memcmp(self->pinchangeFirstInsert, self->pinchangeSecondInsert, PIN_NUMBER_OF_DIGITS != 0))
|
||||
{
|
||||
// Inserted PINs are not equal
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
Reference in New Issue
Block a user