| 68 | } |
| 69 | |
| 70 | void testFrameContents() |
| 71 | { |
| 72 | lm::packet pkt("W5XD", "APRS", {}, ">Hello world"); |
| 73 | auto nrzi = makeNrziBitstream(pkt); |
| 74 | |
| 75 | HdlcCodec codec; |
| 76 | bool gotFrame = false; |
| 77 | for (uint8_t bit : nrzi) { |
| 78 | if (codec.processBit(bit)) { |
| 79 | gotFrame = true; |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | report("frame contents: complete flag set", gotFrame && codec.complete()); |
| 85 | report("frame contents: FCS valid", codec.fcsValid()); |
| 86 | report("frame contents: at least 15 bytes", codec.frameSize() >= 15); |
| 87 | |
| 88 | // Verify via libmodem's AX.25 parser (passing frame without last 2 FCS bytes) |
| 89 | if (codec.fcsValid() && codec.frameSize() >= 2) { |
| 90 | lm::packet decoded; |
| 91 | bool ok = lm::ax25::try_decode_frame_no_fcs( |
| 92 | std::span<const uint8_t>(codec.frameData(), codec.frameSize() - 2), |
| 93 | decoded); |
| 94 | report("frame contents: libmodem parses callsigns", ok && decoded.from == "W5XD"); |
| 95 | report("frame contents: libmodem parses data", |
| 96 | ok && decoded.data == ">Hello world"); |
| 97 | } else { |
| 98 | report("frame contents: libmodem parses callsigns", false); |
| 99 | report("frame contents: libmodem parses data", false); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void testFcsMatchesLibmodem() |
| 104 | { |
no test coverage detected