def __init__(self, *args, **kwargs):
        super(rt_testcase, self).__init__(*args, **kwargs)
        self.testname = '' # This should be the testcase class


        self.arduino_path = "/fi/hacklab/ardubus/ruuvitracker_tester"
        self.loop = gobject.MainLoop()
        self.bus = dbus.SessionBus()
        # Make sure the HP is powered
        dbus_call_cached(self.arduino_path, 'set_alias', 'hp_power', True)
        self.hp6632b = hp6632b.rs232(self.get_serialport_tty(HP_SERIALPORT_DEVICEID))
        self.usb_device_present_timeout = 10.0
        # Currently our only input is the pulse so the method name is apt even though we trap all alias signals (also dio_change:s)
        self.bus.add_signal_receiver(self.pulse_received, dbus_interface = "fi.hacklab.ardubus", signal_name = "alias_change", path=self.arduino_path)
        self.pulse_trains = []
        self._active_pulse_train = False
        self.logger = None
        self.log_handle = None
        self.log_timer = None
        self._tick_count = 0 # How many ticks this test has been running, ticks are seconds
        self._tick_limit = -1 # infinite
        self._tick_timer = None # This will be set later
        self._cleanup_files = []
        self._min_servo_step_time = 50 # ms

        # Some defaults 
        self.default_voltage = 4100 # millivolts
        self.default_current = 50 # milliamps
        self.default_pan = 10
        self.default_tilt = 62
        # note if you change these in setup() make sure theyre suitable
        self.bootloader_voltage = 4100 # millivolts
        self.bootloader_current = 50 # milliamps

        # Testcase should define their defaults here
        self.defaults_setup()
        # Finish by restoring a known state
        self.set_defaut_state()
 def reset_stm32(self, enter_bootloader=False):
     """Boots the STM32 on the board, optionally will enter bootloader mode (though only if the board is actually powered on at this point...)"""
     if enter_bootloader:
         dbus_call_cached(self.arduino_path, 'set_alias', 'rt_boot0', True)
     else:
         dbus_call_cached(self.arduino_path, 'set_alias', 'rt_boot0', False)
     self.hold_stm32_reset()
     time.sleep(0.100)
     self.release_stm32_reset()
     if enter_bootloader:
         time.sleep(0.100)
         dbus_call_cached(self.arduino_path, 'set_alias', 'rt_boot0', False)
#!/usr/bin/env python
import sys,os
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
from dbushelpers.call_cached import call_cached as dbus_call_cached


arduino_path = "/fi/hacklab/ardubus/ruuvitracker_tester"
loop = gobject.MainLoop()
bus = dbus.SessionBus()
dbus_call_cached(arduino_path, 'set_alias', 'hp_power', bool(int(sys.argv[1])))
#!/usr/bin/env python
import sys, os
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
from dbushelpers.call_cached import call_cached as dbus_call_cached


arduino_path = "/fi/hacklab/ardubus/ruuvitracker_tester"
loop = gobject.MainLoop()
bus = dbus.SessionBus()
dbus_call_cached(arduino_path, "set_alias", "usb_power", bool(int(sys.argv[1])))
 def pulse_boot0(self, wait=0.500):
     """Pushes and releases the bootloader button on boot0"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_boot0', True)
     time.sleep(wait)
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_boot0', False)
 def pulse_pa0(self, wait=0.500):
     """Pushes and releases the wakeup button on pa0, NOTE: in RevC2 (and earlier) this is same as boot0, which will cause problems in wakeup"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_pa0', True)
     time.sleep(wait)
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_pa0', False)
 def release_stm32_reset(self):
     """Releases the reset line"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_nrst', True)
 def hold_stm32_reset(self):
     """Holds the reset line down"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'rt_nrst', False)
 def enable_usb(self, state=True):
     """Enables power to the USB hub, or disables if state is set to False"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'usb_power', state)
 def enable_servos(self, state=True):
     """Enables servo DC power, or disables if state is set to False"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'servo_power', state)
 def set_tilt(self, angle):
     """sets target angle for the tilt-servo, you are responsible for enabling & disabling servo power"""
     dbus_call_cached(self.arduino_path, 'set_alias', 'tilt', angle)