Connect to the serial port
352242
def connect(self):
        '''
        
        '''
        if self._port:
            self._driver = MagDeckDriver()
            self._driver.connect(self._port)
            self._device_info = self._driver.get_device_info()
        else:
            # Sanity check: Should never happen, because connect should
            # never be called without a port on Module
            raise MissingDevicePortError(
                "MagDeck couldnt connect to port {}".format(self._port)
            )
174891
function SerialDevice(port, settings, Connection) {

  // call super class
  Device.call(this, Connection);

  this.set('portName', port);
  this.set('settings', settings);

  this.set('state', 'close');
}
555554
def connect(self, protocol=None, mode=None, disposition=None):
        """"""
        self.component.connect(protocol, mode, disposition)
1018050
def connect(self):
        """"""
        self.socket = socket.create_connection(self.address, self.timeout)
120101
def connect(self):
        '''
        
        '''
        # Don't try to register if we already have
        if self.validate_registration():
            return True

        body = {
            'devicetype': self.device_type,
            'username': self.username,
        }
        response = self.make_request('POST', '/api', body)

        if 'error' in response:
            if response['error']['type'] == 101:
                msg = 'Please press the link button and try again'
            else:
                msg = response['error']['description']

            raise Exception(msg)
355725
function connect() {
    let port = null;

    try {
      port = parseInt(readFileSync(path.join(
        datadir,
        'control-port'
      )).toString().split(':')[1]);
    } catch (err) {
      /* istanbul ignore next */
      portFileReads++;

      /* istanbul ignore next */
      if (portFileReads <= 20) {
        return setTimeout(() => connect(), 1000);
      } else {
        return controller.emit('error',
                               new Error('Failed to read control port'));
      }
    }

    socket.connect(port, '127.0.0.1');
  }
1177429
private function connect()
    {
        if (!$this->socket->isOpened()) {
            $this->socket->open();

            if ($this->secret) {
                $this->socket->send(join(Driver::SEP, ['A', 1, Driver::encode($this->secret)]).Driver::EOL);
            }
        }
    }
1161664
def connect(self, (host, port)):
        '''
        
        '''
        super(GeventTransport, self).connect((host, port), klass=socket.socket)
143404
function(options) {
		console.log('Connecting to usb serial port:', this.portname);
		var port;
		try {
			port = new SerialPort(this.portname, {
				baudrate: options.baud || 57600,
				buffersize: options.buffersize || 20480
			});
		} catch(e) {
			process.stdout.write('Cannot open serial port.');
			process.exit(-2);
		}
		this.serialport = port;
		var self = this;
		this.serialport.on('data', function(data) { self.seriallistener.call(self, data); });

		////////////////////
		//
		// Keyboard / stdin listener
		//
		if (this.kbdin) {
			process.stdin.resume();
			process.stdin.setEncoding('utf8');
			process.stdin.setRawMode(true);			// pass ^C through to serial port
			process.stdin.on('data', function (data) {	// keyboard input goes to port
				if (data === '\x1d') process.exit(0);	// ^] to quit
				else if (port) self.serialport.write(data);
			});
		}
	}
166581
def connect(self):
        '''
        
        '''
        if self.connected:
            raise RuntimeError(
                '{} is connected already'.format(self.__class__.__name__))
        if self.closed:
            raise RuntimeError(
                '{} is closed already'.format(self.__class__.__name__))
        self.connected = True
        self._connect()
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)
476054
function setup() {
  createCanvas(windowWidth, windowHeight);

  // Instantiate our SerialPort object
  serial = new p5.SerialPort();

  // Get a list the ports available
  // You should have a callback defined to see the results
  serial.list();

  // Assuming our Arduino is connected, let's open the connection to it
  // Change this to the name of your arduino's serial port
  serial.open("/dev/cu.usbmodem1411");

  // Here are the callbacks that you can register

  // When we connect to the underlying server
  serial.on('connected', serverConnected);

  // When we get a list of serial ports that are available
  serial.on('list', gotList);
  // OR
  //serial.onList(gotList);

  // When we some data from the serial port
  serial.on('data', gotData);
  // OR
  //serial.onData(gotData);

  // When or if we get an error
  serial.on('error', gotError);
  // OR
  //serial.onError(gotError);

  // When our serial port is opened and ready for read/write
  serial.on('open', gotOpen);
  // OR
  //serial.onOpen(gotOpen);

  // Callback to get the raw data, as it comes in for handling yourself
  //serial.on('rawdata', gotRawData);
  // OR
  //serial.onRawData(gotRawData);
}
808492
def main(jlink_serial, device):
    
    buf = StringIO.StringIO()
    jlink = pylink.JLink(log=buf.write, detailed_log=buf.write)
    jlink.open(serial_no=jlink_serial)

    jlink.set_tif(pylink.enums.JLinkInterfaces.SWD)
    jlink.connect(device, verbose=True)

    # Figure out our original endianess first.
    big_endian = jlink.set_little_endian()
    if big_endian:
        jlink.set_big_endian()

    print('Target Endian Mode: %s Endian' % ('Big' if big_endian else 'Little'))
33561
def connect(self):
        
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            self.socket.connect((self.host, self.port))
        except socket.error as (err, msg):
            self.connected = False
            raise ScratchError("[Errno %d] %s" % (err, msg))
        self.connected = True
1292263
def get_usb_serial(self, port_num):
    

    port = self.port_map[str(port_num)]
    arg = ''.join(['DEVICE INFO,', self._addr, '.', port])
    cmd = (['esuit64', '-t', arg])
    info = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    serial = None
    if "SERIAL" in info:
      serial_info = info.split('SERIAL:')[1]
      serial = serial_info.split('\n')[0].strip()
      use_info = info.split('BY')[1].split(' ')[1]
      if use_info == 'NO':
        cmd = (['esuit64', '-t', 'AUTO USE ALL'])
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        time.sleep(50.0/1000.0)
    else:
      raise ValueError('No USB device detected')
    return serial
1196523
def connect(self):
        
        connection_method = 'SMTP_SSL' if self.ssl else 'SMTP'
        self._logger.debug('Trying to connect via {}'.format(connection_method))
        smtp = getattr(smtplib, connection_method)
        if self.port:
            self._smtp = smtp(self.address, self.port)
        else:
            self._smtp = smtp(self.address)
        self._smtp.ehlo()
        if self.tls:
            self._smtp.starttls()
            self._smtp.ehlo()
        self._logger.info('Got smtp connection')
        if self.username and self.password:
            self._logger.info('Logging in')
            self._smtp.login(self.username, self.password)
        self._connected = True
508853
def open(self):
        """"""
        self._serial.port = self._port
        self._serial.baudrate = self._baud
        self._serial.timeout = self._timeout
        self._serial.open()
        self._serial.flushInput()
        self._serial.flushOutput()