Page 1 of 1

FreePie IMU receive

Posted: Wed Oct 13, 2021 7:11 am
by o1113199
Hello everyone, I can't figure out which buffer to accept from the FreePie IMU application for Android. Does anyone know?

The application sends a UDP packet containing accel, gyro, magnetometr and rotation, but I can't find the right buffer to get this data.

Source code ... #L147-L174

Another app with receive this packet ... ie-udp.cpp

As far as I understand, the first 2 bytes are the device index and flags. This is followed by a float array, I tried 6, 9, 12 values, but the data cannot be obtained correctly (except for the first two bytes).

Code: Select all

	struct _freePieIMUAndroid {
		unsigned char deviceIndex;
		unsigned char flags; //raw data = 1, orient = 2, both = 3
		float data[12]; ///?????
I tried using double instead of float, but that didn't help either. Please help me find the right structure for UDP packet, thanks.

Re: FreePie IMU receive

Posted: Thu Oct 14, 2021 5:04 am
by o1113199
I realized that it turns out there need to read the
unsigned char buff buffer[50];
the first 2 bytes are responsible for the index and flags, and then 4 bytes per value to convert need to use this function

float bytesToFloat(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3)
unsigned char byte_array[] = { b3, b2, b1, b0 };
float result;
std::copy(reinterpret_cast<const char*>(&byte_array[0]),
reinterpret_cast<const char*>(&byte_array[4]),
return result;

float AccelX = bytesToFloat(buff[5], buff[4], buff[3], buff[2]);