Target: arm上实际采集的数据,byte输出,读取数据并输出来;
格式为
意义 | 格式 | 大小 |
---|---|---|
PPDU_ID | 1个int32 | 4B |
mac_id | 1个int32 | 4B |
mac_addr | 1个6字节 hex | 6B |
data 1 dim数组 | 256长度复数,先实部后虚部都是float16 | 256x4B |
import numpy as np
import binascii
import matplotlib.pyplot as plt
f = open(r'./phone_2020_08_22__16_26_57.dat','rb')
buf = f.read()
#####4B ppduID, 4B MPDUid, 6B mac Addr, 256*4B data,
x1 = np.frombuffer(buf[0:4],dtype=np.uint32)
print(x1)
x2 = np.frombuffer(buf[4:8],dtype=np.uint32)
print(x2)
mac0 = np.frombuffer(buf[8:14],dtype=np.uint8)
mac = '-'.join([np.base_repr(i,16) if m>15 else '0'+str(m) for i in mac0 ])
mac_secondWay = binascii.hexlify(buf[8:14]).decode('utf-8')
print('Mac 1st way:', type(mac0[0]),mac, 'mac second way\n', mac_secondWay)
dt = np.dtype(np.float16)
dt = dt.newbyteorder('<') #arm核上所采数据,通常是小端
dataCsi = np.frombuffer(buf[14:14+256*4],dtype=dt)
print('Data is :\n', dataCsi)
plt.figure()
plt.plot(range(len(dataCsi)),dataCsi)
st = 14+256*4
id1 = np.frombuffer(buf[st:st+4],dtype=np.uint32)
id2 = np.frombuffer(buf[st+4:st+8],dtype=np.uint32)
mac_raw = np.frombuffer(buf[st+8:st+14],dtype= np.uint8)
mac2 = [np.base_repr(m,16) if m>15 else '0'+str(m) for m in mac_raw]
print('Second ppdu is :', id1,id2, mac2)
dataCsi2 = np.frombuffer(buf[st+14:st+14+256*4],dtype=dt)
print('4 of Data is:\n',dataCsi2[0:4])
plt.figure()
plt.plot(dataCsi2[0::2],dataCsi2[1::2],'b.')
plt.show()