mod parser and config entry for new format
This commit is contained in:
parent
418921b6d3
commit
040a880d68
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in `seq 1 1000`; do
|
||||
for i in `seq 1 100`; do
|
||||
sudo /usr/sbin/iw wlp58s0 measurement ftm_request config_entry | tail -n +3 >> result_$1
|
||||
sleep 0.01
|
||||
done
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
34:f6:4b:5e:69:1f bw=20 cf=2462 retries=5 asap
|
||||
34:f6:4b:5e:69:1f bw=20 cf=2462 retries=3 asap spb=255
|
||||
|
|
|
|||
24
iw_parser.py
24
iw_parser.py
|
|
@ -11,17 +11,27 @@ def wrapper(args):
|
|||
if not args['filepath'] or not os.path.isfile(args['filepath']):
|
||||
return
|
||||
results = []
|
||||
regex = (
|
||||
r"Target: (([0-9a-f]{2}:*){6}), " +
|
||||
r"status: ([0-9]), rtt: ([0-9\-]+) \(±([0-9\-]+)\) psec, " +
|
||||
r"distance: ([0-9\-]+) \(±([0-9\-]+)\) cm, rssi: ([0-9\-]+) dBm"
|
||||
)
|
||||
with open(args['filepath']) as f:
|
||||
for line in f:
|
||||
tmp = line.rstrip().split(', ')
|
||||
status = int(tmp[1].split(' ')[1])
|
||||
if status is not 0:
|
||||
match = re.search(regex, line)
|
||||
if match:
|
||||
mac = match.group(1)
|
||||
status = int(match.group(3))
|
||||
rtt = int(match.group(4))
|
||||
rtt_var = int(match.group(5))
|
||||
raw_distance = int(match.group(6))
|
||||
raw_distance_var = int(match.group(7))
|
||||
rssi = int(match.group(8))
|
||||
else:
|
||||
continue
|
||||
psec = int(tmp[2].split(' ')[1])
|
||||
distance = int(tmp[3].split(' ')[1])
|
||||
if distance < -1000:
|
||||
if status is not 0 or raw_distance < -1000:
|
||||
continue
|
||||
results.append(distance * args['cali'][0] + args['cali'][1])
|
||||
results.append(raw_distance * args['cali'][0] + args['cali'][1])
|
||||
print('statics of results')
|
||||
print('* num of valid data: {0}'.format(len(results)))
|
||||
print('* min: {0:.2f}cm'.format(min(results)))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class Measurement(object):
|
|||
try:
|
||||
self.outf = open(ofp, 'w')
|
||||
self.outf.write(
|
||||
'MAC,caliDist(cm),rawRTT(psec),rawDist(cm),time(sec)\n'
|
||||
'MAC,caliDist(cm),rawRTT(psec),rawRTTVar,rawDist(cm),' +
|
||||
'rawDistVar,rssi(dBm),time(sec)\n'
|
||||
)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
|
@ -121,18 +122,22 @@ class Measurement(object):
|
|||
result.append((mac, distance, rtt, raw_distance))
|
||||
if self.outf is not None:
|
||||
self.outf.write(
|
||||
"{0},{1:.2f},{2},{3},{4:.6f}\n".format(
|
||||
mac, distance, rtt, raw_distance, time.time()
|
||||
"{0},{1:.2f},{2},{3},{4},{5},{6},{7:.6f}\n".format(
|
||||
mac, distance, rtt, rtt_var,
|
||||
raw_distance, raw_distance_var,
|
||||
rssi, time.time()
|
||||
)
|
||||
)
|
||||
return result
|
||||
|
||||
def get_distance_median(self, rounds=10):
|
||||
def get_distance_median(self, rounds=1):
|
||||
'''
|
||||
use median instead of mean for less bias with small number of rounds
|
||||
'''
|
||||
result = {}
|
||||
median_result = {}
|
||||
if rounds < 1:
|
||||
rounds = 1
|
||||
for i in range(rounds):
|
||||
# no guarantee that all rounds are successful
|
||||
for each in self.get_distance_once():
|
||||
|
|
@ -199,9 +204,9 @@ def main():
|
|||
)
|
||||
p.add_argument(
|
||||
'--rounds',
|
||||
default=10,
|
||||
default=3,
|
||||
type=int,
|
||||
help="how many rounds to run one command; default is 10"
|
||||
help="how many rounds to run one command; default is 3"
|
||||
)
|
||||
p.add_argument(
|
||||
'--interface', '-i',
|
||||
|
|
|
|||
Loading…
Reference in New Issue