Fixed relay test
Added basic keypad test Added tesla interlock git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@246 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -63,6 +63,8 @@ struct HwValidationMenuItems
|
||||
struct Gpio* power6v5Enable;
|
||||
struct Gpio* interlock1;
|
||||
struct Gpio* interlock2;
|
||||
struct Gpio* tesla1;
|
||||
struct Gpio* tesla2;
|
||||
struct Gpio* solenoid;
|
||||
struct Gpio* mcp0Relay;
|
||||
struct Gpio* mcp1Relay;
|
||||
@@ -72,6 +74,7 @@ struct HwValidationMenuItems
|
||||
struct Gpio* cat2Relay;
|
||||
struct Gpio* teslaLock;
|
||||
struct Pcba* pcba;
|
||||
struct Keypad *keypad;
|
||||
// struct Eeprom* eeprom; // Not implemented yet
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "nhd0420.h"
|
||||
|
||||
#include "Logger.h"
|
||||
#include "keypadMatrix.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
@@ -246,7 +248,7 @@ static const char conTestInterlock[] =
|
||||
" Test the interlock [1-2] \r\n"
|
||||
" \r\n"
|
||||
" [%c] Read Interlock 1 \r\n"
|
||||
" [%c] Read Interlock 2 \r\n"
|
||||
" [%c] Read Interlock 2 (Tesla only) \r\n"
|
||||
" [%c] Back \r\n"
|
||||
" \r\n";
|
||||
|
||||
@@ -263,7 +265,7 @@ static const char conTestSolenoid[] =
|
||||
ANSI_TERMINAL_HOME
|
||||
" TEST Solenoid \r\n"
|
||||
" \r\n"
|
||||
" Test the interlock [1-2] \r\n"
|
||||
" Test the solenoid [1-2] \r\n"
|
||||
" \r\n"
|
||||
" [%c] Toggle Solenoid \r\n"
|
||||
" [%c] Back \r\n"
|
||||
@@ -875,11 +877,14 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
|
||||
}
|
||||
else if( button == BUTTON_ENTER )
|
||||
{
|
||||
bool value = false;
|
||||
bool value1 = false;
|
||||
bool value2 = false;
|
||||
if( self->menuItemSelected == MENU_TEST_INTERLOCK_1)
|
||||
{
|
||||
if( GPIO_getValue(self->testItems->interlock1, &value) == SUCCESS ){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock: %d\r\n", value);
|
||||
if( GPIO_getValue(self->testItems->interlock1, &value1) == SUCCESS &&
|
||||
GPIO_getValue(self->testItems->interlock2, &value2) == SUCCESS
|
||||
){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock: NO: %d - NC: %d\r\n", value1, value2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -889,13 +894,24 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
|
||||
}
|
||||
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_2 )
|
||||
{
|
||||
if( GPIO_getValue(self->testItems->interlock2, &value) == SUCCESS ){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock: %d\r\n", value);
|
||||
|
||||
if(pcba->pcba == Tesla)
|
||||
{
|
||||
|
||||
if( GPIO_getValue(self->testItems->tesla1, &value1) == SUCCESS &&
|
||||
GPIO_getValue(self->testItems->tesla2, &value2) == SUCCESS
|
||||
){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock (tesla): NO: %d - NC: %d\r\n", value1, value2);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock: Failure\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Interlock: Only available on Tesla PCBA\r\n");
|
||||
}
|
||||
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
|
||||
}
|
||||
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_BACK )
|
||||
@@ -932,11 +948,11 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
|
||||
bool value = false;
|
||||
if( self->menuItemSelected == MENU_TEST_SOLENOID_TOGGLE)
|
||||
{
|
||||
if( GPIO_getValue(self->testItems->interlock1, &value) == SUCCESS)
|
||||
if( GPIO_getValue(self->testItems->solenoid, &value) == SUCCESS)
|
||||
{
|
||||
// Invert current value
|
||||
value = !value;
|
||||
if( GPIO_setValue(self->testItems->interlock1, value) == SUCCESS)
|
||||
if( GPIO_setValue(self->testItems->solenoid, value) == SUCCESS)
|
||||
{
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Solenoid: Toggled\r\n");
|
||||
}
|
||||
@@ -1010,7 +1026,7 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
|
||||
break;
|
||||
|
||||
case MENU_TEST_RELAYS_TOGGLE_6:
|
||||
relay = self->testItems->cat1Relay;
|
||||
relay = self->testItems->cat2Relay;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1090,7 +1106,56 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
|
||||
{
|
||||
if( self->menuItemSelected == MENU_TEST_GENERIC_KEYPAD)
|
||||
{
|
||||
outputBufferLength = sprintf(self->outputBuffer, "[TODO] KEYPAD TEST\r\n");
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
char data[CMD_BUFFER_SIZE] = {0};
|
||||
size_t actual_length = 0;
|
||||
|
||||
size_t actualLength;
|
||||
char buffer[sizeof(struct KeypadQueueItem) / sizeof(char)];
|
||||
ErrorStatus returnValueKeypad = SUCCESS;
|
||||
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Keypad test started. Press Esc to stop this test.\r\n");
|
||||
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
IODevice_read(self->ioDevice, data, 1, &actual_length);
|
||||
// Check if ESC has been pressed
|
||||
if(actual_length == 1 && data[0] == 0x1B)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(self->testItems->keypad == NULL){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Keypad not initialized\r\n");
|
||||
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
|
||||
break;
|
||||
}
|
||||
|
||||
returnValueKeypad = IODevice_read(&self->testItems->keypad->device, buffer, sizeof(struct KeypadQueueItem) / sizeof(char), &actualLength);
|
||||
|
||||
if (returnValueKeypad == SUCCESS)
|
||||
{
|
||||
struct KeypadQueueItem* rxQueueItem = (struct KeypadQueueItem*)buffer;
|
||||
|
||||
keyState = rxQueueItem->keyEvent;
|
||||
|
||||
if(keyState == RELEASED){
|
||||
outputBufferLength = sprintf(self->outputBuffer, "KEYPAD: Pressed %d-%d\r\n", rxQueueItem->rowCoordinate, rxQueueItem->columnCoordinate);
|
||||
} else {
|
||||
outputBufferLength = sprintf(self->outputBuffer, "KEYPAD: Released %d-%d\r\n", rxQueueItem->rowCoordinate, rxQueueItem->columnCoordinate);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
outputBufferLength = sprintf(self->outputBuffer, "KEYPAD: Read error\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outputBufferLength = sprintf(self->outputBuffer, "Keypad test exited\r\n");
|
||||
IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
|
||||
}
|
||||
else if( self->menuItemSelected == MENU_TEST_GENERIC_EEPROM)
|
||||
@@ -1352,7 +1417,7 @@ static void hwValidationMenuDisplay(struct HwValidationMenu* self, Display_State
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self, uint8_t * pData, uint16_t numBytes )
|
||||
static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self, uint8_t * pData, uint16_t numBytes)
|
||||
{
|
||||
|
||||
size_t actual_length = 0;
|
||||
|
||||
Reference in New Issue
Block a user