Re: hex2bin im string aufloesen [erledigt]
Thomas Moritz <[email protected]> Sun, 10 Apr 2011 20:05:22 +0200
| Newsgroups | gmane.linux.suse.programming |
|---|---|
| Organization | - |
| Message-ID | <[email protected]> |
Am Sonntag, 10. April 2011 15:48:48 schrieb Thomas Moritz: Hallo, > > da ich im Erklaeren so gut bin, mache ich es mal schrittweise :-) > > i2cget -y 0 0x27 0 > > liefert mir den Registerinhalt Register0 in der Form 0xFC > (Beispiel) zurueck. Das Ergebnis moechte ich aber binaer > darstellen. > > Das Wandeln hex2bin geht ja mit bc > > echo "obase=2;ibase=16;FC" | bc Ich weiss nicht, von was ich da getraeumt hatte :-( Das ist fast die Loesung: echo "obase=2;ibase=16;`i2cget -y 0 0x27 0 | cut -d 'x' -f2 | tr f F`" | bc Dummerweise kommt bei 0x00 als Input nur "0" raus statt "00000000" Input 0xFF bringt jedenfalls schonmal "11111111" und 0xF0 bringt auch brav "11110000" Irgendwas habe ich noch uebersehen... MfG Th. Moritz