From d5b99eb1bdccc6373cad430bd69a2bfb67ea91e6 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 14 Jan 2024 15:01:38 +0100 Subject: Indicate change in received Sa bits Change-Id: I4ea2a11e221629a90ed227a0df33576c8607881b --- src/e1d.h | 2 ++ src/intf_line.c | 1 + src/mux_demux.c | 13 ++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/e1d.h b/src/e1d.h index 3188cfc..4b70c0f 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -148,6 +148,8 @@ struct e1_line { uint8_t prev_errmask; /*! timer to re-set the rx_crc4_err and rx_alarm above */ struct osmo_timer_list timer; + /*! last received frame with Sa bits */ + uint8_t rx_frame; } ts0; /* watchdog timer to catch situations where no more USB data is received */ diff --git a/src/intf_line.c b/src/intf_line.c index 4433e96..b3dafff 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -272,6 +272,7 @@ e1_line_new(struct e1_intf *intf, int line_id, void *drv_data) line->intf = intf; line->drv_data = drv_data; line->mode = E1_LINE_MODE_CHANNELIZED; + line->ts0.rx_frame = 0xff; for (int i = 0; i < 32; i++) _ts_init(&line->ts[i], line, i); diff --git a/src/mux_demux.c b/src/mux_demux.c index abe01a3..71374ef 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -378,8 +378,8 @@ _e1_line_demux_in_ts0(struct e1_line *line, const uint8_t *buf, int ftr, uint8_t const uint8_t *frame = buf + i*32; uint8_t frame_nr = (frame_base + i) & 0xf; - /* A bit is present in each odd frame */ if (frame_nr % 2) { + /* A bit is present in each odd frame */ if (frame[0] & 0x20) { if (!(line->ts0.cur_errmask & E1L_TS0_RX_ALARM)) { line->ts0.cur_errmask |= E1L_TS0_RX_ALARM; @@ -394,6 +394,17 @@ _e1_line_demux_in_ts0(struct e1_line *line, const uint8_t *buf, int ftr, uint8_t line->intf->id, line->id, 0, NULL, 0); } } + /* SA bits changed */ + if (line->ts0.rx_frame != (frame[0] | 0xe0)) { + uint8_t sa_bits = ((frame[0] & 0x01) << 7) | /* Sa8 -> Bit 7 */ + ((frame[0] & 0x02) << 5) | /* Sa7 -> Bit 6 */ + ((frame[0] & 0x04) >> 2) | /* Sa6 -> Bit 0 */ + ((frame[0] & 0x08) << 2) | /* Sa5 -> Bit 5 */ + (frame[0] & 0x10); /* Sa4 -> Bit 4 */ + line->ts0.rx_frame = frame[0] | 0xe0; + osmo_e1dp_server_event(line->intf->e1d->srv, E1DP_EVT_SABITS, + line->intf->id, line->id, 0, &sa_bits, 1); + } } /* E bits are present in frame 13 + 15 */ -- cgit v1.2.3