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:
swo
2017-10-10 14:02:32 +00:00
parent a688a6549a
commit a8dceb88a0
2 changed files with 83 additions and 15 deletions

View File

@@ -63,6 +63,8 @@ struct HwValidationMenuItems
struct Gpio* power6v5Enable; struct Gpio* power6v5Enable;
struct Gpio* interlock1; struct Gpio* interlock1;
struct Gpio* interlock2; struct Gpio* interlock2;
struct Gpio* tesla1;
struct Gpio* tesla2;
struct Gpio* solenoid; struct Gpio* solenoid;
struct Gpio* mcp0Relay; struct Gpio* mcp0Relay;
struct Gpio* mcp1Relay; struct Gpio* mcp1Relay;
@@ -72,6 +74,7 @@ struct HwValidationMenuItems
struct Gpio* cat2Relay; struct Gpio* cat2Relay;
struct Gpio* teslaLock; struct Gpio* teslaLock;
struct Pcba* pcba; struct Pcba* pcba;
struct Keypad *keypad;
// struct Eeprom* eeprom; // Not implemented yet // struct Eeprom* eeprom; // Not implemented yet
}; };

View File

@@ -35,6 +35,8 @@
#include "nhd0420.h" #include "nhd0420.h"
#include "Logger.h" #include "Logger.h"
#include "keypadMatrix.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Constant and macro definitions // Constant and macro definitions
@@ -246,7 +248,7 @@ static const char conTestInterlock[] =
" Test the interlock [1-2] \r\n" " Test the interlock [1-2] \r\n"
" \r\n" " \r\n"
" [%c] Read Interlock 1 \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" " [%c] Back \r\n"
" \r\n"; " \r\n";
@@ -263,7 +265,7 @@ static const char conTestSolenoid[] =
ANSI_TERMINAL_HOME ANSI_TERMINAL_HOME
" TEST Solenoid \r\n" " TEST Solenoid \r\n"
" \r\n" " \r\n"
" Test the interlock [1-2] \r\n" " Test the solenoid [1-2] \r\n"
" \r\n" " \r\n"
" [%c] Toggle Solenoid \r\n" " [%c] Toggle Solenoid \r\n"
" [%c] Back \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 ) else if( button == BUTTON_ENTER )
{ {
bool value = false; bool value1 = false;
bool value2 = false;
if( self->menuItemSelected == MENU_TEST_INTERLOCK_1) if( self->menuItemSelected == MENU_TEST_INTERLOCK_1)
{ {
if( GPIO_getValue(self->testItems->interlock1, &value) == SUCCESS ){ if( GPIO_getValue(self->testItems->interlock1, &value1) == SUCCESS &&
outputBufferLength = sprintf(self->outputBuffer, "Interlock: %d\r\n", value); GPIO_getValue(self->testItems->interlock2, &value2) == SUCCESS
){
outputBufferLength = sprintf(self->outputBuffer, "Interlock: NO: %d - NC: %d\r\n", value1, value2);
} }
else else
{ {
@@ -889,13 +894,24 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
} }
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_2 ) 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 else
{ {
outputBufferLength = sprintf(self->outputBuffer, "Interlock: Failure\r\n"); 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); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if (self->menuItemSelected == MENU_TEST_INTERLOCK_BACK ) 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; bool value = false;
if( self->menuItemSelected == MENU_TEST_SOLENOID_TOGGLE) 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 // Invert current value
value = !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"); outputBufferLength = sprintf(self->outputBuffer, "Solenoid: Toggled\r\n");
} }
@@ -1010,7 +1026,7 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
break; break;
case MENU_TEST_RELAYS_TOGGLE_6: case MENU_TEST_RELAYS_TOGGLE_6:
relay = self->testItems->cat1Relay; relay = self->testItems->cat2Relay;
break; break;
default: default:
@@ -1090,7 +1106,56 @@ static void hwValidationMenuSM(struct HwValidationMenu* self, Button_Pressed_t b
{ {
if( self->menuItemSelected == MENU_TEST_GENERIC_KEYPAD) 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); IODevice_write(self->ioDevice, self->outputBuffer, outputBufferLength);
} }
else if( self->menuItemSelected == MENU_TEST_GENERIC_EEPROM) else if( self->menuItemSelected == MENU_TEST_GENERIC_EEPROM)