firmware/Temperature/src/Terminal.c
///////////////////////////////////////////////////////////////////////////////
/// \brief process the buffer data and extract the commands
///
///	\return TRUE success
///
///	\todo update the document return state value. need to implement
///////////////////////////////////////////////////////////////////////////////
\brief process the buffer data and extract the commands
\return TRUE success

\todo update the document return state value. need to implement
\ brief process the buffer data and extract the commands \ return TRUE success \ todo update the document return state value . need to implement
static int_fast8_t ProcessData(uint8_t *source, uint32_t length, ListOfParameterStructureType * destination)
{
	uint32_t ParameterCharacterLength = 0;
	uint32_t ParameterCounter = 0;
	uint8_t *CurrentParamStrPointer;
	if ( !source || !destination)
	{
		destination->NumberOfParameter = 0; 
		return ERROR;
	}
	destination->NumberOfParameter = 0; 
	CurrentParamStrPointer = &destination->List[destination->NumberOfParameter].StringArray[0];
	for( ; length ; length--)
	{
		if ( *source  == ' ')
		{
			destination->NumberOfParameter++;
			if (destination->NumberOfParameter < MAX_NUMBER_OF_PARAMETERS )
			{
				CurrentParamStrPointer = &destination->List[destination->NumberOfParameter].StringArray[0];
			}
			else
			{
				destination->NumberOfParameter = 0; 
				return FALSE;
			}
			ParameterCharacterLength = 0;
		}
		else
		{
			if ( ParameterCharacterLength < (PARAMETER_STRING_SIZE -1) )
			{
				*CurrentParamStrPointer = *source;
				CurrentParamStrPointer++;
				*CurrentParamStrPointer = 0;
				ParameterCharacterLength++;
			}
		}
		source++;
	}
	if (ParameterCharacterLength >= 2)
	{
		destination->NumberOfParameter++;
	}
	else if ( !destination->NumberOfParameter )
	{
		destination->NumberOfParameter = 0;
		return FALSE;
	} else if ( 's' == !destination->List[0].Type && 'S' == !destination->List[0].Type)
	{
		destination->NumberOfParameter = 0;
		return ERROR;
	}
	for(ParameterCounter = 0; ParameterCounter < destination->NumberOfParameter ; ParameterCounter++)
	{
		switch (destination->List[ParameterCounter].Type)
		{
		case 'S':
		case 'U':
			destination->List[ParameterCounter].Type += 32; 
		case 's':
		case 'u':
			destination->List[ParameterCounter].Value.i32_t[0] = atoi((char *) &destination->List[ParameterCounter].StringArray[1]);
			break;
		case 'F':
		case 'f':
			destination->List[ParameterCounter].Value.f32_t[0] = atof((char *) &destination->List[ParameterCounter].StringArray[1]);
			break;
		case 'T':
			destination->List[ParameterCounter].Type += 32; 
		case 't':
			break;
		default:
			destination->NumberOfParameter = 0;
			return ERROR;
			break;
		}
	}
	return TRUE;
}
static int_fast8_t ProcessData ( uint8_t * source , uint32_t length , ListOfParameterStructureType * destination ) { uint32_t ParameterCharacterLength = 0 ; uint32_t ParameterCounter = 0 ; uint8_t * CurrentParamStrPointer ; if ( ! source || ! destination ) { destination -> NumberOfParameter = 0 ; return ERROR ; } destination -> NumberOfParameter = 0 ; CurrentParamStrPointer = & destination -> List [ destination -> NumberOfParameter ] . StringArray [ 0 ] ; for ( ; length ; length -- ) { if ( * source == ' ' ) { destination -> NumberOfParameter ++ ; if ( destination -> NumberOfParameter < MAX_NUMBER_OF_PARAMETERS ) { CurrentParamStrPointer = & destination -> List [ destination -> NumberOfParameter ] . StringArray [ 0 ] ; } else { destination -> NumberOfParameter = 0 ; return FALSE ; } ParameterCharacterLength = 0 ; } else { if ( ParameterCharacterLength < ( PARAMETER_STRING_SIZE - 1 ) ) { * CurrentParamStrPointer = * source ; CurrentParamStrPointer ++ ; * CurrentParamStrPointer = 0 ; ParameterCharacterLength ++ ; } } source ++ ; } if ( ParameterCharacterLength >= 2 ) { destination -> NumberOfParameter ++ ; } else if ( ! destination -> NumberOfParameter ) { destination -> NumberOfParameter = 0 ; return FALSE ; } else if ( ' ' == ! destination -> List [ 0 ] . Type && ' ' == ! destination -> List [ 0 ] . Type ) { destination -> NumberOfParameter = 0 ; return ERROR ; } for ( ParameterCounter = 0 ; ParameterCounter < destination -> NumberOfParameter ; ParameterCounter ++ ) { switch ( destination -> List [ ParameterCounter ] . Type ) { case ' ' : case ' ' : destination -> List [ ParameterCounter ] . Type += 32 ; case ' ' : case ' ' : destination -> List [ ParameterCounter ] . Value . i32_t [ 0 ] = atoi ( ( char * ) & destination -> List [ ParameterCounter ] . StringArray [ 1 ] ) ; break ; case ' ' : case ' ' : destination -> List [ ParameterCounter ] . Value . f32_t [ 0 ] = atof ( ( char * ) & destination -> List [ ParameterCounter ] . StringArray [ 1 ] ) ; break ; case ' ' : destination -> List [ ParameterCounter ] . Type += 32 ; case ' ' : break ; default : destination -> NumberOfParameter = 0 ; return ERROR ; break ; } } return TRUE ; }
\brief process the buffer data and extract the commands
\return TRUE success
\ brief process the buffer data and extract the commands \ return TRUE success
// checking the pointer aren't null // reset the number of parameters // reset // reset the number of parameters // We have a valid number of parameters /// \fallthrough /// \fallthrough // convert to uppercase /// \fallthrough /// \fallthrough /// \fallthrough // convert to uppercase // don't need to do anything its already converted