@@ -144,15 +144,30 @@ public void openFolder(File file) throws Exception {
144144 }
145145 }
146146
147- public Map <String , Object > resolveDeviceAttachedTo (String serial , Map <String , TargetPackage > packages , String devicesListOutput ) {
148- return null ;
147+ static {
148+ loadLib (new File (BaseNoGui .getContentFile ("lib" ), System .mapLibraryName ("listSerialsj" )));
149+ };
150+
151+ private static void loadLib (File lib ) {
152+ try {
153+ System .load (lib .getAbsolutePath ());
154+ } catch (UnsatisfiedLinkError e ) {
155+ e .printStackTrace ();
156+ System .out .println (e .getMessage ());
157+ System .out .println ("Cannot load native library " + lib .getAbsolutePath ());
158+ System .out .println ("The program has terminated!" );
159+ System .exit (1 );
160+ }
149161 }
150162
163+ public native String resolveDeviceAttachedToNative (String serial );
164+
151165 public String preListAllCandidateDevices () {
152166 return null ;
153167 }
154168
155- protected Map <String , Object > resolveDeviceByVendorIdProductId (Map <String , TargetPackage > packages , String readVIDPID ) {
169+ public Map <String , Object > resolveDeviceByVendorIdProductId (String serial , Map <String , TargetPackage > packages , String devicesListOutput ) {
170+ String vid_pid_iSerial = resolveDeviceAttachedToNative (serial );
156171 for (TargetPackage targetPackage : packages .values ()) {
157172 for (TargetPlatform targetPlatform : targetPackage .getPlatforms ().values ()) {
158173 for (TargetBoard board : targetPlatform .getBoards ().values ()) {
@@ -161,12 +176,12 @@ protected Map<String, Object> resolveDeviceByVendorIdProductId(Map<String, Targe
161176 List <String > pids = new LinkedList <String >(board .getPreferences ().subTree ("pid" , 1 ).values ());
162177 for (int i = 0 ; i < vids .size (); i ++) {
163178 String vidPid = vids .get (i ) + "_" + pids .get (i );
164- if (readVIDPID .contains (vidPid .toUpperCase ())) {
179+ if (vid_pid_iSerial . toUpperCase () .contains (vidPid .toUpperCase ())) {
165180 Map <String , Object > boardData = new HashMap <String , Object >();
166181 boardData .put ("board" , board );
167182 boardData .put ("vid" , vids .get (i ));
168183 boardData .put ("pid" , pids .get (i ));
169- boardData .put ("iserial" , readVIDPID .substring (vidPid .length ()+1 ));
184+ boardData .put ("iserial" , vid_pid_iSerial .substring (vidPid .length ()+1 ));
170185 return boardData ;
171186 }
172187 }
0 commit comments