Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Fix _i2c_read_request function to allow direct I2C read without preliminary I2C write #15

Merged
merged 2 commits into from
Jun 10, 2020

Conversation

rbarzic
Copy link
Contributor

@rbarzic rbarzic commented Jun 4, 2020

allow direct read from the device without initial register selection.
This should match the two possible I2C read supported by the
FirmataExpress firmware.

Explanation: With the current code, an I2C write occurs to select a register before the I2C read access.
This prevents usage of I2C circuits like an I2C multiplexer (like the tca9548a ) with pymata4.
The FirmataExpress supports the two different types of access (with or without the first I2C write) by looking at the number of data passed in the sysex call.
(see https://github.com/MrYsLab/FirmataExpress/blob/eff00dba368b10286a6bbfe753b0de44850e1362/examples/FirmataExpress/FirmataExpress.ino#L625)

The pull-request does not change the other I2C read functions but it is very likely that the same documentation update is needed

Before the fix (an simple 1-byte I2C read):

board.i2c_read(I2C_MUX_SLAVE_ADDRESS, 0, 1, i2c_read_callback)

before_fix

After the fix

board.i2c_read(I2C_MUX_SLAVE_ADDRESS, None, 1, i2c_read_callback)

after-fix

allow direct read from the device without initial register selection.
This should match the two possible I2C read supported by the
FirmataExpress firmware
@MrYsLab
Copy link
Owner

MrYsLab commented Jun 6, 2020

Thanks for the pull request. I will merge this in the next release sometime in the near future.

@MrYsLab MrYsLab merged commit 954e07b into MrYsLab:master Jun 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants