Skip to content

Commit

Permalink
Add M20 decoder for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
darksidelemm committed Jun 27, 2020
1 parent 864cae7 commit 8da5f8a
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 111 deletions.
2 changes: 1 addition & 1 deletion auto_rx/auto_rx.py
Expand Up @@ -468,7 +468,7 @@ def telemetry_filter(telemetry):
meisei_callsign_valid = False

# If Vaisala or DFMs, check the callsigns are valid. If M10, iMet or LMS6, just pass it through.
if vaisala_callsign_valid or dfm_callsign_valid or meisei_callsign_valid or ('M10' in telemetry['type']) or ('LMS' in telemetry['type']) or ('IMET' in telemetry['type']):
if vaisala_callsign_valid or dfm_callsign_valid or meisei_callsign_valid or ('M10' in telemetry['type']) or ('M20' in telemetry['type']) or ('LMS' in telemetry['type']) or ('IMET' in telemetry['type']):
return "OK"
else:
_id_msg = "Payload ID %s is invalid." % telemetry['id']
Expand Down
2 changes: 1 addition & 1 deletion auto_rx/autorx/__init__.py
Expand Up @@ -17,7 +17,7 @@
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
# PATCH - Small changes, or minor feature additions.

__version__ = "1.3.2-beta6"
__version__ = "1.3.2-beta7"


# Global Variables
Expand Down
29 changes: 27 additions & 2 deletions auto_rx/autorx/decode.py
Expand Up @@ -21,7 +21,7 @@
from .fsk_demod import FSKDemodStats

# Global valid sonde types list.
VALID_SONDE_TYPES = ['RS92', 'RS41', 'DFM', 'M10', 'IMET', 'MK2LMS', 'LMS6', 'MEISEI', 'UDP']
VALID_SONDE_TYPES = ['RS92', 'RS41', 'DFM', 'M10', 'M20', 'IMET', 'MK2LMS', 'LMS6', 'MEISEI', 'UDP']

# Known 'Drifty' Radiosonde types
# NOTE: Due to observed adjacent channel detections of RS41s, the adjacent channel decoder restriction
Expand Down Expand Up @@ -70,7 +70,7 @@ class SondeDecoder(object):
}

# TODO: Use the global valid sonde type list.
VALID_SONDE_TYPES = ['RS92', 'RS41', 'DFM', 'M10', 'IMET', 'MK2LMS', 'LMS6', 'MEISEI', 'UDP']
VALID_SONDE_TYPES = ['RS92', 'RS41', 'DFM', 'M10', 'M20', 'IMET', 'MK2LMS', 'LMS6', 'MEISEI', 'UDP']

def __init__(self,
sonde_type="None",
Expand Down Expand Up @@ -580,6 +580,31 @@ def generate_decoder_command_experimental(self):
demod_stats = FSKDemodStats(averaging_time=2.0, peak_hold=True)
self.rx_frequency = _freq

elif self.sonde_type == "M20":
# M20 Sondes
# 9600 baud.
_sdr_rate = 48000
_baud_rate = 9600
_offset = 0.25 # Place the sonde frequency in the centre of the passband.
_lower = int(0.025 * _sdr_rate) # Limit the frequency estimation window to not include the passband edges.
_upper = int(0.475 * _sdr_rate)
_freq = int(self.sonde_freq - _sdr_rate*_offset)

demod_cmd = "%s %s-p %d -d %s %s-M raw -F9 -s %d -f %d 2>/dev/null |" % (self.sdr_fm, bias_option, int(self.ppm), str(self.device_idx), gain_param, _sdr_rate, _freq)

# Add in tee command to save IQ to disk if debugging is enabled.
if self.save_decode_iq:
demod_cmd += " tee decode_IQ_%s.bin |" % str(self.device_idx)

demod_cmd += "./fsk_demod --cs16 -b %d -u %d -s -p 5 --stats=%d 2 %d %d - -" % (_lower, _upper, _stats_rate, _sdr_rate, _baud_rate)

# M20 decoder
decode_cmd = "./mXXmod --json --ptu -vvv --softin -i 2>/dev/null"

# M20 sondes transmit in short, irregular pulses - average over the last 2 frames, and use a peak hold
demod_stats = FSKDemodStats(averaging_time=2.0, peak_hold=True)
self.rx_frequency = _freq

elif self.sonde_type.startswith("LMS"):
# LMS6 (400 MHz variant) Decoder command.
_sdr_rate = 48000 # IQ rate. Lower rate = lower CPU usage, but less frequency tracking ability.
Expand Down
3 changes: 2 additions & 1 deletion auto_rx/build.sh
Expand Up @@ -10,7 +10,7 @@ echo "Building dft_detect"
cd ../scan/
gcc dft_detect.c -lm -o dft_detect -DNOC34C50

echo "Building RS92/RS41/DFM/LMS6/iMS Demodulators"
echo "Building RS92/RS41/DFM/LMS6/iMS/M10/M20 Demodulators"
#cd ../demod/
#gcc -c demod.c
#gcc -c demod_dft.c
Expand Down Expand Up @@ -65,6 +65,7 @@ cp ../mk2a/mk2a_lms1680 .
cp ../demod/mod/rs41mod .
cp ../demod/mod/dfm09mod .
cp ../demod/mod/m10mod .
cp ../demod/mod/mXXmod .
cp ../demod/mod/rs92mod .
cp ../demod/mod/lms6Xmod .
cp ../demod/mod/meisei100mod .
Expand Down
16 changes: 13 additions & 3 deletions demod/mod/dfm09mod.c
Expand Up @@ -772,8 +772,8 @@ static void print_gpx(gpx_t *gpx) {

// Print JSON blob // valid sonde_ID?
printf("{ \"type\": \"%s\"", "DFM");
printf(", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
gpx->frnr, json_sonde_id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->horiV, gpx->dir, gpx->vertV);
printf(", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d",
gpx->frnr, json_sonde_id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->horiV, gpx->dir, gpx->vertV, gpx->gps.nSV);
if (gpx->ptu_out >= 0xA && gpx->status[0] > 0) { // DFM>=09(P): Battery (STM32)
printf(", \"batt\": %.2f", gpx->status[0]);
}
Expand Down Expand Up @@ -926,6 +926,8 @@ int main(int argc, char **argv) {
float thres = 0.65;
float _mv = 0.0;

float lpIQ_bw = 12e3;

int symlen = 2;
int bitofs = 2; // +1 .. +2
int shift = 0;
Expand Down Expand Up @@ -1023,6 +1025,14 @@ int main(int argc, char **argv) {
option_min = 1;
}
else if (strcmp(*argv, "--dbg") == 0) { gpx.option.dbg = 1; }
else if (strcmp(*argv, "--lpbw") == 0) { // IQ lowpass BW / kHz
double bw = 0.0;
++argv;
if (*argv) bw = atof(*argv);
else return -1;
if (bw > 4.6 && bw < 24.0) lpIQ_bw = bw*1e3;
option_lp = 1;
}
else if (strcmp(*argv, "--sat") == 0) { gpx.option.sat = 1; }
else if (strcmp(*argv, "-") == 0) {
int sample_rate = 0, bits_sample = 0, channels = 0;
Expand Down Expand Up @@ -1138,7 +1148,7 @@ int main(int argc, char **argv) {
dsp.h = 1.8; // 2.4 modulation index abzgl. BT
dsp.opt_iq = option_iq;
dsp.opt_lp = option_lp;
dsp.lpIQ_bw = 12e3; // IF lowpass bandwidth
dsp.lpIQ_bw = lpIQ_bw; // 12e3; // IF lowpass bandwidth
dsp.lpFM_bw = 4e3; // FM audio lowpass
dsp.opt_dc = option_dc;
dsp.opt_IFmin = option_min;
Expand Down
18 changes: 9 additions & 9 deletions demod/mod/m10mod.c
Expand Up @@ -89,6 +89,7 @@ typedef struct {
ui8_t numSV;
ui8_t utc_ofs;
char SN[12];
ui8_t SNraw[5];
ui8_t frame_bytes[FRAME_LEN+AUX_LEN+4];
char frame_bits[BITFRAME_LEN+BITAUX_LEN+8];
int auxlen; // 0 .. 0x76-0x64
Expand Down Expand Up @@ -449,19 +450,17 @@ static int get_GPSvel(gpx_t *gpx) {
static int get_SN(gpx_t *gpx) {
int i;
unsigned byte;
ui8_t sn_bytes[5];

for (i = 0; i < 11; i++) gpx->SN[i] = ' '; gpx->SN[11] = '\0';

for (i = 0; i < 5; i++) {
byte = gpx->frame_bytes[pos_SN + i];
sn_bytes[i] = byte;
gpx->SNraw[i] = gpx->frame_bytes[pos_SN + i];
}

byte = sn_bytes[2];
byte = gpx->SNraw[2];
sprintf(gpx->SN, "%1X%02u", (byte>>4)&0xF, byte&0xF);
byte = sn_bytes[3] | (sn_bytes[4]<<8);
sprintf(gpx->SN+3, " %1X %1u%04u", sn_bytes[0]&0xF, (byte>>13)&0x7, byte&0x1FFF);
byte = gpx->SNraw[3] | (gpx->SNraw[4]<<8);
sprintf(gpx->SN+3, " %1X %1u%04u", gpx->SNraw[0]&0xF, (byte>>13)&0x7, byte&0x1FFF);

return 0;
}
Expand Down Expand Up @@ -867,6 +866,7 @@ static int print_pos(gpx_t *gpx, int csOK) {
gpx->_RH = get_RH(gpx);
gpx->Ti = get_intTemp(gpx);
gpx->batV = get_BatV(gpx);
get_SN(gpx);


if (gpx->option.col) {
Expand All @@ -886,7 +886,6 @@ static int print_pos(gpx_t *gpx, int csOK) {
fprintf(stdout, " vH: "col_GPSvel"%.1f"col_TXT" D: "col_GPSvel"%.1f"col_TXT" vV: "col_GPSvel"%.1f"col_TXT" ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
get_SN(gpx);
fprintf(stdout, " SN: "col_SN"%s"col_TXT, gpx->SN);
}
if (gpx->option.vbs >= 2) {
Expand Down Expand Up @@ -925,7 +924,6 @@ static int print_pos(gpx_t *gpx, int csOK) {
fprintf(stdout, " vH: %.1f D: %.1f vV: %.1f ", gpx->vH, gpx->vD, gpx->vV);
}
if (gpx->option.vbs >= 2) {
get_SN(gpx);
fprintf(stdout, " SN: %s", gpx->SN);
}
if (gpx->option.vbs >= 2) {
Expand Down Expand Up @@ -1003,6 +1001,8 @@ static int print_pos(gpx_t *gpx, int csOK) {
if (gpx->_RH > -0.5) fprintf(stdout, ", \"humidity\": %.1f", gpx->_RH);
}
}
fprintf(stdout, ", \"rawid\": \"M10_%02X%02X%02X%02X%02X\"", gpx->frame_bytes[pos_SN], gpx->frame_bytes[pos_SN+1],
gpx->frame_bytes[pos_SN+2], gpx->frame_bytes[pos_SN+3], gpx->frame_bytes[pos_SN+4]); // gpx->type
fprintf(stdout, ", \"subtype\": \"0x%02X\"", gpx->type);
fprintf(stdout, " }\n");
fprintf(stdout, "\n");
Expand Down Expand Up @@ -1401,7 +1401,7 @@ int main(int argc, char **argv) {
if (option_iq >= 2) spike = 0;
if (option_iq > 2) bl = 4.0;
//bitQ = read_slbit(&dsp, &bit, 0, bitofs, bitpos, bl, spike); // symlen=2
bitQ = read_softbit2p(&dsp, &hsbit, 0, bitofs, bitpos, bl, spike, &hsbit1); // symlen=1
bitQ = read_softbit2p(&dsp, &hsbit, 0, bitofs, bitpos, bl, spike, &hsbit1); // symlen=2
bit = hsbit.hb;
if (option_chk == 3 && option_iq) {
//if (hsbit.sb*hsbit1.sb < 0)
Expand Down

0 comments on commit 8da5f8a

Please sign in to comment.