Commit 52078374 authored by Stefano Rivera's avatar Stefano Rivera

Add a test-station role

parent 842deb20
Pipeline #32615 passed with stage
in 2 minutes and 41 seconds
# test-station
Depends on the `opsis` role.
A speaker test-station, so that speakers can test their laptops with the
Opsis.
## Tasks
Everything is in the `tasks/main.yml` file.
## Available variables
Main variables are:
* `user_name`: Main user username.
#!/usr/bin/python3
import curses
import serial
def input1_on(opsis):
send_slow_line(opsis,'input1 on\r')
opsis.read(1024)
def input1_status(opsis):
send_slow_line(opsis, 'status\r')
status = opsis.read(1024).decode('utf-8')
filtered = [line for line in status.splitlines()
if line.startswith('input1:')]
return filtered[0]
def main():
opsis = opsis_open()
win = curses.initscr()
win.clear()
curses.noecho()
height, width = win.getmaxyx()
title = 'Speaker Test Station'
win.addstr(0, 0, '#' * width)
win.addstr(1, 0, '##')
win.addstr(1, (width - len(title)) // 2, title)
win.addstr(1, width - 2, '##')
win.addstr(2, 0, '#' * width)
win.addstr( 5, 0, 'Instructions:')
win.addstr( 6, 0, '1. Plug your laptop into end of the loose HDMI cable.')
win.addstr( 7, 0, '2. Press any key.')
win.addstr( 8, 0, '3. Your machine should see an extra monitor.')
win.addstr( 9, 0, '4. Display your presentation on this. '
'Check that it looks OK.')
win.addstr(10, 0, '5. Unplug the HDMI cable, and enjoy the conference.')
win.addstr(12, 0, 'If you run into any problems, please get hold of the '
'video team,')
win.addstr(13, 0, "they're only too happy to help.")
win.refresh()
win.timeout(1)
try:
while True:
keypress = win.getch()
if keypress != -1:
input1_on(opsis)
win.addstr(21, 0, 'input1 reset')
win.refresh()
win.addstr(20, 0, 'We see: ' + input1_status(opsis))
win.clrtobot()
win.refresh()
finally:
curses.endwin()
def send_slow_line(child, string):
"""Send input slowly to the opsis"""
for character in string:
child.write(character.encode())
child.flush()
def opsis_open():
"""Open the serial port to the opsis"""
return serial.Serial('/dev/hdmi2usb/by-num/all0/tty0', 115200, timeout=1)
if __name__ == '__main__':
main()
#!/bin/sh
set -euf
screen=$(xdpyinfo | awk '/dimensions/{print $2}')
width=${screen%x*}
height=${screen#*x}
zoom=4
factor=$((zoom / 2))
geom=$((width / 10 / factor))x$((height / 19 / factor))
xfce4-terminal --hide-menubar --hide-scrollbar \
--geometry $geom --zoom $zoom \
--command=test-station
---
- name: Install test-station dependencies
apt:
name: python3-serial
- name: Install test-station script
copy:
src: files/test-station.py
dest: /usr/local/bin/test-station
mode: 0755
tags:
- test-station
- name: Install test-station xsession
copy:
src: files/xsession
dest: /home/{{ user_name }}/.xsession
mode: 0755
......@@ -36,6 +36,12 @@
roles:
- xorg
- hosts: test-station
roles:
- xorg
- opsis
- test-station
# everything on one box
# secrets copied from ansible master
......
Markdown is supported
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