forked from muccc/iridium-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bits_to_dfs.py
executable file
·53 lines (43 loc) · 1.35 KB
/
bits_to_dfs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import fileinput
import sys
"""
VOC: i-1443338945.6543-t1 033399141 1625872817 81% 0.027 179 L:no LCW(0,001111,100000000000000000000 E1) 01111001000100010010010011011011011001111 011000010000100001110101111011110010010111011001010001011101010001100000000110010100000110111110010101110101001111010100111001000110100110001110110 1010101010010010001000001110011000001001001010011110011100110100111110001101110010110101010110011101011100011101011000000000 descr_extra:
"""
def turn_symbols(byte):
out = 0
if byte & 0x01:
out |= 0x02
if byte & 0x02:
out |= 0x01
if byte & 0x04:
out |= 0x08
if byte & 0x08:
out |= 0x04
if byte & 0x10:
out |= 0x20
if byte & 0x20:
out |= 0x10
if byte & 0x40:
out |= 0x80
if byte & 0x80:
out |= 0x40
return out
def chunks(l, n):
""" Yield successive n-sized chunks from l.
"""
for i in xrange(0, len(l), n):
yield l[i:i+n]
infile = sys.argv[1]
outfile = open(sys.argv[2], 'wb')
data = ''
for line in fileinput.input(infile):
line = line.split()
if line[0] == 'VOC:':
if int(line[6]) < 179:
continue
data = line[10]
#print data
for bits in chunks(data, 8):
byte = int(bits[::-1],2)
outfile.write(chr(turn_symbols(byte)))