-
Notifications
You must be signed in to change notification settings - Fork 1
/
pro93-dump-explore
executable file
·185 lines (146 loc) · 4.97 KB
/
pro93-dump-explore
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env python3
import struct
import decoder
import csv
import argparse
parser = argparse.ArgumentParser(description='Decodes an image.')
parser.add_argument('imagefile', help='Image file to decode')
args = parser.parse_args()
bank_radix = 100
banks = 10
channels_per_bank = 30
channels = banks * channels_per_bank
tg_sub_banks_per_bank = 5
tg_mem_per_sub_bank = 20
tg_mem_per_bank = tg_sub_banks_per_bank * tg_mem_per_sub_bank
talkgroups = banks * tg_mem_per_bank
# CB and Marine search are channelized and handled seperatly
search_groups = 4
search_lockout_max = 50
search_lockout_count = []
search_lockout_freq = []
cb_channels_count = 40
cb_channels = []
marine_channels_count = 60
marine_channels = []
sectionA = []
memory = []
text_tags = []
tg_memory = []
tg_text_tags = []
limit_search_low = None
limit_search_high = None
priority = None
bank_text_tags = []
limit_search_text_tag = None
fn = args.imagefile
with open(fn, 'rb') as f:
for i in range(channels):
bs = f.read(4)
memory.append(decoder.channel.decode(bs))
for i in range(channels):
bs = f.read(12)
text_tags.append(decoder.text_tag.decode(bs))
for i in range(talkgroups):
bs = f.read(2)
tg_memory.append(decoder.talk_group.decode(bs))
ip = i % tg_mem_per_bank
# Not sure what this is, but I needed it in order to get some
# preëxisting tags to line up.
# Seems to be 000000000000000000647c01c0c71800d007000000000000
# for all 10 of my banks.
# end? Could the sub bank text tag be in here? those normally have
# text or 0xff though.
if ip == (tg_mem_per_bank - 1):
bs = f.read(24)
for i in range(search_groups):
# Toss the 0xff away
bs = f.read(1)
# Gets the number of lockouts
bs = f.read(1)
search_lockout_count.append(int(bs[0]))
freqs = []
for j in range(search_lockout_max):
bs = f.read(4)
freqs.append(decoder.channel.decode(bs))
search_lockout_freq.append(freqs)
for i in range(talkgroups):
bs = f.read(12)
tg_text_tags.append(decoder.text_tag.decode(bs))
for i in range(cb_channels_count):
bs = f.read(1)
cb_channels.append(decoder.chan_flags.decode(bs))
# Unsure
bs = f.read(64)
for i in range(marine_channels_count):
bs = f.read(1)
marine_channels.append(decoder.chan_flags.decode(bs))
# Unsure
bs = f.read(4)
bs = f.read(12)
limit_search_text_tag = decoder.text_tag.decode(bs)
for i in range(banks):
bs = f.read(12)
bank_text_tags.append(decoder.text_tag.decode(bs))
# Unsure
bs = f.read(12)
bs = f.read(38)
bs = f.read(4)
limit_search_low = decoder.channel.decode(bs)
bs = f.read(4)
limit_search_high = decoder.channel.decode(bs)
bs = f.read(4)
priority = decoder.channel.decode(bs)
with open(fn + ".channels.csv", 'w') as csvfile:
spamwriter = csv.writer(csvfile)
spamwriter.writerow(["i", "memory_slot", "text_tag", "freq",
"delay", "attenuated", "lockout", "mode"])
for i in range(channels):
memory_slot = decoder.index_to_memory_slot(i, channels_per_bank, bank_radix)
memory_slot = f"{memory_slot:03d}"
print(f"memory[{i}] {memory_slot} {memory[i]} {text_tags[i]}")
freq = memory[i].freq
flags = memory[i].flags
unused = freq.unused
ffreq = None
delay = None
atten = None
lockout = None
mode = None
text_tag = None
if not unused:
ffreq = str(freq.freq)
delay = flags.delay
atten = flags.atten
lockout = flags.lockout
mode = decoder.mode_map[flags.mode]
text_tag = text_tags[i]
spamwriter.writerow([
i,
"'" + memory_slot, # GD Lotus 1-2-3, and then Excel, and not LibreOffice Calc
text_tag,
ffreq,
delay,
atten,
lockout,
mode
])
for i in range(talkgroups):
tg_id = decoder.index_to_tg_memory_slot(i, tg_mem_per_sub_bank, tg_sub_banks_per_bank)
print(f"{tg_id} {tg_memory[i]} {tg_text_tags[i]}")
for i in range(search_groups):
lockouts = ", ".join([f"{f}" for f in search_lockout_freq[i] if not f.freq.unused])
print(f"SR{i+2} {search_lockout_count[i]:02} {lockouts}")
for i in range(cb_channels_count):
print(f"CB Chan#{i+1} {cb_channels[i]}")
for i in range(marine_channels_count):
print(f"Marine Chan#{i+1} {marine_channels[i]}")
with open(fn + ".bank_names.csv", 'w') as csvfile:
spamwriter = csv.writer(csvfile)
spamwriter.writerow(["i", "name"])
for i in range(banks):
print(f"Bank {i}: {bank_text_tags[i]}")
spamwriter.writerow([i, bank_text_tags[i]])
print(f"Limit Search Text: {limit_search_text_tag}")
print(f"Limit Search Range: {limit_search_low} - {limit_search_high}")
print(f"Priority Channel: {priority}")