-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubnero_rx.py
More file actions
58 lines (47 loc) · 1.47 KB
/
subnero_rx.py
File metadata and controls
58 lines (47 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Settings
ip_address = "192.168.0.11"
rx_out_folder = "rx_out"
rx_out_file = "rx_rec_"
number_of_rec = 5
##--------------------------------------##
import sys
import os
import time
import numpy as np
import arlpy as ap
from unetpy import *
# Open connection to the modem
print("-I- connecting to modem: " + ip_address)
try:
sock = UnetSocket('192.168.0.11', 1100)
modem = sock.getGateway()
except:
exit(1)
# If necessary, create out folder
if not os.path.exists(rx_out_folder):
os.makedirs(rx_out_folder)
bb = modem.agentForService(Services.BASEBAND)
file_idx = 0
for i in range(0,number_of_rec):
print("-I- rx #" + str(i+1))
# what is the next avaiable file name?
next_out_file = None
while not next_out_file:
possible_name = "{}/{}{}".format(rx_out_folder, rx_out_file, file_idx)
if os.path.isfile(possible_name): # already in use?
file_idx = file_idx + 1
else:
next_out_file = possible_name
# Record a baseband signal
bb << RecordBasebandSignalReq(recLen=24000)
# Receive the notification when the signal is recorded
rxntf = modem.receive(RxBasebandSignalNtf, 192000)
if rxntf is not None:
# Extract the recorded signal
rec_signal = rxntf.signal
# rec_signal.tofile(next_out_file)
np.savetxt(next_out_file, rec_signal)
print('-I- signal was recorded successfully')
else:
print('-E- signal was not recorded successfully')
modem.close()