Skip to content

Commit

Permalink
Try implementing read_byte and write_byte
Browse files Browse the repository at this point in the history
  • Loading branch information
gkluoe committed Apr 2, 2021
1 parent 539d595 commit 2321171
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions usmbus/__init__.py
Expand Up @@ -49,14 +49,17 @@ def write_i2c_block_data(self, addr, register, data):
data = bytes([data])
return self.writeto_mem(addr, register, data)

# The follwing haven't been implemented, but could be.
def read_byte(self, *args, **kwargs):
""" Not yet implemented """
raise RuntimeError("Not yet implemented")
def read_byte(self, addr):
""" Read a single byte of data from the device at addr
Returns a bytes object with the data read """
return self.readfrom(addr, 1)

def write_byte(self, *args, **kwargs):
""" Not yet implemented """
raise RuntimeError("Not yet implemented")
def write_byte(self, addr, data):
""" Write a single byte of data to the device at addr
Returns None """
if isinstance(data, int):
data = bytes([data])
return self.writeto(addr, data)

def read_word_data(self, *args, **kwargs):
""" Not yet implemented """
Expand Down

0 comments on commit 2321171

Please sign in to comment.