|
@@ -77,7 +77,7 @@ public class HelperUtility {
|
77
|
77
|
inChannel.close();
|
78
|
78
|
outChannel.close();
|
79
|
79
|
System.load(fileOut.toString());
|
80
|
|
- System.out.println("Loaded Serial Library from " + fileOut.toString());
|
|
80
|
+ System.out.println("Loaded Serial Library!");
|
81
|
81
|
} catch (Exception e) {
|
82
|
82
|
System.out.println("Failed to load Serial Library:");
|
83
|
83
|
e.printStackTrace();
|
|
@@ -113,18 +113,19 @@ public class HelperUtility {
|
113
|
113
|
* others
|
114
|
114
|
*/
|
115
|
115
|
public static String[] getPorts() {
|
116
|
|
- String[] ports = { "No serial ports!" };
|
117
|
116
|
String portLines = getPortsOS();
|
118
|
117
|
if (portLines == null) {
|
|
118
|
+ String[] ports = { "Select serial port..." };
|
|
119
|
+ return ports;
|
|
120
|
+ } else {
|
|
121
|
+ StringTokenizer sT = new StringTokenizer(portLines, "\n");
|
|
122
|
+ int size = sT.countTokens();
|
|
123
|
+ String[] ports = new String[size];
|
|
124
|
+ for (int i = 0; i < size; i++) {
|
|
125
|
+ ports[i] = sT.nextToken();
|
|
126
|
+ }
|
119
|
127
|
return ports;
|
120
|
128
|
}
|
121
|
|
- StringTokenizer sT = new StringTokenizer(portLines, "\n");
|
122
|
|
- int size = sT.countTokens();
|
123
|
|
- ports = new String[size];
|
124
|
|
- for (int i = 0; i < size; i++) {
|
125
|
|
- ports[i] = sT.nextToken();
|
126
|
|
- }
|
127
|
|
- return ports;
|
128
|
129
|
}
|
129
|
130
|
|
130
|
131
|
/**
|
|
@@ -137,7 +138,7 @@ public class HelperUtility {
|
137
|
138
|
try {
|
138
|
139
|
if (os.indexOf("windows") > -1) {
|
139
|
140
|
return getThePorts("COM");
|
140
|
|
- } else if (os.indexOf("max") > -1) {
|
|
141
|
+ } else if (os.indexOf("mac") > -1) {
|
141
|
142
|
return getThePorts("tty.");
|
142
|
143
|
} else {
|
143
|
144
|
return getThePorts("tty");
|
|
@@ -146,7 +147,6 @@ public class HelperUtility {
|
146
|
147
|
// Unsatisfied linker error:
|
147
|
148
|
// Serial.dll was probably not found
|
148
|
149
|
System.out.println("Exception: " + e.toString());
|
149
|
|
- } finally {
|
150
|
150
|
return null;
|
151
|
151
|
}
|
152
|
152
|
}
|