This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Problem with f-format
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Robert Brusa <bob dot brusa at gmail dot com>
- Cc: MailingList: ecos-discuss <ecos-discuss at ecos dot sourceware dot org>;
- Date: Wed, 20 Aug 2008 15:59:54 +0200
- Subject: Re: [ECOS] Problem with f-format
- References: <op.uf6s0evdkeg3uf@localhost>
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