MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / write_sector_data

Function write_sector_data

arch/brother/encoder.cc:60–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static void write_sector_data(
61 std::vector<bool>& bits, unsigned& cursor, const Bytes& data)
62{
63 write_bits(bits, cursor, 0xffffffff, 32);
64 write_bits(bits, cursor, BROTHER_DATA_RECORD, 32);
65
66 uint16_t fifo = 0;
67 int width = 0;
68
69 if (data.size() != BROTHER_DATA_RECORD_PAYLOAD)
70 error("unsupported sector size");
71
72 auto write_byte = [&](uint8_t byte)
73 {
74 fifo |= (byte << (8 - width));
75 width += 8;
76
77 while (width >= 5)
78 {
79 uint8_t quintet = fifo >> 11;
80 fifo <<= 5;
81 width -= 5;
82
83 write_bits(bits, cursor, encode_data_gcr(quintet), 8);
84 }
85 };
86
87 for (uint8_t byte : data)
88 write_byte(byte);
89
90 uint32_t realCrc = crcbrother(data);
91 write_byte(realCrc >> 16);
92 write_byte(realCrc >> 8);
93 write_byte(realCrc);
94 write_byte(0x58); /* magic */
95 write_byte(0xd4);
96 while (width != 0)
97 write_byte(0);
98}
99
100class BrotherEncoder : public Encoder
101{

Callers 1

encodeMethod · 0.85

Calls 6

errorFunction · 0.85
write_byteFunction · 0.85
crcbrotherFunction · 0.85
write_bitsFunction · 0.70
encode_data_gcrFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected