def test_warn_when_i2c_isnt_available(self):
     if not is_on_raspberry_pi():
         self._i2c.close()
         with self.assertWarns(UserWarning,
                               msg="Fails to warn the user when I2C "
                               "communication isn't available."):
             self._i2c = I2CInterface(0x70)
예제 #2
0
 def __init__(self, SDO_high=True, dump_communication=False):
     """The sensor takes(107 + /- 8) ms to initialize."""
     if SDO_high:
         self._i2c_address = SensorConstants.DEVICE_ADDRESS_SDO_HIGH
     else:
         self._i2c_address = SensorConstants.DEVICE_ADDRESS_SDO_LOW
     self._i2c = I2CInterface(self._i2c_address,
                              dump_communication=dump_communication)
     self._i2c.find_device()
     self._reset_sensor()
     self.set_op_mode(PressureSensor.OpMode.standby)
     self._calculate_calibration_coefficients()
예제 #3
0
 def __init__(self, dump_communication=False):
     """Initializes self."""
     self._i2c = I2CInterface(SensorConstants.ADDRESS,
                              dump_communication=dump_communication)
     if SensorConstants.ADDRESS in self._i2c.scan():
         self._reset()
         self._sensor_available = True
     else:
         self._sensor_available = False
     self._flow_inited = False
     self._crc8 = crcmod.mkCrcFun(SensorConstants.CRC_POLYNOMIAL,
                                  initCrc=0x00,
                                  rev=False,
                                  xorOut=0x00)
예제 #4
0
 def __init__(self, mux_address, dump_communication=False):
     self._i2c = I2CInterface(mux_address,
                              dump_communication=dump_communication)
예제 #5
0
 def __init__(self, mux_address):
     self._i2c = I2CInterface(mux_address)
 def setUp(self):
     warnings.filterwarnings("ignore",
                             message="I2C communication",
                             category=UserWarning)
     self._i2c = I2CInterface(0x70)