Skip to content

Commit

Permalink
StratosatTk1 is actually Geoscan
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Nov 2, 2024
1 parent a7bb9af commit d8c219f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 61 deletions.
23 changes: 18 additions & 5 deletions src/main/java/ru/r2cloud/jradio/geoscan/Geoscan.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ru.r2cloud.jradio.Beacon;
import ru.r2cloud.jradio.BeaconSource;
import ru.r2cloud.jradio.ByteInput;
import ru.r2cloud.jradio.blocks.AdditiveScrambler;
Expand All @@ -14,19 +15,25 @@
import ru.r2cloud.jradio.crc.Crc16Cc11xx;
import ru.r2cloud.jradio.fec.ccsds.UncorrectableException;

public class Geoscan extends BeaconSource<GeoscanBeacon> {
public class Geoscan<T extends Beacon> extends BeaconSource<T> {

private static final Logger LOG = LoggerFactory.getLogger(Geoscan.class);

private final AdditiveScrambler scrambler;
private final Class<T> clazz;

public Geoscan(ByteInput demod) {
super(new CorrelateSyncword(new SoftToHard(demod), 4, "10010011000010110101000111011110", 66 * 8));
public Geoscan(ByteInput demod, Class<T> clazz) {
this(demod, clazz, 66);
}

public Geoscan(ByteInput demod, Class<T> clazz, int beaconSizeBytes) {
super(new CorrelateSyncword(new SoftToHard(demod), 4, "10010011000010110101000111011110", beaconSizeBytes * 8));
scrambler = new AdditiveScrambler(0x21, 0x1ff, 8, 8);
this.clazz = clazz;
}

@Override
protected GeoscanBeacon parseBeacon(byte[] raw) throws UncorrectableException, IOException {
protected T parseBeacon(byte[] raw) throws UncorrectableException, IOException {
raw = UnpackedToPacked.pack(raw);
scrambler.shuffle(raw);
if (Crc16Cc11xx.calculate(raw, 0, raw.length) != 0) {
Expand All @@ -38,7 +45,13 @@ protected GeoscanBeacon parseBeacon(byte[] raw) throws UncorrectableException, I
// cutoff crc
byte[] payload = new byte[raw.length - 2];
System.arraycopy(raw, 0, payload, 0, payload.length);
GeoscanBeacon result = new GeoscanBeacon();
T result;
try {
result = clazz.getDeclaredConstructor().newInstance();
} catch (Exception e) {
LOG.error("unable to init beacon", e);
return null;
}
result.readExternal(payload);
return result;
}
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/ru/r2cloud/jradio/sstk1/StratosatTk1.java

This file was deleted.

8 changes: 3 additions & 5 deletions src/test/java/ru/r2cloud/jradio/geoscan/GeoscanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
import ru.r2cloud.jradio.source.WavFileSource;

public class GeoscanTest {


private Geoscan input;

private Geoscan<GeoscanBeacon> input;

@Test
public void testDecodeTelemetry() throws Exception {
WavFileSource source = new WavFileSource(GeoscanTest.class.getClassLoader().getResourceAsStream("geoscan.wav"));
FskDemodulator demod = new FskDemodulator(source, 9600, 5000.0f, 1, 2000.0f, true);
input = new Geoscan(demod);
input = new Geoscan<>(demod, GeoscanBeacon.class);
assertTrue(input.hasNext());
AssertJson.assertObjectsEqual("GeoscanBeacon.json", input.next());
}
Expand All @@ -30,5 +29,4 @@ public void stop() throws Exception {
}
}


}
5 changes: 3 additions & 2 deletions src/test/java/ru/r2cloud/jradio/sstk1/StratosatTk1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@

import ru.r2cloud.jradio.AssertJson;
import ru.r2cloud.jradio.demod.FskDemodulator;
import ru.r2cloud.jradio.geoscan.Geoscan;
import ru.r2cloud.jradio.source.WavFileSource;

public class StratosatTk1Test {

private StratosatTk1 input;
private Geoscan<StratosatTk1Beacon> input;

@Test
public void testDecodeTelemetry() throws Exception {
WavFileSource source = new WavFileSource(StratosatTk1Test.class.getClassLoader().getResourceAsStream("sstk1.wav"));
FskDemodulator demod = new FskDemodulator(source, 9600, 5000.0f, 1, 2000.0f, true);
input = new StratosatTk1(demod);
input = new Geoscan<>(demod, StratosatTk1Beacon.class);
assertTrue(input.hasNext());
input.next();
AssertJson.assertObjectsEqual("StratosatTk1.json", input.next());
Expand Down
4 changes: 1 addition & 3 deletions src/test/resources/expected/StratosatTk1.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@
0,
0,
0,
0,
-85,
-3
0
],
"beginSample": 1796,
"beginMillis": 0,
Expand Down

0 comments on commit d8c219f

Please sign in to comment.