[Oberon] pcreceive.sh not working for files that are multiples of 255
Paul Reed
paulreed at paddedcell.com
Fri Jun 30 13:25:35 CEST 2017
Hi Andreas,
> I do not really understand 100% the part starting with
> "int pos = (rxcount - fnlen -1) % 256, followed by two cascaded if
> statements, one with condition pos == 0 and one with condition flen >
> 255".
Nor did I, even though I wrote it :( However, after sitting down with my
former self and getting him to explain himself, I have tested the
following patch (on macOS, at least; the latter diff just gets rid of a
warning).
The rxcount variable tracks how many characters have been "received" by
the *virtual* machine, which is why it's % 256 not % 255 (took me a
while...).
So a packet header byte is "received" every 256 bytes, or (now) when the
remaining file length (flen) is zero, otherwise it's a data byte. That's
what the if statement *should* have said. Apologies!
Thanks again,
Paul
diff --git a/src/pclink.c b/src/pclink.c
index 5c4aa81..fa9ce3d 100644
--- a/src/pclink.c
+++ b/src/pclink.c
@@ -101,18 +101,18 @@ static uint32_t PCLink_RData(const struct
RISC_Serial *serial) {
}
} else {
int pos = (rxcount - fnlen - 1) % 256;
- if (pos == 0) {
+ if (pos == 0 || flen == 0) {
if (flen > 255) {
ch = 255;
} else {
ch = (uint8_t)flen;
+ if (flen == 0) {
+ mode = 0; unlink(RecName);
+ }
}
} else {
read(fd, &ch, 1);
flen--;
- if (flen == 0) {
- mode = 0; unlink(RecName);
- }
}
}
}
diff --git a/src/sdl-main.c b/src/sdl-main.c
index 892f9e9..8510f2a 100644
--- a/src/sdl-main.c
+++ b/src/sdl-main.c
@@ -66,7 +66,7 @@ static struct option long_options[] = {
{ "leds", no_argument, NULL, 'L' },
{ "size", required_argument, NULL, 's' },
{ "serial-fd", required_argument, NULL, 'F' },
- { NULL }
+ { NULL, no_argument, NULL, '\0' }
};
static void fail(int code, const char *fmt, ...) {
More information about the Oberon
mailing list