mirror of
https://github.com/jopohl/urh.git
synced 2026-03-03 23:14:00 +01:00
* precompile device extensions * set lib path * prevent double build * download libs in travis * fix unittest * update path * protect access * adapt shared path to linux * sort os listdir * ensure libstdc++ loaded first * change name * remove required * improve test * add usrp test * set shared library path when processes spawn * test pypi release with travis * test pypi release with travis * test pypi release with travis * skip cleanup * fix pypi test link * test wheelhouse build * skip tests * fix path * fix dir * cd repo * quote var * do not use for loop * add missing quote * quote dollar * script deployment * fix twine upload * deploy libs only for windows * add 32 bit support * fix command * disable 32 bit * push version for test * push ver * prepare merge * trigger build * fix windows path * improve shortcut * remove debug * edit copyright
65 lines
1.5 KiB
Python
65 lines
1.5 KiB
Python
from multiprocessing.connection import Pipe
|
|
|
|
import sys
|
|
|
|
from urh.util import util
|
|
|
|
util.set_shared_library_path()
|
|
|
|
|
|
from urh.dev.native.USRP import USRP
|
|
from urh.dev.native.lib import usrp
|
|
import unittest
|
|
|
|
class TestUSRP(unittest.TestCase):
|
|
def test_cython_wrapper(self):
|
|
print(usrp.find_devices(""))
|
|
|
|
usrp.set_tx(False)
|
|
|
|
return_code = usrp.open("addr=192.168.10.2")
|
|
print("open", return_code)
|
|
|
|
usrp.setup_stream()
|
|
print("Made rx_streame handler")
|
|
|
|
print(usrp.get_device_representation())
|
|
|
|
print("Set sample rate", usrp.set_sample_rate(2e6))
|
|
print("Set freq", usrp.set_center_freq(433.92e6))
|
|
print("Set bandwidth", usrp.set_bandwidth(1e6))
|
|
print("Set gain", usrp.set_rf_gain(0.5))
|
|
|
|
|
|
|
|
buffer = bytearray()
|
|
|
|
num_samples = 32768 // 2
|
|
|
|
usrp.start_stream(num_samples)
|
|
parent_conn, child_conn = Pipe()
|
|
|
|
for i in range(500):
|
|
usrp.recv_stream(child_conn, num_samples)
|
|
received_bytes = parent_conn.recv_bytes()
|
|
#print(received_bytes)
|
|
print(i)
|
|
buffer.extend(received_bytes)
|
|
#print(USRP.unpack_complex(received_bytes, len(received_bytes) // 8))
|
|
|
|
f = open("/tmp/test.complex", "wb")
|
|
f.write(buffer)
|
|
f.close()
|
|
|
|
usrp.destroy_stream()
|
|
print("Freed rx streamer handler")
|
|
|
|
return_code = usrp.close()
|
|
print("close", return_code)
|
|
|
|
|
|
#self.assertTrue(True)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|