def rawSHT1X(self, Data = [3,0,0,0], WaitForMeasurementReady = True, IssueSerialReset = False, Add1MsDelay = False, Add300UsDelay = False, IO3State = 1, IO2State = 1, IO3Direction = 1, IO2Direction = 1, NumberOfBytesToWrite = 1, NumberOfBytesToRead = 3):
        """
        Name: U12.rawSHT1X( Data = [3, 0, 0, 0],
                            WaitForMeasurementReady = True,
                            IssueSerialReset = False, Add1MsDelay = False,
                            Add300UsDelay = False, IO3State = 1, IO2State = 1,
                            IO3Direction = 1, IO2Direction = 1,
                            NumberOfBytesToWrite = 1, NumberOfBytesToRead = 3)
        
        Args: Data, a list of bytes to write to the SHT.
              WaitForMeasurementReady, Wait for the measurement ready signal.
              IssueSerialReset, perform a serial reset
              Add1MsDelay, adds 1ms delay
              Add300UsDelay, adds a 300us delay
              IO3State, sets the state of IO3
              IO2State, sets the state of IO2
              IO3Direction, sets the direction of IO3 ( 1 = Output )
              IO2Direction, sets the direction of IO3 ( 1 = Output )
              NumberOfBytesToWrite, how many bytes to write
              NumberOfBytesToRead, how may bytes to read back
              
        Desc: Sends and receives data from a SHT1X T/RH sensor from Sensirion.
              See Section 5.15 of the User's Guide.
              
              By default, reads the temperature from the SHT.
              
        Returns: A dictionary with the following keys,
            DataByte0-3, the four data bytes read
            ErrorFlags, a BitField representing the error flags.
        
        Example:
        Uses an EI-1050 Temp/Humidity probe wired as follows:
        Data ( Green ) -> IO0
        Clock ( White ) -> IO1
        Ground ( Black ) -> GND
        Power ( Red ) -> +5V
        Enable ( Brown ) -> IO2
        
        >>> import u12
        >>> d = u12.U12()
        >>> results = d.rawSHT1X()
        >>> print results
        {
         'DataByte3': 0,
         'DataByte2': 69,
         'DataByte1': 48,
         'DataByte0': 25,
         'ErrorFlags':
          <BitField object: [ Serial Reset Error Flag = 0 (0), ... ] >
        }
        >>> tempC = (results['DataByte0'] * 256 ) + results['DataByte1']
        >>> tempC = (tempC * 0.01) - 40
        >>> print tempC
        24.48
        >>> results = d.rawSHT1X(Data = [5,0,0,0])
        >>> print results
        {
         'DataByte3': 0,
         'DataByte2': 200,
         'DataByte1': 90,
         'DataByte0': 2,
         'ErrorFlags':
          <BitField object: [ Serial Reset Error Flag = 0 (0), ... ] >
        }
        >>> sorh = (results['DataByte0'] * 256 ) + results['DataByte1']
        >>> rhlinear = (-0.0000028*sorh*sorh)+(0.0405*sorh)-4.0
        >>> rh = ((tempC-25.0)*(0.01+(0.00008*sorh)))+rhlinear
        >>> print rh
        19.3360256
        """
        command = [ 0 ] * 8
        
        if NumberOfBytesToWrite != 0:
            if not isinstance(Data, list) or len(Data) > 4:
                raise U12Exception("Data wasn't a list, or was too long.")
                
            Data.reverse()
            command[:len(Data)] = Data
        
        if max(NumberOfBytesToWrite, NumberOfBytesToRead) > 4:
            raise U12Exception("Can only read/write up to 4 bytes at a time.")
            
        bf = BitField()
        bf.bit7 = int(bool(WaitForMeasurementReady))
        bf.bit6 = int(bool(IssueSerialReset))
        bf.bit5 = int(bool(Add1MsDelay))
        bf.bit4 = int(bool(Add300UsDelay))
        bf.bit3 = int(bool(IO3State))
        bf.bit2 = int(bool(IO2State))
        bf.bit1 = int(bool(IO3Direction))
        bf.bit0 = int(bool(IO2Direction))
        
        command[4] = int(bf)
        
        # 01101000 (SHT1X)
        bf2 = BitField()
        bf2.bit6 = 1
        bf2.bit5 = 1
        bf2.bit3 = 1
        command[5] = int(bf2)
        
        command[6] = NumberOfBytesToWrite
        command[7] = NumberOfBytesToRead
        
        self.write(command)
        results = self.read()
        
        if results[5] != command[5]:
            raise U12Exception("Expected SHT1x response, got %s instead." % results[5])
        
        returnDict = dict()
        returnDict['DataByte3'] = results[0]
        returnDict['DataByte2'] = results[1]
        returnDict['DataByte1'] = results[2]
        returnDict['DataByte0'] = results[3]
        
        bfLabels = ["Serial Reset Error Flag", "Measurement Ready Error Flag", "Ack Error Flag"]
        bf = BitField( rawByte = results[4], labelPrefix = "", labelList = bfLabels )
        
        returnDict["ErrorFlags"] = bf
        
        return returnDict
dataset/ETHPy150Open LabPy/lantz/lantz/drivers/labjack/_internal/u12.py/U12.rawSHT1X/original