Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rdma-mwe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
rdma-mwe
Commits
b67c4205
Commit
b67c4205
authored
Feb 12, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trx-bridge: write back to input before reading
parent
cda3078f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
trx-bridge/bridge.c
trx-bridge/bridge.c
+16
-15
No files found.
trx-bridge/bridge.c
View file @
b67c4205
...
...
@@ -310,6 +310,22 @@ int main(int argc, char *argv[]) {
// Read from output first to know how many samples should be read
output_read_count
=
output_trx_state
.
trx_read_func2
(
&
output_trx_state
,
&
output_rx_ts
,
(
void
**
)
output_channels
,
TRX_BUFFER_SIZE
,
0
,
&
read_md
);
// Expected behavior: TX (i.e. write) timestamp is set once based on RX (i.e. read)
// timestamp and incremented after every write.
// The buffer size in TRX SDR is four times the samples rate, so this
// value is used here as an offset between the two timestamps.
if
(
output_tx_ts
==
0
)
output_tx_ts
=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
output_tx_ts
+=
output_read_count
;
// Real behavior: sometimes, the TX timestamp deviates, so it should be matched again.
if
(
output_tx_ts
!=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
)
{
printf
(
"trx-bridge: output timestamp deviated %lu != %lu
\n
"
,
output_tx_ts
,
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
);
output_tx_ts
=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
}
// Write back samples read from output
if
(
output_read_count
>
0
)
input_trx_state
.
trx_write_func2
(
&
input_trx_state
,
input_tx_ts
,
(
const
void
**
)
output_channels
,
output_read_count
,
0
,
&
write_md
);
// As much samples should be read from input than from output.
// However, sometimes, the input driver won't return enough samples,
// so we need to loop for samples.
...
...
@@ -326,25 +342,10 @@ int main(int argc, char *argv[]) {
input_read_count
+=
input_read_count_extra
;
}
// Expected behavior: TX (i.e. write) timestamp is set once based on RX (i.e. read)
// timestamp and incremented after every write.
// The buffer size in TRX SDR is four times the samples rate, so this
// value is used here as tn offset between the two timestamps.
if
(
output_tx_ts
==
0
)
output_tx_ts
=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
if
(
input_tx_ts
==
0
)
input_tx_ts
=
input_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
output_tx_ts
+=
output_read_count
;
input_tx_ts
+=
input_read_count
;
// Write back samples read from input and output
if
(
input_read_count
>
0
)
output_trx_state
.
trx_write_func2
(
&
output_trx_state
,
output_tx_ts
,
(
const
void
**
)
input_channels
,
input_read_count
,
0
,
&
write_md
);
if
(
output_read_count
>
0
)
input_trx_state
.
trx_write_func2
(
&
input_trx_state
,
input_tx_ts
,
(
const
void
**
)
output_channels
,
output_read_count
,
0
,
&
write_md
);
// Real behavior: sometimes, the TX timestamp deviates, so it should be matched again.
if
(
output_tx_ts
!=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
)
{
printf
(
"trx-bridge: output timestamp deviated %lu != %lu
\n
"
,
output_tx_ts
,
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
);
output_tx_ts
=
output_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
}
if
(
input_tx_ts
!=
input_rx_ts
+
4
*
SAMPLE_RATE_KHZ
)
{
printf
(
"trx-bridge: input timestamp deviated %lu != %lu
\n
"
,
input_tx_ts
,
input_rx_ts
+
4
*
SAMPLE_RATE_KHZ
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment