Skip to content

Instantly share code, notes, and snippets.

@somidad
Last active November 28, 2016 09:38
Show Gist options
  • Save somidad/5372beaf5c295e71eae132d2c44f071d to your computer and use it in GitHub Desktop.
Save somidad/5372beaf5c295e71eae132d2c44f071d to your computer and use it in GitHub Desktop.
import pandas as pd
pd.set_option('max_rows', 999,
'expand_frame_repr', False)
def parse_reg(h):
txt = ''
if not h & (1 << 0):
return '-'
if not h & (1 << 1):
txt += 'NO-IBSS '
if not h & (1 << 3):
txt += 'PASSIVE-SCAN '
if h & (1 << 4):
txt += 'RADAR-DETECT '
if h & (1 << 7):
txt += 'DFS '
return txt
def unset_reg(h):
if not h & (1 << 0):
return h
h |= (1 << 1) # IBSS
h |= (1 << 3) # active scan
h &= ~(1 << 4) # disable radar detection
h &= ~(1 << 7) # disable DFS
return h
fname = 'eeprom_dump'
f = open(fname, 'r')
raw_data = list(f)
N = len(raw_data)
data = [[None for x in range(6)] for y in range(N)]
for i in range(N):
splited = raw_data[i].split(':')
for j in range(2):
data[i][j] = splited[j].strip()
data[i][2] = bin(int(data[i][1], 16))
data[i][3] = parse_reg(int(data[i][1], 16))
data[i][4] = hex(unset_reg(int(data[i][1], 16)))[2:]
data[i][4] = '0' * (4-len(data[i][4])) + data[i][4]
data[i][5] = parse_reg(int(data[i][4], 16))
df = pd.DataFrame(data=data,
columns=['Channel', 'Reg (Hex)', 'Reg (Bin)', 'Reg (for Human)', 'Reg Unset', 'Reg Unset (for Human)'])
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment