From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sat, 2 Jan 2016 10:06:31 -0800 To: blstuart@bellsouth.net, 9fans@9fans.net, quanstro@quanstro.net Message-ID: <9a649e41e74960f62d15a7e14e9cfa07@mule> In-Reply-To: <594280736.4698467.1451711534944.JavaMail.yahoo@mail.yahoo.com> References: <594280736.4698467.1451711534944.JavaMail.yahoo.ref@mail.yahoo.com> <594280736.4698467.1451711534944.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] Pi updates Topicbox-Message-UUID: 7d3705f0-ead9-11e9-9d60-3106f5b1d025 On Fri Jan 1 21:15:03 PST 2016, blstuart@bellsouth.net wrote: > On Fri, 1/1/16, erik quanstrom wrote: > > i'm looking @ the gpio interface, and i wonder what the recommended > > technique for sampling a pin might be from a shell script? >=20 > I haven't really used it in shell scripts, but if I were going to do > so, I'd probably write up a little utility to take a hex string and > a bit number and do the 'and' on it. Then feed that with the > result of dd to get exactly one sample from devgpio. On the > other hand, if one of the usual suspects (e.g. hoc, bc, dc, awk) > have some bit-wise operators I'm forgetting, use that. the (atom) aux/number program does do that; none of the others do for fairly fundamental reasons: as awk and hoc are really floating point, and bc and dc are mp, and the mp library has no bit operations. i believe acid can as well, but only with great pain. perhaps just using base 2 for the encoding would make life a lot easer. s= o=20 00000000000000000000000000010000000000000000000000000000000000000 for bit 27 active. with this format there's no limit to the number of bi= ts one could represent. also, mightn't there be some value in presenting the full state of the de= vice to allow it to be restored directly from the status file, so perhaps 3 li= nes could be added, one each for up/down/float settings? 00000000000000000000000000010000000000000000000000000000000000000 00000000000000000000000000010000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 might represent bit 27 set, with the pull up resistor active. (perhaps float =E2=89=A1 (pullup | pulldown) =3D=3D 0? and could be elimitated. i'm sure a little tinkering with this idea can make it a lot more useful. - erik