-
Notifications
You must be signed in to change notification settings - Fork 200
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
applet.interface.i2c_master: add "scan" command #166
Conversation
Should we maybe have a single |
would also be an option. I'm indifferent, both ways are a reasonable interface IMO. |
Let's do that instead. Would you adjust the PR please? |
will do |
b150081
to
a1ab8c3
Compare
|
||
p_scan.add_argument( | ||
"--readwrite", "-rw", action="store_true", default=False, | ||
help="scan read and write addresses") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the combination of -r
and -w
already work as -rw
with no additional effort? Or does argparse not provide that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, you are right. I didn't give argparse enough credit, it can do it.
Will fix it in the next rev.
@@ -233,6 +233,24 @@ def __init__(self, interface, logger): | |||
revision = device_id[2] & 0x7 | |||
return (manufacturer, part_ident, revision) | |||
|
|||
async def scan(self, read_addrs=True, write_addrs=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should mark any boolean flags as keyword-only arguments, like async def scan(self, *, read_addrs=True, write_addrs=True):
. (I should add a CONTRIBUTING.md file that explains these things...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I wasn't thinking pythonic enough. Will fix that in the next rev.
…mands with "scan" "-r", "-w" and "-rw" allow to select which type of addresses to scan. "-rw" is the default. Some devices only ACK one of the addresses, so scanning both gives a better overview of the bus.
…sterInterface Allows to use it from other applets or the repl interface
a1ab8c3
to
a7a5bf1
Compare
Thanks! |
Do you think side effects are more likely with read scanning than write scanning? |
In case of read scanning you're reading one byte, in case of write scanning you're aborting the transaction after the address, which is why I thought it's more likely. |
I remember reading a datasheet where the interrupt line was reset when reading out the irq register or something like that. That would match your line of thought. |
Let's. |
grmpf. additions to a branch aren't possible in github once it's merged. |
"scan" scans for i2c devices on read and write addresses in one go.
Some devices only ACK one of the addresses, so scanning both gives
a better overview of the bus. With this command you don't need to
do a "scan-read" and then a "scan-write" to get the result.