Get serial number of USB-ISS module
558026
def get_iss_serial_no(self):
        
        self.write_data([self.ISS_CMD, self.ISS_SER_NUM])
        # Return 8 bytes serial number
        self.iss_sn = self.read_data(8)
444134
def _detect_available_configs(serial_matcher=None):
        
        if serial_matcher:
            channels = find_serial_devices(serial_matcher)
        else:
            channels = find_serial_devices()

        return [{'interface': 'usb2can', 'channel': c} for c in channels]
499179
def find_microbit():
    
    ports = list_serial_ports()
    for port in ports:
        if "VID:PID=0D28:0204" in port[2].upper():
            return (port[0], port.serial_number)
    return (None, None)
305764
private function _fetchUsbIdsLinux()
    {
        foreach ((array) @glob('/sys/bus/usb/devices/*', GLOB_NOSORT) as $path) {

            // First try uevent
            if (is_readable($path.'/uevent') &&
                preg_match('/^product=([^\/]+)\/([^\/]+)\/[^$]+$/m', strtolower(Common::getContents($path.'/uevent')), $match)) {
                $this->_usb_entries[str_pad($match[1], 4, '0', STR_PAD_LEFT)][str_pad($match[2], 4, '0', STR_PAD_LEFT)] = 1;
            }

            // And next modalias
            elseif (is_readable($path.'/modalias') &&
                preg_match('/^usb:v([0-9A-Z]{4})p([0-9A-Z]{4})/', Common::getContents($path.'/modalias'), $match)) {
                $this->_usb_entries[strtolower($match[1])][strtolower($match[2])] = 1;
            }
        }
    }
740360
def hid(manufacturer: str, serial_number: str, model: str) -> str:
        """"""
        return Naming.url_word(manufacturer) + '-' + Naming.url_word(serial_number) + '-' + Naming.url_word(model)
70207
def serial_number():
    """"""
    sdata = {}
    if os.getuid() == 0:
        try:
            sdata['Serial'] = open('/sys/class/dmi/id/product_serial') \
                .read().strip()
        except:
            for line in os.popen('/usr/sbin/dmidecode -s system-serial-number'):
                sdata['Serial'] = line.strip()
    return sdata
985382
def Find(cls, setting_matcher, port_path=None, serial=None, timeout_ms=None):
        """"""
        if port_path:
            device_matcher = cls.PortPathMatcher(port_path)
            usb_info = port_path
        elif serial:
            device_matcher = cls.SerialMatcher(serial)
            usb_info = serial
        else:
            device_matcher = None
            usb_info = 'first'
        return cls.FindFirst(setting_matcher, device_matcher,
                             usb_info=usb_info, timeout_ms=timeout_ms)
1302957
def _connect(self, id_mask):
        
        # Get all devices attached as USB serial
        all_devices = glob.glob('/dev/ttyUSB*')

        # Identify which of the devices are LoadStar Serial Sensors
        sensors = []
        for device in all_devices:
            try:
                ser = serial.Serial(port=device,
                                    timeout=0.5,
                                    exclusive=True)
                ser.write('ID\r')
                ser.flush()
                time.sleep(0.05)
                resp = ser.read(13)
                ser.close()

                if len(resp) >= 10 and resp[:len(id_mask)] == id_mask:
                    sensors.append((device, resp.rstrip('\r\n')))
            except:
                continue
        sensors = sorted(sensors, key=lambda x : x[1])

        # Connect to each of the serial devices
        serials = []
        for device, key in sensors:
            ser = serial.Serial(port=device, timeout=0.5)
            serials.append(ser)
            rospy.loginfo('Connected to load cell {} at {}'.format(key, device))
        return serials
405491
def get_system_name(self, oid_system_name):
        """"""
        short_system_name = None

        if oid_system_name == '':
            return short_system_name

        # Find the short name in the oid_to_short_os_name dict
        for r, v in iteritems(oid_to_short_system_name):
            if re.search(r, oid_system_name):
                short_system_name = v
                break

        return short_system_name
886202
def _find_devices(serial=None):
    
    ret = []

    if pyusb1:
        for d in usb.core.find(idVendor=0x1915, idProduct=0x7777, find_all=1,
                               backend=pyusb_backend):
            if serial is not None and serial == d.serial_number:
                return d
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == CRADIO_VID:
                    if device.idProduct == CRADIO_PID:
                        if serial == device.serial_number:
                            return device
                        ret += [device, ]

    return ret
1315321
def serial(self):
        
        asnint = libcrypto.X509_get_serialNumber(self.cert)
        bio = Membio()
        libcrypto.i2a_ASN1_INTEGER(bio.bio, asnint)
        return int(str(bio), 16)
898535
def _get_camera_properties(self):
        """"""
        if self.base_station and self.base_station.camera_properties:
            for cam in self.base_station.camera_properties:
                if cam["serialNumber"] == self.device_id:
                    return cam
        return None
192814
def InternalSend(self, cmd, payload):
    """"""
    length_to_send = len(payload)

    max_payload = self.packet_size - 7
    first_frame = payload[0:max_payload]
    first_packet = UsbHidTransport.InitPacket(self.packet_size, self.cid, cmd,
                                              len(payload), first_frame)
    del payload[0:max_payload]
    length_to_send -= len(first_frame)
    self.InternalSendPacket(first_packet)

    seq = 0
    while length_to_send > 0:
      max_payload = self.packet_size - 5
      next_frame = payload[0:max_payload]
      del payload[0:max_payload]
      length_to_send -= len(next_frame)
      next_packet = UsbHidTransport.ContPacket(self.packet_size, self.cid, seq,
                                               next_frame)
      self.InternalSendPacket(next_packet)
      seq += 1
223201
def device_info(device):
    """"""

    status = subprocess.check_output([
        'ibstat', device, '-s']).splitlines()

    regexes = {
        "CA type: (.*)": "device_type",
        "Number of ports: (.*)": "num_ports",
        "Firmware version: (.*)": "fw_ver",
        "Hardware version: (.*)": "hw_ver",
        "Node GUID: (.*)": "node_guid",
        "System image GUID: (.*)": "sys_guid",
    }

    device = DeviceInfo()

    for line in status:
        for expression, key in regexes.items():
            matches = re.search(expression, line)
            if matches:
                setattr(device, key, matches.group(1))

    return device
672560
def get_iss(self, key):
        
        _state = self.get_state(key)
        if not _state:
            raise KeyError(key)
        return _state['iss']
1095831
def get_serial():
    
    port, serial_number = find_microbit()
    if port is None:
        raise IOError('Could not find micro:bit.')
    return Serial(port, SERIAL_BAUD_RATE, timeout=1, parity='N')
632966
def is_micropython_usb_device(port):
    
    if type(port).__name__ == 'Device':
        # Assume its a pyudev.device.Device
        if ('ID_BUS' not in port or port['ID_BUS'] != 'usb' or
            'SUBSYSTEM' not in port or port['SUBSYSTEM'] != 'tty'):
            return False
        usb_id = 'usb vid:pid={}:{}'.format(port['ID_VENDOR_ID'], port['ID_MODEL_ID'])
    else:
        # Assume its a port from serial.tools.list_ports.comports()
        usb_id = port[2].lower()
    # We don't check the last digit of the PID since there are 3 possible
    # values.
    if usb_id.startswith('usb vid:pid=f055:980'):
        return True
    # Check for Teensy VID:PID
    if usb_id.startswith('usb vid:pid=16c0:0483'):
        return True
    return False