mirror of
https://github.com/jopohl/urh.git
synced 2026-03-11 02:36:48 +01:00
rx prototype
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
from libcpp cimport bool
|
||||
|
||||
ctypedef unsigned int uint32_t
|
||||
ctypedef unsigned long long uint64_t
|
||||
|
||||
ctypedef enum dataFmt_t:
|
||||
# Data output format
|
||||
LMS_FMT_F32 = 0
|
||||
LMS_FMT_I16 = 1
|
||||
LMS_FMT_I12 = 2
|
||||
|
||||
cdef extern from "lime/LimeSuite.h":
|
||||
ctypedef double float_type
|
||||
const int LMS_SUCCESS = 0
|
||||
@@ -30,6 +39,7 @@ cdef extern from "lime/LimeSuite.h":
|
||||
LMS_TESTSIG_DC # DC test signal
|
||||
|
||||
int LMS_Init(lms_device_t *device)
|
||||
int LMS_Reset(lms_device_t *device)
|
||||
int LMS_GetNumChannels(lms_device_t *device, bool dir_tx)
|
||||
int LMS_EnableChannel(lms_device_t *device, bool dir_tx, size_t chan, bool enabled)
|
||||
|
||||
@@ -49,7 +59,12 @@ cdef extern from "lime/LimeSuite.h":
|
||||
int LMS_GetLPFBWRange(lms_device_t *device, bool dir_tx, lms_range_t *range)
|
||||
int LMS_SetLPF(lms_device_t *device, bool dir_tx, size_t chan, bool enabled)
|
||||
int LMS_SetGFIRLPF(lms_device_t *device, bool dir_tx, size_t chan, bool enabled, float_type bandwidth)
|
||||
|
||||
int LMS_Calibrate(lms_device_t *device, bool dir_tx, size_t chan, double bw, unsigned flags)
|
||||
int LMS_CalibrateInternalADC(lms_device_t *device);
|
||||
int LMS_CalibrateAnalogRSSIDC(lms_device_t *device);
|
||||
int LMS_CalibrateRP_BIAS(lms_device_t *device);
|
||||
|
||||
|
||||
ctypedef char lms_name_t[16]
|
||||
int LMS_GetAntennaList(lms_device_t *device, bool dir_tx, size_t chan, lms_name_t *list)
|
||||
@@ -58,3 +73,59 @@ cdef extern from "lime/LimeSuite.h":
|
||||
int LMS_GetAntennaBW(lms_device_t *device, bool dir_tx, size_t chan, size_t index, lms_range_t *range)
|
||||
|
||||
int LMS_GetChipTemperature(lms_device_t *dev, size_t ind, float_type *temp)
|
||||
|
||||
ctypedef struct lms_stream_meta_t:
|
||||
# Timestamp is a value of HW counter with a tick based on sample rate.
|
||||
# In RX: time when the first sample in the returned buffer was received
|
||||
# In TX: time when the first sample in the submitted buffer should be send
|
||||
uint64_t timestamp
|
||||
|
||||
# In TX: wait for the specified HW timestamp before broadcasting data over the air
|
||||
# In RX: wait for the specified HW timestamp before starting to receive samples
|
||||
bool waitForTimestamp
|
||||
|
||||
# Indicates the end of send/receive transaction. Discards data remainder
|
||||
# in buffer (if there is any) in RX or flushes transfer buffer in TX (even
|
||||
# if the buffer is not full yet)
|
||||
bool flushPartialPacket
|
||||
|
||||
ctypedef struct lms_stream_t:
|
||||
# Stream handle. Should not be modified manually. Assigned by LMS_SetupStream()
|
||||
size_t handle
|
||||
|
||||
# Indicates whether stream is TX (true) or RX (false)
|
||||
bool isTx
|
||||
|
||||
# Channel number. Starts at 0.
|
||||
uint32_t channel
|
||||
|
||||
# FIFO size (in samples) used by stream.
|
||||
uint32_t fifoSize
|
||||
|
||||
# Parameter for controlling configuration bias toward low latency or high data throughput range [0,1.0].
|
||||
# 0 - lowest latency, usually results in lower throughput
|
||||
# 1 - higher throughput, usually results in higher latency
|
||||
float throughputVsLatency
|
||||
|
||||
dataFmt_t dataFmt
|
||||
|
||||
ctypedef struct lms_stream_status_t:
|
||||
bool active # Indicates whether the stream is currently active
|
||||
uint32_t fifoFilledCount # Number of samples in FIFO buffer
|
||||
uint32_t fifoSize # Size of FIFO buffer
|
||||
uint32_t underrun # FIFO underrun count
|
||||
uint32_t overrun # FIFO overrun count
|
||||
uint32_t droppedPackets # Number of dropped packets by HW
|
||||
float_type sampleRate # Sampling rate of the stream
|
||||
float_type linkRate # Combined data rate of all stream of the same direction (TX or RX)
|
||||
uint64_t timestamp # Current HW timestamp
|
||||
|
||||
int LMS_SetupStream(lms_device_t *device, lms_stream_t *stream)
|
||||
int LMS_DestroyStream(lms_device_t *device, lms_stream_t *stream)
|
||||
int LMS_StartStream(lms_stream_t *stream)
|
||||
int LMS_StopStream(lms_stream_t *conf)
|
||||
int LMS_GetStreamStatus(lms_stream_t *stream, lms_stream_status_t*status)
|
||||
int LMS_RecvStream(lms_stream_t *stream, void *samples, size_t sample_count, lms_stream_meta_t *meta,
|
||||
unsigned timeout_ms)
|
||||
int LMS_SendStream(lms_stream_t *stream, const void *samples, size_t sample_count, const lms_stream_meta_t *meta,
|
||||
unsigned timeout_ms)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
import time
|
||||
from climesdr cimport *
|
||||
from libc.stdlib cimport malloc
|
||||
|
||||
@@ -311,3 +312,54 @@ cpdef float_type get_chip_temperature():
|
||||
return chip_temp
|
||||
else:
|
||||
return -1
|
||||
|
||||
cpdef start_rx():
|
||||
cdef lms_stream_t stream
|
||||
cdef lms_stream_meta_t meta
|
||||
|
||||
stream.channel = 0
|
||||
stream.isTx = 0
|
||||
#stream.fifoSize = 1000
|
||||
#stream.throughputVsLatency = 0.5
|
||||
#print(stream.dataFmt)
|
||||
print("SAMPLE RATE:", get_sample_rate(False, 0))
|
||||
rc = LMS_SetupStream(_c_device, &stream)
|
||||
if rc != 0:
|
||||
print("Setup stream failed")
|
||||
return -1
|
||||
|
||||
print(stream.fifoSize)
|
||||
rc = LMS_StartStream(&stream)
|
||||
if rc != 0:
|
||||
print("Start stream failed")
|
||||
return -1
|
||||
|
||||
cdef lms_stream_status_t stream_status
|
||||
for i in range(10):
|
||||
LMS_GetStreamStatus(&stream, &stream_status)
|
||||
print("Channel", stream.channel)
|
||||
print("StreamRX", stream.isTx)
|
||||
print("Dropped PAckets", stream_status.droppedPackets)
|
||||
print("Sample rate", stream_status.sampleRate)
|
||||
print("link rate", stream_status.linkRate)
|
||||
print("fifo size", stream_status.fifoSize)
|
||||
print(stream_status.fifoFilledCount)
|
||||
time.sleep(1)
|
||||
|
||||
cdef size_t num_samples = 1000
|
||||
cdef float*buff = <float *> malloc(num_samples * 2 * sizeof(float))
|
||||
print("buff 0 before rx", buff[0])
|
||||
LMS_RecvStream(&stream, <void *> buff, num_samples, &meta, 100)
|
||||
print("buff 0 after rx", buff[0])
|
||||
|
||||
rc = LMS_StopStream(&stream)
|
||||
if rc != 0:
|
||||
print("Stop stream failed")
|
||||
return -1
|
||||
|
||||
LMS_DestroyStream(_c_device, &stream)
|
||||
if rc != 0:
|
||||
print("Destroy stream failed")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestLimeSDR(unittest.TestCase):
|
||||
print("Init", limesdr.init())
|
||||
print("Num Channels TX:", limesdr.get_num_channels(True))
|
||||
print("Num Channels RX:", limesdr.get_num_channels(False))
|
||||
# print("Enable RX Channel 0:", limesdr.enable_channel(dir_tx=False, chan=0, enabled=True))
|
||||
print("Enable RX Channel 0:", limesdr.enable_channel(dir_tx=False, chan=0, enabled=True))
|
||||
|
||||
print("RX Sample Rate Range:", limesdr.get_sample_rate_range(False))
|
||||
print("RX Channel 0 Sample Rate:", limesdr.get_sample_rate(dir_tx=False, chan=0))
|
||||
@@ -41,10 +41,10 @@ class TestLimeSDR(unittest.TestCase):
|
||||
|
||||
print("RX Bandwidth Range", limesdr.get_lpf_bandwidth_range(False))
|
||||
print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth(False, 0))
|
||||
print("RX 0 set Bandwidth", limesdr.set_lpf_bandwidth(False, 0, 2e6))
|
||||
print("RX 0 set Bandwidth", limesdr.set_lpf_bandwidth(False, 0, 20e6))
|
||||
print("RX 0 Bandwidth", limesdr.get_lpf_bandwidth(False, 0))
|
||||
|
||||
print("RX 0 calibrate:", limesdr.calibrate(False, 0, 2e6))
|
||||
print("RX 0 calibrate:", limesdr.calibrate(False, 0, 20e6))
|
||||
|
||||
antenna_list = limesdr.get_antenna_list(False, 0)
|
||||
print("RX 0 antenna list", antenna_list)
|
||||
@@ -53,6 +53,8 @@ class TestLimeSDR(unittest.TestCase):
|
||||
|
||||
print("Chip Temperature", limesdr.get_chip_temperature())
|
||||
|
||||
limesdr.start_rx()
|
||||
|
||||
print("-" * 20)
|
||||
print("Close:", limesdr.close())
|
||||
print("Is Open 0:", limesdr.is_open(0))
|
||||
|
||||
Reference in New Issue
Block a user