rp_get_sayma_data: Prettify human-readable output

This commit is contained in:
Harry Ho 2021-10-06 14:37:53 +08:00
parent 8b397c0728
commit 1688ceecde

View File

@ -114,13 +114,25 @@ def main():
print("Succesfully written y2 raw data from RP {}.".format(rp.name))
if args.txt:
header = '''\
RedPitaya Oscilloscope Reading
RP Hostname: {} ({})
RP Channel: Input {} ({})
Date & Time: {}
------
'''
y1 = [float(i) for i in y1_raw.split(',')]
y2 = [float(i) for i in y2_raw.split(',')]
with open(os.path.join(args.dir, 'rp_{}_y1_raw.txt'.format(rp.name)), 'w') as f:
f.write(''.join([l.lstrip(' ') for l in header.format(
RP_IP_ADDRS[rp.name], rp.name, 1, ch1_gain.upper(), now_iso).splitlines(True)]))
for i in y1:
f.write(str(i) + '\n')
print("Succesfully written y1 human-readable data from {}.".format(rp.name))
with open(os.path.join(args.dir, 'rp_{}_y2_raw.txt'.format(rp.name)), 'w') as f:
f.write(''.join([l.lstrip(' ') for l in header.format(
RP_IP_ADDRS[rp.name], rp.name, 2, ch2_gain.upper(), now_iso).splitlines(True)]))
for i in y2:
f.write(str(i) + '\n')
print("Succesfully written y2 human-readable data from {}.".format(rp.name))