Hallo,
ich versuche mich mit dem I2C Bus, doch leider klappt es nicht wie es
soll.
Vorneweg, der Bus scheint in Ordnung zu sein, ich kann über den
entsprechenden Treiber die Temperatur eines LM75 über I2C auslesen. Ich
arbeite auf einem PPC405GPr.
Doch wenn ich ohne Treiber direkt darauf zugreifen will, oder auch auf
andere Bausteine, dann klappt das nicht.
Ich habe zwei Dinge versucht. Erst mit dem Programm i2cdetect:
http://www.lm-sensors.org/wiki/man/i2cdetect
sagt mir
1 | i2c-0 i2c IBM IIC I2C adapter
|
Mein Bus ist der i2c-0, soweit alles ok. Doch wenn ich
ausführe erhalte ich
1 | Error: I2C bus name doesn't match any bus present!
|
:-( Dann habe ich versucht selbst ein paar Zeilen zu coden:
1 | int file;
|
2 | char *filename = "/dev/i2c-0";
|
3 | //const gchar *buffer;
|
4 |
|
5 | if ((file = open(filename, O_RDWR)) < 0) {
|
6 | /* ERROR HANDLING: you can check errno to see what went wrong */
|
7 | perror("Failed to open the i2c bus");
|
8 | exit(1);
|
9 | }
|
10 |
|
11 | int addr = 0x93; // Adresse des LM75 0b10010011
|
12 |
|
13 | if (ioctl(file, I2C_SLAVE, addr) < 0) {
|
14 | perror("Failed to acquire bus access and/or talk to slave");
|
15 | /* ERROR HANDLING; you can check errno to see what went wrong */
|
16 | exit(1);
|
17 | }
|
Dies bricht ab mit
1 | Failed to acquire bus access and/or talk to slave: Invalid argument
|
Hat wer eine Idee was da falsch läuft? Warum "invalid argument"? Und
warum funktioniert nicht mal i2cdetect?
Vielen Dank,
Reto