mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-17 06:48:07 +11:00
tools: use the new "puth" BASIC command
This commit is contained in:
parent
fb93fcd6e6
commit
fcee98ee4e
@ -50,17 +50,12 @@ int main(int argc, char **argv)
|
||||
for (int i=0; i<bytecount; i++) {
|
||||
sendcmd(fd, "peek m");
|
||||
read(fd, s, 2); // read prompt
|
||||
sendcmd(fd, "print a");
|
||||
for (int j=0; j<3; j++) {
|
||||
read(fd, s+j, 1);
|
||||
s[j+1] = 0; // always null-terminate
|
||||
if (s[j] < '0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
unsigned char c = strtol(s, NULL, 10);
|
||||
sendcmd(fd, "puth a");
|
||||
read(fd, s, 2); // read hex pair
|
||||
s[2] = 0; // null terminate
|
||||
unsigned char c = strtol(s, NULL, 16);
|
||||
putchar(c);
|
||||
read(fd, s, 3); // read \r\n + prompt - last char
|
||||
read(fd, s, 2); // read prompt
|
||||
sendcmd(fd, "m=m+1");
|
||||
read(fd, s, 2); // read prompt
|
||||
}
|
||||
|
@ -50,19 +50,15 @@ while (sysread $fh, my $char, 1) {
|
||||
sendcmd("getc");
|
||||
syswrite $devh, $char;
|
||||
sysread $devh, $rd, 2; # read prompt
|
||||
sendcmd("print a");
|
||||
my $s = "";
|
||||
while (1) {
|
||||
sysread $devh, $rd, 1;
|
||||
if ($rd !~ /\d/) { last; }
|
||||
$s .= $rd;
|
||||
}
|
||||
sysread $devh, $rd, 3; # read prompt
|
||||
if ($s == ord($char)) {
|
||||
sendcmd("puth a");
|
||||
sysread $devh, $rd, 2;
|
||||
my $ri = hex($rd);
|
||||
sysread $devh, $rd, 2; # read prompt
|
||||
if ($ri == ord($char)) {
|
||||
last;
|
||||
} else {
|
||||
if ($i < 4) {
|
||||
print "Mismatch at byte ${i}! ${s} != ${ord($char)}. Retrying.\n";
|
||||
print "Mismatch at byte ${i}! ${ri} != ${ord($char)}. Retrying.\n";
|
||||
} else {
|
||||
die "Maximum retries reached, abort.\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user