Read ADC data from the BMP including voltages and temperature.

        Returns
        -------
        :py:class:`.ADCInfo`
354342
def read_adc(self, cabinet, frame, board):
        
        response = self._send_scp(cabinet, frame, board, SCPCommands.bmp_info,
                                  arg1=BMPInfoType.adc, expected_args=0)
        data = struct.unpack("<"   # Little-endian
                             "8H"  # uint16_t adc[8]
                             "4h"  # int16_t t_int[4]
                             "4h"  # int16_t t_ext[4]
                             "4h"  # int16_t fan[4]
                             "I"   # uint32_t warning
                             "I",  # uint32_t shutdown
                             response.data)

        return ADCInfo(
            voltage_1_2c=data[1] * BMP_V_SCALE_2_5,
            voltage_1_2b=data[2] * BMP_V_SCALE_2_5,
            voltage_1_2a=data[3] * BMP_V_SCALE_2_5,
            voltage_1_8=data[4] * BMP_V_SCALE_2_5,
            voltage_3_3=data[6] * BMP_V_SCALE_3_3,
            voltage_supply=data[7] * BMP_V_SCALE_12,
            temp_top=float(data[8]) * BMP_TEMP_SCALE,
            temp_btm=float(data[9]) * BMP_TEMP_SCALE,
            temp_ext_0=((float(data[12]) * BMP_TEMP_SCALE)
                        if data[12] != BMP_MISSING_TEMP else None),
            temp_ext_1=((float(data[13]) * BMP_TEMP_SCALE)
                        if data[13] != BMP_MISSING_TEMP else None),
            fan_0=float(data[16]) if data[16] != BMP_MISSING_FAN else None,
            fan_1=float(data[17]) if data[17] != BMP_MISSING_FAN else None,
        )
10100
def decode_temperature(packet, channel=1):
    """"""
    val = str(packet.get(QSDATA, ''))
    if len(val) == 12 and val.startswith('34') and channel == 1:
        temperature = int(val[-4:], 16)
        return round(float((-46.85 + (175.72 * (temperature / pow(2, 16))))))
    return None
709001
def voltage(self):
        """"""
        raw = self.value
        volts = raw * (_ADS1X15_PGA_RANGE[self._ads.gain] / (2**(self._ads.bits-1) - 1))
        return volts
324490
def read(self):
        
        # Read value
        try:
            buf = os.read(self._fd, 8)
        except OSError as e:
            raise LEDError(e.errno, "Reading LED brightness: " + e.strerror)

        # Rewind
        try:
            os.lseek(self._fd, 0, os.SEEK_SET)
        except OSError as e:
            raise LEDError(e.errno, "Rewinding LED brightness: " + e.strerror)

        return int(buf)
351965
def get_dpi(raise_error=True):
    
    try:
        user32.SetProcessDPIAware()
    except AttributeError:
        pass  # not present on XP
    dc = user32.GetDC(0)
    h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)
    v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)
    h_res = gdi32.GetDeviceCaps(dc, HORZRES)
    v_res = gdi32.GetDeviceCaps(dc, VERTRES)
    user32.ReleaseDC(None, dc)
    return (h_res/float(h_size) + v_res/float(v_size)) * 0.5 * 25.4
362716
async def _analog_message(self, data):
        
        pin = data[0]
        value = (data[PrivateConstants.MSB] << 7) + data[PrivateConstants.LSB]
        # if self.analog_pins[pin].current_value != value:
        self.analog_pins[pin].current_value = value

        # append pin number, pin value, and pin type to return value and return as a list
        message = [pin, value, Constants.ANALOG]

        if self.analog_pins[pin].cb:
            if self.analog_pins[pin].cb_type:
                await self.analog_pins[pin].cb(message)
            else:
                loop = self.loop
                loop.call_soon(self.analog_pins[pin].cb, message)

        # is there a latch entry for this pin?
        key = 'A' + str(pin)
        if key in self.latch_map:
            await self._check_latch_data(key, message[1])
1193556
def read_memory(self, addr, transfer_size=32, now=True):
        
        result = self.ap.read_memory(addr, transfer_size, now)

        # Read callback returned for async reads.
        def read_memory_cb():
            return self.bp_manager.filter_memory(addr, transfer_size, result())

        if now:
            return self.bp_manager.filter_memory(addr, transfer_size, result)
        else:
            return read_memory_cb
1373503
def _get_temperature(self, decoded):
        ''''''
        temp = (decoded[2] & 127) + decoded[3] / 100
        sign = (decoded[2] >> 7) & 1
        if sign == 0:
            return round(temp, 2)
        return round(-1 * temp, 2)
906179
def get_temperature(self):
        
        #raise NotImplementedError("This should work according to the AVM docs, but don't...")
        value = self.box.homeautoswitch("gettemperature", self.actor_id)
        if value.isdigit():
            self.temperature = float(value)/10
        else:
            self.temperature = None
        return self.temperature
1051836
def get_adcm(self):
        
        adcm = 0
        for class_def in self.classes:
            if len(class_def) > 0:
                yc = self.y[class_def]
                yc_med = np.median(yc)
                ycd = np.abs(yc - yc_med)
                adcm += sum(ycd)
        return adcm
1345307
def _get_temperature(self, data):
        ''''''
        if data[1:2] == 0x7FFF:
            return None

        temperature = twos_complement((data[1] << 8) + data[2], 16) / 200
        return round(temperature, 2)
424507
def humidity(self):
        
        self._read_temperature()
        hum = self._read_register(_BME280_REGISTER_HUMIDDATA, 2)
        #print("Humidity data: ", hum)
        adc = float(hum[0] << 8 | hum[1])
        #print("adc:", adc)

        # Algorithm from the BME280 driver
        # https://github.com/BoschSensortec/BME280_driver/blob/master/bme280.c
        var1 = float(self._t_fine) - 76800.0
        #print("var1 ", var1)
        var2 = (self._humidity_calib[3] * 64.0 + (self._humidity_calib[4] / 16384.0) * var1)
        #print("var2 ",var2)
        var3 = adc - var2
        #print("var3 ",var3)
        var4 = self._humidity_calib[1] / 65536.0
        #print("var4 ",var4)
        var5 = (1.0 + (self._humidity_calib[2] / 67108864.0) * var1)
        #print("var5 ",var5)
        var6 = 1.0 + (self._humidity_calib[5] / 67108864.0) * var1 * var5
        #print("var6 ",var6)
        var6 = var3 * var4 * (var5 * var6)
        humidity = var6 * (1.0 - self._humidity_calib[0] * var6 / 524288.0)

        if humidity > _BME280_HUMIDITY_MAX:
            return _BME280_HUMIDITY_MAX
        if humidity < _BME280_HUMIDITY_MIN:
            return _BME280_HUMIDITY_MIN
        # else...
        return humidity
1318462
def tell(self):
        
        pos = ctypes.c_size_t()
        check_call(_LIB.MXRecordIOReaderTell(self.handle, ctypes.byref(pos)))
        return pos.value
929091
def read(self, vals):
        
        i = 0
        count = int(vals[i])
        i += 1
        for _ in range(count):
            obj = GroundTemperature()
            obj.read(vals[i:i + obj.field_count])
            self.add_ground_temperature(obj)
            i += obj.field_count
1107664
def returnData(self, dsptr):
        
        dataPtr = dsptr & 0x00FFFFFFL
        dataLen = (dsptr >> 24) & 0xFF

        self.__f.seek(dataPtr)

        data = self.__f.read(dataLen)
        result = data[4:].split('|')
        location = Location(self.getLong(data, 0), result[0], result[1], result[2], result[3], result[4])

        return location
1125755
def main():
    
    options = handle_options()

    # read in observed and synthetic data
    elecs, d_obs = readin_volt(options.d_obs)
    elecs, d_est = readin_volt(options.d_est)
    elecs, d_estTC = readin_volt(options.d_estTC)
    # calculate corrected data
    volt_corr = calc_correction(d_obs,
                                d_est,
                                d_estTC,
                                )
    # save data
    save_volt(elecs,
              volt_corr,
              options.output,
              )
1268787
def read(self):
        
        self.reset()
        for dic in self.datamodel.camera_collection.get(): # TODO: search directly for RTSPCameraRow
            if (self.verbose): print(self.pre, "read : dic", dic)
            
            if (dic["classname"] == DataModel.RTSPCameraRow.__name__):
                affinity = -1
                if self.cpu_scheme:
                    affinity = self.cpu_scheme.getAV()
                
                dic.pop("classname")
                device = DataModel.RTSPCameraDevice(**dic) # a neat object with useful methods
                
                print("FilterChainGroup : read : slot    =", device.getLiveMainSlot())
                print("FilterChainGroup : read : address =", device.getMainAddress())
                print("FilterChainGroup : read : _id     =", device._id)
                
                # chain = ManagedFilterchain( # decoding and branching the stream happens here
                # chain = ManagedFilterchain2( # decoding and branching the stream happens here
                chain = LiveManagedFilterchain( # decoding and branching the stream happens here
                    livethread  = self.livethread,
                    openglthreads
                                = self.gpu_handler.openglthreads,
                    address     = device.getMainAddress(),
                    slot        = device.getLiveMainSlot(),
                    _id         = device._id,
                    affinity    = affinity,
                    msreconnect = 10000,
                    # verbose     = True,
                    verbose     =False,
                    
                    shmem_image_dimensions = constant.shmem_image_dimensions,
                    shmem_n_buffer = constant.shmem_n_buffer,
                    shmem_image_interval = constant.shmem_image_interval
                )
                self.chains.append(chain) # important .. otherwise chain will go out of context and get garbage collected
                
            elif (dic["classname"] == DataModel.USBCameraRow.__name__):
                affinity = -1
                if self.cpu_scheme:
                    affinity = self.cpu_scheme.getAV()
                
                dic.pop("classname")
                device = DataModel.USBCameraDevice(**dic) # a neat object with useful methods
                
                print("FilterChainGroup : read : slot    =", device.getLiveMainSlot())
                print("FilterChainGroup : read : address =", device.getMainAddress())
                print("FilterChainGroup : read : _id     =", device._id)
                
                chain = USBManagedFilterchain( # decoding and branching the stream happens here
                    usbthread   = self.usbthread,
                    openglthreads
                                = self.gpu_handler.openglthreads,
                    address     = device.getMainAddress(),
                    slot        = device.getLiveMainSlot(),
                    _id         = device._id,
                    affinity    = affinity,
                    msreconnect = 10000,
                    # verbose     = True,
                    verbose     =False,
                    
                    shmem_image_dimensions = constant.shmem_image_dimensions,
                    shmem_n_buffer = constant.shmem_n_buffer,
                    shmem_image_interval = constant.shmem_image_interval
                )
                self.chains.append(chain)