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

Read expected payload size of GPIO packet #304

Merged

Conversation

IAmNickNack
Copy link
Contributor

This PR addresses issue #303 and could possibly be expanded to cover SPI and serial data too.

@IAmNickNack IAmNickNack changed the title Read expected payload size Read expected payload size of GPIO packet Oct 18, 2023
@eitch
Copy link
Member

eitch commented Oct 23, 2023

Hi @IAmNickNack
The code looks quite ok. Did you test it on a normal I2C connection as well?

@IAmNickNack
Copy link
Contributor Author

Could you clarify normal I2C?

If you mean I2C via non-socket GPIO, then no. Even prior to making this change I have been unable to get non-socket GPIO working on my local setup. Startup fails on my v4 device with PIGPIO ERROR: PI_INIT_FAILED. I have resorted to either GPIO over sockets or Linuxfs providers.

If this is what you mean. I can persevere.

@eitch
Copy link
Member

eitch commented Oct 23, 2023

Hi @IAmNickNack the PI_INIT_FAILED error you get is most probably because you are not running it as root. Can you try again with root?

@IAmNickNack
Copy link
Contributor Author

IAmNickNack commented Oct 23, 2023

Hi @IAmNickNack the PI_INIT_FAILED error you get is most probably because you are not running it as root. Can you try again with root?

Running as root appears to make no difference. I will have to try a simpler test case than the application I'm currently working on to see if I can find out what's going on.

Filesystem permissions appear to be correct. I would expect both root and the user account to behave the same in this case anyway:

crw-rw---- 1 root gpio 245, 0 Oct 23 11:17 /dev/gpiomem

@IAmNickNack
Copy link
Contributor Author

IAmNickNack commented Oct 23, 2023

Hi @IAmNickNack the PI_INIT_FAILED error you get is most probably because you are not running it as root. Can you try again with root?

A-ha! This could be useful information to others, as I've seen this error mentioned in a number of posts:

Non-socket GPIO doesn't work when pigpiod is running! In my case it runs as a service to support development from a laptop. pigpiod presumably has some lock on /dev/gpiomem (?) 🤷

I did still need to be running as root for this to work though.

So, in response to your original question @eitch, yes. I have tested this code change with a normal, non-socket i2c connection and have satisfied myself that it is good.

Please feel free to suggest a more rigorous and definitive testing strategy to me if you like however.

Thanks

@eitch eitch merged commit de5bfd9 into Pi4J:develop Oct 24, 2023
1 check passed
@eitch
Copy link
Member

eitch commented Oct 24, 2023

Hi @IAmNickNack thanks for your work! I have merged your PR. Happy to see it works!

@IAmNickNack
Copy link
Contributor Author

Thanks @eitch. Hopefully somebody with an active serial or SPI project can add appropriate support for the equivalent operations to the switch as necessary.

@IAmNickNack IAmNickNack deleted the wait-for-expected-bytes-from-socket-stream branch October 24, 2023 07: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.

2 participants