diff options
author | root <root@no.no.james.local> | 2019-02-26 15:38:49 +0000 |
---|---|---|
committer | root <root@no.no.james.local> | 2019-02-26 15:38:49 +0000 |
commit | 9ada072d5337a582e987ed57dc4816189208dea7 (patch) | |
tree | 657295fefd5ec9ec153f92ba77bd46d82b0977f8 /msf.c | |
parent | 89aa56f25116fc642928f352c14fe2d485532749 (diff) | |
download | gen_msf-9ada072d5337a582e987ed57dc4816189208dea7.tar.gz gen_msf-9ada072d5337a582e987ed57dc4816189208dea7.tar.bz2 gen_msf-9ada072d5337a582e987ed57dc4816189208dea7.zip |
fix bcd encoder
Diffstat (limited to 'msf.c')
-rw-r--r-- | msf.c | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -1,6 +1,28 @@ #include "project.h" +static int check_min_ident (uint8_t *i) +{ + if (i[0]) return 1; + + if (!i[1]) return 1; + + if (!i[2]) return 1; + + if (!i[3]) return 1; + + if (!i[4]) return 1; + + if (!i[5]) return 1; + + if (!i[6]) return 1; + + if (i[7]) return 1; + + return 0; +} + + static void msf_set_ident (uint8_t *i) @@ -51,6 +73,35 @@ static void msf_make_bits (UTC u, uint8_t *a, uint8_t *b) } +static void process_bits (uint8_t *bitsa, uint8_t *bitsb) +{ + UTC u; + + + if (check_min_ident (&bitsa[52])) return; + + if (check_parity (bitsa, 17, 24, bitsb[54])) return; + + if (check_parity (bitsa, 25, 35, bitsb[55])) return; + + if (check_parity (bitsa, 36, 38, bitsb[56])) return; + + if (check_parity (bitsa, 39, 51, bitsb[57])) return; + + u.jday = 0; + u.year = bcd (bitsa, 17, 24); + u.month = bcd (bitsa, 25, 29); + u.mday = bcd (bitsa, 30, 35); + u.hour = bcd (bitsa, 39, 44); + u.minute = bcd (bitsa, 45, 51); + u.second = 0; + u.nanosecond = 0; + + + + printf ("MSF: decoded %02d-%02d-%02d %02d:%02d\r\n", u.year, u.month, u.mday, u.hour, u.minute); +} + void msf_make_stream (uint8_t *v, UTC u) @@ -60,6 +111,7 @@ void msf_make_stream (uint8_t *v, UTC u) uint8_t *pa, *pb; msf_make_bits (u, a, b); + process_bits (a, b); bzero (v, 600); |