1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-17 07:38:05 +11:00

tools: use the new "puth" BASIC command

This commit is contained in:
Virgil Dupras 2019-12-09 21:17:45 -05:00
parent fb93fcd6e6
commit fcee98ee4e
2 changed files with 11 additions and 20 deletions

View File

@ -50,17 +50,12 @@ int main(int argc, char **argv)
for (int i=0; i<bytecount; i++) { for (int i=0; i<bytecount; i++) {
sendcmd(fd, "peek m"); sendcmd(fd, "peek m");
read(fd, s, 2); // read prompt read(fd, s, 2); // read prompt
sendcmd(fd, "print a"); sendcmd(fd, "puth a");
for (int j=0; j<3; j++) { read(fd, s, 2); // read hex pair
read(fd, s+j, 1); s[2] = 0; // null terminate
s[j+1] = 0; // always null-terminate unsigned char c = strtol(s, NULL, 16);
if (s[j] < '0') {
break;
}
}
unsigned char c = strtol(s, NULL, 10);
putchar(c); putchar(c);
read(fd, s, 3); // read \r\n + prompt - last char read(fd, s, 2); // read prompt
sendcmd(fd, "m=m+1"); sendcmd(fd, "m=m+1");
read(fd, s, 2); // read prompt read(fd, s, 2); // read prompt
} }

View File

@ -50,19 +50,15 @@ while (sysread $fh, my $char, 1) {
sendcmd("getc"); sendcmd("getc");
syswrite $devh, $char; syswrite $devh, $char;
sysread $devh, $rd, 2; # read prompt sysread $devh, $rd, 2; # read prompt
sendcmd("print a"); sendcmd("puth a");
my $s = ""; sysread $devh, $rd, 2;
while (1) { my $ri = hex($rd);
sysread $devh, $rd, 1; sysread $devh, $rd, 2; # read prompt
if ($rd !~ /\d/) { last; } if ($ri == ord($char)) {
$s .= $rd;
}
sysread $devh, $rd, 3; # read prompt
if ($s == ord($char)) {
last; last;
} else { } else {
if ($i < 4) { if ($i < 4) {
print "Mismatch at byte ${i}! ${s} != ${ord($char)}. Retrying.\n"; print "Mismatch at byte ${i}! ${ri} != ${ord($char)}. Retrying.\n";
} else { } else {
die "Maximum retries reached, abort.\n"; die "Maximum retries reached, abort.\n";
} }