[En-Nut-Discussion] freopen(..)

Bernard Fouché bernard.fouche at kuantic.com
Thu Oct 27 11:52:55 CEST 2005


Hi there.

I'm using an Ethernut 2.1b, gcc-3.4.4, Ethernut 3.9.8.

There is something that I don't get with freopen(). I'm using httpd.c as 
a base for my application. At the beginning , there is :

freopen("uart0","w",stdout);

Freopen() return value is not stored anywhere and stdout is functionnal! 
>From what I understand of freopen() it should close stdout if it exists, 
reopen "uart0" and then return a FILE * to the new descriptor. Something 
like

stdout=freopen("uart0","w",stdout);

Now what I want is to use uart0/stdout for debugging and also allow a 
http client send/receive data to/from uart0.

I thought that I would keep freopen() in main.c as it is now if I 
compile with debug and, with or without debug, use it later if a http 
client comes in. Now my second call to freopen() always fail.

How should I process that? Use fopen() instead of freopen() ? Can I 
fopen() twice uart0 without problems? Any hint welcome!

Thanks!

  Bernard



More information about the En-Nut-Discussion mailing list