-
Notifications
You must be signed in to change notification settings - Fork 68
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
FreeBSD support #66
Comments
Hi @tykling. Pardon my lack of experience with FreeBSD. Let's leave SMBus support out of the discussion for now and concentrate on the pure i2c capabilities. The smbus2 lib as well as the example you linked to communicate in similar ways over i2c:
That indicated to me that it should be possible to smbus2's |
Hello :) Thank you for the input, it is much appreciated! I've been trying to make this work. My i2c device is on address 48 and working well:
I am using the first i2c example from the README:
With no changes to smbus2 I get the following error - which is understandable since it is using a Linux ioctl:
It took me a while to resolve the correct ioctl macro I2CRDWR on FreeBSD - finally found the integer with help from a friend and this little program:
After putting the value 0x80086906 in this line: https://github.com/kplindegaard/smbus2/blob/master/smbus2/smbus2.py#L33 the error changes, so I think the ioctl is correct:
Something is still wrong though. This is how far I got in the weekend. I will keep at it, but if you have any ideas I am all ears :) Thanks! 👍 |
OK, playing a bit more with it, I appear to have discovered that it does work, but on some unexpected addresses. Changing my test script to loop over 0-1024 and reading from each turns up my sensor which has i2c address 0x48, but it responds on 144 and 145, and again on 400 and 401, and again on 656 and 657 and so on. The sensor which has i2c address 0x60 responds on 192 and 193, and again on 448 and 449, and so on.
Great, finally some progress \o/ :+1: Can you spot why:
Thanks again! |
Yes, you're not supposed to pass raw addresses anywhere, the kernel always works with It's a bit confusing that you mixed hex and dec in the comment ;) but yeah, BTW, SMBus is a completely separate API on completely separate devices, see smb(4). The |
Hello :) I haven't forgotten or given up on this. I took over my new house on february 15th and haven't had much time since. I will get back to it asap! |
@tykling I hope you are enjoying the new house :) I am wondering if you have had a chance to get back to this as I am interested as well. |
As I was missing this as well and had some spare time, I've been so bold and created a PR implementing support for FreeBSD. Tested on a Raspberry PI 3B. Have fun! |
Thank you @0xc0decafe! #81 |
Hello :)
I would love to see FreeBSD support in smbus2 so Python i2c stuff would be easier in FreeBSD.
Before I do too much I wanted to ask if you are interested in accepting a PR for FreeBSD support (if I get that far)?
I've dug up https://github.com/freebsd/freebsd-src/blob/main/sys/dev/iicbus/iic.h which is used by https://github.com/freebsd/freebsd-src/blob/098dbd7ff7f3da9dda03802cdb2d8755f816eada/usr.sbin/i2c/i2c.c - the latter works well for communicating with i2c devices from the console. So I think the basics are in place.
I am not sure how to continue from here though, any pointers would be much appreciated! My ultimate goal is getting FreeBSD support in the Qwiic_py package for SparkFuns QWIIC ecosystem of sensors.
Thank you! 👍
The text was updated successfully, but these errors were encountered: