Hard-code a preferred I2C bus.
diff --git a/src/com/projectara/araepm/DME.java b/src/com/projectara/araepm/DME.java
index 3937324..6b2771e 100644
--- a/src/com/projectara/araepm/DME.java
+++ b/src/com/projectara/araepm/DME.java
@@ -8,6 +8,7 @@
public class DME {
private static final int slaveAddress = 0x44;
private static final String TAG = "DME";
+ private static final String preferredI2cBus = "/dev/i2c-2";
private static String i2cBus;
private I2cManager i2c;
@@ -143,7 +144,14 @@
public DME(I2cManager i2c) {
this.i2c = i2c;
- this.i2cBus = i2c.getI2cBuses()[0];
+ String[] buses = i2c.getI2cBuses();
+ this.i2cBus = buses[0];
+ for (String bus: buses) {
+ if (bus.equals("/dev/i2c-2")) {
+ this.i2cBus = bus;
+ }
+ }
+ Log.i(TAG, "[EPM app] Using I2C bus: " + this.i2cBus);
}
private void logByteArray(String prefix, byte[] arr) {