Merge remote-tracking branch 'origin/T-macpdu-fix' into integration_2026_w08 (!3924)
T: macpdu2wireshark: gentle exit (and some other minor work in the T tracer) When outputting to a file, typing ctrl+c exits the program without calling fclose(), leading to loss of traces in the output file. Let's intercept ctrl+c and exit gently, calling fclose(). Also include a small fix for compilation of _check_vcd, some work on extract and hacks/plot-ofdm, minor stuff.
This commit is contained in:
@@ -21,7 +21,7 @@ incgen/T_IDs.h: $(GENIDS) T_messages.txt
|
||||
./$(GENIDS) T_messages.txt incgen/T_IDs.h
|
||||
|
||||
check_vcd: incgen/T_IDs.h incgen/T_messages.txt.h
|
||||
gcc -Wall -I. -I.. -I../itti -I../../../openair2/COMMON -Itracer -o _check_vcd check_vcd.c tracer/database.c tracer/utils.c -lm -pthread
|
||||
gcc -Wall -I. -I.. -I../../.. -I../itti -I../../../openair2/COMMON -Itracer -Iincgen -o _check_vcd check_vcd.c tracer/database.c tracer/utils.c -lm -pthread
|
||||
./_check_vcd T_messages.txt ../LOG/vcd_signal_dumper.h || (rm -rf ./_check_vcd ./incgen && false)
|
||||
rm -f ./_check_vcd
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ void usage(void)
|
||||
" (you can use several -f options)\n"
|
||||
" -after <raw time> <nsec> 'event' time has to be greater than this\n"
|
||||
" -count <n> dump 'n' matching events (less if EOF reached)\n"
|
||||
" (default: no limit)\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
@@ -53,7 +54,7 @@ int main(int n, char **v)
|
||||
int filter_count = 0;
|
||||
int buffer_arg;
|
||||
int found;
|
||||
int count = 1;
|
||||
int count = -1;
|
||||
int check_time = 0;
|
||||
time_t sec = 0; /* initialization not necessary but gcc is not happy */
|
||||
long nsec = 0; /* initialization not necessary but gcc is not happy */
|
||||
@@ -132,12 +133,12 @@ int main(int n, char **v)
|
||||
if (fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, out) != 1)
|
||||
{ perror(output_file); exit(1); }
|
||||
found++;
|
||||
if (found == count)
|
||||
if (count != -1 && found == count)
|
||||
break;
|
||||
}
|
||||
|
||||
if (found == 0) printf("ERROR: event not found\n");
|
||||
if (found != count)
|
||||
if (count != -1 && found != count)
|
||||
printf("WARNING: dumped %d events (wanted %d)\n", found, count);
|
||||
|
||||
fclose(out);
|
||||
|
||||
@@ -135,7 +135,7 @@ int main(int n, char **v)
|
||||
int input_is_float = 0;
|
||||
int no_fft = 0;
|
||||
int delay = 0;
|
||||
int skip = 0;
|
||||
uint64_t skip = 0;
|
||||
int symbols_per_subframe;
|
||||
long sampling_rate = 61440000;
|
||||
int mu = 1;
|
||||
@@ -152,7 +152,7 @@ int main(int n, char **v)
|
||||
if (!strcmp(v[i], "-srate")) { if (i>n-2) usage(); sampling_rate = atol(v[++i]); continue; }
|
||||
if (!strcmp(v[i], "-prb")) { if (i>n-2) usage(); prb = atoi(v[++i]); continue; }
|
||||
if (!strcmp(v[i], "-mu")) { if (i>n-2) usage(); mu = atoi(v[++i]); continue; }
|
||||
if (!strcmp(v[i], "-skip")) { if (i>n-2) usage(); skip = atoi(v[++i]); continue; }
|
||||
if (!strcmp(v[i], "-skip")) { if (i>n-2) usage(); skip = atoll(v[++i]); continue; }
|
||||
usage();
|
||||
}
|
||||
|
||||
@@ -222,14 +222,14 @@ int main(int n, char **v)
|
||||
int back_color = 0;
|
||||
int hpixel = 0;
|
||||
|
||||
if (skip) {
|
||||
if (input_is_float) {
|
||||
float intime[skip * 2];
|
||||
if (fread(intime, skip * 8, 1, stdin) != 1) abort();
|
||||
} else {
|
||||
short intime[skip * 2];
|
||||
if (fread(intime, skip * 4, 1, stdin) != 1) abort();
|
||||
}
|
||||
/* skip data */
|
||||
int sample_size = input_is_float ? 8 : 4;
|
||||
uint64_t to_skip = skip;
|
||||
while (to_skip) {
|
||||
char intime[4096 * sample_size];
|
||||
int count = to_skip > 4096 ? 4096 : to_skip;
|
||||
if (fread(intime, count * sample_size, 1, stdin) != 1) abort();
|
||||
to_skip -= count;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -387,6 +389,7 @@ void sr(void *_d, event e)
|
||||
#define MAC_NR_HARQID 0x06
|
||||
#define MAC_NR_FRAME_SLOT_TAG 0x07
|
||||
|
||||
#define NR_FDD_RADIO 1
|
||||
#define NR_TDD_RADIO 2
|
||||
|
||||
#define NR_DIRECTION_UPLINK 0
|
||||
@@ -948,6 +951,18 @@ void usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
volatile int run = 1;
|
||||
|
||||
static int sock = -1;
|
||||
|
||||
void force_stop(int x)
|
||||
{
|
||||
printf("\ngently quit...\n");
|
||||
close(sock);
|
||||
sock = -1;
|
||||
run = 0;
|
||||
}
|
||||
|
||||
int main(int n, char **v)
|
||||
{
|
||||
char *database_filename = NULL;
|
||||
@@ -968,6 +983,9 @@ int main(int n, char **v)
|
||||
int live = 0;
|
||||
memset(&d, 0, sizeof(ev_data));
|
||||
|
||||
/* write on a socket fails if the other end is closed and we get SIGPIPE */
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
|
||||
|
||||
for (i = 0; i < 65536; i++) {
|
||||
d.lte_rnti_to_ueid[i] = -1;
|
||||
d.nr_rnti_to_ueid[i] = -1;
|
||||
@@ -1014,8 +1032,10 @@ int main(int n, char **v)
|
||||
perror(input_filename);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
in = connect_to(live_ip, live_port);
|
||||
sock = in;
|
||||
}
|
||||
|
||||
database = parse_database(database_filename);
|
||||
load_config_file(database_filename);
|
||||
@@ -1121,10 +1141,15 @@ int main(int n, char **v)
|
||||
new_thread(receiver, &d);
|
||||
}
|
||||
|
||||
/* exit on ctrl+c and ctrl+z */
|
||||
if (signal(SIGQUIT, force_stop) == SIG_ERR) abort();
|
||||
if (signal(SIGINT, force_stop) == SIG_ERR) abort();
|
||||
if (signal(SIGTSTP, force_stop) == SIG_ERR) abort();
|
||||
|
||||
OBUF ebuf = {.osize = 0, .omaxsize = 0, .obuf = NULL};
|
||||
|
||||
/* read messages */
|
||||
while (1) {
|
||||
while (run) {
|
||||
event e;
|
||||
e = get_event(in, &ebuf, database);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user