KugleFirmware/Libraries/Devices/MTI200/xbusmessage.c
/*!
 * \brief Get a data item from an XMID_MtData2 Xbus message.
 * \param item Pointer to where to store the data.
 * \param id The data identifier to get.
 * \param message The message to read the data item from.
 * \returns true if the data item is found in the message, else false.
 */
\brief Get a data item from an XMID_MtData2 Xbus message.
\param item Pointer to where to store the data.
\param id The data identifier to get.
\param message The message to read the data item from.
\returns true if the data item is found in the message, else false.
\ brief Get a data item from an XMID_MtData2 Xbus message . \ param item Pointer to where to store the data . \ param id The data identifier to get . \ param message The message to read the data item from . \ returns true if the data item is found in the message else false .
bool XbusMessage_getDataItem(void* item, enum XsDataIdentifier id, struct XbusMessage const* message)
{
	uint8_t const* raw = getPointerToData(id, message->data, message->length);
	if (raw)
	{
		switch (id)
		{
			case XDI_PacketCounter:
				raw = XbusUtility_readU16(item, raw);
				break;
			case XDI_SampleTimeFine:
			case XDI_StatusWord:
				raw = XbusUtility_readU32(item, raw);
				break;
			case XDI_Quaternion:
			case XDI_DeltaQ:
				readFloats(item, raw, 4);
				break;
			case XDI_DeltaV:
			case XDI_Acceleration:
			case XDI_RateOfTurn:
			case XDI_MagneticField:
				readFloats(item, raw, 3);
				break;
			default:
				return false;
		}
		return true;
	}
	else
	{
		return false;
	}
}
bool XbusMessage_getDataItem ( void * item , enum XsDataIdentifier id , struct XbusMessage const * message ) { uint8_t const * raw = getPointerToData ( id , message -> data , message -> length ) ; if ( raw ) { switch ( id ) { case XDI_PacketCounter : raw = XbusUtility_readU16 ( item , raw ) ; break ; case XDI_SampleTimeFine : case XDI_StatusWord : raw = XbusUtility_readU32 ( item , raw ) ; break ; case XDI_Quaternion : case XDI_DeltaQ : readFloats ( item , raw , 4 ) ; break ; case XDI_DeltaV : case XDI_Acceleration : case XDI_RateOfTurn : case XDI_MagneticField : readFloats ( item , raw , 3 ) ; break ; default : return false ; } return true ; } else { return false ; } }
\brief Get a data item from an XMID_MtData2 Xbus message.
\ brief Get a data item from an XMID_MtData2 Xbus message .