another attempt

This commit is contained in:
2026-11-15 00:58:12 +01:00
parent e7ae3d3ee8
commit 7832c1968e
14 changed files with 332 additions and 126 deletions

No files matched your search

+34 -1
View File
@@ -86,6 +86,25 @@ int main(void)
}
}
// Radio RX: the chip locks anywhere in the preamble and the capture is cut off
// when the transmission ends (decoded on squelch close), in both FIFO byte orders.
assert(POCSAG_Encode(1234567U, "12345678901234567890", frame, sizeof(frame), NULL));
for (size_t lock = 0; lock < POCSAG_PREAMBLE_BYTES; lock++) {
const size_t size = sizeof(frame) - lock;
assert(POCSAG_Decode(frame + lock, size, 1234567U, NULL, decoded, sizeof(decoded)));
assert(strcmp(decoded, "12345678901234567890") == 0);
}
// Sync codeword with 2 bit errors (both batches) still decodes, also inverted.
assert(POCSAG_Encode(1234567U, "sync errors", frame, sizeof(frame), NULL));
frame[POCSAG_PREAMBLE_BYTES] ^= 0x81U;
frame[POCSAG_PREAMBLE_BYTES + POCSAG_BATCH_BYTES + 2U] ^= 0x18U;
assert(POCSAG_Decode(frame, sizeof(frame), 1234567U, NULL, decoded, sizeof(decoded)));
assert(strcmp(decoded, "sync errors") == 0);
invert(frame, sizeof(frame));
assert(POCSAG_Decode(frame, sizeof(frame), 1234567U, NULL, decoded, sizeof(decoded)));
assert(strcmp(decoded, "sync errors") == 0);
// Monitor mode: any address decodes and reports the RIC.
assert(POCSAG_Encode(1234567U, "Ahoj", frame, sizeof(frame), NULL));
assert(POCSAG_Decode(frame, sizeof(frame), POCSAG_ANY_RIC, &sender, decoded, sizeof(decoded)));
@@ -93,7 +112,21 @@ int main(void)
assert(!POCSAG_Encode(0x200000U, "bad", frame, sizeof(frame), NULL));
assert(!POCSAG_Encode(123U, "", frame, sizeof(frame), NULL));
assert(!POCSAG_Encode(123U, "123456789012345678901", frame, sizeof(frame), NULL));
// longest message, for every frame position, then one character too many
{
char longest[POCSAG_MAX_MESSAGE_LENGTH + 2U];
for (size_t i = 0; i < POCSAG_MAX_MESSAGE_LENGTH + 1U; i++)
longest[i] = (char) ('A' + i % 26U);
longest[POCSAG_MAX_MESSAGE_LENGTH] = '\0';
for (uint32_t ric = 0; ric < 8U; ric++) {
assert(POCSAG_Encode(1000000U + ric, longest, frame, sizeof(frame), NULL));
assert(POCSAG_Decode(frame, sizeof(frame), 1000000U + ric, NULL, decoded, sizeof(decoded)));
assert(strcmp(decoded, longest) == 0);
}
longest[POCSAG_MAX_MESSAGE_LENGTH] = 'X';
longest[POCSAG_MAX_MESSAGE_LENGTH + 1U] = '\0';
assert(!POCSAG_Encode(123U, longest, frame, sizeof(frame), NULL));
}
assert(!POCSAG_Encode(123U, "ok", frame, sizeof(frame) - 1U, NULL));
puts("pocsag tests passed");