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
13856694
Commit
13856694
authored
Feb 06, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trx-bridge: timestamp improvements
parent
b5706454
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
trx-bridge/bridge.c
trx-bridge/bridge.c
+17
-16
No files found.
trx-bridge/bridge.c
View file @
13856694
...
...
@@ -2,6 +2,7 @@
// Size of TRX buffer in IQ samples (complex)
#define TRX_BUFFER_SIZE 4096
#define SAMPLE_RATE_KHZ 30720
char
*
bridge_trx_input_get_param_string
(
void
*
app_opaque
,
const
char
*
prop_name
)
{
return
potoml_toml_get_string
((
struct
PotomlTomlSubset
*
)
app_opaque
,
prop_name
);
...
...
@@ -300,7 +301,6 @@ int main(int argc, char *argv[]) {
while
(
1
)
{
// Read from output first to know how many samples should be read
output_rx_ts
=
0
;
output_read_count
=
output_trx_state
.
trx_read_func2
(
&
output_trx_state
,
&
output_rx_ts
,
(
void
**
)
output_channels
,
TRX_BUFFER_SIZE
,
0
,
&
read_md
);
// As much samples should be read from input than from output.
...
...
@@ -314,7 +314,7 @@ int main(int argc, char *argv[]) {
input_read_count_extra
=
input_trx_state
.
trx_read_func2
(
&
input_trx_state
,
&
input_rx_ts
,
(
void
**
)
input_channels
,
output_read_count
-
input_read_count
,
0
,
&
read_md
);
// If no samples can be read, escape from infinite loop
// This return to operations, but
will
discard some frames
// This return to operations, but
might
discard some frames
if
(
input_read_count_extra
==
0
)
break
;
input_read_count
+=
input_read_count_extra
;
}
...
...
@@ -323,25 +323,26 @@ int main(int argc, char *argv[]) {
// 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
*
23040
;
if
(
input_tx_ts
==
0
)
input_tx_ts
=
input_rx_ts
+
4
*
23040
;
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
*
23040
)
{
printf
(
"
Output timestamp don't match %lu != %lu
\n
"
,
output_tx_ts
,
output_rx_ts
+
4
*
23040
);
output_tx_ts
=
output_rx_ts
+
4
*
23040
;
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
*
23040
)
{
printf
(
"
Input timestamp don't match %lu != %lu
\n
"
,
input_tx_ts
,
input_rx_ts
+
4
*
23040
);
input_tx_ts
=
input_rx_ts
+
4
*
23040
;
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
);
input_tx_ts
=
input_rx_ts
+
4
*
SAMPLE_RATE_KHZ
;
}
output_trx_state
.
trx_write_func2
(
&
output_trx_state
,
output_tx_ts
,
(
const
void
**
)
input_channels_base
,
input_read_count
,
0
,
&
write_md
);
output_tx_ts
+=
input_read_count
;
input_trx_state
.
trx_write_func2
(
&
input_trx_state
,
input_tx_ts
,
(
const
void
**
)
output_channels
,
output_read_count
,
0
,
&
write_md
);
input_tx_ts
+=
output_read_count
;
}
dlclose
(
input_lib_handle
);
...
...
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