meisei: adjust baud for option_b+ecc

pull/18/head
Zilog80 2019-06-07 15:54:09 +02:00
rodzic 358bea29a4
commit 0a833bf02e
1 zmienionych plików z 43 dodań i 17 usunięć

Wyświetl plik

@ -22,6 +22,9 @@ Variante 1 (RS-11G ?)
0x20..0x23 32 bit GPS-lat * 1e7 (DD.dddddd)
0x24..0x27 32 bit GPS-lon * 1e7 (DD.dddddd)
0x28..0x2B 32 bit GPS-alt * 1e2 (m)
0x2C..0x2D 16 bit GPS-vH * 1e2 (m/s)
0x2E..0x2F 16 bit GPS-vD * 1e2 (degree) (0..360 unsigned)
0x30..0x31 16 bit GPS-vU * 1e2 (m/s)
0x32..0x35 32 bit date jjJJMMTT
0x00..0x02 HEADER 0x049DCE
@ -48,6 +51,8 @@ Variante 2 (iMS-100 ?)
0x20..0x23 32 bit GPS-lat * 1e4 (NMEA DDMM.mmmm)
0x24..0x27 32 bit GPS-lon * 1e4 (NMEA DDMM.mmmm)
0x28..0x2A 24 bit GPS-alt * 1e2 (m)
0x30..0x31 16 bit GPS-vD * 1e2 (degree)
0x32..0x33 16 bit GPS-vH * 1.944e2 (knots)
0x00..0x02 HEADER 0x049DCE
0x03..0x04 16 bit 0.5s-counter, count%2=1:
@ -63,6 +68,13 @@ Die 34 Nachrichtenbits sind aufgeteilt in 16+1+16+1, d.h. nach einem 16 bit Bloc
dass 1 ist, wenn die Anzahl 1en in den 16 bit davor gerade ist, und sonst 0.
*/
/*
2 "raw" symbols -> 1 biphase-symbol (bit): 2400 (raw) baud
ecc: option_b, exact symbol rate; if necessary, adjust --br <baud>
e.g.
./meisei_ecc -1 --ecc -v -b --br 2398 audio.wav
*/
#include <stdio.h>
#include <stdlib.h>
@ -97,6 +109,8 @@ int option_verbose = 0, // ausfuehrliche Anzeige
option_ecc = 0, // BCH(63,51)
wavloaded = 0;
float baudrate = -1;
/* -------------------------------------------------------------------------- */
// Fehlerkorrektur (noch?) nicht sehr effektiv... (t zu klein)
@ -111,7 +125,7 @@ int block, check_err;
/* -------------------------------------------------------------------------- */
#define BAUD_RATE 2400
#define BAUD_RATE 2400 // raw symbol rate; bit=biphase_symbol, bitrate=1200
int sample_rate = 0, bits_sample = 0, channels = 0;
float samples_per_bit = 0;
@ -475,6 +489,14 @@ int main(int argc, char **argv) {
else if ( (strcmp(*argv, "-v") == 0) ) {
option_verbose = 1;
}
else if ( (strcmp(*argv, "--br") == 0) ) {
++argv;
if (*argv) {
baudrate = atof(*argv);
if (baudrate < 2200 || baudrate > 2400) baudrate = 2400; // default: 2400
}
else return -1;
}
else {
if ((option1 == 1 && option2 == 1) || (!option_raw && option1 == 0 && option2 == 0)) goto help_out;
fp = fopen(*argv, "rb");
@ -494,6 +516,10 @@ int main(int argc, char **argv) {
fclose(fp);
return -1;
}
if (baudrate > 0) {
samples_per_bit = sample_rate/baudrate; // default baudrate: 2400
fprintf(stderr, "sps corr: %.4f\n", samples_per_bit);
}
if (option_ecc) {
rs_init_BCH64();
@ -637,7 +663,7 @@ int main(int argc, char **argv) {
velH = (double)vH/1e2;
velD = (double)vD/1e2;
velU = (double)vU/1e2;
printf(" %.2fm/s %.1f %.2fm/s", velH, velD, velU);
printf(" vH: %.2fm/s D: %.1f vV: %.2fm/s", velH, velD, velU);
printf(" ");
jj = bits2val(frame_bits+HEADLEN+5*46+ 8, 8) + 0x0700;
@ -705,9 +731,9 @@ int main(int argc, char **argv) {
vD = bits2val(frame_bits+HEADLEN+46*4+17, 16);
vH = bits2val(frame_bits+HEADLEN+46*5 , 16);
velD = (double)vD/1e2;
velH = (double)vH/1.94384e2; // knots -> m/s
printf(" (course=%.1f speed=%.2fm/s)", velD, velH);
velD = (double)vD/1e2; // course, true
velH = (double)vH/1.94384e2; // speed: knots -> m/s
printf(" (vH: %.1fm/s D: %.2f)", velH, velD);
printf(" ");
}
//else { printf("\n"); }