[En-Nut-Discussion] Bugs in Uart.c

Moritz Struebe morty at gmx.net
Thu Mar 27 10:47:02 CET 2008


Henrik Maier schrieb:
>> -----Original Message-----
>> Nathan Moore schrieb:
>> Unfortunately it's unsigned long int. I googled for size_t and basically
>> it seems to be "some kind" of unsigned integer. This is fine if you do
>> have performance, but if every tick count's and registers are quite
>> valuable IMHO one should know how a variable looks like. (I hate
>> decisions which depend on the mood of your compiler. I therefore
>> generally prefer uint8_t, etc. Even char is defined mostly signed.)
>>     
>
> size_t on an AVR is a 16-bit unsigned int. 
>   

You're right. I should have double checked. But should it then be
int UsartRead(NUTFILE * fp, void *buffer, -int- size_t size) ?



> Using an 8-bit value would limit your API to only handle data chunks of 255
> bytes. This may not be a problem for your application but would complicate
> matters for other applications.
>   

Yes, 16bit do make sense. I thought it were 32.. (Being too stupid to 
look it up int the right file.)

> I believe Nut/OS has a good balance between optimisation for small MCUs
> while still following accepted standards, offering a convenient API and
> being reasonable portable.
>
> If you start optimising too much towards a particular architecture or
> application, you will lose portability or your code may only work if certain
> assumptions are met. 
>   

Yes that's true.

Anyway: Thanks to all for the feedback. I'm learning a lot. :-)

Cheers
Morty


>
>   




More information about the En-Nut-Discussion mailing list