This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Jan Hrach gerrit-no-reply at lists.osmocom.orgJan Hrach has uploaded this change for review. ( https://gerrit.osmocom.org/10264
Change subject: add traffic dumping patch, use getopt to parse arguments
......................................................................
add traffic dumping patch, use getopt to parse arguments
Enable the user to specify a directory, where contents of traffic channel will
be saved. Together with this dump, a text file with SSIs of the engaged
stations is saved too.
Based on 0004-HACK-Quick-hack-to-save-the-speech-data-from-TCH.patch available at
https://build.opensuse.org/package/view_file/home:mnhauke:sdr/osmo-tetra/0004-HACK-Quick-hack-to-save-the-speech-data-from-TCH.patch
Change-Id: I94135753a76cadfa373167ffca18e89bee5bcff8
---
M src/lower_mac/tetra_lower_mac.c
M src/tetra-rx.c
M src/tetra_common.h
M src/tetra_gsmtap.c
M src/tetra_gsmtap.h
M src/tetra_upper_mac.c
6 files changed, 84 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-tetra refs/changes/64/10264/1
diff --git a/src/lower_mac/tetra_lower_mac.c b/src/lower_mac/tetra_lower_mac.c
index 7b62bb4..81832bc 100644
--- a/src/lower_mac/tetra_lower_mac.c
+++ b/src/lower_mac/tetra_lower_mac.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <linux/limits.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
@@ -184,6 +185,48 @@
DEBUGP("%s %s type4: %s\n", tbp->name, time_str,
osmo_ubit_dump(type4, tbp->type345_bits));
+ /* If this is a traffic channel, dump. */
+ if ((type == TPSAP_T_SCH_F) && tms->cur_burst.is_traffic && tms->dumpdir) {
+ char fname[PATH_MAX];
+ int16_t block[690];
+ FILE *f;
+ int i;
+
+ /* Open target file */
+ snprintf(fname, sizeof(fname), "%s/traffic_%d_%d.out", tms->dumpdir,
+ tms->cur_burst.is_traffic, tms->tsn);
+ f = fopen(fname, "ab");
+
+ /* Generate a block */
+ memset(block, 0x00, sizeof(int16_t) * 690);
+ for (i = 0; i < 6; i++)
+ block[115*i] = 0x6b21 + i;
+
+ for (i = 0; i < 114; i++)
+ block[1+i] = type4[i] ? -127 : 127;
+
+ for (i = 0; i < 114; i++)
+ block[116+i] = type4[114+i] ? -127 : 127;
+
+ for (i = 0; i < 114; i++)
+ block[231+i] = type4[228+i] ? -127 : 127;
+
+ for (i = 0; i < 90; i++)
+ block[346+i] = type4[342+i] ? -127 : 127;
+
+ /* Write it */
+ fwrite(block, sizeof(int16_t), 690, f);
+
+ fclose(f);
+
+ /* Write used ssi */
+ snprintf(fname, sizeof(fname), "%s/traffic_%d_%d.txt", tms->dumpdir,
+ tms->cur_burst.is_traffic, tms->tsn);
+ f = fopen(fname, "a");
+ fprintf(f, "%d\n", tms->ssi);
+ fclose(f);
+ }
+
if (tbp->interleave_a) {
/* Run block deinterleaving: type-3 bits */
block_deinterleave(tbp->type345_bits, tbp->interleave_a, type4, type3);
diff --git a/src/tetra-rx.c b/src/tetra-rx.c
index c751772..ed4d252 100644
--- a/src/tetra-rx.c
+++ b/src/tetra-rx.c
@@ -39,28 +39,39 @@
int main(int argc, char **argv)
{
int fd;
+ int opt;
struct tetra_rx_state *trs;
struct tetra_mac_state *tms;
- if (argc < 2) {
- fprintf(stderr, "Usage: %s <file_with_1_byte_per_bit>\n", argv[0]);
- exit(1);
- }
-
- fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
- perror("open");
- exit(2);
- }
-
- tetra_gsmtap_init("localhost", 0);
-
tms = talloc_zero(tetra_tall_ctx, struct tetra_mac_state);
tetra_mac_state_init(tms);
trs = talloc_zero(tetra_tall_ctx, struct tetra_rx_state);
trs->burst_cb_priv = tms;
+ while ((opt = getopt(argc, argv, "d:")) != -1) {
+ switch (opt) {
+ case 'd':
+ tms->dumpdir = strdup(optarg);
+ break;
+ default:
+ fprintf(stderr, "Unknown option %c\n", opt);
+ }
+ }
+
+ if (argc <= optind) {
+ fprintf(stderr, "Usage: %s [-d DUMPDIR] <file_with_1_byte_per_bit>\n", argv[0]);
+ exit(1);
+ }
+
+ fd = open(argv[optind], O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(2);
+ }
+
+ tetra_gsmtap_init("localhost", 0);
+
while (1) {
uint8_t buf[64];
int len;
@@ -76,6 +87,7 @@
tetra_burst_sync_in(trs, buf, len);
}
+ free(tms->dumpdir);
talloc_free(trs);
talloc_free(tms);
diff --git a/src/tetra_common.h b/src/tetra_common.h
index 3207c0d..d141e9b 100644
--- a/src/tetra_common.h
+++ b/src/tetra_common.h
@@ -47,7 +47,11 @@
struct {
int is_traffic;
} cur_burst;
- struct tetra_si_decoded last_sid;
+ struct tetra_si_decoded last_sid;
+
+ char *dumpdir; /* Where to save traffic channel dump */
+ int ssi; /* SSI */
+ int tsn; /* Timeslon number */
};
void tetra_mac_state_init(struct tetra_mac_state *tms);
diff --git a/src/tetra_gsmtap.c b/src/tetra_gsmtap.c
index f575c20..79b48a7 100644
--- a/src/tetra_gsmtap.c
+++ b/src/tetra_gsmtap.c
@@ -28,9 +28,9 @@
};
-struct msgb *tetra_gsmtap_makemsg(struct tetra_tdma_time *tm, enum tetra_log_chan lchan,
- uint8_t ts, uint8_t ss, int8_t signal_dbm,
- uint8_t snr, const ubit_t *bitdata, unsigned int bitlen)
+struct msgb *tetra_gsmtap_makemsg(struct tetra_tdma_time *tm, enum tetra_log_chan lchan, uint8_t ts, uint8_t ss,
+ int8_t signal_dbm, uint8_t snr, const ubit_t *bitdata, unsigned int bitlen,
+ struct tetra_mac_state *tms)
{
struct msgb *msg;
struct gsmtap_hdr *gh;
@@ -47,6 +47,7 @@
gh->hdr_len = sizeof(*gh)/4;
gh->type = GSMTAP_TYPE_TETRA_I1;
gh->timeslot = ts;
+ tms->tsn = ts;
gh->sub_slot = ss;
gh->snr_db = snr;
gh->signal_dbm = signal_dbm;
diff --git a/src/tetra_gsmtap.h b/src/tetra_gsmtap.h
index b62a4c5..34963d0 100644
--- a/src/tetra_gsmtap.h
+++ b/src/tetra_gsmtap.h
@@ -2,9 +2,9 @@
#define TETRA_GSMTAP_H
#include "tetra_common.h"
-struct msgb *tetra_gsmtap_makemsg(struct tetra_tdma_time *tm, enum tetra_log_chan lchan,
- uint8_t ts, uint8_t ss, int8_t signal_dbm,
- uint8_t snr, const uint8_t *data, unsigned int len);
+struct msgb *tetra_gsmtap_makemsg(struct tetra_tdma_time *tm, enum tetra_log_chan lchan, uint8_t ts, uint8_t ss,
+ int8_t signal_dbm, uint8_t snr, const uint8_t *bitdata, unsigned int bitlen,
+ struct tetra_mac_state *tms);
int tetra_gsmtap_sendmsg(struct msgb *msg);
diff --git a/src/tetra_upper_mac.c b/src/tetra_upper_mac.c
index fdc8c73..a4c7e59 100644
--- a/src/tetra_upper_mac.c
+++ b/src/tetra_upper_mac.c
@@ -181,6 +181,8 @@
rx_tm_sdu(tms, msg, len_bits);
}
+ tms->ssi = rsd.addr.ssi;
+
out:
printf("\n");
}
@@ -241,7 +243,7 @@
/* save the state whether the current burst is traffic or not */
if (aad.dl_usage > 3)
- tms->cur_burst.is_traffic = 1;
+ tms->cur_burst.is_traffic = aad.dl_usage;
else
tms->cur_burst.is_traffic = 0;
@@ -276,7 +278,7 @@
gsmtap_msg = tetra_gsmtap_makemsg(&tup->tdma_time, tup->lchan,
tup->tdma_time.tn,
/* FIXME: */ 0, 0, 0,
- msg->l1h, msgb_l1len(msg));
+ msg->l1h, msgb_l1len(msg), tms);
if (gsmtap_msg)
tetra_gsmtap_sendmsg(gsmtap_msg);
--
To view, visit https://gerrit.osmocom.org/10264
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-tetra
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94135753a76cadfa373167ffca18e89bee5bcff8
Gerrit-Change-Number: 10264
Gerrit-PatchSet: 1
Gerrit-Owner: Jan Hrach <jenda.2vf9h at hrach.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180730/c1d6c32f/attachment.htm>