Create a serial connect to the arm.
972476
def r12_serial_port(port):
    '''  '''
    return serial.Serial(port, baudrate=BAUD_RATE, parity=PARITY,
                         stopbits=STOP_BITS, bytesize=BYTE_SIZE)
1208059
def connect(self, obj, params):
        """"""

        connect_params = WLAN_CONNECTION_PARAMETERS()
        connect_params.wlanConnectionMode = 0  # Profile
        connect_params.dot11BssType = 1  # infra
        profile_name = create_unicode_buffer(params.ssid)

        connect_params.strProfile = profile_name.value
        ret = self._wlan_connect(
            self._handle, obj['guid'], byref(connect_params))
        self._logger.debug('connect result: %d', ret)
1283186
def connect(port, baud=115200, user='micro', password='python', wait=0):
    """"""
    try:
        ip_address = socket.gethostbyname(port)
        #print('Connecting to ip', ip_address)
        connect_telnet(port, ip_address, user=user, password=password)
    except socket.gaierror:
        # Doesn't look like a hostname or IP-address, assume its a serial port
        #print('connecting to serial', port)
        connect_serial(port, baud=baud, wait=wait)
878577
def connect(self, driver):
        """"""
        #              0            1                              2                      3
        events = [ESCAPE_CHAR, driver.press_return_re, driver.standby_re, driver.username_re,
                  #            4                   5                  6                     7
                  driver.password_re, driver.more_re, self.device.prompt_re, driver.rommon_re,
                  #       8                              9              10            11              12
                  driver.unable_to_connect_re, driver.timeout_re, pexpect.TIMEOUT, PASSWORD_OK, driver.syntax_error_re]

        transitions = [
            (ESCAPE_CHAR, [0], 1, None, _C['esc_char_timeout']),
            (driver.syntax_error_re, [0], -1, CommandSyntaxError("Command syntax error"), 0),
            (driver.press_return_re, [0, 1], 1, a_send_newline, 10),
            (PASSWORD_OK, [0, 1], 1, a_send_newline, 10),
            (driver.standby_re, [0, 5], -1, partial(a_standby_console), 0),
            (driver.username_re, [0, 1, 5, 6], -1, partial(a_save_last_pattern, self), 0),
            (driver.password_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.more_re, [0, 5], 7, partial(a_send, "q"), 10),
            # router sends it again to delete
            (driver.more_re, [7], 8, None, 10),
            # (prompt, [0, 1, 5], 6, a_send_newline, 10),
            (self.device.prompt_re, [0, 1, 5], 0, None, 10),
            (self.device.prompt_re, [6, 8, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.rommon_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.unable_to_connect_re, [0, 1, 5], -1, a_unable_to_connect, 0),
            (driver.timeout_re, [0, 1, 5], -1, ConnectionTimeoutError("Connection Timeout", self.hostname), 0),
            (pexpect.TIMEOUT, [0, 1], 5, a_send_newline, 10),
            (pexpect.TIMEOUT, [5], -1, ConnectionTimeoutError("Connection timeout", self.hostname), 0)
        ]

        self.log("EXPECTED_PROMPT={}".format(pattern_to_str(self.device.prompt_re)))
        # setting max_transitions to large number to swallow prompt like strings from prompt
        fsm = FSM("TELNET-CONNECT", self.device, events, transitions, timeout=_C['connect_timeout'],
                  init_pattern=self.last_pattern, max_transitions=500)
        return fsm.run()
101276
def connection_made(self, transport):
        """"""
        super().connection_made(transport)
        if hasattr(self.transport, 'serial'):
            _LOGGER.info('Connected to %s', self.transport.serial)
        else:
            _LOGGER.info('Connected to %s', self.transport)
250143
async def pair(self):
        """"""
        # Connect using the specified protocol
        # TODO: config should be stored elsewhere so that API is same for both
        protocol = self.atv.service.protocol
        if protocol == const.PROTOCOL_DMAP:
            await self.atv.pairing.start(zeroconf=Zeroconf(),
                                         name=self.args.remote_name,
                                         pairing_guid=self.args.pairing_guid)
        elif protocol == const.PROTOCOL_MRP:
            await self.atv.pairing.start()

        # Ask for PIN if present or just wait for pairing to end
        if self.atv.pairing.device_provides_pin:
            pin = await _read_input(self.loop, 'Enter PIN on screen: ')
            self.atv.pairing.pin(pin)
        else:
            self.atv.pairing.pin(self.args.pin_code)

            print('Use {0} to pair with "{1}" (press ENTER to stop)'.format(
                self.args.pin_code, self.args.remote_name))

        if self.args.pin_code is None:
            print('Use any pin to pair with "{}" (press ENTER to stop)'.format(
                self.args.remote_name))
        else:
            print('Use pin {} to pair with "{}" (press ENTER to stop)'.format(
                self.args.pin_code, self.args.remote_name))

        await self.loop.run_in_executor(None, sys.stdin.readline)

        await self.atv.pairing.stop()

        # Give some feedback to the user
        if self.atv.pairing.has_paired:
            print('Pairing seems to have succeeded, yey!')
            print('You may now use these credentials: {0}'.format(
                self.atv.pairing.credentials))
        else:
            print('Pairing failed!')
            return 1

        return 0
222190
def _connect_remote(self, host, host_port, lan_ports, race, name, map_inst,
                      save_map, interface):
    """"""
    # Connect!
    logging.info("Connecting...")
    self._controllers = [remote_controller.RemoteController(host, host_port)]
    logging.info("Connected")

    if map_inst and save_map:
      run_config = run_configs.get()
      self._controllers[0].save_map(map_inst.path, map_inst.data(run_config))

    # Create the join request.
    join = sc_pb.RequestJoinGame(options=interface)
    join.race = race
    join.player_name = name
    join.shared_port = 0  # unused
    join.server_ports.game_port = lan_ports.pop(0)
    join.server_ports.base_port = lan_ports.pop(0)
    join.client_ports.add(
        game_port=lan_ports.pop(0), base_port=lan_ports.pop(0))

    logging.info("Joining game.")
    self._controllers[0].join_game(join)
    self._in_game = True
    logging.info("Game joined.")
655238
def _write_to_device_and_return(cmd, ack, device_connection):
    ''''''
    log.debug('Write -> {}'.format(cmd.encode()))
    device_connection.write(cmd.encode())
    response = device_connection.read_until(ack.encode())
    log.debug('Read <- {}'.format(response))
    if ack.encode() not in response:
        raise SerialNoResponse(
            'No response from serial port after {} second(s)'.format(
                device_connection.timeout))
    clean_response = _parse_serial_response(response, ack.encode())
    if clean_response:
        return clean_response.decode()
    return ''
1030726
def connect(self, object, callback):
		""""""
		def signal_fired(sender, object, iface, signal, params):
			callback(*params)
		return object._bus.subscribe(sender=object._bus_name, object=object._path, iface=self._iface_name, signal=self.__name__, signal_fired=signal_fired)
891519
def arm(self, wait=True, timeout=None):
        '''
        '''

        self.armed = True

        if wait:
            self.wait_for(lambda: self.armed, timeout=timeout,
                          errmsg='failed to arm vehicle')
259854
def _serial_send(self, port, payload):
        '''
        
        '''
        if port not in self.open_devices:
            # Not connected to device.
            logger.error('Error sending data: `%s` not connected', port)
            self._publish_status(port)
        else:
            try:
                device = self.open_devices[port]
                device.write(payload)
                logger.debug('Sent data to `%s`', port)
            except Exception as exception:
                logger.error('Error sending data to `%s`: %s', port, exception)
1096300
def connect(*args, **kwargs):
    """"""
    kwargs['cursor_factory'] = TraceCursor
    conn = pg_connect(*args, **kwargs)
    return conn
362993
def connect(self, port=None):
        '''  '''
        if port is None:
            self.port = search_for_port('/dev/ttyUSB*', 'ROBOFORTH\r\n',
                                        'ROBOFORTH')
        else:
            self.port = port

        if self.port is None:
            raise ArmException('ST Robotics connection not found.')

        self.ser = r12_serial_port(port)

        if not self.ser.isOpen():
            self.ser.open()

        if not self.ser.isOpen():
            raise ArmException('Failed to open serial port. Exiting.')

        return self.port
1053731
def open
			@serial ||= SerialPort.new @port, @rate
			@serial_input = Enumerator.new { |y| loop do
				y.yield @serial.readbyte
			end }
			@connected = true
		end
130809
def main(jlink_serial, device):
    
    buf = StringIO.StringIO()
    jlink = pylink.JLink(log=buf.write, detailed_log=buf.write)
    jlink.open(serial_no=jlink_serial)

    # Use Serial Wire Debug as the target interface.
    jlink.set_tif(pylink.enums.JLinkInterfaces.SWD)
    jlink.connect(device, verbose=True)

    sys.stdout.write('ARM Id: %d\n' % jlink.core_id())
    sys.stdout.write('CPU Id: %d\n' % jlink.core_cpu())
    sys.stdout.write('Core Name: %s\n' % jlink.core_name())
    sys.stdout.write('Device Family: %d\n' % jlink.device_family())
85523
def _send_rpc(self, device_info, control_info, address, rpc_id, payload, poll_interval, timeout):
        """"""

        write_address, write_data = control_info.format_rpc(address, rpc_id, payload)
        self._jlink.memory_write32(write_address, write_data)

        self._trigger_rpc(device_info)

        start = monotonic()
        now = start

        poll_address, poll_mask = control_info.poll_info()

        while (now - start) < timeout:
            time.sleep(poll_interval)
            value, = self._jlink.memory_read8(poll_address, 1)

            if value & poll_mask:
                break

            now = monotonic()

        if (now - start) >= timeout:
            raise HardwareError("Timeout waiting for RPC response", timeout=timeout, poll_interval=poll_interval)

        read_address, read_length = control_info.response_info()
        read_data = self._read_memory(read_address, read_length, join=True)

        return control_info.format_response(read_data)
890504
function initSerial(robot, port, callback) {
	serial = new Serial.SerialPort(port, {
		//Defaults for Roomba Open Interface:
		baudrate:115200, dataBits:8,
		parity:'none', stopBits:1,
		flowControl:false
	});
	serial.on('open', function() {
		//Send Start Command:
		serial.write(Buffer([128]));
		setSensorRead(true, robot);
		//Listen to Incoming Data:
		serial.on('data', function(data) {
			//Combine Previous Data:
			if(robot.inputBuffer) {
				robot.inputBuffer = Buffer.concat([robot.inputBuffer,
				data], robot.inputBuffer.length + data.length);
			} else robot.inputBuffer = data;
			//Data Parsing Timer:
			if(robot.inputTimer) clearTimeout(robot.inputTimer);
			robot.inputTimer = setTimeout(function() {
				if(robot.dataParser && robot.inputBuffer && robot.inputBuffer.length >= 80)
				{ robot.dataParser(robot.inputBuffer); robot.inputBuffer = robot.inputTimer = null; }
				if(exports.debug && robot.inputBuffer && robot.inputBuffer.length != 80)
				console.log(chalk.bold.green("Packet Miss ["+robot.inputBuffer.length+"]"));
			}, 5);
		});
		if(callback) callback(robot);
	});
	return serial;
}