[En-Nut-Discussion] fread() on serial port 0 problem

Kyle Rhodes kyle at ghbraille.com
Fri Nov 21 10:23:19 CET 2003


Hi Michel,

I did notice that and have recently changed it to <= 0.  However, this
had no impact on the result. (from what I remember, I've been at this
for WAY too long now!)  :)

One interesting thing did happen a few minutes ago.  The problem went
away for one job.  Everything worked perfectly.  Alas, when I sent
another job and caused the condition which it fails, it failed.  fread()
returned an error, and has since.  How frustrating!  


Thanks for your help,

Kyle Rhodes
Hardware / Software Engineer
gh, LLC
3000 Kent Ave
Lafayette, IN 47906
(765) 775-3776  ext 205


-----Original Message-----
From: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of Michel
Sent: Friday, November 21, 2003 3:14 AM
To: en-nut-discussion at egnite.de
Subject: Re: [En-Nut-Discussion] fread() on serial port 0 problem

Hi,

I'm not really an expert in NutOS, but I do see one thing in your
readFull()
function. And what I see is that you do not return when fread returns 0
bytes, only
when a negative number is returned.

Don't know if it helps, but I think you should return on 0 bytes as
well.

Greets

Kyle Rhodes said:
>
> size_t readFull(void *ptr, size_t size, FILE *fp)
> {
>   size_t retVal;
>   size_t numRead = 0;
>   unsigned char *cptr;
>
>   cptr = (unsigned char *) ptr;
>
>   while(numRead < size)
>   {
>     retVal = fread(&cptr[numRead], 1, size - numRead, fp);
>
>     if(retVal < 0)                                  <------- change
this into <=
>       return(retVal);
>
>     numRead += retVal;
>   }
>
>   return(numRead);
> }



_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion




More information about the En-Nut-Discussion mailing list