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

Add const specifiers to posix and nuttx I2C class constructors and transfer() methods #12934

Closed
wants to merge 2 commits into from

Conversation

mcsauder
Copy link
Contributor

@mcsauder mcsauder commented Sep 9, 2019

Describe problem solved by the proposed pull request
This PR adds const specifiers to the posix and nuttx I2C class constructors and transfer() method arguments. Currently, a few of the arguments have const specifiers and this work adds const to the remaining arguments.

Test data / coverage
This PR was test flown on a 250 quad with pixhawk 4 mini. (The pixhawk mini primary mag, the IST8310, is I2C.)
image

Flight tests perform the same as current PX4:master branch

Please let me know if you have any questions on this PR! Thanks!

-Mark

@dagar
Copy link
Member

dagar commented Sep 10, 2019

The receive buffer shouldn't be const.

@mcsauder
Copy link
Contributor Author

The receive buffer shouldn't be const.

Yes. Agreed. But we can expect the pointer to the buffer to not change during the execution of the method, though, right?

@dagar
Copy link
Member

dagar commented Sep 10, 2019

Declare a pointer to a const uint8_t type.

const uint8_t * buf

Declare a const pointer to a uint8_t type.

const * uint8_t buf

Both.

const * uint8_t * buf

@mcsauder mcsauder force-pushed the i2c_class_const_additions branch from 5c9baf0 to 505a339 Compare September 11, 2019 02:05
@mcsauder
Copy link
Contributor Author

Thanks for pointing that out @dagar, I've removed the const specifiers from the receive buffers added in the previous commit, specifying them the right (intended) way is just really ugly.

I'm still curious how that worked at all:
image

Let me know if you'd like to see anything else done with this PR! Thanks!

TSC21
TSC21 previously approved these changes Sep 24, 2019
@TSC21
Copy link
Member

TSC21 commented Sep 24, 2019

@mcsauder can you rebase?

@mcsauder
Copy link
Contributor Author

Rebased and commits squashed. Thanks for the ping @TSC21 !

@mcsauder mcsauder force-pushed the i2c_class_const_additions branch from cc55383 to 64e6315 Compare September 26, 2019 03:05
@mcsauder
Copy link
Contributor Author

Closing, merged with PR #12695.

@mcsauder mcsauder closed this Sep 28, 2019
@mcsauder mcsauder deleted the i2c_class_const_additions branch September 28, 2019 03:22
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