tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26817 )
Change subject: mux_demux: In RAW mode, fill with dummy until first TX ......................................................................
mux_demux: In RAW mode, fill with dummy until first TX
Until the remote side sends the first byte, we send fill data since it can take it some time after the mode change and the file descriptor is open for data to show up.
Previously due to a bug, the warning about short read was not printed, but now that it's fixed, you get a bunch of fairly "useless" warning at the beginning of the timeslot.
This fixes that since reported data by _e1_tx_raw is "faked" until the pipe is active. (Fill data is actually added upstream)
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: Iaa6268e9b4a7bce5ea3027a29c48c147499373be --- M src/e1d.h M src/mux_demux.c 2 files changed, 20 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/17/26817/1
diff --git a/src/e1d.h b/src/e1d.h index 618776d..a0c8ceb 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -79,6 +79,7 @@ uint8_t *rx_buf; /* actual buffer storage */ unsigned int rx_buf_size; /* size of 'buf' in bytes */ unsigned int rx_buf_used; /* number of bytes used so far */ + bool tx_started; /* tx started */ } raw;
/* Remote end */ diff --git a/src/mux_demux.c b/src/mux_demux.c index 6d854dd..3919580 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -45,6 +45,24 @@ // ---------------------------------------------------------------------------
static int +_e1_tx_raw(struct e1_ts *ts, uint8_t *buf, int len) +{ + int l; + + l = read(ts->fd, buf, len); + /* FIXME: handle underflow */ + + /* If we're not started yet, we 'fake' data until the other side + * send something */ + if (l < 0 && errno == EAGAIN && !ts->raw.tx_started) + return len; + + ts->raw.tx_started = true; + + return l; +} + +static int _e1_tx_hdlcfs(struct e1_ts *ts, uint8_t *buf, int len) { int rv, oo, cl; @@ -105,8 +123,7 @@
switch (ts->mode) { case E1_TS_MODE_RAW: - l = read(ts->fd, buf, len); - /* FIXME: handle underflow */ + l = _e1_tx_raw(ts, buf, len); break; case E1_TS_MODE_HDLCFCS: l = _e1_tx_hdlcfs(ts, buf, len);
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26817 )
Change subject: mux_demux: In RAW mode, fill with dummy until first TX ......................................................................
Patch Set 2: Code-Review+2
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26817 )
Change subject: mux_demux: In RAW mode, fill with dummy until first TX ......................................................................
mux_demux: In RAW mode, fill with dummy until first TX
Until the remote side sends the first byte, we send fill data since it can take it some time after the mode change and the file descriptor is open for data to show up.
Previously due to a bug, the warning about short read was not printed, but now that it's fixed, you get a bunch of fairly "useless" warning at the beginning of the timeslot.
This fixes that since reported data by _e1_tx_raw is "faked" until the pipe is active. (Fill data is actually added upstream)
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: Iaa6268e9b4a7bce5ea3027a29c48c147499373be --- M src/e1d.h M src/mux_demux.c 2 files changed, 20 insertions(+), 2 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/src/e1d.h b/src/e1d.h index 618776d..a0c8ceb 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -79,6 +79,7 @@ uint8_t *rx_buf; /* actual buffer storage */ unsigned int rx_buf_size; /* size of 'buf' in bytes */ unsigned int rx_buf_used; /* number of bytes used so far */ + bool tx_started; /* tx started */ } raw;
/* Remote end */ diff --git a/src/mux_demux.c b/src/mux_demux.c index 7513d1e..2971c87 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -45,6 +45,24 @@ // ---------------------------------------------------------------------------
static int +_e1_tx_raw(struct e1_ts *ts, uint8_t *buf, int len) +{ + int l; + + l = read(ts->fd, buf, len); + /* FIXME: handle underflow */ + + /* If we're not started yet, we 'fake' data until the other side + * send something */ + if (l < 0 && errno == EAGAIN && !ts->raw.tx_started) + return len; + + ts->raw.tx_started = true; + + return l; +} + +static int _e1_tx_hdlcfs(struct e1_ts *ts, uint8_t *buf, int len) { int rv, oo, cl; @@ -105,8 +123,7 @@
switch (ts->mode) { case E1_TS_MODE_RAW: - l = read(ts->fd, buf, len); - /* FIXME: handle underflow */ + l = _e1_tx_raw(ts, buf, len); break; case E1_TS_MODE_HDLCFCS: l = _e1_tx_hdlcfs(ts, buf, len);