Lists all available SPI interfaces @return String array @webref
()
| 119 | * @webref |
| 120 | */ |
| 121 | public static String[] list() { |
| 122 | if (NativeInterface.isSimulated()) { |
| 123 | // as on the Raspberry Pi |
| 124 | return new String[]{ "spidev0.0", "spidev0.1" }; |
| 125 | } |
| 126 | |
| 127 | ArrayList<String> devs = new ArrayList<String>(); |
| 128 | File dir = new File("/dev"); |
| 129 | File[] files = dir.listFiles(); |
| 130 | if (files != null) { |
| 131 | for (File file : files) { |
| 132 | if (file.getName().startsWith("spidev")) { |
| 133 | devs.add(file.getName()); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | // listFiles() does not guarantee ordering |
| 138 | String[] tmp = devs.toArray(new String[devs.size()]); |
| 139 | Arrays.sort(tmp); |
| 140 | return tmp; |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /** |
nothing calls this directly
no test coverage detected