Add 'raw_prbs' handler to transmit a PRBS15 sequence
This commit is contained in:
parent
d375bee190
commit
7de4f058f3
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ clean:
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -o $@ -c $^
|
$(CC) $(CFLAGS) -o $@ -c $^
|
||||||
|
|
||||||
capi-test: capi.o capiconn.o bchan.o hdlr_raw_loop.o
|
capi-test: capi.o capiconn.o bchan.o hdlr_raw_loop.o hdlr_raw_prbs.o
|
||||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
1
capi.c
1
capi.c
|
@ -305,6 +305,7 @@ int main(int argc, char **argv)
|
||||||
osmo_init_logging2(ctx, &log_info);
|
osmo_init_logging2(ctx, &log_info);
|
||||||
capi_init(ctx);
|
capi_init(ctx);
|
||||||
|
|
||||||
|
bchan_route_add(-1, "142", "raw_prbs");
|
||||||
bchan_route_add(-1, NULL, "raw_loop");
|
bchan_route_add(-1, NULL, "raw_loop");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
|
||||||
|
#include <osmocom/core/utils.h>
|
||||||
|
#include <osmocom/core/prbs.h>
|
||||||
|
|
||||||
|
#include "bchan.h"
|
||||||
|
#include "errno.h"
|
||||||
|
|
||||||
|
struct raw_prbs_priv {
|
||||||
|
struct osmo_prbs_state prbs;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int raw_prbs_init(struct call_state *cst)
|
||||||
|
{
|
||||||
|
struct raw_prbs_priv *rpp;
|
||||||
|
rpp = cst->priv = talloc_zero(cst, struct raw_prbs_priv);
|
||||||
|
if (!rpp)
|
||||||
|
return -ENOMEM;
|
||||||
|
osmo_prbs_state_init(&rpp->prbs, &osmo_prbs15);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void raw_prbs_rx(struct call_state *cst, const uint8_t *data, uint8_t len)
|
||||||
|
{
|
||||||
|
struct raw_prbs_priv *rpp = cst->priv;
|
||||||
|
uint8_t tx_ubit[len*8];
|
||||||
|
uint8_t tx_pbit[len];
|
||||||
|
/* TODO: process what we received */
|
||||||
|
|
||||||
|
/* generate respective number of PRBS bits and transmit them */
|
||||||
|
osmo_prbs_get_ubits(tx_ubit, len, &rpp->prbs);
|
||||||
|
osmo_ubit2pbit(tx_pbit, tx_ubit, len*8);
|
||||||
|
bchan_call_tx(cst, tx_pbit, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void raw_prbs_fini(struct call_state *cst)
|
||||||
|
{
|
||||||
|
struct raw_prbs_priv *rpp = cst->priv;
|
||||||
|
talloc_free(rpp);
|
||||||
|
cst->priv = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct bchan_handler bch_raw_prbs = {
|
||||||
|
.name = "raw_prbs",
|
||||||
|
.cfg = {
|
||||||
|
.proto = { 1, 1, 0 },
|
||||||
|
.ncpi = NULL,
|
||||||
|
.max_b_data_blocks = 10,
|
||||||
|
.max_b_data_len = 32,
|
||||||
|
},
|
||||||
|
.ops = {
|
||||||
|
.init = raw_prbs_init,
|
||||||
|
.rx_data = raw_prbs_rx,
|
||||||
|
.fini = raw_prbs_fini,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void hdlr_raw_prbs_init(void)
|
||||||
|
{
|
||||||
|
bchan_handler_register(&bch_raw_prbs);
|
||||||
|
}
|
Loading…
Reference in New Issue