66 lines
1.3 KiB
Python
66 lines
1.3 KiB
Python
#!/usr/bin/python3
|
|
|
|
import optparse
|
|
import os
|
|
import time
|
|
|
|
import DeviceInterface
|
|
from LinuxPtpObserver import LinuxPtpObserver
|
|
from TestController import TestController
|
|
from GUI import GUI
|
|
|
|
# ----------------------------------
|
|
|
|
gui = GUI()
|
|
|
|
gui.mainloop()
|
|
|
|
exit(0)
|
|
|
|
usage = "<device/url> <interface> [-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)
|
|
|
|
def echo(str: str) -> None:
|
|
print(str, end="")
|
|
|
|
di.register_out_callback(echo)
|
|
|
|
# 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 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!")
|
|
|
|
lptp_observer = LinuxPtpObserver(args[1])
|
|
lptp_observer.register_observer_callback(echo)
|
|
|
|
tc = TestController(di, lptp_observer)
|
|
|
|
tc.start_test_gPTP()
|
|
|
|
time.sleep(15)
|
|
|
|
tc.stop_test()
|
|
tc.start_test_e2e_udp()
|
|
|
|
time.sleep(15)
|
|
|
|
tc.stop_test()
|
|
|
|
di.close() |