Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#21237 - 27/10/2000 17:20 Found it! A fix for the "Read 0 bytes" error.
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31565
Loc: Seattle, WA
How many people have tried to use some version of download.c and gotten this error, as described in this thread?

Read 0 bytes
Read 0 bytes
Read 0 bytes
Error Status In Readbyte 16
(etc., followed by the flash failing at some point with a different error.)

Well, I think I just fixed it.

Okay, first of all, here is how I reproduced the error:

  • Running on Windows NT 4.0 (doesn't seem to happen on '98).


  • Perform an upgrade to the Empeg using one of the ".upgrade" files.


  • After that, download.c no longer functions and you cannot flash any new logos or kernels. It gives the "Read 0 bytes" error.


  • If you use Hyperterminal, connect to the Empeg, then close Hyperterminal, it clears the problem up and download.c works correctly again.


So, since I was working on integrating a new version of the download.c sources with my Empeg Logo Editor, I was interested in fixing this bug. I figured, "if Hyperterminal clears the error, then if I figure out what Hyperterminal does, then I can clear the error myself if I want to."

So, I used PortMon (a great GREAT freeware program, by the way) to sniff the serial port and see what Hyperterminal was doing. After a few failed excursions in pursuit of wild waterfowl, I finally found what I think is the proper fix. Add the following lines to download.c:

  • At the top of the Win32 openport routine, add the definition:

    COMMTIMEOUTS lpCommTimeouts ;


  • At the end of the openport routine, just before the return statement, add these lines:

    lpCommTimeouts.ReadIntervalTimeout = 0x10;
    lpCommTimeouts.ReadTotalTimeoutMultiplier = 0;
    lpCommTimeouts.ReadTotalTimeoutConstant = 0;
    lpCommTimeouts.WriteTotalTimeoutMultiplier = 0;
    lpCommTimeouts.WriteTotalTimeoutConstant = 0x5000;
    SetCommTimeouts (hPort, &lpCommTimeouts);


That's all! Something about the previous program had messed up the timeouts, making download.c fail to function. Resetting them took care of it.

I haven't tested this on Win98 yet. I will do that tonight. If all is well, the next release of the Empeg Logo Editor will include this code change in its Upload.exe file.

Enjoy!

___________
Tony Fabris
_________________________
Tony Fabris

Top
#21238 - 12/01/2004 11:27 Re: Found it! A fix for the "Read 0 bytes" error. [Re: tfabris]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
Cool. I've been hacking on something recently that talks serial. My problem was different -- it was eating 100% CPU -- and I don't mean in a busy-wait loop, but this code fixed it.

Took me most of the afternoon to find the relevant post, though.

Now if only I could work out what it actually does, and why it was a problem before...
_________________________
-- roger

Top
#21239 - 12/01/2004 11:30 Re: Found it! A fix for the "Read 0 bytes" error. [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31565
Loc: Seattle, WA
Cool! I knew someday this might come in handy for somebody.

Sorry it took so long for you to find it.
_________________________
Tony Fabris

Top