diff options
author | Vasilii Chernov <vchernov@inr.ru> | 2016-02-26 10:19:58 +0100 |
---|---|---|
committer | Vasilii Chernov <vchernov@inr.ru> | 2016-02-26 10:19:58 +0100 |
commit | e2550e6df11558ccd6e8b95f489c0988b34347af (patch) | |
tree | 7f959bbfe4a332b83e77f939a7c308d21e62b747 /pywrap | |
parent | 3bf5383a7ea03c5aa263aa4d8acf8b4949547319 (diff) | |
download | pcitool-e2550e6df11558ccd6e8b95f489c0988b34347af.tar.gz pcitool-e2550e6df11558ccd6e8b95f489c0988b34347af.tar.bz2 pcitool-e2550e6df11558ccd6e8b95f489c0988b34347af.tar.xz pcitool-e2550e6df11558ccd6e8b95f489c0988b34347af.zip |
1. pywrap:
- fix get_registers_list crash with bank != NULL
- set correct python version in cmake install step
2. html_server:
- merge set and get value boxes into one box
- add registers bank view mode
- read registers/properties values in bank/branch view mode
3. xml/test
- remove cmosis registers
- add multithread safe property example
Diffstat (limited to 'pywrap')
-rw-r--r-- | pywrap/CMakeLists.txt | 2 | ||||
-rw-r--r-- | pywrap/pcipywrap.c | 29 | ||||
-rw-r--r-- | pywrap/pcipywrap.h | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/pywrap/CMakeLists.txt b/pywrap/CMakeLists.txt index f1c909e..f77c2ff 100644 --- a/pywrap/CMakeLists.txt +++ b/pywrap/CMakeLists.txt @@ -19,7 +19,7 @@ swig_add_module(pcipywrap python pcipywrap.i pcipywrap.c) swig_link_libraries(pcipywrap ${PYTHON_LIBRARIES} pcilib) #install pcilib python wrapper into Python site packages folder -execute_process ( COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process ( COMMAND python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) install(TARGETS ${SWIG_MODULE_pcipywrap_REAL_NAME} DESTINATION ${PYTHON_SITE_PACKAGES}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pcipywrap.py DESTINATION ${PYTHON_SITE_PACKAGES}) diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index 64e059a..dca5973 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -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) @@ -551,7 +556,7 @@ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) pcilib_lock_t* lock = pcilib_get_lock(self->ctx, PCILIB_LOCK_FLAGS_DEFAULT, lock_id); - if(!lock) + if(!lock) { set_python_exception("Failed pcilib_get_lock"); return NULL; diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index 5876a06..dcce245 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -74,7 +74,7 @@ void Pcipywrap_unlock_global(Pcipywrap *self); * \brief Wrap for pcilib_lock * \param lock_id lock identificator * \warning This function should be called only under Python standart threading lock. - * Otherwise it will stuck with more than 1 threads. See /xml/test_pywrap/test_prop_mt.py + * Otherwise it will stuck with more than 1 threads. See /xml/test/test_prop_mt.py * for example. * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ |