Skip to content
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

Return only as many bytes as the hardware returned #94

Merged
merged 1 commit into from
Apr 18, 2020

Conversation

pgrawehr
Copy link
Contributor

This small patch fixes firmata/arduino#444. Instead of returning a buffeer with fewer (or no) valid data than expected, we're only returning as many bytes as there actually were.
Most clients should not be affected by this, because if the hardware is properly working, this should not happen. However it enables the possibility to use ReadByte() commands to poll for valid I2C addresses, making the equivalent of I2Cdetect work over firmata.

@soundanalogous
Copy link
Member

Thanks!

@soundanalogous soundanalogous merged commit b06322f into firmata:master Apr 18, 2020
@soundanalogous
Copy link
Member

Do you mind also making the same change in all the StandardFirmata example variants here?

@pgrawehr
Copy link
Contributor Author

@soundanalogous I haven't used any of those, and since they report a smaller version number than this one does, I thought they were obsolete.
For my understanding: What is the advantage of StandardFirmata over ConfigurableFirmata? Or: Why do they exist in parallel?

@soundanalogous
Copy link
Member

StandardFirmata requires much less memory than ConfigurableFirmata with the exact same feature set enabled. If I could figure out a way to reduce that I'd merge them back together and use the modular approach for both.

@pgrawehr
Copy link
Contributor Author

@soundanalogous : Well, a bit of testing doesn't really confirm that for me. For StandardFirmata.ino, the Compiler tells me it uses 1065Bytes of RAM. For ConfigurableFirmata, I get 1165Bytes when I disable OneWire and Serial, which seem not to be part of StandardFirmata (so the feature set includes Digital in/out, Analog in/out, i2c, scheduler and reporting). This is an acceptable pay-off for the larger flexibility and better architecture IMHO. The ConfigurableFirmata OneWire driver wastes a lot of memory by allocating a struct for each possible pin.

@soundanalogous
Copy link
Member

It is nearly a 10% increase in RAM. However you don't need to include Scheduler so that saves a few bytes.

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.

I2C read to unexisting address returns a reply
2 participants