Skip to content

Commit d82dd49

Browse files
authored
Merge pull request #115 from BillBrown341/KrakenDriverUpdates
Kraken Driver Updates
2 parents 9d6adcf + 01c3087 commit d82dd49

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

sensors/detection/sensorhub-driver-krakenSDR/src/main/java/org/sensorhub/impl/sensor/krakenSDR/KrakenSdrConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public class KrakenSdrConfig extends SensorConfig {
3434
*/
3535
@DisplayInfo.Required
3636
@DisplayInfo(desc = "Serial number or unique identifier")
37-
public String serialNumber = "test";
37+
public String serialNumber = "kraken_rt";
3838

3939
@DisplayInfo.Required
4040
@DisplayInfo(label="Kraken IP Address", desc="Provide the shared IP Address assigned to the KrakenSD")
41-
public String krakenIPaddress = "192.168.50.186";
41+
public String krakenIPaddress = "localhost";
4242

4343
@DisplayInfo.Required
4444
@DisplayInfo(label="Kraken Data-out Port", desc="Provide the USB Port for your Sensor (Usually 8081)")

sensors/detection/sensorhub-driver-krakenSDR/src/main/java/org/sensorhub/impl/sensor/krakenSDR/KrakenSdrOutputDOA.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
import org.vast.swe.helper.GeoPosHelper;
2222

2323
import java.io.BufferedReader;
24+
import java.io.IOException;
2425
import java.io.InputStreamReader;
2526
import java.net.HttpURLConnection;
27+
import java.net.MalformedURLException;
28+
import java.net.ProtocolException;
2629
import java.net.URL;
2730
import java.time.Instant;
2831
import java.time.OffsetDateTime;
@@ -79,7 +82,7 @@ public void doInit() {
7982
.label("KrakenSDR Collection Time")
8083
.description("Timestamp of when KrakenSDR reading was generated")
8184
.definition(SWEHelper.getPropertyUri("time")))
82-
.addField("raw-lob", sweFactory.createQuantity()
85+
.addField("raw_lob", sweFactory.createQuantity()
8386
.uomCode("deg")
8487
.label("Raw LOB")
8588
.description("The LOB to the emitter in absolute (true north) value")
@@ -95,7 +98,7 @@ public void doInit() {
9598
.definition(SWEHelper.getPropertyUri("rssi")))
9699
.addField("frequency", sweFactory.createQuantity()
97100
.uomCode("Hz")
98-
.label("frequency")
101+
.label("Frequency")
99102
.dataType(DataType.LONG)
100103
.description("The transmission frequency of the event in Hertz")
101104
.definition(SWEHelper.getPropertyUri("frequency")))
@@ -105,16 +108,20 @@ public void doInit() {
105108
.definition(SWEHelper.getPropertyUri("antenna_arrangement")))
106109
.addField("time-delta", sweFactory.createQuantity()
107110
.uomCode("ms")
108-
.label("latency")
111+
.label("Latency")
109112
.description("Latency in ms : (Time from signal arrival at antenna, to result. NOT including network latency.)")
110113
.definition(SWEHelper.getPropertyUri("latency")))
111114
.addField("uuid", sweFactory.createText()
112115
.label("UUID")
113116
.description("Name of the KrakenSDR station inputted in the Station Information box in the Web GUI")
114-
.definition(SWEHelper.getPropertyUri("id")))
115-
.addField("location", geoFac.newLocationVectorLatLon(SWEHelper.getPropertyUri("location")))
117+
.definition(SWEHelper.getPropertyUri("id"))
118+
)
119+
.addField("location", geoFac.createLocationVectorLatLon().label(SWEHelper.getPropertyUri("location"))
120+
.label("Location")
121+
.description("Lat and Long of the Kraken's Position")
122+
)
116123
.addField("heading", sweFactory.createQuantity()
117-
.label("heading")
124+
.label("Heading")
118125
.uomCode("deg")
119126
.description("heading")
120127
.definition(SWEHelper.getPropertyUri("heading")))
@@ -123,9 +130,9 @@ public void doInit() {
123130
.description("Main Heading Sensor Used (\"GPS\"/\"Compass\")")
124131
.definition(SWEHelper.getPropertyUri("heading")))
125132
;
126-
127133
dataStruct = recordBuilder.build();
128134

135+
129136
dataEncoding = sweFactory.newTextEncoding(",", "\n");
130137
}
131138

@@ -151,7 +158,7 @@ public double getAverageSamplingPeriod() {
151158
}
152159

153160
public void SetData() {
154-
DataBlock dataBlock;
161+
DataBlock dataBlock;
155162
try {
156163
if (latestRecord == null) {
157164
dataBlock = dataStruct.createDataBlock();
@@ -177,9 +184,14 @@ public void SetData() {
177184
String DoA_csv;
178185
String[] DOA_Array;
179186

180-
while ((DoA_csv = in.readLine()) != null) {
181-
187+
DoA_csv = in.readLine();
188+
DoA_csv = DoA_csv.trim();
189+
if (!DoA_csv.isEmpty()) {
190+
// Create an array from the html csv data. If it's not the right amount of fields, go to next iteration.
182191
DOA_Array = DoA_csv.split(",");
192+
if (DOA_Array.length < 13) {
193+
return;
194+
}
183195

184196
// Convert Unix Epoch time provided by GPS to OffsetDateTime
185197
Instant krakenTimeInstant = Instant.ofEpochMilli(Long.parseLong(DOA_Array[0]));
@@ -207,10 +219,8 @@ public void SetData() {
207219

208220
eventHandler.publish(new DataEvent(latestRecordTime, KrakenSdrOutputDOA.this, dataBlock));
209221
}
210-
211-
} catch (Exception e) {
212-
System.err.println("Error reading from krakenSDR: " + e.getMessage());
213-
e.printStackTrace();
222+
} catch (IOException ex) {
223+
throw new RuntimeException(ex);
214224
}
215225
}
216226

sensors/detection/sensorhub-driver-krakenSDR/src/main/java/org/sensorhub/impl/sensor/krakenSDR/KrakenSdrOutputSettings.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public double getAverageSamplingPeriod() {
155155
}
156156

157157
public void SetData() {
158-
DataBlock dataBlock;
158+
DataBlock dataBlock;
159159
try {
160160
if (latestRecord == null) {
161161
dataBlock = dataStruct.createDataBlock();
@@ -174,6 +174,10 @@ public void SetData() {
174174
// RETRIEVE CURRENT JSON SETTINGS AS A JSON OBJECT
175175
JsonObject currentSettings = util.retrieveJSONFromAddr(parent.settings_URL);
176176

177+
if(currentSettings == null || currentSettings.entrySet().isEmpty()){
178+
return;
179+
}
180+
177181
dataBlock.setDoubleValue(0, System.currentTimeMillis() / 1000d); // time
178182
dataBlock.setBooleanValue(1, currentSettings.get("en_remote_control").getAsBoolean());
179183
dataBlock.setDoubleValue(2, currentSettings.get("center_freq").getAsDouble());

sensors/detection/sensorhub-driver-krakenSDR/src/main/java/org/sensorhub/impl/sensor/krakenSDR/KrakenSdrSensor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ public void doInit() throws SensorHubException {
8989
krakenSdrControlStation.doInit(initialSettings);
9090

9191
} catch (SensorHubException e) {
92-
throw new RuntimeException("Failed to connect to: " + settings_URL);
92+
// System.err.println("Failed to connect to: " + settings_URL + "\nConfirm that Kraken DOA Software Configuration is displaying this output");
93+
logger.error("Failed to connect to: " + settings_URL + "\nConfirm that Kraken DOA Software Configuration is displaying this output");
94+
throw new SensorHubException("Failed to connect to: (" + settings_URL + "). Confirm Kraken DOA Software Configuration is displaying to this this output");
95+
// throw new RuntimeException("Failed to connect to: " + settings_URL);
9396
}
9497

9598
/// INITIALIZE OUTPUTS

sensors/detection/sensorhub-driver-krakenSDR/src/main/resources/org/sensorhub/impl/sensor/krakenSDR/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ To set this up properly, i found the following [YouTube Tutorial](https://www.yo
5555
to type these commands in your Raspberry Pi's terminal:
5656
1. Install GPSD
5757
```commandline
58-
sudo apt-get install gpsd gpsd-clients python-gps
58+
sudo apt-get install gpsd gpsd-clients
59+
pip3 install gpsd-py3
5960
```
6061
2. Stop current GPSD service, rebind to the correct serial, and then restart it.
6162

0 commit comments

Comments
 (0)