Merge pull request #4 from nqrduck/get-device-list

Bump version and add device listing.

Tested with LimeSDR USB and LimeSDR Mini  2.0 connected  to one PC. Devices could be retrieved using the get_devices_list()  method. The  active  device could  be  changed using the device  property of the PyLimeConfig object.
This commit is contained in:
Julia P 2024-02-17 18:25:13 +01:00 committed by GitHub
commit 3d0481a9d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 4 deletions

2
extern/limedriver vendored

@ -1 +1 @@
Subproject commit d1e1cd6bba209c0ca604411d50329abaa5a824b1 Subproject commit 294e31d9cfa3f49f4973b92dc5d93a757653057e

View file

@ -1,6 +1,6 @@
[project] [project]
name = "limedriver" name = "limedriver"
version = "0.3.0" version = "0.4.0"
description = "Python bindings for limedriver" description = "Python bindings for limedriver"
authors = [{name = "Kumi", email = "limedriver@kumi.email"}] authors = [{name = "Kumi", email = "limedriver@kumi.email"}]
license = {file = "LICENSE"} license = {file = "LICENSE"}

View file

@ -5,13 +5,16 @@ from cpython.mem cimport PyMem_Malloc, PyMem_Free
from libc.stdlib cimport malloc, free from libc.stdlib cimport malloc, free
from libc.string cimport memcpy, strcpy from libc.string cimport memcpy, strcpy
from libcpp.vector cimport vector
from libcpp.string cimport string from libcpp.string cimport string
from libcpp.pair cimport pair
import pathlib import pathlib
cdef extern from "limedriver.h": cdef extern from "limedriver.h":
cdef struct LimeConfig_t: cdef struct LimeConfig_t:
string device
float srate float srate
int channel int channel
int TX_matching int TX_matching
@ -92,6 +95,10 @@ cdef extern from "limedriver.h":
cdef LimeConfig_t initializeLimeConfig(int Npulses) cdef LimeConfig_t initializeLimeConfig(int Npulses)
cdef int run_experiment_from_LimeCfg(LimeConfig_t config) cdef int run_experiment_from_LimeCfg(LimeConfig_t config)
cdef pair[int, int] getChannelsFromInfo(string device)
cdef vector[string] getDeviceList()
cdef class PyLimeConfig: cdef class PyLimeConfig:
@ -656,6 +663,14 @@ cdef class PyLimeConfig:
self._config.c3_synth[i] = values[i] self._config.c3_synth[i] = values[i]
# String properties # String properties
@property
def device(self):
return self._config.device.decode('utf-8')
@device.setter
def device(self, str value):
self._config.device = value.encode('utf-8')
@property @property
def file_pattern(self): def file_pattern(self):
return self._config.file_pattern.decode() return self._config.file_pattern.decode()
@ -703,4 +718,11 @@ cdef class PyLimeConfig:
path = self.save_path + self.file_stamp + '_' + self.file_pattern + '.h5' path = self.save_path + self.file_stamp + '_' + self.file_pattern + '.h5'
path = pathlib.Path(path).absolute() path = pathlib.Path(path).absolute()
return path return path
def get_device_list():
cdef vector[string] devices = getDeviceList()
return [device.decode('utf-8') for device in devices]
def get_channels_for_device(device = ""):
cdef pair[int, int] channels = getChannelsFromInfo(device.encode())
return channels.first, channels.second