Skip to content

Commit 88023e6

Browse files
committed
corregido el bug de grabar nal los mensajes concatenados de cat02+cat01, ej. montejunto
1 parent 71aa675 commit 88023e6

File tree

6 files changed

+88
-66
lines changed

6 files changed

+88
-66
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
0.73
2+
- BUG: cuando en un paquete udp había más de un mensaje
3+
encapsulado y eran de distintas categorías, el segundo
4+
se tiraba. Esto afectaba especialmente a Montejunto, Foia,
5+
etc, porque encapsulaban un cat02+cat01...
6+
17
0.72
28
- SOPORTE: para CAT10, client soporta el canal operativo.
39
- SOPORTE: añadida utilidad para eliminar categorías asterix
410
de archivos GPS.
11+
- SOPORTE: Añadido el sic de Lanzarote (198)
512

613
0.71
714
- SOPORTE: para CAT10, se envían a cálculo de demoras los

include/defines.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reader_network - A package of utilities to record and work with
33
multicast radar data in ASTERIX format. (radar as in air navigation
44
surveillance).
55
6-
Copyright (C) 2002-2018 Diego Torres <diego dot torres at gmail dot com>
6+
Copyright (C) 2002-2019 Diego Torres <diego dot torres at gmail dot com>
77
88
This file is part of the reader_network utils.
99
@@ -22,8 +22,8 @@ along with reader_network. If not, see <http://www.gnu.org/licenses/>.
2222
*/
2323

2424

25-
#define VERSION "0.72"
26-
#define COPYRIGHT_NOTICE " v%s Copyright (C) 2002 - 2018 Diego Torres\n\n" \
25+
#define VERSION "0.73"
26+
#define COPYRIGHT_NOTICE " v%s Copyright (C) 2002 - 2019 Diego Torres\n\n" \
2727
"This program comes with ABSOLUTELY NO WARRANTY.\n" \
2828
"This is free software, and you are welcome to redistribute it\n" \
2929
"under certain conditions; see COPYING file for details.\n\n"

package.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
rm distrib/rn072.tar.bz2
2-
tar cvfj distrib/rn072.tar.bz2 \
1+
rm distrib/rn073.tar.bz2
2+
tar cvfj distrib/rn073.tar.bz2 \
33
bin/client* \
44
bin/reader_network* \
55
bin/reader_rrd3* bin/cleanast* bin/scripts/* bin/conf/* bin/filter*

src/asterix.c

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ int index = 0;
412412
struct datablock_plot dbp;
413413

414414
memset(&dbp, 0, sizeof(struct datablock_plot));
415-
// log_printf(LOG_NORMAL, "fspec %02X\n", ptr_raw[0]);
415+
log_printf(LOG_NORMAL, "a)CAT01] fspec %02X\n", ptr_raw[0]);
416416

417417
sizeFSPEC = ast_get_size_FSPEC(ptr_raw, size_datablock);
418418
dbp.cat = CAT_01;
@@ -442,13 +442,13 @@ int index = 0;
442442
}
443443
if ( ptr_raw[0] & 64 ) { //I001/010
444444
if ( ptr_raw[j] & 128 ) { // track
445-
//log_printf(LOG_NORMAL, "type %02X TRACK\n", ptr_raw[j]);
445+
log_printf(LOG_NORMAL, "b)CAT01] type %02X TRACK\n", ptr_raw[j]);
446446
dbp.available |= IS_TRACK;
447447
size_current = size_datablock - 3; //exit without further decompression
448448

449449
} else { // plot
450450
dbp.available |= IS_TYPE;
451-
//log_printf(LOG_NORMAL, "type %02X\n", ptr_raw[j]);
451+
log_printf(LOG_NORMAL, "c)CAT01] type %02X\n", ptr_raw[j]);
452452

453453
if ( (!(ptr_raw[j] & 32)) && (!(ptr_raw[j] & 16)) ) {
454454
dbp.type = NO_DETECTION;
@@ -522,11 +522,11 @@ int index = 0;
522522
}
523523
}
524524
}
525-
// ast_output_datablock(ptr_raw, j , dbp.id, dbp.index);
525+
ast_output_datablock(ptr_raw, j , dbp.id, dbp.index);
526526
// if ( (dbp.available & IS_TYPE) && (dbp.available & IS_TOD) ) {
527527
if ( dbp.available & IS_TYPE ) {
528-
/* log_printf(LOG_NORMAL, "%3.3f %3.3f %3.3f\n", dbp.tod_stamp, dbp.tod, dbp.tod_stamp - dbp.tod);
529-
if ((dbp.tod_stamp - dbp.tod < 0) || ((dbp.tod_stamp - dbp.tod > 5)) ) {
528+
log_printf(LOG_NORMAL, "%3.3f %3.3f %3.3f\n", dbp.tod_stamp, dbp.tod, dbp.tod_stamp - dbp.tod);
529+
/* if ((dbp.tod_stamp - dbp.tod < 0) || ((dbp.tod_stamp - dbp.tod > 5)) ) {
530530
log_printf(LOG_NORMAL, "%3.3f %3.3f %3.3f\n", dbp.tod_stamp, dbp.tod, dbp.tod_stamp - dbp.tod);
531531
exit(EXIT_FAILURE);
532532
}
@@ -548,58 +548,66 @@ int index = 0;
548548
}
549549

550550
int ast_procesarCAT02(unsigned char *ptr_raw, ssize_t size_datablock, unsigned long id, bool enviar) {
551-
int sizeFSPEC=0, pos=0;
552-
struct datablock_plot dbp;
553551

552+
// do
553+
{
554554

555-
memset(&dbp, 0, sizeof(struct datablock_plot));
556-
dbp.plot_type = IS_ERROR;
557-
dbp.tod_stamp = current_time_today;
558-
dbp.flag_test = 0;
559-
dbp.id = id;
560-
dbp.index = 0;
561-
sizeFSPEC = ast_get_size_FSPEC(ptr_raw, size_datablock);
555+
int sizeFSPEC=0, pos=0;
556+
struct datablock_plot dbp;
562557

563-
// log_printf(LOG_ERROR, "a)CAT02] (%d) %02X %02X\n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
558+
memset(&dbp, 0, sizeof(struct datablock_plot));
559+
dbp.plot_type = IS_ERROR;
560+
dbp.tod_stamp = current_time_today;
561+
dbp.flag_test = 0;
562+
dbp.id = id;
563+
dbp.index = 0;
564+
sizeFSPEC = ast_get_size_FSPEC(ptr_raw, size_datablock);
564565

565-
if ( (ptr_raw[0] & 128) && // sac/sic
566-
(ptr_raw[0] & 64) && // msg type
567-
(ptr_raw[0] & 16) ) { // timeofday
568-
569-
// log_printf(LOG_ERROR, "b)CAT02] (%d) %02X %02X \n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
566+
log_printf(LOG_ERROR, "a)CAT02] (%d) %02X %02X\n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
570567

571-
if (ptr_raw[0] & 32) pos++;
568+
if ( (ptr_raw[0] & 128) && // sac/sic
569+
(ptr_raw[0] & 64) && // msg type
570+
(ptr_raw[0] & 16) ) { // timeofday
571+
572+
log_printf(LOG_ERROR, "b)CAT02] (%d) %02X %02X \n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
573+
if (ptr_raw[0] & 32) pos++;
572574

573-
pos += sizeFSPEC + 3; //FSPEC SACSIC MSGTYPE
575+
pos += sizeFSPEC + 3; //FSPEC SACSIC MSGTYPE
574576

575-
// log_printf(LOG_ERROR, "c)CAT02] (%d) %02X %02X \n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
577+
log_printf(LOG_ERROR, "c)CAT02] (%d) %02X %02X \n", sizeFSPEC, ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC+1] );
576578

577-
ttod_put_full(ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC + 1], ptr_raw + pos);
579+
ttod_put_full(ptr_raw[sizeFSPEC], ptr_raw[sizeFSPEC + 1], ptr_raw + pos);
578580

579-
dbp.cat = CAT_02;
580-
dbp.sac = ptr_raw[sizeFSPEC]; dbp.sic = ptr_raw[sizeFSPEC+1];
581-
dbp.available = IS_TOD | IS_TYPE | IS_SACSIC;
582-
dbp.tod = ((float)(ptr_raw[pos]*256*256 + ptr_raw[pos+1]*256 + ptr_raw[pos+2]))/128.0;
583-
//if (dbp.sac == 1 && dbp.sic==1) {
584-
// ast_output_datablock(ptr_raw, size_datablock - 3, dbp.id, dbp.index);
585-
//}
586-
switch(ptr_raw[sizeFSPEC+2]) {
587-
case 1: dbp.type = TYPE_C2_NORTH_MARKER; break;
588-
case 2: dbp.type = TYPE_C2_SECTOR_CROSSING; break;
589-
case 3: dbp.type = TYPE_C2_SOUTH_MARKER; break;
590-
case 8: dbp.type = TYPE_C2_START_BLIND_ZONE_FILTERING; break;
591-
case 9: dbp.type = TYPE_C2_STOP_BLIND_ZONE_FILTERING; break;
592-
default: dbp.type = NO_DETECTION; break;
593-
}
594-
if (enviar) {
595-
usleep(10);
596-
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT002
597-
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
581+
dbp.cat = CAT_02;
582+
dbp.sac = ptr_raw[sizeFSPEC]; dbp.sic = ptr_raw[sizeFSPEC+1];
583+
dbp.available = IS_TOD | IS_TYPE | IS_SACSIC;
584+
dbp.tod = ((float)(ptr_raw[pos]*256*256 + ptr_raw[pos+1]*256 + ptr_raw[pos+2]))/128.0;
585+
if (dbp.sac == 104 && dbp.sic==1) {
586+
log_printf(LOG_ERROR, "d)CAT02] datablock follows:\n");
587+
ast_output_datablock(ptr_raw, size_datablock - 3, dbp.id, dbp.index);
598588
}
599-
} else {
589+
switch(ptr_raw[sizeFSPEC+2]) {
590+
case 1: dbp.type = TYPE_C2_NORTH_MARKER; break;
591+
case 2: dbp.type = TYPE_C2_SECTOR_CROSSING; break;
592+
case 3: dbp.type = TYPE_C2_SOUTH_MARKER; break;
593+
case 8: dbp.type = TYPE_C2_START_BLIND_ZONE_FILTERING; break;
594+
case 9: dbp.type = TYPE_C2_STOP_BLIND_ZONE_FILTERING; break;
595+
default: dbp.type = NO_DETECTION; break;
596+
}
597+
log_printf(LOG_ERROR, "e)CAT02] dbp.type(%d) db.tod(%3.3f) dbp.available(%d)\n", dbp.type, dbp.tod, dbp.available);
598+
if (enviar) {
599+
usleep(10);
600+
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT002
601+
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
602+
}
603+
} else {
600604
update_calculations(&dbp);
601-
}
605+
}
606+
}
607+
602608
}
609+
// while ((size_current + 3) < size_datablock);
610+
603611
return T_OK;
604612
}
605613

src/reader_network.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ unsigned long count2_plot_filtered = 0;
997997
fs.filter_type = dest_filter_flags;
998998

999999
if ( dest_localhost || dest_filter_flags ) {
1000+
log_printf(LOG_NORMAL, "\n==================================================================\n");
1001+
ast_output_datablock(ast_ptr_raw + ast_pos, ast_size_datablock, count2_plot_processed, 0);
10001002

10011003
if (ast_ptr_raw[ast_pos] == '\x01') {
10021004
count2_plot_processed++;
@@ -1323,8 +1325,8 @@ unsigned long count2_plot_filtered = 0;
13231325
}
13241326
is_processed = true;
13251327

1326-
// log_printf(LOG_VERBOSE,"-----udp(%d) ast(%d)\n", udp_size, ast_size_datablock);
1327-
// ast_output_datablock(ast_ptr_raw, udp_size, count_plot_processed, 0);
1328+
log_printf(LOG_VERBOSE,"-----udp(%d) ast_size_datablock(%d)\n", udp_size, ast_size_datablock);
1329+
ast_output_datablock(ast_ptr_raw, udp_size, 0, 0);
13281330

13291331
do {
13301332
unsigned int crc = 0;
@@ -1358,31 +1360,31 @@ unsigned long count2_plot_filtered = 0;
13581360
// RBTreePrint(tree);
13591361
}
13601362

1361-
//log_printf(LOG_NORMAL, "\n==================================================================\n");
1362-
//ast_output_datablock(ast_ptr_raw, ast_size_datablock, count2_plot_processed, 0);
1363-
//ast_output_datablock(ast_ptr_raw_tmp, ast_size_datablock, count2_plot_processed, 0);
1363+
ast_output_datablock(ast_ptr_raw_tmp, ast_size_datablock, count2_plot_processed, 0);
13641364
if (dest_localhost && record) {
1365-
if (ast_ptr_raw[0] == '\x01')
1365+
if (ast_ptr_raw_tmp[0] == '\x01')
13661366
ast_procesarCAT01(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1367-
if (ast_ptr_raw[0] == '\x02')
1367+
if (ast_ptr_raw_tmp[0] == '\x02')
13681368
ast_procesarCAT02(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1369-
if (ast_ptr_raw[0] == '\x08')
1369+
if (ast_ptr_raw_tmp[0] == '\x08')
13701370
ast_procesarCAT08(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1371+
// excepción, el antiguo SMR de Terma concatenaba cat-size-datarecord+datarecord+datarecord
1372+
// el resto del mundo hace cat-size-datarecords+cat-size-datarecord....
13711373
if (ast_ptr_raw[0] == '\x0a')
13721374
ast_procesarCAT10(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1373-
if (ast_ptr_raw[0] == '\x013')
1375+
if (ast_ptr_raw_tmp[0] == '\x013')
13741376
ast_procesarCAT19(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1375-
if (ast_ptr_raw[0] == '\x014')
1377+
if (ast_ptr_raw_tmp[0] == '\x014')
13761378
ast_procesarCAT20(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1377-
if (ast_ptr_raw[0] == '\x15')
1379+
if (ast_ptr_raw_tmp[0] == '\x15')
13781380
ast_procesarCAT21(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1379-
if (ast_ptr_raw[0] == '\x22')
1381+
if (ast_ptr_raw_tmp[0] == '\x22')
13801382
ast_procesarCAT34(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
1381-
if (ast_ptr_raw[0] == '\x30')
1383+
if (ast_ptr_raw_tmp[0] == '\x30')
13821384
//ast_procesarCAT48(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true); //, FILTER_GROUND);
13831385
//ast_procesarCAT48F(ast_ptr_raw + ast_pos + 3, ast_size_datablock, count2_plot_processed, dest_localhost, dest_filter_flags, ast_ptr_raw_new, ast_size_datablock_new);
13841386
ast_procesarCAT48F(ast_ptr_raw + ast_pos + 3, ast_size_datablock, count2_plot_processed, dest_localhost, NULL);
1385-
if (ast_ptr_raw[0] == '\x3e')
1387+
if (ast_ptr_raw_tmp[0] == '\x3e')
13861388
ast_procesarCAT62(ast_ptr_raw_tmp + 3, ast_size_datablock, count2_plot_processed, true);
13871389
}
13881390
if (dest_file != NULL && record) {
@@ -1422,12 +1424,15 @@ unsigned long count2_plot_filtered = 0;
14221424
}
14231425
}
14241426
ast_ptr_raw_tmp += ast_size_datablock;
1427+
// realmente, si ast_size_datablock < udp_size
14251428
if (ast_ptr_raw_tmp < (ast_ptr_raw+udp_size)) {
14261429
ast_size_datablock = (ast_ptr_raw_tmp[1]<<8) + ast_ptr_raw_tmp[2];
14271430
} else {
14281431
salir=1;
14291432
}
14301433
} while (salir==0);
1434+
log_printf(LOG_NORMAL, "\n==================================================================\n");
1435+
14311436
// j=radar_count/5; // no seguir buscando, ya ha sido procesado
14321437
// } else {
14331438
// log_printf(LOG_VERBOSE, "%02d) rcv(%s) cfg(%s) counter(%ld)\n",j, inet_ntoa(cast_group.sin_addr), radar_definition[j*5+3], count2_udp_received);

src/sacsic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reader_network - A package of utilities to record and work with
33
multicast radar data in ASTERIX format. (radar as in air navigation
44
surveillance).
55
6-
Copyright (C) 2002-2016 Diego Torres <diego dot torres at gmail dot com>
6+
Copyright (C) 2002-2018 Diego Torres <diego dot torres at gmail dot com>
77
88
This file is part of the reader_network utils.
99
@@ -171,6 +171,7 @@ char *tmp;
171171
case 195:{ strncpy(tmp, "PDC", TEXT_LENGTH_SHORT); break; }
172172
case 196:{ strncpy(tmp, "LPM", TEXT_LENGTH_SHORT); break; }
173173
case 197:{ strncpy(tmp, "TBN", TEXT_LENGTH_SHORT); break; }
174+
case 198:{ strncpy(tmp, "LAN", TEXT_LENGTH_SHORT); break; }
174175
case 199:{ strncpy(tmp, "FPV", TEXT_LENGTH_SHORT); break; }
175176
case 201:{ strncpy(tmp, "AST", TEXT_LENGTH_SHORT); break; }
176177
default: sprintf(tmp, "U%03d", sic[0]);
@@ -220,6 +221,7 @@ char *tmp;
220221
case 195:{ strncpy(tmp, "Peñas del Chache", TEXT_LENGTH_LONG); break; }
221222
case 196:{ strncpy(tmp, "La Palma", TEXT_LENGTH_LONG); break; }
222223
case 197:{ strncpy(tmp, "Taborno", TEXT_LENGTH_LONG); break; }
224+
case 198:{ strncpy(tmp, "Lanzarote", TEXT_LENGTH_LONG); break; }
223225
case 199:{ strncpy(tmp, "Fuerteventura PV", TEXT_LENGTH_LONG); break; }
224226
case 201:{ strncpy(tmp, "Asturias WAM", TEXT_LENGTH_LONG); break; }
225227
default: sprintf(tmp, "U%03d", sic[0]);

0 commit comments

Comments
 (0)