Skip to content

Added debug to i2c_device. #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2019
Merged

Conversation

kattni
Copy link
Contributor

@kattni kattni commented Feb 8, 2019

No description provided.

@kattni kattni requested review from tannewt and ladyada February 8, 2019 19:02
@kattni
Copy link
Contributor Author

kattni commented Feb 8, 2019

Tested on Feather M4 with VCNL4040.

code.py output:
i2c_device.write: ['0xc', '0x0', '0x0']
i2c_device.readinto: ['0xc', '0x86', '0x1']
i2c_device.write: ['0x3', '0x0', '0x0']
i2c_device.readinto: ['0x3', '0x1', '0x0']
i2c_device.write: ['0x3', '0x1', '0x0']
i2c_device.write: ['0x0', '0x0', '0x1']

@@ -147,10 +152,19 @@ def write_then_readinto(self, out_buffer, in_buffer, *,
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
out_start=out_start, out_end=out_end,
in_start=in_start, in_end=in_end, stop=stop)
if self._debug:
print("i2c_device.writeto_then_readfrom.out_buffer:", [hex(i) for i in out_buffer])
print("i2c_device.writeto_then_readfrom.in_buffer:", [hex(i) for i in in_buffer])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to slice in_start and in_end here, ditto above for out_buffer

else:
# If we don't have a special implementation, we can fake it with two calls
self.write(out_buffer, start=out_start, end=out_end, stop=stop)
if self._debug:
print("i2c_device.write_then_readinto.write.out_buffer:",
[hex(i) for i in out_buffer])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice here too

self.readinto(in_buffer, start=in_start, end=in_end)
if self._debug:
print("i2c_device.write_then_readinto.readinto.in_buffer:",
[hex(i) for i in in_buffer])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n here!

print("i2c_device.writeto_then_readfrom.in_buffer:", [hex(i) for i in in_buffer])
print("i2c_device.writeto_then_readfrom.out_buffer:",
[hex(i) for i in out_buffer[out_start:out_end]])
print("i2c_device.writeto_then_readfrom.in_buffer:",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think print the writebuffer slice before the command, then the readbuffer after.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@ladyada ladyada merged commit 3e6bf71 into adafruit:master Feb 8, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants