Commit bdfdf896 authored by Joanne Hugé's avatar Joanne Hugé

WIP

parent aa579a91
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
#include "private/trx_driver.h" #include "private/trx_driver.h"
#include "utils.c" #include "utils.c"
#define EFREQ 38400 #define EFREQ 10
//#define DEBUG // Enables / deactivates log_debug //#define DEBUG // Enables / deactivates log_debug
//#define TRACE 0 #define TRACE 0
//#define TRACE_TX //#define TRACE_TX
//#define TRACE_RX #define TRACE_RX
//#define MONITOR //#define MONITOR
//#define MONITOR_EXIT //#define MONITOR_EXIT
...@@ -76,8 +76,10 @@ ...@@ -76,8 +76,10 @@
#define N_SAMPLES (32) #define N_SAMPLES (32)
#define TRX_MAX_GROUP 1500 #define TRX_MAX_GROUP 1500
#define TRX_BUF_MAX_SIZE 500000 //#define TRX_BUF_MAX_SIZE 500000
#define TXRX_BUF_MAX_SIZE 500000 //#define TXRX_BUF_MAX_SIZE 500000
#define TRX_BUF_MAX_SIZE 4000
#define TXRX_BUF_MAX_SIZE 4000
#define STATISTIC_REFRESH_RATE INT64_C(500 * 1000 * 1000) #define STATISTIC_REFRESH_RATE INT64_C(500 * 1000 * 1000)
#define STAT_INT_LEN "9" #define STAT_INT_LEN "9"
...@@ -164,10 +166,6 @@ static volatile int rx_trace_ready = 0; ...@@ -164,10 +166,6 @@ static volatile int rx_trace_ready = 0;
static volatile int tx_trace_ready = 1; static volatile int tx_trace_ready = 1;
static int64_t encode_counter_prev = 0; static int64_t encode_counter_prev = 0;
static int64_t decode_counter_prev = 0; static int64_t decode_counter_prev = 0;
static volatile int rx_exited = 0;
static volatile int trxr_exited = 0;
static volatile int trxw_exited = 0;
static volatile int tx_exited = 0;
#endif #endif
// Network // Network
...@@ -410,15 +408,14 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) { ...@@ -410,15 +408,14 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) {
log_info("TRACE", "Duration: %" PRIi64, d); log_info("TRACE", "Duration: %" PRIi64, d);
log_info("TRACE", "FRAME_FREQ: %" PRIi64, FRAME_FREQ); log_info("TRACE", "FRAME_FREQ: %" PRIi64, FRAME_FREQ);
usleep(1000 * 200);
#ifdef TRACE_TX #ifdef TRACE_TX
while (!tx_exited || !trxw_exited) {
usleep(1000);
}
memset(n, '\0', 256); memset(n, '\0', 256);
sprintf(n, "%s/tx.trace", s->log_directory); sprintf(n, "%s/tx.trace", s->log_directory);
f = fopen(n, "wb+"); f = fopen(n, "wb+");
start = (TRACE + encode_counter_prev) % tx_rbuf.buf_len; start = (TRACE + encode_counter_prev) % tx_rbuf.buf_len;
log_info("TRACE", "Writing %d frames to tx.trace", tx_rbuf.write_index + tx_rbuf.buf_len - start); log_info("TRACE", "Writing %d frames to tx.trace", (tx_rbuf.write_index + tx_rbuf.buf_len - start) % tx_rbuf.buf_len);
for(int i = start; i != tx_rbuf.write_index; i = (i + 1) % tx_rbuf.buf_len) { for(int i = start; i != tx_rbuf.write_index; i = (i + 1) % tx_rbuf.buf_len) {
fwrite(ones, 14, 1, f); fwrite(ones, 14, 1, f);
fwrite(((uint8_t*) tx_rbuf.buffer) + i * tx_rbuf.len, tx_rbuf.len, 1, f); fwrite(((uint8_t*) tx_rbuf.buffer) + i * tx_rbuf.len, tx_rbuf.len, 1, f);
...@@ -429,7 +426,7 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) { ...@@ -429,7 +426,7 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) {
sprintf(n, "%s/trxw.trace", s->log_directory); sprintf(n, "%s/trxw.trace", s->log_directory);
f = fopen(n, "wb+"); f = fopen(n, "wb+");
start = (TRACE) % trxw_rbuf[0].buf_len; start = (TRACE) % trxw_rbuf[0].buf_len;
log_info("TRACE", "Writing %d frames to trxw.trace", trxw_rbuf[0].write_index + trxw_rbuf[0].buf_len - start); log_info("TRACE", "Writing %d frames to trxw.trace", (trxw_rbuf[0].write_index + trxw_rbuf[0].buf_len - start) % trxw_rbuf[0].buf_len);
for(int i = start; i != trxw_rbuf[0].write_index; i = (i + 1) % trxw_rbuf[0].buf_len) { for(int i = start; i != trxw_rbuf[0].write_index; i = (i + 1) % trxw_rbuf[0].buf_len) {
for(int j = 0; j < TX_N_CHANNEL; j++) for(int j = 0; j < TX_N_CHANNEL; j++)
fwrite((uint8_t *) (((Complex *) trxw_rbuf[j].buffer) + i * trxw_rbuf[0].len), trxw_rbuf[0].len * sizeof(Complex), 1, f); fwrite((uint8_t *) (((Complex *) trxw_rbuf[j].buffer) + i * trxw_rbuf[0].len), trxw_rbuf[0].len * sizeof(Complex), 1, f);
...@@ -438,14 +435,11 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) { ...@@ -438,14 +435,11 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) {
#endif #endif
#ifdef TRACE_RX #ifdef TRACE_RX
while (!rx_exited || !trxr_exited) {
usleep(1000);
}
memset(n, '\0', 256); memset(n, '\0', 256);
sprintf(n, "%s/rx.trace", s->log_directory); sprintf(n, "%s/rx.trace", s->log_directory);
f = fopen(n, "wb+"); f = fopen(n, "wb+");
start = TRACE % rx_rbuf.buf_len; start = TRACE % rx_rbuf.buf_len;
log_info("TRACE", "Writing %d frames to rx.trace", rx_rbuf.write_index + rx_rbuf.buf_len - start); log_info("TRACE", "Writing %d frames to rx.trace", (rx_rbuf.write_index + rx_rbuf.buf_len - start) % rx_rbuf.buf_len);
for(int i = start; i != rx_rbuf.write_index; i = (i + 1) % rx_rbuf.buf_len) { for(int i = start; i != rx_rbuf.write_index; i = (i + 1) % rx_rbuf.buf_len) {
fwrite(((uint8_t*) rx_rbuf.buffer) + i * rx_rbuf.len, rx_rbuf.len, 1, f); fwrite(((uint8_t*) rx_rbuf.buffer) + i * rx_rbuf.len, rx_rbuf.len, 1, f);
} }
...@@ -455,7 +449,7 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) { ...@@ -455,7 +449,7 @@ static void trace_handler(struct timespec initial, TRXEcpriState * s) {
sprintf(n, "%s/trxr.trace", s->log_directory); sprintf(n, "%s/trxr.trace", s->log_directory);
f = fopen(n, "wb+"); f = fopen(n, "wb+");
start = (TRACE + decode_counter_prev) % trxr_rbuf[0].buf_len; start = (TRACE + decode_counter_prev) % trxr_rbuf[0].buf_len;
log_info("TRACE", "Writing %d frames to trxr.trace", trxr_rbuf[0].write_index + trxr_rbuf[0].buf_len - start); log_info("TRACE", "Writing %d frames to trxr.trace", (trxr_rbuf[0].write_index + trxr_rbuf[0].buf_len - start) % trxr_rbuf[0].buf_len);
for(int i = start; i != trxr_rbuf[0].write_index; i = (i + 1) % trxr_rbuf[0].buf_len) { for(int i = start; i != trxr_rbuf[0].write_index; i = (i + 1) % trxr_rbuf[0].buf_len) {
for(int j = 0; j < RX_N_CHANNEL; j++) for(int j = 0; j < RX_N_CHANNEL; j++)
fwrite((uint8_t *) (((Complex *) trxr_rbuf[j].buffer) + i * trxr_rbuf[0].len), trxr_rbuf[0].len * sizeof(Complex), 1, f); fwrite((uint8_t *) (((Complex *) trxr_rbuf[j].buffer) + i * trxr_rbuf[0].len), trxr_rbuf[0].len * sizeof(Complex), 1, f);
...@@ -553,10 +547,8 @@ static void *recv_thread(void *p) { ...@@ -553,10 +547,8 @@ static void *recv_thread(void *p) {
if((recv_counter.counter + nc) >= (rx_rbuf.buf_len + TRACE)) { if((recv_counter.counter + nc) >= (rx_rbuf.buf_len + TRACE)) {
rx_trace_ready = 1; rx_trace_ready = 1;
log_info("RECV_THREAD", "RX Trace ready"); log_info("RECV_THREAD", "RX Trace ready");
rx_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} else if (rx_trace_ready) { } else if (rx_trace_ready) {
rx_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} }
#endif #endif
...@@ -708,10 +700,8 @@ static void *encode_thread(void *p) { ...@@ -708,10 +700,8 @@ static void *encode_thread(void *p) {
if(sync_complete && (encode_counter.counter + nb_frames) >= (tx_rbuf.buf_len + TRACE)) { if(sync_complete && (encode_counter.counter + nb_frames) >= (tx_rbuf.buf_len + TRACE)) {
tx_trace_ready = 1; tx_trace_ready = 1;
log_info("ENCODE_THREAD", "TX Trace ready"); log_info("ENCODE_THREAD", "TX Trace ready");
tx_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} else if (tx_trace_ready) { } else if (tx_trace_ready) {
tx_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} }
#endif #endif
...@@ -813,10 +803,8 @@ static void *decode_thread(void *p) { ...@@ -813,10 +803,8 @@ static void *decode_thread(void *p) {
if(received_pkts && ((decode_counter.counter + nc) >= (trxr_rbuf[0].buf_len + TRACE))) { if(received_pkts && ((decode_counter.counter + nc) >= (trxr_rbuf[0].buf_len + TRACE))) {
rx_trace_ready = 1; rx_trace_ready = 1;
log_info("DECODE_THREAD", "RX Trace ready"); log_info("DECODE_THREAD", "RX Trace ready");
trxr_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} else if (rx_trace_ready) { } else if (rx_trace_ready) {
trxr_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} }
#endif #endif
...@@ -1164,10 +1152,8 @@ static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void ...@@ -1164,10 +1152,8 @@ static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void
if((write_counter.counter + write_count) >= (trxw_rbuf[0].buf_len + TRACE)) { if((write_counter.counter + write_count) >= (trxw_rbuf[0].buf_len + TRACE)) {
tx_trace_ready = 1; tx_trace_ready = 1;
log_info("TRX_ECPRI_WRITE", "TX Trace ready"); log_info("TRX_ECPRI_WRITE", "TX Trace ready");
trxw_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} else if (tx_trace_ready) { } else if (tx_trace_ready) {
trxw_exited = 1;
pthread_exit(EXIT_SUCCESS); pthread_exit(EXIT_SUCCESS);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment