From 2d4e2b87bcbe61a66ed2c0ab6c18f67933b4b8cf Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Fri, 25 Feb 2022 21:59:18 -0800 Subject: [PATCH 1/2] micropolis: Improve decode a little more. seekToPattern() can skip the index hole if it doesn't find the SYNC pattern. If this happens too close to the end of the flux stream, it can result in a conflicted sector. In this case, discard the sector. --- arch/micropolis/decoder.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/micropolis/decoder.cc b/arch/micropolis/decoder.cc index b9ad8146..930a777b 100644 --- a/arch/micropolis/decoder.cc +++ b/arch/micropolis/decoder.cc @@ -103,6 +103,15 @@ public: clock = seekToPattern(SECTOR_SYNC_PATTERN); } + _sector->headerStartTime = tell().ns(); + + /* seekToPattern() can skip past the index hole, if this happens + * too close to the end of the Fluxmap, discard the sector. + */ + if (_sector->headerStartTime > (getFluxmapDuration() - 12.5e6)) { + return 0; + } + return clock; } From d028db1ba32f41d02edbc5885f69e80289bcb090 Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Fri, 25 Feb 2022 22:08:57 -0800 Subject: [PATCH 2/2] northstar: Improve decode a little more. seekToPattern() can skip the index hole if it doesn't find the SYNC pattern. If this happens too close to the end of the flux stream, it can result in a conflicted sector. In this case, discard the sector. --- arch/northstar/decoder.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/northstar/decoder.cc b/arch/northstar/decoder.cc index 98b8c36b..ffc99faf 100644 --- a/arch/northstar/decoder.cc +++ b/arch/northstar/decoder.cc @@ -106,8 +106,14 @@ public: * _hardSectorId after the sector header is found. */ nanoseconds_t clock = seekToPattern(ANY_SECTOR_PATTERN); + _sector->headerStartTime = tell().ns(); - int sectorFoundTimeRaw = std::round((tell().ns()) / 1e6); + /* Discard a possible partial sector. */ + if (_sector->headerStartTime > (getFluxmapDuration() - 21e6)) { + return 0; + } + + int sectorFoundTimeRaw = std::round(_sector->headerStartTime / 1e6); int sectorFoundTime; /* Round time to the nearest 20ms */