aboutsummaryrefslogtreecommitdiff
path: root/fw/8b10b_test.c
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-12-20 22:42:17 +0900
committerjaseg <git@jaseg.net>2018-12-20 22:42:17 +0900
commit132fd4f9c0184be033533953cc2c7ae92da311d9 (patch)
tree634c961de6168237d915e459c53fb6d5f1aed8b3 /fw/8b10b_test.c
parent90038f4378b7cdbe98e32ed1e5e3055dbe4776f2 (diff)
download8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.tar.gz
8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.tar.bz2
8seg-132fd4f9c0184be033533953cc2c7ae92da311d9.zip
8b10b encoder and decoder working
Tested on all 24-bit inputs after sync and on ~500M of random input with and without intermediate sync
Diffstat (limited to 'fw/8b10b_test.c')
-rw-r--r--fw/8b10b_test.c78
1 files changed, 0 insertions, 78 deletions
diff --git a/fw/8b10b_test.c b/fw/8b10b_test.c
deleted file mode 100644
index d11e6b2..0000000
--- a/fw/8b10b_test.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-#include <stdio.h>
-
-#include "8b10b.h"
-
-static const char * const rc_names[] = {
- [K28_0] = "K.28.0",
- [K28_1] = "K.28.1",
- [K28_2] = "K.28.2",
- [K28_3] = "K.28.3",
- [K28_4] = "K.28.4",
- [K28_5] = "K.28.5",
- [K28_6] = "K.28.6",
- [K28_7] = "K.28.7",
- [K23_7] = "K.23.7",
- [K27_7] = "K.27.7",
- [K29_7] = "K.29.7",
- [K30_7] = "K.30.7",
- [DECODING_ERROR] = "ERROR",
- [DECODING_IN_PROGRESS] = "."
-};
-
-int main(void) {
- struct state_8b10b st;
-
- xfr_8b10b_reset(&st);
-
- int c;
- int comment = 0;
- while ((c=fgetc(stdin)) != EOF) {
- int bit;
-
- if (comment) {
- if (c == '\n')
- comment = 0;
- continue;
- }
-
- if (c == '\r' || c == ' ' || c == '\t' || c == '\n')
- continue;
-
- if (c == '#') {
- comment = 1;
- continue;
- }
-
- if (c == '0') {
- bit = 0;
- } else if (c == '1') {
- bit = 1;
- } else {
- fprintf(stderr, "Parse error: Bit must be 0 or 1, not '%c'. Exiting.\n", c);
- return 1;
- }
-
- int read_result = xfr_8b10b_feed_bit(&st, bit);
- char sync_status = xfr_8b10b_has_sync(&st) ? 'S' : 'U';
-
- if (read_result >= 0) {
- fprintf(stdout, "%c%02x ", sync_status, read_result);
-
- } else {
- if (-read_result > sizeof(rc_names)/sizeof(rc_names[0])) {
- fprintf(stderr, "Illegal read result %d. Exiting.\n", read_result);
- return 2;
- }
-
- const char * const msg = rc_names[-read_result];
- if (!msg) {
- fprintf(stderr, "Illegal read result %d. Exiting.\n", read_result);
- return 2;
- }
-
- fprintf(stdout, "%c%s ", sync_status, msg);
- }
- }
-}
-