mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:38:05 +11:00
Revert "tools: make upload a bit faster"
This optimisation appears to make the upload process unreliable in some cases. I can't appear to reliably upload to my TRS-80 with this version. I prefer reliability than speed...
This commit is contained in:
parent
63d2c97386
commit
f0087cd48e
@ -2,7 +2,6 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@ -41,11 +40,9 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Could not open %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
uint16_t checksum = 0;
|
||||
char s[0x40];
|
||||
// Write all received bytes, keeping a checksum, then print that checksum
|
||||
sprintf(s,
|
||||
": _ 0 %d %d DO KEY DUP I C! + LOOP .X ; _",
|
||||
": _ 0x%04x 0x%04x DO KEY DUP .x I C! LOOP ; _",
|
||||
memptr+bytecount, memptr);
|
||||
sendcmd(fd, s);
|
||||
|
||||
@ -54,22 +51,23 @@ int main(int argc, char **argv)
|
||||
putc('.', stderr);
|
||||
fflush(stderr);
|
||||
unsigned char c = s[0];
|
||||
checksum += c;
|
||||
write(fd, &c, 1);
|
||||
usleep(1000); // let it breathe
|
||||
}
|
||||
fprintf(stderr, "\nBytes sent, checksum...\n");
|
||||
mread(fd, s, 4); // read hex string
|
||||
s[4] = 0; // null terminate
|
||||
uint16_t checksum2 = strtol(s, NULL, 16);
|
||||
if (checksum == checksum2) {
|
||||
fprintf(stderr, "OK\n");
|
||||
} else {
|
||||
fprintf(stderr, "Mismatch! Expected %04x and got %04x.\n", checksum, checksum2);
|
||||
returncode = 1;
|
||||
mread(fd, s, 2); // read hex pair
|
||||
s[2] = 0; // null terminate
|
||||
unsigned char c2 = strtol(s, NULL, 16);
|
||||
if (c != c2) {
|
||||
// mismatch!
|
||||
unsigned int pos = ftell(fp);
|
||||
fprintf(stderr, "Mismatch at byte %d! %d != %d.\n", pos, c, c2);
|
||||
// we don't exit now because we need to "consume" our whole program.
|
||||
returncode = 1;
|
||||
}
|
||||
usleep(1000); // let it breathe
|
||||
}
|
||||
readprompt(fd);
|
||||
sendcmdp(fd, "FORGET _");
|
||||
fprintf(stderr, "Done!\n");
|
||||
fclose(fp);
|
||||
if (fd > 0) {
|
||||
close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user