Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r050984357442e3ee0d6d5b21e274c1306643c598 -r6e86723c766c0097c9867af984c0c7e82802537a --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 050984357442e3ee0d6d5b21e274c1306643c598) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 6e86723c766c0097c9867af984c0c7e82802537a) @@ -984,9 +984,9 @@ bloodLeakEmbModeRespIndex++; } - // Check if the buffer index is > 0 so the first char has been inserted and the rest is data - // For instance, V has been inserted and XXX is inserted that is followed by V. So V123. - else if ( bloodLeakEmbModeRespIndex > 0 ) + // Check if the buffer index is > 0 so the first char has been inserted and the rest is data but it is not the echo of the command + // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. + else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) { bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; @@ -1047,8 +1047,6 @@ } } } - - BOOL test = FALSE; // TODO for testing remove } // 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 @@ -1068,21 +1066,25 @@ for ( i = 0; i < length; i++ ) { + // Loop through the elements of the buffer and make sure none of the elements are not NULL. + // The elements are checked until the specified length that is expected for a command isNull |= ( bloodLeakEmbModeRespBuffer[ i ] != NU ? FALSE : TRUE ); } // Check if the failed command is Control S which is switch to embedded mode and if // it failed set the embedded mode request to false so the other commands cannot be sent again bloodLeakSignalEmbModeReq = ( ( CS == bloodLeakEmbModeRqstedCmd ) && ( NU == bloodLeakEmbModeRespBuffer[ 0 ] ) ? FALSE : TRUE ); - if ( ( TRUE == isNull ) && ( bloodLeakEmbModeNumOfCmdTries < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) ) + if ( ( TRUE == isNull ) && ( ++bloodLeakEmbModeNumOfCmdTries < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) ) { state = BLOOD_LEAK_CAL_SEND_COMMAND_STATE; } else { bloodLeakEmbModeRqstedCmd = NU; state = BLOOD_LEAK_CAL_WAIT_FOR_COMAND_STATE; + + handleSendBloodLeakEmbeddedModeCommandResponse( length, bloodLeakEmbModeRespBuffer ); } } } @@ -1217,15 +1219,15 @@ // Get self test command bloodLeakEmbModeCmd[ G ].commandASCII = 71; // ASCII for G - bloodLeakEmbModeCmd[ G ].expChar1 = NU; + bloodLeakEmbModeCmd[ G ].expChar1 = 71; bloodLeakEmbModeCmd[ G ].expChar2 = NU; - bloodLeakEmbModeCmd[ G ].length = 4; + bloodLeakEmbModeCmd[ G ].length = 5; // Intensity command bloodLeakEmbModeCmd[ I ].commandASCII = 73; // ASCII for I - bloodLeakEmbModeCmd[ I ].expChar1 = NU; + bloodLeakEmbModeCmd[ I ].expChar1 = 73; bloodLeakEmbModeCmd[ I ].expChar2 = NU; - bloodLeakEmbModeCmd[ I ].length = 4; + bloodLeakEmbModeCmd[ I ].length = 5; // Blood detection command bloodLeakEmbModeCmd[ V ].commandASCII = 86; // ASCII for V Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r050984357442e3ee0d6d5b21e274c1306643c598 -r6e86723c766c0097c9867af984c0c7e82802537a --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 050984357442e3ee0d6d5b21e274c1306643c598) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 6e86723c766c0097c9867af984c0c7e82802537a) @@ -1651,7 +1651,7 @@ break; case MSG_ID_HD_SET_BLOOD_LEAK_EMB_MODE_COMMAND: - handleSetBloodEmbeddedModeCommand( message ); + handleSetBloodLeakEmbeddedModeCommand( message ); break; default: Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r050984357442e3ee0d6d5b21e274c1306643c598 -r6e86723c766c0097c9867af984c0c7e82802537a --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 050984357442e3ee0d6d5b21e274c1306643c598) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 6e86723c766c0097c9867af984c0c7e82802537a) @@ -7209,14 +7209,14 @@ /*********************************************************************//** * @brief -* The handleSetBloodEmbeddedModeCommand function handles a request to set the HD -* blood leak to embedded mode command. +* The handleSetBloodLeakEmbeddedModeCommand function handles a request to set +* the HD blood leak to embedded mode command. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleSetBloodEmbeddedModeCommand( MESSAGE_T* message ) +void handleSetBloodLeakEmbeddedModeCommand( MESSAGE_T* message ) { U08 command; U16 commandPayload; @@ -7240,4 +7240,37 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleSendBloodLeakEmbeddedModeCommandResponse function sends out + * the blood leak embedded mode command response. + * @details Inputs: none + * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param responseLen: the length of the buffer + * @param response: pointer to the response buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +{ + BOOL result; + MESSAGE_T msg; + + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) + responseLen; + + memcpy( payloadPtr, &responseLen, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, response, responseLen ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r22cab5beebd48faf29e78c5003b0bdd0a32748e8 -r6e86723c766c0097c9867af984c0c7e82802537a --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 22cab5beebd48faf29e78c5003b0bdd0a32748e8) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 6e86723c766c0097c9867af984c0c7e82802537a) @@ -806,9 +806,10 @@ void handleSetBloodLeak2EmbeddedMode( MESSAGE_T* message ); // MSG_ID_HD_SET_BLOOD_LEAK_EMB_MODE_COMMAND -void handleSetBloodEmbeddedModeCommand( MESSAGE_T* message ); +void handleSetBloodLeakEmbeddedModeCommand( MESSAGE_T* message ); -// MSG_ID_HD_SET_BLOOD_LEAK_EMB_MODE_SET_POINT +// MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE +BOOL handleSendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ); /**@}*/