[Top][All Lists]

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

Re: [avr-libc-dev] fwrite() not working as expected

From: NicoHood
Subject: Re: [avr-libc-dev] fwrite() not working as expected
Date: Sat, 10 Mar 2018 16:47:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 03/10/2018 11:52 AM, Georg-Johann Lay wrote:
> address@hidden schrieb:
>> Hi,
>> I am trying to use fwrite() to write the first X bytes of a string like
>> this, but with a wrong output:
>> auto ret = fwrite("Hello World!", 1, 5, stdout);
>> printf("%d\n", ret);
>> // Output: H0
>> Its documented here:
>> https://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#gadd5777719a41713629a62b68c239a774
>> Can anyone please tell me if this is a bug or if I am doing something
>> wrong. I am using avr-libc 2.0.0 on Arch Linux with the latest
>> avr-gcc 7.3.0
>> ~Nico
> How did you setup stdout? Using FDEV_SETUP_STREAM?
> https://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#gaea2b6be92ead4673bc487b271b7227fb
> Are you sure the communication / output routines passed to stdout are
> correct and I/O correctly set up? Including host I/O, given you use it.
> Johann

This is how I use stdout:

void usart_init_stream(FILE* const stream)
    *stream = (FILE)FDEV_SETUP_STREAM(usart_fputc, usart_fgetc,

Every other print works fine. I can use printf with %d and %s without
any errors. Only this single fwrite function does not work. You should
be able to easily reproduce this i guess. You can use my usart example
as a base if you dont have any stdio test sample handy.


reply via email to

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