Date: Sat, 15 May 2021 20:14:01 +0000 From: Poul-Henning Kamp <phk@phk.freebsd.dk> To: hackers@freebsd.org Subject: patch: make i2c(8) usable for scripting Message-ID: <12056.1621109641@critter.freebsd.dk>
next in thread | raw e-mail | index | archive | help
Here is a patch to make i2c(8) much more usable from scripts and scripting= languages: http://phk.freebsd.dk/misc/i2c.patch That patch applies only to -current, I had to give i2c.c a good wash first= . If you are not -current, it will be easier to fetch: http://phk.freebsd.dk/misc/i2c.c http://phk.freebsd.dk/misc/i2c.8 The patch adds two new modes "-i" and "-iv" "-i" mode is intended to use from hardware-initialization scripts etc, and= treats any error as fatal. "-iv" on the other hand treats no error as fatal, and is targeted more at = python classes, continous data collection etc. In both cases i2c(8) takes (argv/stdin) commands like: r 0 0x50 16BE 24 8 or w 0 0x50 16BE 24 48656c6c 6f20576f 726c6421 0a (see manpage for details) These modes always use the I2CRDWR ioctl, which works on all the hardware = I have. The /dev/iic%d filedescriptor is opened and closed for every single command, in the hope that it will aid multiple separate programs sharing I2C busses. I have not actually tried that yet, so it may need more work (exclusive opens etc.). Comments & inputs welcome... Poul-Henning -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence= .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12056.1621109641>