I am using the Fastrack Supreme, it has the Q2687 CPU. I will like to know if it handles floating point calculations well and if
wm_sprintf handles float type well.
/* Get the current position */
val = FillGPSData();
if (val < 0)
{
adl_atSendResponsePort ( ADL_AT_RSP, ADL_PORT_UART1, "\r\nM2M Weather Station: GPS Fix not obtained yet\r\n");
//return;
}
/* Print the position on serial port */
/* Format==> Decimal degree */
wm_sprintf(RspBuffer, "\r\nLong/Lat/Alt: %0.02f%c, %0.02f%c, %0.02f%c\r\n",
fabs(GPSposition_t.Longitude),
GPSposition_t.dir[1],
fabs(GPSposition_t.Latitude),
GPSposition_t.dir[0],
GPSposition_t.Altitude,'m');
/* Send the buffer on serial */
adl_atSendResponsePort ( ADL_AT_RSP, ADL_PORT_UART1, RspBuffer);
}
when i look at the results on UART1. the longitude and latitude always have 2 decimal points as expected but sometimes the altitude has about 7 decimal places. After some time it has 2 decimal places as expected. Altitude also varies a lot, Is it because of the floating issue or the GPS altitude measurements ?
Somtimes the altitude has the following value: 0.429496726m then after sometime it is ok. even then it is not fixed like the longitude and latitude. It varies a lot. I am using the sample CGPS program: “Simple Sample”
hi,
there is some warning in documentation(Basic_development_guide) saying:
Important remark about GCC compiler:
When using GCC compiler, due to internal standard C library
architecture, it is strongly not recommended to use the “%f” mode in
the wm_sprintf function in order to convert a float variable to a
string. This leads to an ARM exception (product reset).
A way around for this conversion is:
float MyFloat; // float to display
ascii MyString [ 100 ]; // destination string
s16 d,f;
d = (s16) MyFloat * 1000; // Decimal precision: 3 digits
f = ( MyFLoat * 1000 ) - d; // Decimal precision: 3 digits
wm_sprintf ( MyString, “%d.%03d”, (s16)MyFloat, f ); // Decimal
precision: 3 digits