Skip to content

Commit

Permalink
Calculate gaps in bits, not bytes (more accurate). Pad the end of the…
Browse files Browse the repository at this point in the history
… track to

avoid weirdness reading the last sector.
  • Loading branch information
davidgiven committed Apr 30, 2024
1 parent 3e053b3 commit 8876aae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
15 changes: 7 additions & 8 deletions arch/tartu/encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ class TartuEncoder : public Encoder
_bits.resize(bitsPerRevolution);
_cursor = 0;

writeFillerRawBytesUs(_config.gap1_us());
writeFillerRawBitsUs(_config.gap1_us());
bool first = true;
for (const auto& sectorData : sectors)
{
if (!first)
writeFillerRawBytesUs(_config.gap4_us());
writeFillerRawBitsUs(_config.gap4_us());
first = false;
writeSector(sectorData);
}

if (_cursor > _bits.size())
error("track data overrun");
writeFillerRawBitsUs(_config.target_rotational_period_ms() * 1000.0);

std::unique_ptr<Fluxmap> fluxmap(new Fluxmap);
fluxmap->appendBits(_bits,
Expand Down Expand Up @@ -67,13 +68,11 @@ class TartuEncoder : public Encoder
}
}

void writeFillerRawBytesUs(double us)
void writeFillerRawBitsUs(double us)
{
uint16_t byte = _config.gap_fill_byte();
unsigned count = (us / _clockRateUs) / 16;
fmt::print("count={}\n", count);
unsigned count = (us / _clockRateUs) / 2;
for (int i = 0; i < count; i++)
writeRawBits(byte, 16);
writeRawBits(0b10, 2);
};

void writeSector(const std::shared_ptr<const Sector>& sectorData)
Expand All @@ -90,7 +89,7 @@ class TartuEncoder : public Encoder
writeBytes(bytes);
}

writeFillerRawBytesUs(_config.gap3_us());
writeFillerRawBitsUs(_config.gap3_us());
writeRawBits(_config.data_marker(), 64);
{
Bytes bytes;
Expand Down
3 changes: 0 additions & 3 deletions arch/tartu/tartu.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ message TartuEncoderProto {
optional uint64 data_marker = 7
[ default = 0xaaaaaaaa44895545,
(help) = "64-bit raw bit pattern of data record marker" ];
optional uint32 gap_fill_byte = 8
[ default = 0xaaaa,
(help) = "16-bit raw bit pattern of fill byte" ];
}

0 comments on commit 8876aae

Please sign in to comment.