Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2319f2

Browse files
committed
Merge pull request taimos#17 from msemtd/master
Workaround for issue taimos#16 (in parent)
2 parents d677715 + b891bff commit c2319f2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/main/java/de/taimos/gpsd4java/backend/GPSdEndpoint.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,16 @@ public void start() {
122122
*/
123123
public void stop() {
124124
try {
125-
this.listenThread.halt();
125+
socket.close();
126+
} catch (final IOException e1) {
127+
GPSdEndpoint.LOG.debug("Close forced: "+ e1.getMessage());
128+
}
129+
130+
try {
131+
this.listeners.clear();
132+
if(listenThread != null) {
133+
this.listenThread.halt();
134+
}
126135
} catch (final Exception e) {
127136
GPSdEndpoint.LOG.debug("Interrupted while waiting for listenThread to stop", e);
128137
}
@@ -295,4 +304,20 @@ void handle(final IGPSObject object) {
295304
}
296305
}
297306
}
307+
308+
/**
309+
* Attempt to kick a failed device back into life on gpsd server.
310+
*
311+
* @see https://lists.gnu.org/archive/html/gpsd-dev/2015-06/msg00001.html
312+
*
313+
* @param path Path of device known to gpsd
314+
* @throws IOException
315+
* @throws JSONException
316+
*/
317+
public void kickDevice(String path) throws IOException, JSONException {
318+
final JSONObject d = new JSONObject();
319+
d.put("class", "DEVICE");
320+
d.put("path", path);
321+
voidCommand("?DEVICE="+d);
322+
}
298323
}

0 commit comments

Comments
 (0)