[ECOS] Problem with f-format
Andrew Lunn
andrew@lunn.ch
Wed Aug 20 14:41:00 GMT 2008
On Wed, Aug 20, 2008 at 03:27:42PM +0200, Robert Brusa wrote:
> I am using ecos on a AT91SAM7X-EK-target. The routine shown below outputs
> the three lines (to UART1):
>
> j:770 x:%f
> j:
> j:772 x:5.980000
>
> which is not what I would expect from the producing routine shown here:
>
> void fproblem( void)
> { //simple procedure to demonstrate problem with f-format
> unsigned int j = 770;
> float x = 5.98;
> diag_printf("\nj:%u x:%f", j, x);
diag_printf does not implement float/double etc. It is supposed to be
a lean/mean printf you can use in interrupt handlers, and other debug
situations, not a full blown POSIX compatible printf.
> j++;
> printf("\nj:%u x:%f", j, x);
You probably want to flush the stream. If i remember correctly, it
only gets flushed when you write a \n, which you don't have here.
> char str[15];
> j++;
> sprintf(str, "\nj:%u x:%f", j, x);
> diag_printf("%s", str);
> } // end fproblem
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list