Herzlichen Glückwunsch! /public/style_emoticons/default/d.gif...
Win7 Home oder Pro?
Home Premium
|
![]() - USB-Partner (Interessiert?) - |
$P_UMFALLWAGEN=1003;
Edited by Synthor, 19. Aug. 2014 - 13:45 Uhr.
$P_UMFALLWAGEN=1003;
def readS16(self, register): "Reads a signed 16-bit value" hi = self.i2c.readS8(register) lo = self.i2c.readU8(register+1) return (hi << <img src='/public/style_emoticons/<#EMO_DIR#>/8).gif' class='bbc_emoticon' alt='8)' /> + lo def readU16(self, register): "Reads an unsigned 16-bit value" hi = self.i2c.readU8(register) lo = self.i2c.readU8(register+1) return (hi << <img src='/public/style_emoticons/<#EMO_DIR#>/8).gif' class='bbc_emoticon' alt='8)' /> + lo def readCalibrationData(self): "Reads the calibration data from the IC" self._cal_AC1 = self.readS16(self.__BMP085_CAL_AC1) # INT16 self._cal_AC2 = self.readS16(self.__BMP085_CAL_AC2) # INT16 self._cal_AC3 = self.readS16(self.__BMP085_CAL_AC3) # INT16 self._cal_AC4 = self.readU16(self.__BMP085_CAL_AC4) # UINT16 self._cal_AC5 = self.readU16(self.__BMP085_CAL_AC5) # UINT16 self._cal_AC6 = self.readU16(self.__BMP085_CAL_AC6) # UINT16 self._cal_B1 = self.readS16(self.__BMP085_CAL_B1) # INT16 self._cal_B2 = self.readS16(self.__BMP085_CAL_B2) # INT16 self._cal_MB = self.readS16(self.__BMP085_CAL_MB) # INT16 self._cal_MC = self.readS16(self.__BMP085_CAL_MC) # INT16 self._cal_MD = self.readS16(self.__BMP085_CAL_MD) # INT16
#!/usr/bin/perl use strict; use warnings; use Device::SMBus; my $debug = 1; my $dev = Device::SMBus->new( I2CBusDevicePath => '/dev/i2c-1', I2CDeviceAddress => 0x77, ); my %calibits = ( "AC1","0xAA", # Int "AC2","0xAC", # Int "AC3","0xAE", # Int "AC4","0xB0", # Unsigned Int "AC5","0xB2", # Unsigned Int "AC6","0xB4", # Unsigned Int "B1","0xB6", # Int "B2","0xB8", # Int "MB","0xBA", # Int "MC","0xBC", # Int "MD","0xBE" # Int ); my %bits = ( "CONTROL","0xF4", "TEMPDATA","0xF6", "PRESSUREDATA","0xF6", "READTEMPCMD","0x2E", "READPRESSURECMD","0x34", ); sub calibrate { while ((my $key,my $value) = each(%calibits)) { if (($key eq 'AC4') || ($key eq 'AC5') || ($key eq 'AC6')) { my $calidata = $dev->readWordData($value); if ($debug) { print ("Unsigned INT: $key - $value - $calidata\n"); } } else { my $calidata = $dev->readWordData($value); if ($debug) { print ("Signed INT: $key - $value - $calidata\n"); } } } } &calibrate();
pi@etdis23 ~/scripts/terraPi $ perl terraPi.pl
Argument "0xAE" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: AC3 - 0xAE - 0
Argument "0xAC" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: AC2 - 0xAC - 0
Argument "0xB6" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: B1 - 0xB6 - 0
Argument "0xBA" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: MB - 0xBA - 0
Argument "0xB4" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Unsigned INT: AC6 - 0xB4 - 0
Argument "0xBC" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: MC - 0xBC - 0
Argument "0xB2" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Unsigned INT: AC5 - 0xB2 - 0
Argument "0xBE" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: MD - 0xBE - 0
Argument "0xAA" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: AC1 - 0xAA - 0
Argument "0xB0" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Unsigned INT: AC4 - 0xB0 - 0
Argument "0xB8" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 118.
Signed INT: B2 - 0xB8 - 0
"AC1", 0xAA, # Int
$P_UMFALLWAGEN=1003;
def readS16(self, register): hi = self.i2c.readS8(register) lo = self.i2c.readU8(register+1) return (hi << <img src='/public/style_emoticons/<#EMO_DIR#>/8).gif' class='bbc_emoticon' alt='8)' /> + loEs wird erst das eine bit gelesen, dann das andere, und dann addiert.
sub readU16 { my $a = $_[0]; my $b = hex($_[0]); $b++; my $bhex = sprintf("0x%x",$b); my $aa = $dev->readByteData($a); my $bb = $dev->readByteData($bhex); print ("a: $a\nb: $b\naa: $aa\nbb: $bb\n"); }$a ist das register aus dem calibits hash.
%calibits = ( AC1 => { lo => "0xAA", hi => "0xAB", }, AC2 => { lo => "0xAC", hi => "0xAD", }, );Aber ich find die obere lösung eleganter...
Mein code:
sub readU16 {
my $a = $_[0];
my $b = hex($_[0]);
$b++;
my $bhex = hex($b);
my $aa = $dev->readByteData($a);
my $bb = $dev->readByteData($bhex);
print ("a: $a\nb: $b\naa: $aa\nbb: $bb\n");
}
$P_UMFALLWAGEN=1003;
sub readU16 { my $a = hex($_[0]); my $b = hex($_[0]) + 1; print("hi - s: $a\nlo - u: $b\n"); my $ahex = &dec2hex8s($a); my $bhex = &dec2hex8u($b); my $aa = $dev->readByteData($ahex); my $bb = $dev->readByteData($bhex); print ("a: $a\nahex: $ahex\nb: $b\nbhex: $bhex\naa: $aa\nbb: $bb\n"); } sub dec2hex8u { my $hex = unpack "H2",pack "C", $_[0]; return "0x" . $hex; } sub dec2hex8s { my $hex = unpack "H2",pack "c", $_[0]; return "0x" . $hex; } sub dec2hex16 { my $hex = unpack "H4",pack "n", $_[0]; return $hex; }Ausgabe:
pi@etdis23 ~/scripts/terraPi $ perl terraPi.pl
hi - s: 180
lo - u: 181
Character in 'c' format wrapped in pack at terraPi.pl line 55.
Argument "0xb4" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
Argument "0xb5" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
a: 180
ahex: 0xb4
b: 181
bhex: 0xb5
aa: -1
bb: -1
hi - s: 178
lo - u: 179
Character in 'c' format wrapped in pack at terraPi.pl line 55.
Argument "0xb2" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
Argument "0xb3" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
a: 178
ahex: 0xb2
b: 179
bhex: 0xb3
aa: -1
bb: -1
hi - s: 176
lo - u: 177
Character in 'c' format wrapped in pack at terraPi.pl line 55.
Argument "0xb0" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
Argument "0xb1" isn't numeric in subroutine entry at /usr/local/lib/perl/5.14.2/Device/SMBus.pm line 95.
a: 176
ahex: 0xb0
b: 177
bhex: 0xb1
aa: -1
bb: -1
pi@etdis23 ~/scripts/terraPi $
$self->readNBytes($value,2);
Read together N bytes of Data in linear register order. i.e. to read from 0x28,0x29,0x2a
To Hell and Back
$P_UMFALLWAGEN=1003;
gestern war ich echt nich fit, und gerad hab ich noch diesen c codegefunden, jetzt raff ich das auch komplett...
http://www.amazon.de/TP-Link-TL-WDR4300-Simultan-Dual-Band-LAN-Ports/dp/B00810P80S
Der soll was taugen. Steht auf meiner Einkaufsliste, aber nicht dazu gekommen den zu bestellen. Irgendwie stören mich die Netzwerkkabel quer durch die Wohnung nicht. /public/style_emoticons/default/lol.gif...
To Hell and Back
Ne Nacht drüber schlafen hilft meistens Wunder wenn man irgendwie "festgefahren" ist. /public/style_emoticons/default/d.gif...
$P_UMFALLWAGEN=1003;
War Linksys nicht der Cisco-Ableger? /public/style_emoticons/default/noidea.g...
Ne Nacht drüber schlafen hilft meistens Wunder wenn man irgendwie "festgefahren" ist. /public/style_emoticons/default/d.gif...
/public/style_emoticons/default/kiffer.g... auch. /public/style_emoticons/default/d.gif...
Edited by Staatsfeind2k, 20. Aug. 2014 - 19:53 Uhr.
$P_UMFALLWAGEN=1003;
Aber ich kann dann nicht darüber aufhören nachzudenken, bis ich die Lösung im Kopf habe. Dafür hasse ich mich manchmal... /public/style_emoticons/default/roll.gif...
Edited by m1ndfuck, 20. Aug. 2014 - 20:56 Uhr.
Logisch, wenn man eh schon viereckige Augen hat, dann sollte man besser aufhören. In so einem Zustand baut man auch üble Bugs ein, die am Tag später kaum auffindbar sind. ^^
Aber ich kann dann nicht darüber aufhören nachzudenken, bis ich die Lösung im Kopf habe. Dafür hasse ich mich manchmal... /public/style_emoticons/default/roll.gif...
Ich nicht, aber das hassen andere an mir /public/style_emoticons/default/lol.gif...Aber ich kann dann nicht darüber aufhören nachzudenken, bis ich die Lösung im Kopf habe. Dafür hasse ich mich manchmal... /public/style_emoticons/default/roll.gif...
/public/style_emoticons/default/lol.gif... kenn ich
Ich nicht, aber das hassen andere an mir /public/style_emoticons/default/lol.gif...Aber ich kann dann nicht darüber aufhören nachzudenken, bis ich die Lösung im Kopf habe. Dafür hasse ich mich manchmal... /public/style_emoticons/default/roll.gif...
ich meinte damit das es mir oft ähnlich ergeht mit dem gehasst werden/public/style_emoticons/default/lol.gif... /public/style_emoticons/default/lol.gif... /public/style_emoticons/default/lol.gif...
/public/style_emoticons/default/lol.gif... kenn ich
Ich nicht, aber das hassen andere an mir /public/style_emoticons/default/lol.gif...Aber ich kann dann nicht darüber aufhören nachzudenken, bis ich die Lösung im Kopf habe. Dafür hasse ich mich manchmal... /public/style_emoticons/default/roll.gif...
$P_UMFALLWAGEN=1003;
FUUUUUUUTzeh. Da hab ich den Typ mit dem Mainboard gerade 10€ runtergehandelt, schreibt der mir, dass jemand bei eBay das zum Festpreis genommen hat.
Argggghhhh... /public/style_emoticons/default/facepalm...
0 members, 1 guests, 0 anonymous users