aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-05-11 21:20:05 +0200
committerHarald Welte <laforge@gnumonks.org>2018-05-11 22:00:46 +0200
commitce18a04b270819dca2a7cd524d6501ff847f7961 (patch)
treee0f0409eb78b0889dd74e07cf704fdbcb3b5bd6e
parent8a95fd5481afa321914b4c06bb953efd59256a9b (diff)
add e1_test_dieter to deframe/decode dieters capture
-rw-r--r--src/Makefile6
-rw-r--r--src/e1_test_dieter.c82
2 files changed, 87 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile
index 441696f..d4225c5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
LDFLAGS+=-losmocore -losmogsm
CFLAGS+=-Wall
-all: e1_test
+all: e1_test e1_test_dieter
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $^
@@ -9,5 +9,9 @@ all: e1_test
e1_test: osmo_e1.o crc4itu.o e1_test.o
$(CC) $(LDFLAGS) -o $@ $^
+e1_test_dieter: osmo_e1.o crc4itu.o e1_test_dieter.o
+ $(CC) $(LDFLAGS) -o $@ $^
+
+
clean:
@rm *.o e1_test
diff --git a/src/e1_test_dieter.c b/src/e1_test_dieter.c
new file mode 100644
index 0000000..6277556
--- /dev/null
+++ b/src/e1_test_dieter.c
@@ -0,0 +1,82 @@
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/application.h>
+#include <osmocom/gsm/gsm_utils.h>
+
+#include "osmo_e1.h"
+
+static struct osmo_e1_instance inst;
+static struct log_info log_info = {};
+
+static void data_cb(struct osmo_e1_instance_ts *e1t, struct msgb *msg)
+{
+ printf("Rx TS %02u: %s\n", e1t->ts_nr, msgb_hexdump(msg));
+ msgb_free(msg);
+}
+
+static void notify_cb(struct osmo_e1_instance *e1i, enum osmo_e1_notify_event evt,
+ bool present, void *data)
+{
+ fprintf(stdout, "NOTIFY: %s %s\n", osmo_e1_notify_event_name(evt), present ? "PRESENT" : "ABSENT");
+}
+
+static void read_file(const char *fname)
+{
+ int fd;
+
+ fd = open(fname, O_RDONLY);
+ if (fd < 0)
+ exit(23);
+ while (1) {
+ int rc;
+ uint8_t buf[32];
+
+ rc = read(fd, buf, sizeof(buf));
+ if (rc <= 0)
+ return;
+ if (rc < sizeof(buf))
+ exit(24);
+ //printf("FRAME: %s\n", osmo_hexdump(buf, sizeof(buf)));
+ osmo_e1_rx_frame(&inst, buf);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+
+ osmo_init_logging2(NULL, &log_info);
+ osmo_e1_init();
+
+ osmo_e1_instance_init(&inst, "e1_test", &notify_cb, true, NULL);
+ for (i = 1; i < 32; i++) {
+ struct osmo_e1_instance_ts *e1t = osmo_e1_instance_ts(&inst, i);
+ enum osmo_e1_ts_mode mode;
+ bool enable;
+ switch (i) {
+ case 2:
+ mode = OSMO_E1_TS_HDLC_CRC;
+ enable = true;
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ default:
+ mode = OSMO_E1_TS_RAW;
+ enable = false;
+ break;
+ }
+ osmo_e1_ts_config(e1t, &data_cb, 64, enable, mode);
+ }
+
+ read_file("Insite_to_Racal_E1.bin");
+}