| 1 | package processing.app.linux; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.io.StringReader; |
| 5 | import java.util.Properties; |
| 6 | |
| 7 | public class UDevAdmParser { |
| 8 | |
| 9 | public String extractVIDAndPID(String output) throws IOException { |
| 10 | Properties properties = new Properties(); |
| 11 | properties.load(new StringReader(output)); |
| 12 | |
| 13 | Object vid = properties.get("ID_VENDOR_ID"); |
| 14 | Object pid = properties.get("ID_MODEL_ID"); |
| 15 | if (vid == null || pid == null) |
| 16 | return null; |
| 17 | return ("0x" + vid + "_0x" + pid).toUpperCase(); |
| 18 | } |
| 19 | } |