Skip to content

Commit

Permalink
Merge pull request #129 from davidgiven/fixing
Browse files Browse the repository at this point in the history
Make decoding more robust
  • Loading branch information
davidgiven authored Jan 27, 2020
2 parents 9e75dc3 + 91ffcf5 commit e517f28
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
7 changes: 4 additions & 3 deletions doc/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ directory.
- `fluxengine inspect`: dumps the raw pulsetrain / bitstream to stdout.
Mainly useful for debugging.
- `fluxengine read*`: reads various formats of disk. See the per-format
- `fluxengine read *`: reads various formats of disk. See the per-format
documentation linked from the table above. These all take an optional
`--write-flux` option which will cause the raw flux to be written to the
specified file.
specified file. There are various `--dump` options for showing raw data
during the decode process.
- `fluxengine write*`: writes various formats of disk. Again, see the
- `fluxengine write *`: writes various formats of disk. Again, see the
per-format documentation above.
- `fluxengine writeflux`: writes raw flux files. This is much less useful
Expand Down
12 changes: 9 additions & 3 deletions lib/decoders/decoders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void AbstractDecoder::decodeToSectors(Track& track)
beginTrack();
for (;;)
{
Fluxmap::Position recordStart = sector.position = fmr.tell();
Fluxmap::Position recordStart = fmr.tell();
sector.clock = 0;
sector.status = Sector::MISSING;
sector.data.clear();
Expand All @@ -41,7 +41,7 @@ void AbstractDecoder::decodeToSectors(Track& track)

/* Read the sector record. */

recordStart = fmr.tell();
sector.position = recordStart = fmr.tell();
decodeSectorRecord();
Fluxmap::Position recordEnd = fmr.tell();
pushRecord(recordStart, recordEnd);
Expand All @@ -51,7 +51,13 @@ void AbstractDecoder::decodeToSectors(Track& track)

sector.headerStartTime = recordStart.ns();
sector.headerEndTime = recordEnd.ns();
r = advanceToNextRecord();
for (;;)
{
r = advanceToNextRecord();
if (r != UNKNOWN_RECORD)
break;
fmr.readNextMatchingOpcode(F_OP_PULSE);
}
recordStart = fmr.tell();
if (r == DATA_RECORD)
decodeDataRecord();
Expand Down
20 changes: 19 additions & 1 deletion lib/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ static SettableFlag justRead(

static SettableFlag dumpRecords(
{ "--dump-records" },
"Dump the parsed records.");
"Dump the parsed but undecoded records.");

static SettableFlag dumpSectors(
{ "--dump-sectors" },
"Dump the decoded sectors.");

static IntFlag retries(
{ "--retries" },
Expand Down Expand Up @@ -234,6 +238,20 @@ void readDiskCommand(AbstractDecoder& decoder)
}
}

if (dumpSectors)
{
std::cout << "\nDecoded sectors follow:\n\n";
for (auto& i : readSectors)
{
auto& sector = i.second;
std::cout << fmt::format("{}.{:02}.{:02}: I+{:.2f}us with {:.2f}us clock\n",
sector->logicalTrack, sector->logicalSide, sector->logicalSector,
sector->position.ns() / 1000.0, sector->clock / 1000.0);
hexdump(std::cout, sector->data);
std::cout << std::endl;
}
}

int size = 0;
bool printedTrack = false;
for (auto& i : readSectors)
Expand Down
5 changes: 0 additions & 5 deletions src/fe-readaeslanier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

static FlagGroup flags { &readerFlags };

static StringFlag outputFilename(
{ "--output", "-o" },
"The output image file to write to.",
"aeslanier.img");

int mainReadAESLanier(int argc, const char* argv[])
{
setReaderDefaultSource(":t=0-79:s=0");
Expand Down

0 comments on commit e517f28

Please sign in to comment.