mirror of
https://github.com/jopohl/urh.git
synced 2026-03-04 07:24: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
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
import unittest
|
|
|
|
import time
|
|
from multiprocessing.connection import Connection, Pipe
|
|
|
|
import numpy as np
|
|
from multiprocessing import Process
|
|
|
|
from urh.dev.native.SDRPlay import SDRPlay
|
|
from urh.util import util
|
|
import ctypes
|
|
|
|
util.set_shared_library_path()
|
|
|
|
from urh.dev.native.lib import sdrplay
|
|
|
|
def recv(conn: Connection):
|
|
while True:
|
|
t = time.time()
|
|
result = SDRPlay.unpack_complex(conn.recv_bytes())
|
|
print("UNPACK", time.time()-t)
|
|
|
|
class TestSDRPlay(unittest.TestCase):
|
|
def test_c_wrapper(self):
|
|
def pycallback(data):
|
|
arr = np.asarray(data)
|
|
#result = np.empty(len(arr) // 2, dtype=np.complex64)
|
|
#result.real = (arr[::2] + 0.5) / 32767.5
|
|
#result.imag = (arr[1::2] + 0.5) / 32767.5
|
|
|
|
print(sdrplay.get_api_version())
|
|
print(sdrplay.get_devices())
|
|
print(sdrplay.set_device_index(0))
|
|
|
|
parent_conn, child_conn = Pipe()
|
|
p = Process(target=recv, args=(parent_conn,))
|
|
p.daemon = True
|
|
p.start()
|
|
|
|
null_ptr = ctypes.POINTER(ctypes.c_voidp)()
|
|
print("Init stream", sdrplay.init_stream(50, 2e6, 433.92e6, 2e6, 500, child_conn))
|
|
|
|
time.sleep(2)
|
|
print("settings sample rate")
|
|
print("Set sample rate", sdrplay.set_sample_rate(2e6))
|
|
|
|
time.sleep(1)
|
|
p.terminate()
|
|
p.join()
|