-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubnero_sw.py
More file actions
61 lines (46 loc) · 1.62 KB
/
subnero_sw.py
File metadata and controls
61 lines (46 loc) · 1.62 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
59
60
61
ip_address = "192.168.0.11"
rx_out_folder = "sw_out"
rx_out_file = "sw_rec_"
number_of_loops = 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)
################### Transmit and record a signal ##########################
bb = modem.agentForService(Services.BASEBAND)
for i in range(0,number_of_loops):
print("-I- Tx #" + str(i+1))
bb << TxBasebandSignalReq(signal=signal.tolist(), fc=0, fs=192000)
txntf4 = modem.receive(TxFrameNtf, 5000)
if txntf4 is not None:
# Request a recording from txTime onwards
bb << RecordBasebandSignalReq(recTime=txntf4.txTime, recLen=(len(tx_signal)*2))
else:
print('Transmission not successfull, try again!')
# Read the receive notification
rxntf4 = modem.receive(RxBasebandSignalNtf, 5000)
if rxntf is not None:
# Extract the recorded signal
rec_signal = rxntf4.signal
print('Successfully recorded signal after transmission!')
# The recorded signal is saved in `rec_signal` variable
# It can be processed as required by the user.
else:
print('Recording not successfull, try again!')
if sleep_between_loops:
print("-I- sleeping for {} seconds".format(sleep_between_loops))
time.sleep(sleep_between_loops)
modem.close()