Skip to content
Snippets Groups Projects
Commit a0bb01df authored by Christos Gentsos's avatar Christos Gentsos
Browse files

Utils: fix python tty device detection (select the last dmesg entry)

parent 124cad9e
Branches
No related merge requests found
......@@ -4,11 +4,18 @@ import matplotlib.pyplot as plt
import numpy as np
import io, os
tty_enum = os.popen('./get_tty_devs.sh').read().strip().split('\n')
psu_tty_dev = '/dev/' + next((a for a in tty_enum if a.find('KORAD') > 0), '').split(':')[0]
if psu_tty_dev != '/dev/':
def find_tty_dev(dev_name):
tty_enum = os.popen('./get_tty_devs.sh').read().strip().split('\n')
# only keep the last entry that way
tty_dev = ''
for a in tty_enum:
if a.find(dev_name) > 0:
tty_dev = '/dev/' + a.split(':')[0]
return(tty_dev)
psu_tty_dev = find_tty_dev('KORAD')
if psu_tty_dev != '':
print('found PSU TTY device: ' + psu_tty_dev)
else:
print('couldn\'t find PSU TTY device')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment