| 214 | } |
| 215 | |
| 216 | void testStateTransitions() |
| 217 | { |
| 218 | HdlcCodec codec; |
| 219 | report("initial state: searching", codec.searching()); |
| 220 | report("initial state: not in preamble", !codec.inPreamble()); |
| 221 | report("initial state: not in frame", !codec.inFrame()); |
| 222 | report("initial state: not complete", !codec.complete()); |
| 223 | |
| 224 | // Feed one preamble flag: 0x7E = 0,1,1,1,1,1,1,0 (NRZ LSB-first) |
| 225 | // NRZI encode it starting from level 0. |
| 226 | uint8_t level = 0; |
| 227 | const uint8_t nrzFlag[8] = {0, 1, 1, 1, 1, 1, 1, 0}; |
| 228 | for (int i = 0; i < 8; ++i) { |
| 229 | if (nrzFlag[i] == 0) |
| 230 | level ^= 1; |
| 231 | codec.processBit(level); |
| 232 | } |
| 233 | report("after one flag: in preamble", codec.inPreamble()); |
| 234 | } |
| 235 | |
| 236 | void testLongPayload() |
| 237 | { |
no test coverage detected