diff options
Diffstat (limited to 'pywrap/pcipywrap.c')
-rw-r--r-- | pywrap/pcipywrap.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index ceb0835..0f6729e 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -94,7 +94,7 @@ void set_python_exception(const char* msg, ...) } -void __redirect_logs_to_exeption() +void redirect_logs_to_exeption() { pcilib_set_logger(pcilib_get_log_level(), pcilib_print_error_to_py, @@ -458,17 +458,22 @@ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *pro PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank) { - pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT); - PyObject* pyList = PyList_New(0); - for(int i = 0; i < ((pcilib_t*)self->ctx)->num_reg; i++) - { - //serialize item attributes - PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]); - pcilib_pylist_append(pyList, pylistItem); - //Py_DECREF(pylistItem); - } - pcilib_free_register_info(self->ctx, list); - return pyList; + pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT); + + if(!list) { + set_python_exception("pcilib_get_register_list return NULL"); + return NULL; + } + + PyObject* pyList = PyList_New(0); + for(int i = 0; list[i].name; i++) + { + //serialize item attributes + PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]); + pcilib_pylist_append(pyList, pylistItem); + } + pcilib_free_register_info(self->ctx, list); + return pyList; } PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank) @@ -549,7 +554,7 @@ void Pcipywrap_unlock_global(Pcipywrap *self) PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) { pcilib_lock_t* lock = pcilib_get_lock(self->ctx, - PCILIB_LOCK_FLAGS_DEFAULT, + PCILIB_LOCK_FLAG_PERSISTENT, lock_id); if(!lock) { @@ -571,7 +576,7 @@ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id) { pcilib_lock_t* lock = pcilib_get_lock(self->ctx, - PCILIB_LOCK_FLAGS_DEFAULT, + PCILIB_LOCK_FLAG_PERSISTENT, lock_id); if(!lock) { @@ -592,7 +597,7 @@ PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id) PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id) { pcilib_lock_t* lock = pcilib_get_lock(self->ctx, - PCILIB_LOCK_FLAGS_DEFAULT, + PCILIB_LOCK_FLAG_PERSISTENT, lock_id); if(!lock) { |