flexPTP-test/test_main.py
András Wiesner df1d6a9f1c - initial
2026-04-23 10:34:28 +02:00

32 lines
831 B
Python

#!/usr/bin/python3
import optparse
import DeviceInterface
# ----------------------------------
usage = "<device/url> [-s <baudrate>]"
parser = optparse.OptionParser(usage=usage)
parser.add_option("-s", dest="baudrate", default=115200)
opts, args = parser.parse_args()
missing = (
len(args) < 1
)
if missing:
print("Something is missing! Usage:", usage)
exit(0)
di = DeviceInterface.DeviceInterface(url=args[0], options={"baudrate": opts.baudrate })
#results = di.execute_command("osinfo")
#print(results)
# get device clock identity
OWN_CLOCK_ID_KEY = "Own clock ID"
clock_id = di.execute_command("ptp info", separate_results=True)
if type(clock_id) == dict[str, str] and OWN_CLOCK_ID_KEY in clock_id:
print("Own clock ID:", clock_id[OWN_CLOCK_ID_KEY])
else:
print("Could not retrieve device clock ID!")