Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
su
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dmeiss2s
su
Commits
72634d2e
Commit
72634d2e
authored
9 years ago
by
Daniel Meißner
Committed by
Daniel Meißner
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
live transmission: added support for file sink an tag
parent
1a013d2f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gr_grc/scripts/show_live_transmissions.py
+54
-5
54 additions, 5 deletions
gr_grc/scripts/show_live_transmissions.py
with
54 additions
and
5 deletions
gr_grc/scripts/show_live_transmissions.py
+
54
−
5
View file @
72634d2e
...
...
@@ -18,20 +18,22 @@ import osmosdr
import
numpy
as
np
import
time
import
yaml
import
sys
class
top_block
(
gr
.
top_block
):
def
__init__
(
self
):
gr
.
top_block
.
__init__
(
self
,
"
Top Block
"
)
##################################################
# Variables
##################################################
self
.
cutoff_freq
=
cutoff_freq
=
4
e5
self
.
cutoff_freq
=
cutoff_freq
=
3
e5
self
.
transition_width
=
transition_width
=
cutoff_freq
/
2
self
.
samp_rate
=
samp_rate
=
2
e6
self
.
samp_rate
=
samp_rate
=
5
e6
self
.
freq
=
freq
=
868e6
self
.
center_freq
=
2.7e5
##################################################
# Message Queues
...
...
@@ -54,8 +56,12 @@ class top_block(gr.top_block):
self
.
osmosdr_source_0
.
set_bb_gain
(
20
,
0
)
self
.
osmosdr_source_0
.
set_antenna
(
""
,
0
)
self
.
osmosdr_source_0
.
set_bandwidth
(
0
,
0
)
if
len
(
sys
.
argv
)
==
3
:
self
.
blocks_file_sink_0
=
blocks
.
file_sink
(
gr
.
sizeof_gr_complex
*
1
,
str
(
sys
.
argv
[
2
]),
False
)
self
.
blocks_file_sink_0
.
set_unbuffered
(
False
)
self
.
freq_xlating_fir_filter_xxx_0
=
filter
.
freq_xlating_fir_filter_ccc
(
1
,
(
firdes
.
low_pass
(
1
,
samp_rate
,
transition_width
,
cutoff_freq
,
firdes
.
WIN_HAMMING
,
6.76
)),
3
.5
e5
,
samp_rate
)
self
.
freq_xlating_fir_filter_xxx_0
=
filter
.
freq_xlating_fir_filter_ccc
(
1
,
(
firdes
.
low_pass
(
1
,
samp_rate
,
transition_width
,
cutoff_freq
,
firdes
.
WIN_HAMMING
,
6.76
)),
3e5
,
samp_rate
)
self
.
blocks_threshold_ff_0
=
blocks
.
threshold_ff
(
0.00686
,
0.00686
,
0
)
self
.
blocks_message_sink_0
=
blocks
.
message_sink
(
gr
.
sizeof_float
*
1
,
blocks_message_sink_0_msgq_out
,
False
)
self
.
blocks_complex_to_mag_squared_0
=
blocks
.
complex_to_mag_squared
(
1
)
...
...
@@ -67,6 +73,9 @@ class top_block(gr.top_block):
self
.
connect
((
self
.
blocks_threshold_ff_0
,
0
),
(
self
.
blocks_message_sink_0
,
0
))
self
.
connect
((
self
.
freq_xlating_fir_filter_xxx_0
,
0
),
(
self
.
blocks_complex_to_mag_squared_0
,
0
))
self
.
connect
((
self
.
osmosdr_source_0
,
0
),
(
self
.
freq_xlating_fir_filter_xxx_0
,
0
))
if
len
(
sys
.
argv
)
==
3
:
self
.
connect
((
self
.
osmosdr_source_0
,
0
),
(
self
.
blocks_file_sink_0
,
0
))
def
get_cutoff_freq
(
self
):
return
self
.
cutoff_freq
...
...
@@ -98,17 +107,34 @@ class top_block(gr.top_block):
self
.
freq
=
freq
self
.
osmosdr_source_0
.
set_center_freq
(
self
.
freq
,
0
)
def
get_center_freq
(
self
):
return
self
.
center_freq
def
main
(
top_block_cls
=
top_block
,
options
=
None
):
if
len
(
sys
.
argv
)
==
1
:
print
(
"
Usage:
"
+
sys
.
argv
[
0
]
+
"
'
my transmission dump
'
'
/path/to/file.iq
'"
)
sys
.
exit
(
1
)
tb
=
top_block_cls
()
tb
.
start
()
samples_count
=
0
messages
=
[]
signal_blocks
=
[]
time_added
=
0
samples_len
=
0
transmission_counter
=
0
output
=
{}
output
[
'
capture_file
'
]
=
"
data.iq
"
output
[
'
sha256
'
]
=
None
output
[
'
signal_blocks
'
]
=
[]
output
[
'
freq
'
]
=
int
(
tb
.
freq
)
+
int
(
tb
.
center_freq
)
output
[
'
samp_rate
'
]
=
tb
.
samp_rate
output
[
'
time
'
]
=
int
(
time
.
time
())
output
[
'
tag
'
]
=
sys
.
argv
[
1
]
while
True
:
msg
=
tb
.
msgq_out
.
delete_head
()
samples
=
np
.
fromstring
(
msg
.
to_string
(),
dtype
=
'
float32
'
)
...
...
@@ -132,16 +158,39 @@ def main(top_block_cls=top_block, options=None):
last_one
=
msg
.
rfind
(
"
1
"
)
real_transmission_time
=
round
(
1
/
tb
.
samp_rate
*
(
int
(
last_one
-
first_one
)
*
1000
),
2
)
transmission_counter
+=
1
if
msg
.
find
(
"
1
"
*
700
)
==
-
1
:
modulation
=
"
ASK
"
else
:
modulation
=
"
FSK
"
print
(
msg
)
print
(
"
Transmission time:
\t\t
"
+
str
(
transmission_time
)
+
"
ms
"
)
print
(
"
Real transmission time:
\t
"
+
str
(
real_transmission_time
)
+
"
ms
\n
"
)
print
(
"
Real transmission time:
\t
"
+
str
(
real_transmission_time
)
+
"
ms
"
)
print
(
"
Modulation:
"
+
modulation
+
"
\n
"
)
print
(
"
Transmission block starts at sample:
\t
"
+
str
(
block_samples_start
))
print
(
"
Transmission starts at sample:
\t\t
"
+
str
(
block_samples_start
+
first_one
))
print
(
"
Sample count:
\t\t\t\t
"
+
str
(
samples_count
))
print
(
"
\n
Transmissions:
"
+
str
(
transmission_counter
))
print
(
"
\n\n
"
)
transmission
=
{}
transmission
[
'
id
'
]
=
transmission_counter
transmission
[
'
start
'
]
=
block_samples_start
transmission
[
'
samples
'
]
=
len
(
msg
)
transmission
[
'
plot
'
]
=
None
transmission
[
'
freq
'
]
=
tb
.
freq
transmission
[
'
first_one
'
]
=
first_one
transmission
[
'
last_one
'
]
=
last_one
transmission
[
'
transmission_time
'
]
=
transmission_time
transmission
[
'
real_transmission_time
'
]
=
real_transmission_time
signal_blocks
.
append
(
transmission
)
output
[
'
signal_blocks
'
]
=
signal_blocks
with
open
(
'
data.yml
'
,
'
w
'
)
as
outfile
:
outfile
.
write
(
yaml
.
dump
(
output
,
default_flow_style
=
False
))
messages
=
[]
block_samples_start
=
0
time_added
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment