summaryrefslogtreecommitdiff
path: root/bin
diff options
authorPMR <pmr@pmr-lander>2019-12-19 15:15:57 +0000
committerPMR <pmr@pmr-lander>2019-12-19 15:15:57 +0000
commitc3819c208818c73bb94caa8497b60607018cd66d (patch)
tree1e3196ae5cf2e7cba808194c2ded8beb9a086a07 /bin
parent7899c55f4ac4f2bc98337b62c1debe77ccead729 (diff)
parent6fa95f482b6d63f78c37937942ac86586a28f126 (diff)
Merge #376987 from ~jocave/plainbox-provider-checkbox:chameleon-hotplug
Diffstat (limited to 'bin')
-rwxr-xr-xbin/chameleon_hdmi_hotplug.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/bin/chameleon_hdmi_hotplug.py b/bin/chameleon_hdmi_hotplug.py
new file mode 100755
index 0000000..7366886
--- /dev/null
+++ b/bin/chameleon_hdmi_hotplug.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+
+import sys
+import time
+
+import xmlrpc.client
+
+
+def Chameleon(host, port=9992):
+ """
+ Get a proxy object that is used to control the Chameleon board.
+
+ The interface definition for this object can be found at:
+ https://chromium.googlesource.com/chromiumos/platform/chameleon/+/refs/heads/master/chameleond/interface.py
+ """
+ print('== Chameleon connection ==')
+ print('Target device: {}:{}'.format(host, port))
+ proxy = xmlrpc.client.ServerProxy('http://{}:{}'.format(host, port))
+ try:
+ # test the proxy works
+ mac = proxy.GetMacAddress()
+ print('MAC address: {}'.format(mac))
+ except OSError as e:
+ print(e)
+ raise SystemExit('ERROR connecting to Chameleon board')
+ print()
+ return proxy
+
+
+def get_hdmi_port(chameleon):
+ supported_ports = chameleon.GetSupportedPorts()
+ for port in supported_ports:
+ port_type = chameleon.GetConnectorType(port)
+ if port_type == 'HDMI':
+ return port
+
+
+def get_hdmi_status(drm_id):
+ path = '/sys/class/drm/{}/status'.format(drm_id)
+ with open(path) as sys_f:
+ return sys_f.readline().strip()
+
+
+if __name__ == '__main__':
+ drm_id = sys.argv[1]
+ c = Chameleon(sys.argv[2])
+
+ start = get_hdmi_status(drm_id)
+ print('Starting status: {}'.format(start))
+ print(flush=True)
+
+ port_num = get_hdmi_port(c)
+
+ print('chameleon> plug hdmi')
+ c.Plug(port_num)
+ time.sleep(10)
+
+ new_status = get_hdmi_status(drm_id)
+ print('Status after plug request: {}'.format(new_status))
+ print(flush=True)
+ if new_status != 'connected':
+ raise SystemExit('FAIL: hdmi not connected')
+
+ print('chameleon> unplug hdmi')
+ c.Unplug(port_num)
+ time.sleep(10)
+
+ final_status = get_hdmi_status(drm_id)
+ print('Status after unplug request: {}'.format(final_status))
+ print(flush=True)
+ if final_status != 'disconnected':
+ raise SystemExit('FAIL: hdmi did not disconnect')
+
+ print('PASS')