-
-
Save mhagger/14897a49bff3f3286cdb to your computer and use it in GitHub Desktop.
This is binary data captured from a car stereo and it's companion cd changer. The stereo updates it's screen with the cd track minutes and "seconds". Each row below corresponds to the "seconds". Column 1 is the seconds, 2 is binary, 3 is 2 inverted. The goal is figuring out how to generate the seconds from 0's & 1's without the table below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seconds | message | inverted-message | |
---|---|---|---|
4 | 110 | 001 | |
5 | 00101 | 11010 | |
6 | 10100 | 01011 | |
7 | 01100 | 10011 | |
8 | 11101 | 00010 | |
9 | 00011 | 11100 | |
10 | 10010 | 01101 | |
11 | 0000101 | 1111010 | |
12 | 1000100 | 0111011 | |
13 | 0100100 | 1011011 | |
14 | 1100101 | 0011010 | |
15 | 0010100 | 1101011 | |
16 | 1010101 | 0101010 | |
17 | 0110101 | 1001010 | |
18 | 1110100 | 0001011 | |
19 | 0001100 | 1110011 | |
20 | 1001101 | 0110010 | |
21 | 0000011 | 1111100 | |
22 | 1000010 | 0111101 | |
23 | 0100010 | 1011101 | |
24 | 1100011 | 0011100 | |
25 | 0010010 | 1101101 | |
26 | 1010011 | 0101100 | |
27 | 0110011 | 1001100 | |
28 | 1110010 | 0001101 | |
29 | 0001010 | 1110101 | |
30 | 1001011 | 0110100 | |
31 | 0000110 | 1111001 | |
32 | 1000111 | 0111000 | |
33 | 0100111 | 1011000 | |
34 | 1100110 | 0011001 | |
35 | 0010111 | 1101000 | |
36 | 1010110 | 0101001 | |
37 | 0110110 | 1001001 | |
38 | 1110111 | 0001000 | |
39 | 0001111 | 1110000 | |
40 | 1001110 | 0110001 | |
41 | 000000101 | 111111010 | |
42 | 100000100 | 011111011 | |
43 | 010000100 | 101111011 | |
44 | 110000101 | 001111010 | |
45 | 001000100 | 110111011 | |
46 | 101000101 | 010111010 | |
47 | 011000101 | 100111010 | |
48 | 111000100 | 000111011 | |
49 | 000100100 | 111011011 | |
50 | 100100101 | 011011010 | |
51 | 000010100 | 111101011 | |
52 | 100010101 | 011101010 | |
53 | 010010101 | 101101010 | |
54 | 110010100 | 001101011 | |
55 | 001010101 | 110101010 | |
56 | 101010100 | 010101011 | |
57 | 011010100 | 100101011 | |
58 | 111010101 | 000101010 | |
59 | 000110101 | 111001010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
data = [] | |
for line in open('messages.csv'): | |
line = line.rstrip() | |
if line.startswith('seconds'): | |
continue | |
(seconds, message, inverted) = line.split(',') | |
data.append([int(seconds), message]) | |
for (seconds, message) in data: | |
checksum = sum(c == '1' for c in message) & 0x01 | |
if checksum != 0: | |
raise RuntimeError("invalid checksum") | |
# Reverse the bits: | |
binary = message[::-1] | |
# Discard the parity bit: | |
binary = binary[1:] | |
# Left-pad with zeros: | |
binary = '0' * (8 - len(binary)) + binary | |
# Now it's binary-coded decimal. Decode it, one nibble at a time: | |
i = int(binary[:4], 2) * 10 + int(binary[4:], 2) | |
decoded_seconds = i + 1 | |
if decoded_seconds != seconds: | |
raise RuntimeError("invalid conversion") | |
print seconds, binary, decoded_seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment