Skip to content

Commit d72d532

Browse files
committed
filter-out TRE from cat10 when writing delays
1 parent f611e08 commit d72d532

File tree

6 files changed

+48
-22
lines changed

6 files changed

+48
-22
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
0.71
2+
- SOPORTE: para CAT10, se envían a cálculo de demoras los
3+
DETECTION y los SUC. Antes solo los DETECTION, pero durante
4+
mucho tiempo en aeropuertos pequeños no hay blancos.
5+
- BUG: log_flush() después de log_printf en updatecalculations
6+
para ver el progreso cuando se usa --stdout con --mysql-xxxx
7+
- BUG: áñade 10 microsegs antes de cada sendto para que la pila
8+
udp no tire los paquetes por overflow al enviar de fichero
9+
110
0.70
211
- SOPORTE reader_network: retry ftp upload once
312
- BUG: disable CURLOPT_FTP_USE_EPRT, so it works with new

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-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
@@ -22,8 +22,8 @@ along with reader_network. If not, see <http://www.gnu.org/licenses/>.
2222
*/
2323

2424

25-
#define VERSION "0.70"
26-
#define COPYRIGHT_NOTICE " v%s Copyright (C) 2002 - 2017 Diego Torres\n\n" \
25+
#define VERSION "0.71"
26+
#define COPYRIGHT_NOTICE " v%s Copyright (C) 2002 - 2018 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/rn070.tar.bz2
2-
tar cvfj distrib/rn070.tar.bz2 \
1+
rm distrib/rn071.tar.bz2
2+
tar cvfj distrib/rn071.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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ int index = 0;
531531
exit(EXIT_FAILURE);
532532
}
533533
*/ if (enviar) {
534+
usleep(10);
534535
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT001
535536
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
536537
}
@@ -591,6 +592,7 @@ struct datablock_plot dbp;
591592
default: dbp.type = NO_DETECTION; break;
592593
}
593594
if (enviar) {
595+
usleep(10);
594596
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT002
595597
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
596598
}
@@ -633,6 +635,7 @@ struct datablock_plot dbp;
633635
(ptr_raw[sizeFSPEC + 4]<<8) +
634636
(ptr_raw[sizeFSPEC + 5])) / 128.0;
635637
if (enviar) {
638+
usleep(10);
636639
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT008
637640
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
638641
exit(EXIT_FAILURE);
@@ -728,7 +731,13 @@ int index = 0;
728731
if ( ptr_raw[1] & 128 ) { /* I010/200 */ j +=4; size_current += 4; }
729732
if ( ptr_raw[1] & 64 ) { /* I010/202 */ j +=4; size_current += 4; }
730733
if ( ptr_raw[1] & 32 ) { /* I010/161 */ j +=2; size_current += 2; }
731-
if ( ptr_raw[1] & 16 ) { /* I010/170 */ while (ptr_raw[j] & 1) { j++; size_current++; }; j++;size_current++; }
734+
// cambiamos la definición del I010/170 para mirar si el TRE está definido
735+
// comprobamos solo si el normal y un extent. Si hubiese más, fallaría la
736+
// descodificación, pero también es cierto que incumple el estandar.
737+
if ( ptr_raw[1] & 16 ) { /* I010/170 */
738+
if ( ptr_raw[j] & 64 ) { dbp.plot_type = NO_DETECTION; }
739+
while (ptr_raw[j] & 1) { j++; size_current++; } j++;size_current++;
740+
}
732741
if ( ptr_raw[1] & 8 ) { /* I010/060 */ j +=2; size_current += 2; }
733742
if ( ptr_raw[1] & 4 ) { /* I010/220 */ j +=3; size_current += 3; }
734743
if ( ptr_raw[1] & 2 ) { /* I010/245 */ j +=7; size_current += 7; }
@@ -761,11 +770,14 @@ int index = 0;
761770
}
762771
*/
763772
if (enviar) {
773+
usleep(10);
764774
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT010
765775
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
766776
}
767777
} else {
768-
if ( (dbp.type & TYPE_C10_TARGET_REPORT) == TYPE_C10_TARGET_REPORT ) {
778+
if ( ( ((dbp.type & TYPE_C10_TARGET_REPORT) == TYPE_C10_TARGET_REPORT) ||
779+
((dbp.type & TYPE_C10_TARGET_REPORT) == TYPE_C10_START_UPDATE_CYCLE) ) &&
780+
(dbp.plot_type != NO_DETECTION) ) {
769781
update_calculations(&dbp);
770782
}
771783
}
@@ -809,6 +821,7 @@ struct datablock_plot dbp;
809821
default: dbp.type = IS_ERROR; break;
810822
}
811823
if (enviar) {
824+
usleep(10);
812825
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT019
813826
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
814827
}
@@ -944,6 +957,7 @@ int index = 0;
944957
exit(EXIT_FAILURE);
945958
// }
946959
*/ if (enviar) {
960+
usleep(10);
947961
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT020
948962
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
949963
}
@@ -1071,6 +1085,7 @@ int index = 0;
10711085
}
10721086
*/
10731087
if (enviar) {
1088+
usleep(10);
10741089
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT021
10751090
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
10761091
}
@@ -1136,6 +1151,7 @@ int index = 0;
11361151
dbp.tod = ((float)(ptr_raw[j]*256*256 + ptr_raw[j+1]*256 + ptr_raw[j+2]))/128.0;
11371152
size_current += 3; j += 3;
11381153
if (enviar) {
1154+
usleep(10);
11391155
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT034
11401156
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
11411157
}
@@ -1419,6 +1435,7 @@ unsigned char *datablock_start = NULL;
14191435
}
14201436
*/
14211437
if (enviar) {
1438+
usleep(10);
14221439
if (sendto(s_output_multicast, &dbp, sizeof(dbp), 0, (struct sockaddr *) &srvaddr, sizeof(srvaddr)) < 0) { // CAT048
14231440
log_printf(LOG_ERROR, "ERROR sendto: %s\n", strerror(errno));
14241441
}

src/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ int main(int argc, char *argv[]) {
190190
log_printf(LOG_VERBOSE, "%ld [%s/%s] [%s%s%s%s] [%s%s%s%s%s%s%s%s%s] [AZI %03.3f] [DST %03.3f] [%s] [%s] (%3.4f)\n", dbp.id,
191191
sac_s, sic_l,
192192
(dbp.type == TYPE_C10_TARGET_REPORT) ? "PLOT" : "",
193-
(dbp.type == TYPE_C10_START_UPDATE_CYCLE) ? "UPDATE" : "",
193+
(dbp.type == TYPE_C10_START_UPDATE_CYCLE) ? "SUC" : "",
194194
(dbp.type == TYPE_C10_PERIODIC_STATUS) ? "PERIODIC" : "",
195195
(dbp.type == TYPE_C10_EVENT_STATUS) ? "EVENT" : "",
196-
(dbp.plot_type == NO_DETECTION) ? "na" : "",
196+
(dbp.plot_type == NO_DETECTION) ? "NODETEC" : "",
197197
(dbp.plot_type == TYPE_C10_PLOT_SSR_MULTI) ? "SSRM" : "",
198198
(dbp.plot_type == TYPE_C10_PLOT_SSRS_MULTI) ? "SMMS" : "",
199199
(dbp.plot_type == TYPE_C10_PLOT_ADSB) ? "ADS" : "",

src/reader_rrd3.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,22 @@ void setup_mysql() {
319319

320320
if ( mysql_output == 1 ) {
321321

322-
if (!MYSQL_host) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-host)\n"); exit(EXIT_FAILURE); }
323-
if (!MYSQL_user) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-user)\n"); exit(EXIT_FAILURE); }
324-
if (!MYSQL_pass) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-pass)\n"); exit(EXIT_FAILURE); }
325-
if (!MYSQL_db) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-db)\n"); exit(EXIT_FAILURE); }
322+
if (!stdout_output && !MYSQL_host) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-host)\n"); exit(EXIT_FAILURE); }
323+
if (!stdout_output && !MYSQL_user) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-user)\n"); exit(EXIT_FAILURE); }
324+
if (!stdout_output && !MYSQL_pass) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-pass)\n"); exit(EXIT_FAILURE); }
325+
if (!stdout_output && !MYSQL_db) { log_printf(LOG_ERROR, "ERROR setup_mysql (undefined --mysql-db)\n"); exit(EXIT_FAILURE); }
326326
if (MYSQL_port) {
327327
port = atoi(MYSQL_port);
328328
}
329-
if ( mysql_library_init(0, NULL, NULL) != 0 ) {
329+
if (!stdout_output && mysql_library_init(0, NULL, NULL) != 0 ) {
330330
log_printf(LOG_ERROR, "ERROR setup_mysql (mysql_library_init): %s\n", mysql_error(mysql_con));
331331
exit(EXIT_FAILURE);
332332
}
333-
if ( (mysql_con = mysql_init(NULL)) == NULL ) {
333+
if (!stdout_output && (mysql_con = mysql_init(NULL)) == NULL ) {
334334
log_printf(LOG_ERROR, "ERROR setup_mysql (mysql_init): %s\n", mysql_error(mysql_con));
335335
exit(EXIT_FAILURE);
336336
}
337-
if ( mysql_real_connect(mysql_con,
337+
if (!stdout_output && mysql_real_connect(mysql_con,
338338
MYSQL_host, MYSQL_user, MYSQL_pass, MYSQL_db, port, NULL,
339339
//"192.168.0.34", "reader_rrd", "reader_rrd", "cocir", 0, NULL,
340340
0 /*CLIENT_MULTI_STATEMENTS*/) == NULL ) {
@@ -347,7 +347,7 @@ void setup_mysql() {
347347
if ( stdout_output == 1 ) {
348348
log_printf(LOG_NORMAL, "%s\n", init_table_caps);
349349
}
350-
if ( mysql_output == 1) {
350+
if (!stdout_output && mysql_output == 1) {
351351
if ( mysql_query(mysql_con, init_table_caps) != 0 ) {
352352
log_printf(LOG_ERROR, "ERROR setup_mysql (init_table_caps): %s\n", mysql_error(mysql_con));
353353
exit(EXIT_FAILURE);
@@ -359,7 +359,7 @@ void setup_mysql() {
359359
if ( stdout_output == 1 ) {
360360
log_printf(LOG_NORMAL, "%s\n", init_table_bds30);
361361
}
362-
if ( mysql_output == 1) {
362+
if (!stdout_output && mysql_output == 1) {
363363
if ( mysql_query(mysql_con, init_table_bds30) != 0 ) {
364364
log_printf(LOG_ERROR, "ERROR setup_mysql (init_table_bds30): %s\n", mysql_error(mysql_con));
365365
exit(EXIT_FAILURE);
@@ -392,7 +392,7 @@ void setup_mysql() {
392392
if ( stdout_output == 1 ) {
393393
log_printf(LOG_NORMAL, "%s\n", init_table_availability3);
394394
}
395-
if ( mysql_output == 1) {
395+
if (!stdout_output && mysql_output == 1) {
396396
if ( mysql_query(mysql_con, init_table_availability3) != 0 ) {
397397
log_printf(LOG_ERROR, "ERROR setup_mysql (init_table_availability3): %s\n", mysql_error(mysql_con));
398398
exit(EXIT_FAILURE);
@@ -404,7 +404,7 @@ void setup_mysql() {
404404

405405
void close_mysql() {
406406
//mysql_thread_end();
407-
if ( mysql_output == 0 ) {
407+
if (!stdout_output && mysql_output == 0 ) {
408408
mysql_close(mysql_con);
409409
mysql_library_end();
410410
}
@@ -1068,7 +1068,7 @@ void update_calculations(struct datablock_plot *dbp) {
10681068
double p99_cat34=0.0, p99_cat48=0.0;
10691069

10701070
cuenta = 0;
1071-
// log_printf(LOG_NORMAL, "0>tod:%s tod_stamp:%s diff:%3.3f tod_stamp+midnight(%3.3f) > step(%3.3f)\n", parse_hora(dbp.tod), parse_hora(dbp.tod_stamp), diff, dbp.tod_stamp + midnight_t, step);
1071+
//log_printf(LOG_NORMAL, "0>tod:%s tod_stamp:%s diff:%3.3f tod_stamp+midnight(%3.3f) > step(%3.3f)\n", parse_hora(dbp->tod), parse_hora(dbp->tod_stamp), diff, dbp->tod_stamp + midnight_t, step);
10721072

10731073
if (!forced_exit) {
10741074
step = (d.quot * UPDATE_TIME_RRD + UPDATE_TIME_RRD) - 1.0/2048.0 + midnight_t;
@@ -1590,7 +1590,7 @@ void update(int sac, int sic, int cat, int i, long timestamp, float cuenta, floa
15901590
log_printf(LOG_NORMAL, "%s", stmt);
15911591
} else {
15921592
if (mysql_query(mysql_con, stmt) != 0) {
1593-
log_printf(LOG_ERROR, "ERROR decode_bds30 (mysql_query): %s\n", mysql_error(mysql_con));
1593+
log_printf(LOG_ERROR, "ERROR update database (mysql_query >%s<): %s\n", stmt, mysql_error(mysql_con));
15941594
exit(EXIT_FAILURE);
15951595
}
15961596
}

0 commit comments

Comments
 (0)