Status of key hardware

                Vcc                       : board voltage (mV) (uint16_t)
                I2Cerr                    : I2C error count (uint8_t)
176415
def hwstatus_send(self, Vcc, I2Cerr, force_mavlink1=False):
                '''
                

                '''
                return self.send(self.hwstatus_encode(Vcc, I2Cerr), force_mavlink1=force_mavlink1)
164641
def GetStatus(self):
        
        # status packet format
        STATUS_FORMAT = ">BBBhhhHhhhHBBBxBbHBHHHHBbbHHBBBbbbbbbbbbBH"
        STATUS_FIELDS = [
            "packetType",
            "firmwareVersion",
            "protocolVersion",
            "mainFineCurrent",
            "usbFineCurrent",
            "auxFineCurrent",
            "voltage1",
            "mainCoarseCurrent",
            "usbCoarseCurrent",
            "auxCoarseCurrent",
            "voltage2",
            "outputVoltageSetting",
            "temperature",
            "status",
            "leds",
            "mainFineResistor",
            "serialNumber",
            "sampleRate",
            "dacCalLow",
            "dacCalHigh",
            "powerUpCurrentLimit",
            "runTimeCurrentLimit",
            "powerUpTime",
            "usbFineResistor",
            "auxFineResistor",
            "initialUsbVoltage",
            "initialAuxVoltage",
            "hardwareRevision",
            "temperatureLimit",
            "usbPassthroughMode",
            "mainCoarseResistor",
            "usbCoarseResistor",
            "auxCoarseResistor",
            "defMainFineResistor",
            "defUsbFineResistor",
            "defAuxFineResistor",
            "defMainCoarseResistor",
            "defUsbCoarseResistor",
            "defAuxCoarseResistor",
            "eventCode",
            "eventData",
        ]

        self._SendStruct("BBB", 0x01, 0x00, 0x00)
        while 1:  # Keep reading, discarding non-status packets
            read_bytes = self._ReadPacket()
            if not read_bytes:
                return None
            calsize = struct.calcsize(STATUS_FORMAT)
            if len(read_bytes) != calsize or read_bytes[0] != 0x10:
                logging.warning("Wanted status, dropped type=0x%02x, len=%d",
                                read_bytes[0], len(read_bytes))
                continue
            status = dict(
                zip(STATUS_FIELDS, struct.unpack(STATUS_FORMAT, read_bytes)))
            p_type = status["packetType"]
            if p_type != 0x10:
                raise MonsoonError("Package type %s is not 0x10." % p_type)
            for k in status.keys():
                if k.endswith("VoltageSetting"):
                    status[k] = 2.0 + status[k] * 0.01
                elif k.endswith("FineCurrent"):
                    pass  # needs calibration data
                elif k.endswith("CoarseCurrent"):
                    pass  # needs calibration data
                elif k.startswith("voltage") or k.endswith("Voltage"):
                    status[k] = status[k] * 0.000125
                elif k.endswith("Resistor"):
                    status[k] = 0.05 + status[k] * 0.0001
                    if k.startswith("aux") or k.startswith("defAux"):
                        status[k] += 0.05
                elif k.endswith("CurrentLimit"):
                    status[k] = 8 * (1023 - status[k]) / 1023.0
            return status
927795
def status(self):
        """"""
        vm = self.get_vm_failfast(self.config['name'])
        extra = self.config['extra']
        parserFriendly = self.config['parserFriendly']

        status_to_print = []
        if extra:
            status_to_print = \
                [["vmname", "powerstate", "ipaddress", "hostname", "memory",
                  "cpunum", "uuid", "guestid", "uptime"]] + \
                [[vm.name, vm.runtime.powerState,
                  vm.summary.guest.ipAddress or '',
                  vm.summary.guest.hostName or '',
                  str(vm.summary.config.memorySizeMB),
                  str(vm.summary.config.numCpu),
                  vm.summary.config.uuid, vm.summary.guest.guestId,
                  str(vm.summary.quickStats.uptimeSeconds) or '0']]
        else:
            status_to_print = [[vm.name, vm.runtime.powerState]]

        if parserFriendly:
            self.print_as_lines(status_to_print)
        else:
            self.print_as_table(status_to_print)
62909
def _read_register(self, reg):
        """"""
        self.buf[0] = reg
        with self.i2c_device as i2c:
            i2c.write(self.buf, end=1, stop=False)
            i2c.readinto(self.buf, end=2)
        return self.buf[0] << 8 | self.buf[1]
1127958
def vcpu_pin(vm_, vcpu, cpus):
    '''
    
    '''
    with _get_xapi_session() as xapi:

        vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
        if vm_uuid is False:
            return False

        # from xm's main
        def cpu_make_map(cpulist):
            cpus = []
            for c in cpulist.split(','):
                if c == '':
                    continue
                if '-' in c:
                    (x, y) = c.split('-')
                    for i in range(int(x), int(y) + 1):
                        cpus.append(int(i))
                else:
                    # remove this element from the list
                    if c[0] == '^':
                        cpus = [x for x in cpus if x != int(c[1:])]
                    else:
                        cpus.append(int(c))
            cpus.sort()
            return ','.join(map(str, cpus))

        if cpus == 'all':
            cpumap = cpu_make_map('0-63')
        else:
            cpumap = cpu_make_map('{0}'.format(cpus))

        try:
            xapi.VM.add_to_VCPUs_params_live(vm_uuid,
                                             'cpumap{0}'.format(vcpu), cpumap)
            return True
        # VM.add_to_VCPUs_params_live() implementation in xend 4.1+ has
        # a bug which makes the client call fail.
        # That code is accurate for all others XenAPI implementations, but
        # for that particular one, fallback to xm / xl instead.
        except Exception:
            return __salt__['cmd.run'](
                    '{0} vcpu-pin {1} {2} {3}'.format(_get_xtool(), vm_, vcpu, cpus),
                    python_shell=False)
1208653
def _resolve_dut_count(self):
        
        self._dut_count = len(self._dut_requirements)
        self._resolve_process_count()
        self._resolve_hardware_count()
        if self._dut_count != self._hardware_count + self._process_count:
            raise ValueError("Missing or invalid type fields in dut configuration!")
562615
def _get_cpu_virtualization(self):
        """"""
        try:
            cpu_vt = self._get_bios_setting('ProcVirtualization')
        except exception.IloCommandNotSupportedError:
            return False
        if cpu_vt == 'Enabled':
            vt_status = True
        else:
            vt_status = False
        return vt_status
800895
def warnings(filename,
             board='pro',
             hwpack='arduino',
             mcu='',
                 f_cpu='',
                 extra_lib='',
                 ver='',
             #                 home='auto',
                 backend='arscons',
             ):
    '''
    
    '''
    cc = Arduino(
        board=board,
        hwpack=hwpack,
        mcu=mcu,
        f_cpu=f_cpu,
        extra_lib=extra_lib,
        ver=ver,
        #                 home=home,
        backend=backend,
    )
    cc.build(filename)

    print 'backend:', cc.backend
    print 'MCU:', cc.mcu_compiler()
#    print 'avr-gcc:', AvrGcc().version()

    print
    print('=============================================')
    print('SIZE')
    print('=============================================')
    print 'program:', cc.size().program_bytes
    print 'data:', cc.size().data_bytes

    core_warnings = [x for x in cc.warnings if 'gcc' in x] + [
        x for x in cc.warnings if 'core' in x]
    lib_warnings = [x for x in cc.warnings if 'lib_' in x]
    notsketch_warnings = core_warnings + lib_warnings
    sketch_warnings = [x for x in cc.warnings if x not in notsketch_warnings]

    print
    print('=============================================')
    print('WARNINGS')
    print('=============================================')
    print
    print('core')
    print('-------------------')
    print('\n'.join(core_warnings))
    print
    print('lib')
    print('-------------------')
    print('\n'.join(lib_warnings))
    print
    print('sketch')
    print('-------------------')
    print('\n'.join(sketch_warnings))
992994
def _get_cpu_info_from_sysinfo_v2():
	'''
	
	'''
	try:
		# Just return {} if there is no sysinfo
		if not DataSource.has_sysinfo():
			return {}

		# If sysinfo fails return {}
		returncode, output = DataSource.sysinfo_cpu()
		if output == None or returncode != 0:
			return {}

		# Various fields
		vendor_id = '' #_get_field(False, output, None, None, 'CPU #0: ')
		processor_brand = output.split('CPU #0: "')[1].split('"\n')[0].strip()
		cache_size = '' #_get_field(False, output, None, None, 'machdep.cpu.cache.size')
		signature = output.split('Signature:')[1].split('\n')[0].strip()
		#
		stepping = int(signature.split('stepping ')[1].split(',')[0].strip())
		model = int(signature.split('model ')[1].split(',')[0].strip())
		family = int(signature.split('family ')[1].split(',')[0].strip())

		# Flags
		def get_subsection_flags(output):
			retval = []
			for line in output.split('\n')[1:]:
				if not line.startswith('                ') and not line.startswith('		'): break
				for entry in line.strip().lower().split(' '):
					retval.append(entry)
			return retval

		flags = get_subsection_flags(output.split('Features: ')[1]) + \
				get_subsection_flags(output.split('Extended Features (0x00000001): ')[1]) + \
				get_subsection_flags(output.split('Extended Features (0x80000001): ')[1])
		flags.sort()

		# Convert from GHz/MHz string to Hz
		lines = [n for n in output.split('\n') if n]
		raw_hz = lines[0].split('running at ')[1].strip().lower()
		hz_advertised = raw_hz.rstrip('mhz').rstrip('ghz').strip()
		hz_advertised = _to_decimal_string(hz_advertised)
		hz_actual = hz_advertised

		scale = 0
		if raw_hz.endswith('mhz'):
			scale = 6
		elif raw_hz.endswith('ghz'):
			scale = 9

		info = {
		'vendor_id_raw' : vendor_id,
		'brand_raw' : processor_brand,

		'hz_advertised_friendly' : _hz_short_to_friendly(hz_advertised, scale),
		'hz_actual_friendly' : _hz_short_to_friendly(hz_actual, scale),
		'hz_advertised' : _hz_short_to_full(hz_advertised, scale),
		'hz_actual' : _hz_short_to_full(hz_actual, scale),

		'l2_cache_size' : _to_friendly_bytes(cache_size),

		'stepping' : stepping,
		'model' : model,
		'family' : family,
		'flags' : flags
		}

		info = {k: v for k, v in info.items() if v}
		return info
	except:
		#raise # NOTE: To have this throw on error, uncomment this line
		return {}
683178
def VCTools(self):
        
        si = self.si
        tools = [os.path.join(si.VCInstallDir, 'VCPackages')]

        forcex86 = True if self.vc_ver <= 10.0 else False
        arch_subdir = self.pi.cross_dir(forcex86)
        if arch_subdir:
            tools += [os.path.join(si.VCInstallDir, 'Bin%s' % arch_subdir)]

        if self.vc_ver == 14.0:
            path = 'Bin%s' % self.pi.current_dir(hidex86=True)
            tools += [os.path.join(si.VCInstallDir, path)]

        elif self.vc_ver >= 15.0:
            host_dir = (r'bin\HostX86%s' if self.pi.current_is_x86() else
                        r'bin\HostX64%s')
            tools += [os.path.join(
                si.VCInstallDir, host_dir % self.pi.target_dir(x64=True))]

            if self.pi.current_cpu != self.pi.target_cpu:
                tools += [os.path.join(
                    si.VCInstallDir, host_dir % self.pi.current_dir(x64=True))]

        else:
            tools += [os.path.join(si.VCInstallDir, 'Bin')]

        return tools
1326303
def _erads2bt(self, data, channel_name):
        """"""
        cal_info = CALIB[self.platform_id][channel_name]
        alpha = cal_info["ALPHA"]
        beta = cal_info["BETA"]
        wavenumber = CALIB[self.platform_id][channel_name]["VC"]

        return (self._tl15(data, wavenumber) - beta) / alpha
1015887
def _parse_hwtype(self):
        """"""

        self.chip_name = KNOWN_HARDWARE_TYPES.get(self.hw_type, "Unknown Chip (type=%d)" % self.hw_type)
673255
def device_count(self):
        
        device_count = get_device_count(self.corsair_sdk)
        if device_count == -1:
            self._raise_corsair_error()
        return device_count
898150
def _abs16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2])
    output.append('call __ABS16')
    output.append('push hl')
    REQUIRES.add('abs16.asm')
    return output
7401
def standby(self):
        
        register = self.MMA8452Q_Register['CTRL_REG1']
        self.board.i2c_read_request(self.address, register, 1,
                                    Constants.I2C_READ | Constants.I2C_END_TX_MASK,
                                    self.data_val, Constants.CB_TYPE_DIRECT)


        ctrl1 = self.wait_for_read_result()

        ctrl1 = (ctrl1[self.data_start]) & ~0x01
        self.callback_data = []

        self.board.i2c_write_request(self.address, [register, ctrl1])
184525
def num_devices(self):
        
        c_count = c_uint()
        _check_return(_NVML.get_function(
            "nvmlDeviceGetCount_v2")(byref(c_count)))
        return c_count.value
16210
private function _voltage()
    {
        foreach ($this->_lines as $line) {
            if (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+volts_dc,\s+([0-9\.]+)\s+V.*$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+([0-9\.]+)\s+V\sDC$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC\s+\((.*)\)$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[3]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            } elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC$/', $line, $ar_buf)) {
                $dev = new SensorDevice();
                $dev->setName($ar_buf[1]);
                $dev->setValue($ar_buf[2]);
                $this->mbinfo->setMbVolt($dev);
            }
        }
    }