| 16 | * with it. */ |
| 17 | |
| 18 | class AesLanierDecoder : public Decoder |
| 19 | { |
| 20 | public: |
| 21 | AesLanierDecoder(const DecoderProto& config): Decoder(config) {} |
| 22 | |
| 23 | nanoseconds_t advanceToNextRecord() override |
| 24 | { |
| 25 | return seekToPattern(SECTOR_PATTERN); |
| 26 | } |
| 27 | |
| 28 | void decodeSectorRecord() override |
| 29 | { |
| 30 | /* Skip ID mark (we know it's a AESLANIER_RECORD_SEPARATOR). */ |
| 31 | |
| 32 | readRawBits(16); |
| 33 | |
| 34 | const auto& rawbits = readRawBits(AESLANIER_RECORD_SIZE * 16); |
| 35 | const auto& bytes = |
| 36 | decodeFmMfm(rawbits).slice(0, AESLANIER_RECORD_SIZE); |
| 37 | const auto& reversed = bytes.reverseBits(); |
| 38 | |
| 39 | _sector->logicalCylinder = reversed[1]; |
| 40 | _sector->logicalHead = 0; |
| 41 | _sector->logicalSector = reversed[2]; |
| 42 | |
| 43 | /* Check header 'checksum' (which seems far too simple to mean much). */ |
| 44 | |
| 45 | { |
| 46 | uint8_t wanted = reversed[3]; |
| 47 | uint8_t got = reversed[1] + reversed[2]; |
| 48 | if (wanted != got) |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | /* Check data checksum, which also includes the header and is |
| 53 | * significantly better. */ |
| 54 | |
| 55 | _sector->data = reversed.slice(1, AESLANIER_SECTOR_LENGTH); |
| 56 | uint16_t wanted = reversed.reader().seek(0x101).read_le16(); |
| 57 | uint16_t got = crc16ref(MODBUS_POLY_REF, _sector->data); |
| 58 | _sector->status = (wanted == got) ? Sector::OK : Sector::BAD_CHECKSUM; |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | std::unique_ptr<Decoder> createAesLanierDecoder(const DecoderProto& config) |
| 63 | { |
nothing calls this directly
no outgoing calls
no test coverage detected