def testSetMuxFile(self): """Test Selecting and setting a pin.""" self._writeToMuxFileHelper() self.mox.ReplayAll() # Since testInitialization ran first, BBmuxController should not initialize # its pin maps as they are class variables. mux_controller = bbmux_controller.BBmuxController() mux_controller.set_muxfile(FAKE_MUX_FILE, 0x3, 0x7)
def testSetPinMode(self): """Test Selecting and setting a pin.""" self._writeToMuxFileHelper() self.mox.ReplayAll() # Since testInitialization ran first, BBmuxController should not initialize # its pin maps as they are class variables. mux_controller = bbmux_controller.BBmuxController() mux_controller.set_pin_mode('gpio1_25', 0x3)
def __init__(self): gpio_interface.GpioInterface.__init__(self) self._logger.debug('') self._exported_gpios = [] self._bbmux_controller = None if bbmux_controller.use_omapmux(): self._bbmux_controller = bbmux_controller.BBmuxController() # Ensure we release the system resources at exit time. atexit.register(self.close)
def __init__(self, interface): super(BBuart, self).__init__() self._interface = interface self._uart_num = interface['uart_num'] self._pty = TTY_MAP[self._uart_num] if bbmux_controller.use_omapmux(): self._bbmux_controller = bbmux_controller.BBmuxController() self.open() self._logger = logging.getLogger('bbuart') self._logger.debug('Initialized BBuart for interface %s with tty:%s', interface, self._pty) # Beaglebone defaults to a baudrate of 9600, set it to what servo expects. self.set_uart_props(DEFAULT_UART_SETTINGS)
def testInitialization(self): bbmux_controller.os = self.mox.CreateMockAnything() bbmux_controller.os.path = self.mox.CreateMockAnything() bbmux_controller.os.listdir(bbmux_controller.MUX_ROOT).AndReturn( [FAKE_MUX_FILE]) bbmux_controller.os.path.join( bbmux_controller.MUX_ROOT, FAKE_MUX_FILE).MultipleTimes().AndReturn(FAKE_MUX_FILE_PATH) bbmux_controller.os.path.isdir( mox.IgnoreArg()).MultipleTimes().AndReturn(False) mux_file = self.mox.CreateMockAnything() mux_file.__enter__().AndReturn([FAKE_MUX_FILE_CONTENTS]) mux_file.__exit__(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) open(FAKE_MUX_FILE_PATH, 'r').AndReturn(mux_file) self.mox.ReplayAll() mux_controller = bbmux_controller.BBmuxController() self.assertEquals(EXPECTED_PIN_NAME_MAP, mux_controller._pin_name_map) self.assertEquals(EXPECTED_PIN_MODE_MAP, mux_controller._pin_mode_map)