|
@@ -32,8 +32,6 @@
|
32
|
32
|
#include <termios.h>
|
33
|
33
|
#include <dirent.h>
|
34
|
34
|
|
35
|
|
-#define SEARCH "tty."
|
36
|
|
-
|
37
|
35
|
#define BAUD B19200
|
38
|
36
|
|
39
|
37
|
int fd = -1;
|
|
@@ -140,7 +138,7 @@ char** namesInDev(int *siz) {
|
140
|
138
|
return files;
|
141
|
139
|
}
|
142
|
140
|
|
143
|
|
-char** getSerialPorts(void) {
|
|
141
|
+char** getSerialPorts(const char *search) {
|
144
|
142
|
int size;
|
145
|
143
|
char** files = namesInDev(&size);
|
146
|
144
|
char **fin = NULL, **finish = NULL;
|
|
@@ -153,18 +151,25 @@ char** getSerialPorts(void) {
|
153
|
151
|
|
154
|
152
|
while (files[i] != NULL) {
|
155
|
153
|
// Filter for SEARCH and if it is a serial port
|
156
|
|
- if (strstr(files[i], SEARCH) != NULL) {
|
|
154
|
+ if (strstr(files[i], search) != NULL) {
|
157
|
155
|
// We have a match
|
158
|
|
- // printf("JNI: %s matched %s", files[i], SEARCH);
|
159
|
|
- f = serialOpen(files[i]);
|
160
|
|
- if (f != -1) {
|
|
156
|
+ // printf("JNI: %s matched %s", files[i], search);
|
|
157
|
+
|
|
158
|
+ // Don't actually check if it is a serial port
|
|
159
|
+ // It causes long delays while trying to connect
|
|
160
|
+ // to Bluetooth devices...
|
|
161
|
+
|
|
162
|
+ // f = serialOpen(files[i]);
|
|
163
|
+ // if (f != -1) {
|
161
|
164
|
// printf(" and is a serial port\n");
|
162
|
165
|
fin[j++] = files[i];
|
163
|
|
- serialClose();
|
164
|
|
- } else {
|
|
166
|
+ // serialClose();
|
|
167
|
+ // } else {
|
165
|
168
|
// printf(" and is not a serial port\n");
|
166
|
|
- free(files[i]);
|
167
|
|
- }
|
|
169
|
+ // free(files[i]);
|
|
170
|
+ // }
|
|
171
|
+
|
|
172
|
+
|
168
|
173
|
} else {
|
169
|
174
|
free(files[i]);
|
170
|
175
|
}
|