1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-01 11:58:28 +00:00
trezor-firmware/ci/hardware_tests/device/device.py
Marek Mahut 4264e87319 ci: add hardware tests for T1
This enables to run device tests against an actual device connected to
our CI. It uses https://github.com/mmahut/tpmb to enter bootloader and
then it uploads a debug firmware to the device. The debug mode is the
used to "click" the buttons but we might improve this and actually use
the hardware buttons instead.
2020-04-10 11:23:07 +02:00

47 lines
1.2 KiB
Python

import datetime
import os
import time
import serial
class Device:
def __init__(self, uhub_location, uhub_port, arduino_serial):
self.uhub_location = uhub_location
self.uhub_port = uhub_port
self.arduino_serial = arduino_serial
self.serial = serial.Serial(arduino_serial, 9600)
def power_on(self):
self.now()
print("[hardware/usb] Turning power on...")
os.system(
"uhubctl -l {} -p {} -a on > /dev/null".format(
self.uhub_location, self.uhub_port
)
)
self.wait(3)
def power_off(self):
self.now()
print("[hardware/usb] Turning power off...")
os.system(
"uhubctl -l {} -p {} -r 100 -a off > /dev/null".format(
self.uhub_location, self.uhub_port
)
)
self.wait(3)
def touch(self, location, action):
raise NotImplementedError
@staticmethod
def wait(seconds):
Device.now()
print("[software] Waiting for {} seconds...".format(seconds))
time.sleep(seconds)
@staticmethod
def now():
print("\n[timestamp] {}".format(datetime.datetime.now()))