@@ -57,9 +57,6 @@ class TCA9548A_Channel():
57
57
def __init__ (self , tca , channel ):
58
58
self .tca = tca
59
59
self .channel_switch = bytearray ([1 << channel ])
60
- # provide only if needed
61
- if hasattr (self .tca .i2c , 'writeto_then_readfrom' ):
62
- setattr (self , 'writeto_then_readfrom' , self .writeto_then_readfrom_passthru )
63
60
64
61
def try_lock (self ):
65
62
"""Pass thru for try_lock."""
@@ -85,12 +82,17 @@ def writeto(self, address, buffer, **kwargs):
85
82
raise ValueError ("Device address must be different than TCA9548A address." )
86
83
return self .tca .i2c .writeto (address , buffer , ** kwargs )
87
84
88
- def writeto_then_readfrom_passthru (self , address , buffer_out , buffer_in , ** kwargs ):
85
+ def writeto_then_readfrom (self , address , buffer_out , buffer_in , ** kwargs ):
89
86
"""Pass thru for writeto_then_readfrom."""
90
87
#In linux, at least, this is a special kernel function call
91
88
if address == self .tca .address :
92
89
raise ValueError ("Device address must be different than TCA9548A address." )
93
- return self .tca .i2c .writeto_then_readfrom (address , buffer_out , buffer_in , ** kwargs )
90
+
91
+ if hasattr (self .tca .i2c , 'writeto_then_readfrom' ):
92
+ self .tca .i2c .writeto_then_readfrom (address , buffer_out , buffer_in , ** kwargs )
93
+ else :
94
+ self .tca .i2c .writeto (address , buffer_out , start = kwargs .get ("out_start" , 0 ), end = kwargs .get ("out_end" , None ), stop = False )
95
+ self .tca .i2c .readfrom_into (address , buffer_in , start = kwargs .get ("in_start" , 0 ), end = kwargs .get ("in_end" , None ))
94
96
95
97
class TCA9548A ():
96
98
"""Class which provides interface to TCA9548A I2C multiplexer."""
0 commit comments