avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Standard IO - function fwrite


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Standard IO - function fwrite
Date: Fri, 8 Jun 2007 23:00:21 +0200 (MET DST)

(Please don't send HTML mails, it's cumbersome to handle.)

Marjan Fojkar <address@hidden> wrote:

> Yes you are right. But if you use this function for binary data it
> doesn't work.

Why?

> Function fwrite enters into for loop and stays there
> until putc returns zero or all data have been written.

It's not putc() but rather the put() backend function you provided in
fdevopen()/fdev_setup_stream(), and it stops when this put() function
returns *non*-zero, as that indicates an error or EOF condition.

> If data contain zero values the fwrite will exit on first zero
> value.

I suspect you simply botched your put() backend function.  That
function is supposed to return 0 on success, _FDEV_ERR (-1) on error,
or _FDEV_EOF (-2) on EOF in case your driver/device can experience
some kind of end-of-file situation that is distinguishable from a
simple write error.

Btw., vfprintf() has a bug in that it ignores the error/EOF status
when writing, and proceeds anyway.  Feel free to write a bug report
for that.  Also, fputc() does not appropriately set the error and EOF
flags, another bug.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]