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

Guidance on Implementing simpleRPC with I2C (Wire) #43

Open
CameronBrooks11 opened this issue Nov 10, 2024 · 1 comment
Open

Guidance on Implementing simpleRPC with I2C (Wire) #43

CameronBrooks11 opened this issue Nov 10, 2024 · 1 comment

Comments

@CameronBrooks11
Copy link

Is your feature request related to a problem? Please describe.

I'm trying to implement simpleRPC over I2C (using the Wire library) on an Arduino Nano, with a Raspberry Pi acting as the master running the arduino-simple-rpc Python client with an added interface using SMBus lib on the RPi. The library mentions support for Wire but notes that it’s untested. I've attempted to adapt the examples by setting up Wire-based communication, but I've encountered challenges, particularly with handling the I2C’s 32-byte buffer limit and aligning the response data properly. This has made it difficult to utilize simpleRPC with I2C.

Describe the solution you'd like

It would be great to have guidance or additional documentation for implementing simpleRPC over I2C. Ideally, I'd like an approach or example that demonstrates managing buffer limits and structuring the library's functionality to be able to implement Wire-based communication.

Describe alternatives you've considered

I've tried setting up Wire-based communication by adapting the library’s examples, chunking responses to handle the I2C buffer limit, and testing different ways to align responses between the Arduino and Raspberry Pi. However, I’m not achieving a reliable connection and consistent data handling over I2C.

Additional context

Any insights on how you’d approach implementing simpleRPC over I2C would be helpful. If there are specific areas in the library code to focus on for a Wire-based setup, that guidance would also be appreciated. Thanks for creating and sharing this library!

@chrisflesher
Copy link
Collaborator

I doubt anyone has attempted this before. The I2C is currently untested, we just listed it because it supported the Arduino Stream interface.

I've worked with flaky comms before (wireless comms over long distances) and have had some success just combining all data into one giant packet of bytes. Then on the CPU side unpack using struct.unpack for the individual fields. Sometimes the message will be malformed and you'd need discard it.

If you get I2C working for the general case and would like to try creating a PR I wouldn't mind reviewing / trying it? Not sure I have time to develop this unfortunately.

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

No branches or pull requests

2 participants