Lists all available I2C interfaces @return String array @webref
()
| 139 | * @webref |
| 140 | */ |
| 141 | public static String[] list() { |
| 142 | if (NativeInterface.isSimulated()) { |
| 143 | // as on the Raspberry Pi |
| 144 | return new String[]{ "i2c-1" }; |
| 145 | } |
| 146 | |
| 147 | ArrayList<String> devs = new ArrayList<String>(); |
| 148 | File dir = new File("/dev"); |
| 149 | File[] files = dir.listFiles(); |
| 150 | if (files != null) { |
| 151 | for (File file : files) { |
| 152 | if (file.getName().startsWith("i2c-")) { |
| 153 | devs.add(file.getName()); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | // listFiles() does not guarantee ordering |
| 158 | String[] tmp = devs.toArray(new String[devs.size()]); |
| 159 | Arrays.sort(tmp); |
| 160 | return tmp; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /** |
nothing calls this directly
no test coverage detected