Skip to content

Commit dfd4dff

Browse files
Update linux_i2c.py
Add optioin for read without specifying register. Used for devices that only take a command byte (i.e. qwiic mux).
1 parent 21ecb10 commit dfd4dff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

qwiic_i2c/linux_i2c.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ def readWord(self, address, commandCode):
168168

169169
return data
170170

171-
def readByte(self, address, commandCode):
171+
def readByte(self, address, commandCode = None):
172172
data = 0
173173
for i in range(_retry_count):
174174
try:
175-
data = self.i2cbus.read_byte_data(address, commandCode)
175+
if commandCode == None:
176+
data = self.i2cbus.read_byte(address)
177+
elif commandCode != None:
178+
data = self.i2cbus.read_byte_data(address, commandCode)
176179

177180
break # break if try succeeds
178181

0 commit comments

Comments
 (0)