@@ -598,8 +598,12 @@ def _read_register(self, register):
598
598
# In the original commments, Phil Fenstermacher (pcfens) says this
599
599
# trick is required because smbus doesn't support repeated I2C
600
600
# starts to read the registers directly (singularly) on the sensor.
601
+ i2c .write (bytes ([0x00 ]))
601
602
result = bytearray (9 )
602
- i2c .write_then_readinto (bytes ([0x00 ]), result )
603
+ # write_then_readinto() does not work reliably,
604
+ # so do explicit write followed by read into
605
+ # i2c.write_then_readinto(bytes([0x00]), result)
606
+ i2c .readinto (result )
603
607
if self ._debug :
604
608
print ([hex (i ) for i in result ])
605
609
print ("$%02X => %s" % (register , hex (result [register ])))
@@ -621,8 +625,12 @@ def _read_byte(self, register):
621
625
# In the original commments, Phil Fenstermacher (pcfens) says this
622
626
# trick is required because smbus doesn't support repeated I2C
623
627
# starts to read the registers directly (singularly) on the sensor.
628
+ i2c .write (bytes ([0x00 ]))
624
629
result = bytearray (0x3E )
625
- i2c .write_then_readinto (bytes ([0x00 ]), result )
630
+ # write_then_readinto() does not work reliably,
631
+ # so do explicit write followed by read into
632
+ # i2c.write_then_readinto(bytes([0x00]), result)
633
+ i2c .readinto (result )
626
634
if self ._debug :
627
635
print ([hex (i ) for i in result ])
628
636
print ("$%02X => %s" % (register , hex (result [register ])))
0 commit comments