-
-
Notifications
You must be signed in to change notification settings - Fork 729
Overload beginTransmission and requestFrom to support using an external buffer #289
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
Overload beginTransmission and requestFrom to support using an external buffer #289
Conversation
✅ Build completed. ⬇️ Build URL: ℹ️ To test this build:
|
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.
I think that overall it looks great!
Just a couple of details could be improved. Also, your bracing style does not match the rest of the file (although it was not very consistent to begin with)
} | ||
else | ||
{ | ||
if ( externalTxBufferLength == externalTxBufferQuantity ) |
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.
I would use >= for robustness
} | ||
|
||
void TwoWire::beginTransmission(uint8_t address) { | ||
void TwoWire::beginTransmission(uint8_t address, uint8_t buffer[], size_t length, size_t quantity) { |
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.
I think the name of the arguments in beginTransmission is confusing. How about bufferLength and usedBytes?
Some time ago we all discussed an "addMemory" API to be added to HardwareSerial, Wire, and other libs. I believe @facchinm made an initial implementation, but it never left a branch on his fork, maybe due to lack of agreement over the API details? Is that idea gone now? Is passing pointers really going to become the Arduino API? |
Fix [-Wrestrict] bug
Replacement for #269, with updated API's based on the discussion with @lupalby.
Wire. requestFrom(...)
andWire.beginTransmission(...)
are overloaded to support external buffers.The external buffer for TX can optionally be partially or fully pre-populated with data. The existing
Stream
andPrint
API's can continue to be used to populate the external buffer.