Example #1
0
    def __init__(self, terminal):
        self.log = logging.getLogger("OBC")

        self._formatter = ExtendableFormatter()
        self._formatter.register_conversion('E', lambda d: b64encode(d).rstrip('='))
        self._formatter.register_conversion('n', lambda d: d.name)
        self._formatter.register_conversion('t', self._format_timedelta)

        self._terminal = terminal
Example #2
0
    def __init__(self, terminal):
        self.log = logging.getLogger("OBC")

        self._formatter = ExtendableFormatter()
        self._formatter.register_conversion('E', lambda d: b64encode(d).rstrip('='))

        self._terminal = terminal
        self._terminal.reset()
Example #3
0
class OBC(OBCMixin,
          FileSystemMixin,
          CommMixin,
          TimeMixin,
          I2CMixin,
          AntennaMixin,
          MissionMixin
          ):
    def __init__(self, terminal):
        self.log = logging.getLogger("OBC")

        self._formatter = ExtendableFormatter()
        self._formatter.register_conversion('E', lambda d: b64encode(d).rstrip('='))

        self._terminal = terminal
        self._terminal.reset()

    def _command(self, cmd, *args, **kwargs):
        cmdline = self._formatter.vformat(cmd, args, kwargs)

        return self._terminal.command(cmdline)

    def wait_to_start(self):
        response = self._terminal.command("getState")
        while response != "1":
            response = self._terminal.command("getState")

    def reset(self):
        self._terminal.reset()

    def close(self):
        self._terminal.close()

    def power_off(self):
        self._terminal.power_off()

    def power_on(self, clean_state=False):
        self._terminal.power_on(clean_state)

    def ping(self):
        return self._command("ping")
Example #4
0
class OBC(OBCMixin,
          FileSystemMixin,
          CommMixin,
          TimeMixin,
          I2CMixin,
          AntennaMixin,
          MissionMixin,
          ImtqMixin,
          SunSMixin,
          GyroMixin,
          ExperimentsMixin,
          EPSMixin,
          WatchdogMixin,
          StateMixin,
          ErrorCountersMixin,
          FRAMMixin,
          BootSettingsMixin,
          PayloadMixin,
          RunlevelMixin,
          CameraMixin,
          ADCSMixin,
          RTOSMixin,
          MCUTemperatureMixin,
          FlashMixin
          ):
    def __init__(self, terminal):
        self.log = logging.getLogger("OBC")

        self._formatter = ExtendableFormatter()
        self._formatter.register_conversion('E', lambda d: b64encode(d).rstrip('='))
        self._formatter.register_conversion('n', lambda d: d.name)
        self._formatter.register_conversion('t', self._format_timedelta)

        self._terminal = terminal

    def _command(self, cmd, *args, **kwargs):
        cmdline = self._formatter.vformat(cmd, args, kwargs)

        return self._terminal.command(cmdline)

    def _command_no_wait(self, cmd, *args, **kwargs):
        cmdline = self._formatter.vformat(cmd, args, kwargs)

        return self._terminal.command_no_wait(cmdline)

    def _format_timedelta(self, d):
        if type(d) is int:
            return str(d)

        if type(d) is timedelta:
            return str(int(d.total_seconds() * 1000))

        raise TypeError('Must be int or timedelta')

    def wait_to_start(self):
        self.log.debug("Waiting for OBC initialization finish")

        start = datetime.now()

        self._command("wait_for_init")

        end = datetime.now()
        duration = end - start
        self.log.info("OBC initialization done in %s", str(duration))

    def reset(self, boot_handler):
        self._terminal.reset(boot_handler)

    def close(self):
        self._terminal.close()

    def power_off(self):
        self._terminal.power_off()

    def power_on(self, boot_handler):
        self._terminal.power_on(boot_handler)

    def ping(self):
        return self._command("ping")

    def compile_info(self):
        return self._command("compile_info")

    def wait_for_boot(self, timeout=None):
        return self._terminal.wait_for_boot(timeout)