Hello, I'm having a weird artifact issue. I'm converting from a serial incoming string to a float, and sometimes it works sometimes it doesn't. if this was to happen during a flight it would be so bad :)
Here is the output
39.997784 -112.017746 1705.166626 <---- Plane
39.995972 -112.018707 1609.333374 <---- Ground
39.997784 -112.017746 1705.166626 <---- Plane
-212655061101045080000000000000000000000.000000 39.997780 -112.017662 <---- Ground
-212655061101045080000000000000000000000.000000, 42 1f fd bb
What's happening is ground latitude screws up, and it's always that number -212650...
while(1){
while(groundStation.getc() != 0xff); // wait for the start of communication string
msg[0] = 0xff;
for(int i=1; i<26; i++)
{
msg[i] = groundStation.getc();
if (msg[25] == 0xfe)
led1 = !led1;
}
//airplane
p_lat = toFloat(msg[4], msg[3], msg[2], msg[1]);
p_lon = toFloat(msg[8], msg[7], msg[6], msg[5]);
p_alt = toFloat(msg[12], msg[11], msg[10], msg[9]);
//ground
g_lat = toFloat(msg[16], msg[15], msg[14], msg[13]);
g_lon = toFloat(msg[20], msg[19], msg[18], msg[17]);
g_alt = toFloat(msg[24], msg[23], msg[22], msg[21]);
usb_232.printf("%f %f %f <---- Plane \n", p_lat, p_lon, p_alt );
usb_232.printf("%f %f %f <---- Ground \n", g_lat, g_lon, g_alt);
if (g_lat < 0)
{
g_lat = toFloat(msg[16], msg[15], msg[14], msg[13]);
usb_232.printf("\n\n %f, %0x %0x %0x %0x " , g_lat, msg[4], msg[3], msg[2], msg[1]);
return 0;
}
And Here is the function that does the bytes to float
float toFloat(uchar b0, uchar b1, uchar b2, uchar b3)
{
float f;
uchar b[4] = {b3, b2, b1, b0};
float *fp = (float *)b;
f = *fp;
return f;
}
I really have no idea what is happening. Any clue would be so helpful. Thank you guys
Hello, I'm having a weird artifact issue. I'm converting from a serial incoming string to a float, and sometimes it works sometimes it doesn't. if this was to happen during a flight it would be so bad :)
Here is the output
What's happening is ground latitude screws up, and it's always that number -212650...
And Here is the function that does the bytes to float
I really have no idea what is happening. Any clue would be so helpful. Thank you guys