diff options
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); |