Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
trx_test
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
FANG WANG
trx_test
Commits
c6a662d4
Commit
c6a662d4
authored
Jan 06, 2025
by
Luhan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add trx data
parent
ab5d537f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
18 deletions
+86
-18
oxgrf_lib.c
oxgrf_lib.c
+3
-0
trx_test.c
trx_test.c
+83
-18
No files found.
oxgrf_lib.c
View file @
c6a662d4
...
...
@@ -387,6 +387,9 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
printf
(
"[oxgrf] openair0_cfg->sample_rate == '%f'
\n
"
,
openair0_cfg
->
sample_rate
);
oxgrf
->
sample_rate
=
(
unsigned
int
)
openair0_cfg
->
sample_rate
;
oxgrf
->
sample_rate
=
30720000
;
// set_rx_gain_offset(openair0_cfg, 0);
// if(oxgrf->rx_num_channels > 1)
// set_rx_gain_offset(openair0_cfg, 1);
// return 0;
// init required params
switch
((
int
)
openair0_cfg
->
sample_rate
)
{
...
...
trx_test.c
View file @
c6a662d4
...
...
@@ -6,20 +6,27 @@
#include "system.h"
#include <semaphore.h>
#include <pthread.h>
#include <math.h>
#include <time.h>
/** For SLEEP **/
#include <getopt.h>
#include <stdio.h>
#define NB_ANTENNAS_RX
4
#define NB_ANTENNAS_RX
1
#define NB_ANTENNAS_TX 1
#define SAMPLE_RATE (122880000)
#define FRAME_SAMPLE_NUM 1228800
//#define TX_RX_ONE_THREAD
int
txdata_size
=
61440
*
4
;
int
rxdata_size
=
61440
*
4
;
#define SLOTS_NUM 10
int
txdata_size
=
61440
*
SLOTS_NUM
;
int
rxdata_size
=
61440
*
SLOTS_NUM
;
int
absolute_slot
=
0
;
int
nb_slot_frame
=
2
;
int
samples_per_subframe
=
SAMPLE_RATE
/
1000
;
#define TXSEQLEN 256
int32_t
gTxSeq
[
61440
]
=
{
0
};
//samples_per_subframe 30720, samples_per_slot_wCP 14336.
//txdata_size 57344, txdataF_size 57344, rxdata_size 2465792.
...
...
@@ -48,6 +55,8 @@ struct timespec nr_get_timespec_diff(
openair0_timestamp
rx_timestamp
,
writeTimestamp
;
int32_t
*
rxp
[
NB_ANTENNAS_RX
];
int32_t
*
txp
[
NB_ANTENNAS_TX
];
int32_t
*
rxp_temp
[
NB_ANTENNAS_RX
];
int32_t
*
txp_temp
[
NB_ANTENNAS_RX
];
int
readBlockSize
,
writeBlockSize
;
int
tx_cnt
=
0
;
int
rx_cnt
=
0
;
...
...
@@ -60,6 +69,9 @@ static void *tx_thread(void *param)
double
clock_gettime_cur
;
struct
timespec
time_start
;
struct
timespec
time_stop
;
int
slot_adv
=
2
;
int
mimdelay
=
4096
*
1
+
2048
;
while
(
1
)
{
...
...
@@ -67,17 +79,30 @@ static void *tx_thread(void *param)
//printf("00000000 tx cnt %d rx cnt %d\n", tx_cnt, rx_cnt);
// use previous timing_advance value to compute writeTimestamp
//writeTimestamp = timestamp+samples_per_subframe/20*5;// sent after 5 slot.
writeTimestamp
=
rx_timestamp
+
samples_per_subframe
/
4
;
// sent after 5 slot.
writeTimestamp
=
rx_timestamp
+
61440
+
mimdelay
;
// sent after 5 slot.
// but use current UE->timing_advance value to compute writeBlockSize
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE
,
VCD_FUNCTION_IN
);
clock_gettime
(
CLOCK_REALTIME
,
&
time_start
);
#if 1
if
((
tx_cnt
+
slot_adv
)
%
SLOTS_NUM
==
5
)
{
for
(
int
i
=
0
;
i
<
NB_ANTENNAS_TX
;
i
++
)
{
memcpy
(
txp
[
i
]
,
gTxSeq
,
TXSEQLEN
*
4
);
}
}
for
(
int
i
=
0
;
i
<
NB_ANTENNAS_RX
;
i
++
)
{
txp_temp
[
i
]
=
(
int32_t
*
)
txp
[
i
]
+
((
tx_cnt
+
slot_adv
)
%
SLOTS_NUM
)
*
61440
;
}
rfdevice
->
trx_write_func
(
rfdevice
,
writeTimestamp
,
(
void
**
)
tx
p
,
writeBlockSize
,
(
void
**
)
txp_tem
p
,
writeBlockSize
,
1
,
1
);
#endif
...
...
@@ -86,14 +111,28 @@ static void *tx_thread(void *param)
tx_cnt
++
;
//printf("11111111 tx cnt %d rx cnt %d\n", tx_cnt, rx_cnt);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE
,
VCD_FUNCTION_OUT
);
}
return
NULL
;
}
int
genSineWave
(
double
freq
,
double
sampleRate
,
int
amp
,
int
len
,
void
*
buf
)
{
double
dF
=
2
*
3
.
1415926535898
*
(
freq
)
/
(
sampleRate
);
int
i
;
int16_t
*
p16
=
buf
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
p16
[
i
*
2
]
=
cos
(
dF
*
i
)
*
amp
;
p16
[
i
*
2
+
1
]
=
sin
(
dF
*
i
)
*
amp
;
}
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -112,7 +151,7 @@ int main( int argc, char **argv ) {
sched_setscheduler
(
getpid
(),
SCHED_RR
,
&
rr_param
);
cpu_set_t
mask
;
CPU_ZERO
(
&
mask
);
CPU_SET
(
20
,
&
mask
);
CPU_SET
(
3
,
&
mask
);
int
rc
=
sched_setaffinity
(
getpid
(),
sizeof
(
mask
),
&
mask
);
assert
(
rc
>=
0
);
...
...
@@ -133,6 +172,8 @@ int main( int argc, char **argv ) {
openair0_cfg
[
card
].
time_source
=
0
;
openair0_cfg
[
card
].
tx_num_channels
=
NB_ANTENNAS_TX
;
openair0_cfg
[
card
].
rx_num_channels
=
NB_ANTENNAS_RX
;
openair0_cfg
[
card
].
rx_gain
[
0
]
=
80
;
openair0_cfg
[
card
].
tx_gain
[
0
]
=
90
;
printf
(
"HW: Configuring card %d, sample_rate %f, tx/rx num_channels %d/%d, duplex_mode %d
\n
"
,
card
,
...
...
@@ -192,20 +233,26 @@ int main( int argc, char **argv ) {
for
(
int
i
=
0
;
i
<
NB_ANTENNAS_RX
;
i
++
)
{
rxp
[
i
]
=
(
int32_t
*
)
malloc16_clear
(
rxdata_size
);
rxp
[
i
]
=
(
int32_t
*
)
malloc16_clear
(
rxdata_size
*
sizeof
(
int32_t
)
);
}
for
(
int
i
=
0
;
i
<
NB_ANTENNAS_TX
;
i
++
)
{
txp
[
i
]
=
(
int32_t
*
)
malloc16_clear
(
txdata_size
);
txp
[
i
]
=
(
int32_t
*
)
malloc16_clear
(
txdata_size
*
sizeof
(
int32_t
));
txp_temp
[
i
]
=
(
int32_t
*
)
malloc16_clear
(
61440
*
sizeof
(
int32_t
));
}
printf
(
"sine wave
\n
"
);
genSineWave
(
3.84e6
,
122.88e6
,
0x1ff
,
TXSEQLEN
,
gTxSeq
);
readBlockSize
=
samples_per_subframe
/
2
;
writeBlockSize
=
readBlockSize
;
device_init
(
&
(
rfdevice
),
&
openair0_cfg
[
0
]);
threadCreate
(
&
tx_threads
,
tx_thread
,
&
rfdevice
,
"tx_thread"
,
21
,
sched_get_priority_max
(
SCHED_RR
)
-
2
);
threadCreate
(
&
tx_threads
,
tx_thread
,
&
rfdevice
,
"tx_thread"
,
5
,
sched_get_priority_max
(
SCHED_RR
)
-
2
);
rfdevice
.
trx_start_func
(
&
rfdevice
);
//first time is very long, don't know why.
...
...
@@ -222,13 +269,14 @@ int main( int argc, char **argv ) {
clock_gettime_cur
=
NR_TIMESPEC_TO_DOUBLE_US
(
nr_get_timespec_diff
(
&
time_start
,
&
time_stop
));
//us
printf
(
"using %.2lf msec in 1st time
\n
"
,
clock_gettime_cur
/
1000
);
clock_gettime
(
CLOCK_REALTIME
,
&
time_start
);
while
(
1
)
{
absolute_slot
++
;
clock_gettime
(
CLOCK_REALTIME
,
&
time_stop
);
clock_gettime
(
CLOCK_REALTIME
,
&
time_stop
);
clock_gettime_cur
=
NR_TIMESPEC_TO_DOUBLE_US
(
nr_get_timespec_diff
(
&
time_start
,
&
time_stop
));
//us
if
((
clock_gettime_cur
>
30
0
)
||
(
clock_gettime_cur_tx
>
510
))
if
((
clock_gettime_cur
>
51
0
)
||
(
clock_gettime_cur_tx
>
510
))
printf
(
"slot_num %d, timestamp %ld, writeTimestamp %ld,time = %.2f sec, delay_time=(%.2lf, %d) (tx %.2lf, %d)msec. readBlockSize %d. real read %ld.
\n
"
,
absolute_slot
,
rx_timestamp
,
writeTimestamp
,
((
float
)
absolute_slot
)
/
2
/
1000
,
clock_gettime_cur
/
1000
,
rx_cnt
,
clock_gettime_cur_tx
/
1000
,
tx_cnt
,
readBlockSize
,(
rx_timestamp
-
timestampold
));
clock_gettime
(
CLOCK_REALTIME
,
&
time_start
);
...
...
@@ -236,17 +284,34 @@ int main( int argc, char **argv ) {
#if 1
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ
,
VCD_FUNCTION_IN
);
for
(
int
i
=
0
;
i
<
NB_ANTENNAS_RX
;
i
++
)
{
rxp_temp
[
i
]
=
(
int32_t
*
)
rxp
[
i
]
+
(
rx_cnt
%
SLOTS_NUM
)
*
61440
;
}
rfdevice
.
trx_read_func
(
&
rfdevice
,
&
rx_timestamp
,
(
void
**
)
rxp
,
//(void **)&rxp[0][(rx_cnt % SLOTS_NUM)* 61440],
(
void
**
)
rxp_temp
,
readBlockSize
,
1
);
rx_cnt
++
;
absolute_slot
++
;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ
,
VCD_FUNCTION_OUT
);
#endif
#if 1
if
(
rx_cnt
==
2000
)
{
printf
(
"begin to dump
\n
"
);
FILE
*
fp1
=
fopen
(
"rfdata_v3_ant0.bin"
,
"wb"
);
fwrite
(
&
rxp
[
0
][
0
],
4
,
rxdata_size
,
fp1
);
fclose
(
fp1
);
printf
(
"end, write file ok ++++++++++++++++++++++++
\r\n
"
);
usleep
(
50000
);
exit
(
0
);
}
#endif
#ifdef TX_RX_ONE_THREAD
// use previous timing_advance value to compute writeTimestamp
//writeTimestamp = timestamp+samples_per_subframe/20*5;// sent after 5 slot.
...
...
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