Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r234c2cedfa38520fa523a29156de993e9ace9a79 -r863a9c650d97fbf75d56c60b907b9117d033ca94 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 234c2cedfa38520fa523a29156de993e9ace9a79) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 863a9c650d97fbf75d56c60b907b9117d033ca94) @@ -62,9 +62,13 @@ #define DATA_PUBLISH_COUNTER_START_COUNT 60 ///< Data publish counter start count. // Calibration mode defines -#define BLOOD_LEAK_EMB_MODE_CTRL_S_ASCII 19 ///< Blood leak embedded mode start command, ^S in ascii. -#define BLOOD_LEAK_CAL_COMMAND_SEQ_LENGTH 4 ///< Blood leak calibration state command length. +#define BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH 4 ///< Blood leak embedded mode command sequence length. #define BLOOD_LEAK_EMB_MODE_STOP_INDEX 1 ///< Blood leak embedded mode stop writing to FIFO index. +#define BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_HIGH 5 ///< Blood leak embedded mode communication active high command. +#define BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW 4 ///< Blood leak embedded mode communication active low command. +#define BLOOD_LEAK_EMB_MODE_RX_TIMEOUT_MS ( 5 * MS_PER_SECOND ) ///< Blood leak embedded mode calibration receive timeout in milliseconds. +#define BLOOD_LEAK_EMB_MODE_RX_BUFFER_EMPTY 0x80 ///< Blood leak embedded mode buffer empty value. +#define BLOOD_LEAK_EMB_MODE_RESP_BUFFER_LEN 5 ///< Blood leak embedded mode number of commands. /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates @@ -82,14 +86,58 @@ NUM_OF_BLOOD_LEAK_STATES ///< Number of blood leak detector states. } BLOOD_LEAK_STATE_T; -typedef enum CalibrationStates +/// Defined embedded states +typedef enum EmbStates { BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE = 0, ///< Blood leak calibration state wait for command state. BLOOD_LEAK_CAL_SEND_COMMAND_STATE, ///< Blood leak calibration state send command state. + BLOOD_LEAK_EMB_WAIT_FOR_COMMAND_TO_SETTLE_STATE, BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE, ///< Blood leak calibration state wait for command response state. NUM_CAL_STATES ///< Number of blood leak calibration states. -} BLOOD_LEAK_CAL_STATE_T; +} BLOOD_LEAK_EMB_MODE_STATE_T; +/// Defined embedded commands +/*typedef enum EmbCommands +{ + NU = 0, ///< Null command. + CS = 19, ///< Control S command to switch to embedded mode. + SP = 83, ///< Set point command to set the set point. + T = 84, ///< Self test command. + G = 71, ///< Get self test command. + I = 73, ///< Intensity command. + V = 86, ///< Blood detection level command. + Z = 90, ///< Zero sensor command. + Q = 81, ///< Zero sensor confirm command. + D = 68, ///< Display blood detection command. + C = 67, ///< Calibration sensor command. + NUM_OF_EMB_CMDS, ///< Number of embedded mode commands. +} EMB_MODE_CMD_T;*/ + +enum EmbCommands +{ + NU = 0, ///< Null command. + CS, ///< Control S command to switch to embedded mode. + SP, ///< Set point command to set the set point. + T, ///< Self test command. + G, ///< Get self test command. + I, ///< Intensity command. + V, ///< Blood detection level command. + Z, ///< Zero sensor command. + Q, ///< Zero sensor confirm command. + D, ///< Display blood detection command. + C, ///< Calibration sensor command. + NUM_OF_EMB_CMDS, ///< Number of embedded mode commands. +}; + +/// Embedded mode commands specifications +typedef struct +{ + U08 commandASCII; + U08 expChar1; + U08 expChar2; + U08 length; +} EMB_MODE_CMD_T; + // ********** private data ********** static BLOOD_LEAK_STATE_T bloodLeakState; ///< Current state of blood leak state machine. @@ -123,11 +171,15 @@ BLOOD_LEAK_UART_COMM_ACTIVE_HIGH, BLOOD_LEAK_UART_COMM_ACTIVE_LOW }; // Embedded mode variables -static BOOL bloodLeakSignalEmbeddedModeReq; ///< Blood leak signal embedded mode has been requested. -static U08 bloodLeakCalASCIIChar; ///< Blood leak signal calibration command. -static U08 bloodLeakCalCommandSquence[ BLOOD_LEAK_CAL_COMMAND_SEQ_LENGTH ]; ///< Blood leak calibration command sequence. -static BLOOD_LEAK_CAL_STATE_T bloodLeakCalSubstate; ///< Blood leak calibration substate. -static U16 bloodLeakCalSetPoint; ///< Blood leak calibration set point command. +static BOOL bloodLeakSignalEmbModeReq; ///< Blood leak signal embedded mode has been requested. +static U08 bloodLeakEmbModeRqstedCmd; ///< Blood leak signal embedded mode requested command. +static U08 bloodLeakEmbModeCmdSquence[ BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH ]; ///< Blood leak embedded mode command sequence. +static BLOOD_LEAK_EMB_MODE_STATE_T bloodLeakEmbModeSubstate; ///< Blood leak embedded mode state. +static U32 bloodLeakEmbModeOpsStartTime; ///< Blood leak embedded mode operations start time. +static U16 bloodLeakEmbModeSetPoint; ///< Blood leak embedded mode set point command. +static EMB_MODE_CMD_T bloodLeakEmbModeCmd [ NUM_OF_EMB_CMDS ]; ///< Blood leak embedded mode commands. +static U08 bloodLeakEmbModeRespBuffer[ BLOOD_LEAK_EMB_MODE_RESP_BUFFER_LEN ]; ///< Blood leak embedded mode response buffer. +static U32 bloodLeakEmbModeRespIndex; ///< Blood leak embedded mode response buffer index. // ********** private function prototypes ********** @@ -142,12 +194,14 @@ static BLOOD_LEAK_STATE_T handleBloodLeakNormalState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakCalibrationState( void ); -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakWaitForCommandState( void ); -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakSendCommandState( void ); -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakWaitForCommandResponseState( void ); +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandState( void ); +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakSendCommandState( void ); +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandToSettleState( void ); +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandResponseState( void ); static void prepareSetPointSeq( U16 setPoint ); static void publishBloodLeakData( void ); +static void initEmbModeSpecs( void ); /*********************************************************************//** * @brief @@ -157,9 +211,10 @@ * bloodLeakZeroRequested, bloodLeakZeroRequested, bloodLeakSelfTestStartTime, * bloodLeakUARTCmdIndex, bloodLeakSetPointSequence, bloodLeakPrevFPGARegisterCount * bloodLeakWait2ReadResponseCounter, bloodLeakDataPublicationTimerCounter, - * bloodLeakCommandWriteTryCount, bloodLeakGetCalStartTime, bloodLeakCalSubstate - * bloodLeakIsPOSTComplete, bloodLeakPersistenceCtr, bloodLeakSignalEmbeddedModeReq, - * bloodLeakCalASCIIChar + * bloodLeakCommandWriteTryCount, bloodLeakGetCalStartTime, bloodLeakEmbModeSubstate + * bloodLeakIsPOSTComplete, bloodLeakPersistenceCtr, bloodLeakSignalEmbModeReq, + * bloodLeakEmbModeRqstedCmd, bloodLeakEmbModeOpsStartTime, bloodLeakEmbModeRespBuffer, + * bloodLeakEmbModeRespIndex * @return none *************************************************************************/ void initBloodLeak( void ) @@ -182,20 +237,28 @@ bloodLeakIsPOSTComplete = FALSE; bloodLeakPrevFPGARegisterCount = 0; bloodLeakPersistenceCtr = 0; - bloodLeakSignalEmbeddedModeReq = FALSE; - bloodLeakCalASCIIChar = 0; - bloodLeakCalSubstate = BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE; + bloodLeakSignalEmbModeReq = FALSE; + bloodLeakEmbModeRqstedCmd = NU; + bloodLeakEmbModeSubstate = BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE; + bloodLeakEmbModeOpsStartTime = 0; + bloodLeakEmbModeRespIndex = 0; // Set the blood leak set pint sequence to 0 to be initialized memset( bloodLeakSetPointSequence, 0x0, BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ); + // Initialize the blood leak embedded mode response buffer + memset( bloodLeakEmbModeRespBuffer, 0x0, BLOOD_LEAK_EMB_MODE_RESP_BUFFER_LEN ); + // Initialize the blood leak calibration command sequence array. // The first index is the command character so it can be changed upon request. // The reset of the commands are never changing. - bloodLeakCalCommandSquence[ 0 ] = 0; - bloodLeakCalCommandSquence[ 1 ] = BLOOD_LEAK_STOP_WRITE_FIFO_COMMAND; - bloodLeakCalCommandSquence[ 2 ] = BLOOD_LEAK_UART_COMM_ACTIVE_HIGH; - bloodLeakCalCommandSquence[ 3 ] = BLOOD_LEAK_UART_COMM_ACTIVE_LOW; + bloodLeakEmbModeCmdSquence[ 0 ] = 0; + bloodLeakEmbModeCmdSquence[ 1 ] = BLOOD_LEAK_STOP_WRITE_FIFO_COMMAND; + bloodLeakEmbModeCmdSquence[ 2 ] = BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_HIGH; + bloodLeakEmbModeCmdSquence[ 3 ] = BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW; + + // Initialize the embedded mode specifications + initEmbModeSpecs(); } /*********************************************************************//** @@ -228,7 +291,7 @@ // If a request to transition to embedded mode has been made, change the state to calibration state, and request a transition to service mode. // This type of work can only be done in the service mode and then the user has to restart the device to return to the normal operations of BLD. - if ( TRUE == bloodLeakSignalEmbeddedModeReq ) + if ( TRUE == bloodLeakSignalEmbModeReq ) { bloodLeakState = BLOOD_LEAK_CALIBRATION_STATE; @@ -709,18 +772,22 @@ { BLOOD_LEAK_STATE_T state = BLOOD_LEAK_CALIBRATION_STATE; - switch ( bloodLeakCalSubstate ) + switch ( bloodLeakEmbModeSubstate ) { case BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE: - bloodLeakCalSubstate = handleCalBloodLeakWaitForCommandState(); + bloodLeakEmbModeSubstate = handleCalBloodLeakWaitForCommandState(); break; case BLOOD_LEAK_CAL_SEND_COMMAND_STATE: - bloodLeakCalSubstate = handleCalBloodLeakSendCommandState(); + bloodLeakEmbModeSubstate = handleCalBloodLeakSendCommandState(); break; + case BLOOD_LEAK_EMB_WAIT_FOR_COMMAND_TO_SETTLE_STATE: + bloodLeakEmbModeSubstate = handleCalBloodLeakWaitForCommandToSettleState(); + break; + case BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE: - bloodLeakCalSubstate = handleCalBloodLeakWaitForCommandResponseState(); + bloodLeakEmbModeSubstate = handleCalBloodLeakWaitForCommandResponseState(); break; } @@ -776,23 +843,37 @@ * @details Outputs: bloodLeakCalCommandSquence, bloodLeakUARTCmdIndex * @return next state *************************************************************************/ -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakWaitForCommandState( void ) +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandState( void ) { - BLOOD_LEAK_CAL_STATE_T state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; + BLOOD_LEAK_EMB_MODE_STATE_T state = BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE; - // Check if the requested command is set point, so if the character is S (for set point) - // then prepare the set point buffer to be sent - if ( bloodLeakCalASCIIChar == BLOOD_LEAK_SET_POINT_START_CHAR_ASCII ) + switch( bloodLeakEmbModeRqstedCmd ) { - prepareSetPointSeq( bloodLeakCalSetPoint ); + case NU: + // Null command do nothing + break; + + case CS: + case T: + case G: + case I: + case V: + case Z: + case Q: + case D: + case C: + // The requested command is not set point and so update the command sequence buffer. + // The first index of calibration command sequence is the requested command in ASCII. + bloodLeakEmbModeCmdSquence[ 0 ] = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].commandASCII; + bloodLeakUARTCmdIndex = 0; + state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; + break; + + case SP: + prepareSetPointSeq( bloodLeakEmbModeSetPoint ); + state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; + break; } - else - { - // The requested command is not set point and so update the command sequence buffer. - // The first index of calibration command sequence is the requested command in ASCII. - bloodLeakCalCommandSquence[ 0 ] = bloodLeakCalASCIIChar; - bloodLeakUARTCmdIndex = 0; - } return state; } @@ -806,75 +887,154 @@ * @details Outputs: bloodLeakCalCommandSquence, bloodLeakUARTCmdIndex * @return next state *************************************************************************/ -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakSendCommandState( void ) +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakSendCommandState( void ) { - BLOOD_LEAK_CAL_STATE_T state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; + U32 command; - if ( bloodLeakCalASCIIChar == BLOOD_LEAK_SET_POINT_START_CHAR_ASCII ) + BLOOD_LEAK_EMB_MODE_STATE_T state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; + BOOL isUARTTxDone = FALSE; + BOOL isUARTCtrlDone = TRUE; + + switch ( bloodLeakEmbModeRqstedCmd ) { - // Check if the current buffer index is less than the buffer length - if( bloodLeakUARTCmdIndex < bloodLeakSetPointSeqLength ) - { - U32 command = bloodLeakSetPointSequence[ bloodLeakUARTCmdIndex ]; + case CS: + case T: + case G: + case I: + case V: + case Z: + case Q: + case D: + case C: + command = bloodLeakEmbModeCmdSquence[ bloodLeakUARTCmdIndex ]; + isUARTTxDone = ( bloodLeakUARTCmdIndex <= BLOOD_LEAK_EMB_MODE_STOP_INDEX ? FALSE : TRUE ); + isUARTCtrlDone = ( bloodLeakUARTCmdIndex > ( BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH - 1 ) ? TRUE : FALSE ); - // The active high index is the length - 2 they are the last two elements - U32 activeHighIndex = bloodLeakSetPointSeqLength - 2; + bloodLeakUARTCmdIndex++; + break; - // Check if the current index towards the end of the buffer which are FIFO set and FIFO reset - if( activeHighIndex > bloodLeakUARTCmdIndex ) + case SP: + // Check if the current buffer index is less than the buffer length + if( bloodLeakUARTCmdIndex < bloodLeakSetPointSeqLength ) { - setFPGABloodLeakUARTTransmit( (U08)command ); + // The active high index is the length - 2 they are the last two elements + U32 activeHighIndex = bloodLeakSetPointSeqLength - 2; + command = bloodLeakSetPointSequence[ bloodLeakUARTCmdIndex ]; + isUARTTxDone = ( activeHighIndex > bloodLeakUARTCmdIndex ? TRUE : FALSE ); + isUARTCtrlDone = FALSE; + + bloodLeakUARTCmdIndex++; } - else - { - setFPGABloodLeakUARTControl( (U08)command ); - } + break; - bloodLeakUARTCmdIndex++; - } - else - { - bloodLeakCalASCIIChar = 0; - bloodLeakUARTCmdIndex = 0; - state = BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE; - } } - else - { - U32 command = bloodLeakCalCommandSquence[ bloodLeakUARTCmdIndex ]; - // Check if the index is the stop writing to the FIFO bit. Up until the stop writing - // bit they are written to the UART channel and the high, low bits are written to the UART control - if ( bloodLeakUARTCmdIndex <= BLOOD_LEAK_EMB_MODE_STOP_INDEX ) + // Check if the current index towards the end of the buffer which are FIFO set and FIFO reset + if ( FALSE == isUARTCtrlDone ) + { + if( FALSE == isUARTTxDone ) { setFPGABloodLeakUARTTransmit( (U08)command ); } else { setFPGABloodLeakUARTControl( (U08)command ); } + } + else + { + // Reset the variables for the next + bloodLeakEmbModeOpsStartTime = getMSTimerCount(); + state = BLOOD_LEAK_EMB_WAIT_FOR_COMMAND_TO_SETTLE_STATE; + } - // Done with writing all the commands, reset the index and transition - if ( bloodLeakUARTCmdIndex >= ( BLOOD_LEAK_CAL_COMMAND_SEQ_LENGTH - 1 ) ) - { - bloodLeakCalASCIIChar = 0; - bloodLeakUARTCmdIndex = 0; - state = BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE; - } - else - { - bloodLeakUARTCmdIndex++; - } + return state; +} + +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandToSettleState( void ) +{ + BLOOD_LEAK_EMB_MODE_STATE_T state = BLOOD_LEAK_EMB_WAIT_FOR_COMMAND_TO_SETTLE_STATE; + + if ( TRUE == didTimeout( bloodLeakEmbModeOpsStartTime, 20 ) ) + { + bloodLeakEmbModeOpsStartTime = getMSTimerCount(); + bloodLeakUARTCmdIndex = 0; + bloodLeakEmbModeRespIndex = 0; + state = BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE; + + memset( bloodLeakEmbModeRespBuffer, 0x0, BLOOD_LEAK_EMB_MODE_RESP_BUFFER_LEN ); } return state; } -static BLOOD_LEAK_CAL_STATE_T handleCalBloodLeakWaitForCommandResponseState( void ) +/*********************************************************************//** + * @brief + * The handleCalBloodLeakWaitForCommandResponseState function handles the + * wait for command responses state. The state receives data in the buffer. + * @details Inputs: TODO fill up + * @details Outputs: TODo fill up + * @return next state + *************************************************************************/ +static BLOOD_LEAK_EMB_MODE_STATE_T handleCalBloodLeakWaitForCommandResponseState( void ) { - BLOOD_LEAK_CAL_STATE_T state = BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE; + BLOOD_LEAK_EMB_MODE_STATE_T state = BLOOD_LEAK_CAL_WAIT_FOR_COMMAND_RESPONSE_STATE; + U08 rxFIFOCount = getFPGABloodLeakRxFIFOCount(); + if ( rxFIFOCount > 0 ) + { + /* + * 1. It could be a start character and the length (i.e. VXXXX) + * 2. It could be two discrete characters (i.e. P, F) + * 3. It could be none of the two characters (i.e. XXXX) + */ + U08 data = getFPGABloodLeakRxFIFODataOut(); + U08 expChar1 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar1; + U08 expChar2 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar2; + U08 length = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].length; + if ( ( expChar1 != NU ) && ( NU == expChar2 ) ) + { + if ( bloodLeakEmbModeRespIndex < length ) + { + if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + + bloodLeakEmbModeRespIndex++; + } + else if ( bloodLeakEmbModeRespIndex > 0 ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + + bloodLeakEmbModeRespIndex++; + } + } + } + else if ( ( expChar1 != NU ) && ( expChar2 != NU ) ) + { + if ( bloodLeakEmbModeRespIndex < length ) + { + if ( ( expChar1 == data ) || ( expChar2 == data ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + + bloodLeakEmbModeRespIndex++; + } + } + } + + BOOL test = FALSE; + } + + // If wait for the receive FIFO has timed out or all there is no buffer left in the Rx FIFO transition back to wait for command + // state for the next command + if ( ( TRUE == didTimeout( bloodLeakEmbModeOpsStartTime, BLOOD_LEAK_EMB_MODE_RX_TIMEOUT_MS ) ) || ( BLOOD_LEAK_EMB_MODE_RX_BUFFER_EMPTY == rxFIFOCount ) ) + { + bloodLeakEmbModeRqstedCmd = NU; + state = BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE; + } + return state; } @@ -890,7 +1050,6 @@ static void prepareSetPointSeq( U16 setPoint ) { U08 i; - // Set the local variables. U32 digitCount; char tempCharBuffer[ BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ]; @@ -964,13 +1123,80 @@ data.bloodLeakStCount = (U32)getFPGABloodLeakStCount(); data.bloodLeakLEDIntesity = (U32)getFPGABloodLeakLEDIntensity(); data.bloodLeakRegisterCounter = (U32)getFPGABloodLeakRegisterCounter(); + data.bloodLeakEmbModeRxChars = 0; broadcastData( MSG_ID_HD_BLOOD_LEAK_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( BLOOD_LEAK_DATA_T ) ); bloodLeakDataPublicationTimerCounter = 0; } } +/*********************************************************************//** + * @brief + * The initEmbModeSpecs function initializes the embedded mode specifications + * structure. + * @details Inputs: bloodLeakEmbModeCmd + * @details Outputs: bloodLeakEmbModeCmd + * @return none + *************************************************************************/ +static void initEmbModeSpecs( void ) +{ + bloodLeakEmbModeCmd[ NU ].commandASCII = 0; + bloodLeakEmbModeCmd[ NU ].expChar1 = 0; + bloodLeakEmbModeCmd[ NU ].expChar2 = 0; + bloodLeakEmbModeCmd[ NU ].length = 0; + bloodLeakEmbModeCmd[ CS ].commandASCII = 19; + bloodLeakEmbModeCmd[ CS ].expChar1 = 69; // ASCII for E (Embedded ...) + bloodLeakEmbModeCmd[ CS ].expChar2 = NU; + bloodLeakEmbModeCmd[ CS ].length = 5; + + bloodLeakEmbModeCmd[ SP ].commandASCII = 83; + bloodLeakEmbModeCmd[ SP ].expChar1 = 88; // ASCII for X (Timeout) + bloodLeakEmbModeCmd[ SP ].expChar2 = 70; // ASCII for F (Fail) + bloodLeakEmbModeCmd[ SP ].length = 0; + + bloodLeakEmbModeCmd[ T ].commandASCII = 84; + bloodLeakEmbModeCmd[ T ].expChar1 = 80; // ASCII for P + bloodLeakEmbModeCmd[ T ].expChar2 = 70; // ASCII for F + bloodLeakEmbModeCmd[ T ].length = 1; + + bloodLeakEmbModeCmd[ G ].commandASCII = 71; + bloodLeakEmbModeCmd[ G ].expChar1 = 0; + bloodLeakEmbModeCmd[ G ].expChar2 = 0; + bloodLeakEmbModeCmd[ G ].length = 3; + + bloodLeakEmbModeCmd[ I ].commandASCII = 73; + bloodLeakEmbModeCmd[ I ].expChar1 = 0; + bloodLeakEmbModeCmd[ I ].expChar2 = 0; + bloodLeakEmbModeCmd[ I ].length = 3; + + bloodLeakEmbModeCmd[ V ].commandASCII = 86; + bloodLeakEmbModeCmd[ V ].expChar1 = 86; + bloodLeakEmbModeCmd[ V ].expChar2 = 0; + bloodLeakEmbModeCmd[ V ].length = 5; + + bloodLeakEmbModeCmd[ Z ].commandASCII = 90; + bloodLeakEmbModeCmd[ Z ].expChar1 = 89; // ASCII for Y + bloodLeakEmbModeCmd[ Z ].expChar2 = 0; + bloodLeakEmbModeCmd[ Z ].length = 1; + + bloodLeakEmbModeCmd[ Q ].commandASCII = 81; + bloodLeakEmbModeCmd[ Q ].expChar1 = 80; // ASCII for P + bloodLeakEmbModeCmd[ Q ].expChar2 = 70; // ASCII for F + bloodLeakEmbModeCmd[ Q ].length = 1; + + bloodLeakEmbModeCmd[ D ].commandASCII = 68; + bloodLeakEmbModeCmd[ D ].expChar1 = 68; // ASCII for D + bloodLeakEmbModeCmd[ D ].expChar2 = 0; + bloodLeakEmbModeCmd[ D ].length = 5; + + bloodLeakEmbModeCmd[ C ].commandASCII = 67; + bloodLeakEmbModeCmd[ C ].expChar1 = 67; // ASCII for C + bloodLeakEmbModeCmd[ C ].expChar2 = 0; + bloodLeakEmbModeCmd[ C ].length = 4; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -1093,8 +1319,9 @@ // the embedded mode if ( ( MODE_FAUL == mode ) || ( MODE_SERV == mode ) || ( MODE_STAN == mode ) ) { - bloodLeakSignalEmbeddedModeReq = TRUE; - result = TRUE; + bloodLeakSignalEmbModeReq = TRUE; + bloodLeakEmbModeRqstedCmd = CS; + result = TRUE; } } @@ -1103,23 +1330,23 @@ /*********************************************************************//** * @brief - * The testSetBloodLeakCalibrationCommand function sets the blood leak calibration - * command. + * The testSetBloodLeakEmbeddedModeCommand function sets the blood leak + * calibration command. * @details Inputs: bloodLeakSignalEmbeddedModeReq, bloodLeakCalSubstate * @details Outputs: bloodLeakCalASCIIChar * @return TRUE if the command is accepted otherwise, FALSE *************************************************************************/ -BOOL testSetBloodLeakCalibrationCommand( U08 command ) +BOOL testSetBloodLeakEmbeddedModeCommand( U08 command ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { // If the HD is already in service mode and in the blood leak is in the embedded mode and the sensor is waiting for another command - if ( ( MODE_SERV == getCurrentOperationMode() ) && ( TRUE == bloodLeakSignalEmbeddedModeReq ) && - ( BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE == bloodLeakCalSubstate ) ) + if ( ( MODE_SERV == getCurrentOperationMode() ) && ( TRUE == bloodLeakSignalEmbModeReq ) && + ( BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE == bloodLeakEmbModeSubstate ) ) { - bloodLeakCalASCIIChar = command; + bloodLeakEmbModeRqstedCmd = command; } } @@ -1141,11 +1368,11 @@ if ( TRUE == isTestingActivated() ) { // If the HD is already in service mode and in the blood leak is in the embedded mode and the sensor is waiting for another command - if ( ( MODE_SERV == getCurrentOperationMode() ) && ( TRUE == bloodLeakSignalEmbeddedModeReq ) && - ( BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE == bloodLeakCalSubstate ) ) + if ( ( MODE_SERV == getCurrentOperationMode() ) && ( TRUE == bloodLeakSignalEmbModeReq ) && + ( BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE == bloodLeakEmbModeSubstate ) ) { - bloodLeakCalASCIIChar = BLOOD_LEAK_SET_POINT_START_CHAR_ASCII; - bloodLeakCalSetPoint = setPoint; + bloodLeakEmbModeRqstedCmd = SP; + bloodLeakEmbModeSetPoint = setPoint; } }