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