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

Data from SPI not correct #16

Open
FDelporte opened this issue Jun 12, 2020 · 1 comment
Open

Data from SPI not correct #16

FDelporte opened this issue Jun 12, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@FDelporte
Copy link
Member

As reported by Jim Darby:
I've had some very strange errors when not running as root and using pigpiod. Sometimes when you read from a SPI device you get back more data than you sent. This shouldn't be possible and I'm still investigating.

@FDelporte FDelporte added the bug Something isn't working label Jun 12, 2020
@FDelporte FDelporte added this to the v2.0 (initial release) milestone Jun 12, 2020
@IAmNickNack
Copy link
Contributor

IAmNickNack commented Oct 15, 2023

I have come across a similar issue when using I2C via the GPIO socket implementation over a slow wireless network. I did not observe the problem when running the same code locally on the Pi via the loopback interface.

I think the problem might stem from PiGpioPacket#decode assuming that all the data for the packet, including the payload, is already available from the socket stream.

I have been able to solve this in a local build of pi4j which, rather than assuming all the bytes currently available, depending on the command (e.g. I2CRI, I2CRD) takes packets p3 value as a hint for the content length to expect.

This works for my I2C use cases. I don't have an SPI or serial project on the go at the moment, so have not been able to validate those cases.

I'd be happy to tidy my code an raise a PR for this if that would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants