From e2550e6df11558ccd6e8b95f489c0988b34347af Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 26 Feb 2016 10:19:58 +0100 Subject: 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 --- pywrap/pcipywrap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pywrap/pcipywrap.h') 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. */ -- cgit v1.2.3 From 5d775d64bdec554b9842823bd1c46263210425fd Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 1 Mar 2016 10:42:40 +0100 Subject: 1. multithreading: - Enable multiprocessing for api_server - Enable mutrithreading for html_server 2. py: - extract pcilib->py bases from pcilib->py functions - add api for interact directly with pcilib->py without pcilib context. 3. pcipywrap - Add scripts handling. --- pywrap/pcipywrap.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pywrap/pcipywrap.h') diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index dcce245..2d9115b 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -5,11 +5,23 @@ #include "error.h" #include +#include "config.h" +#include "py.h" + +#include "pci.h" +#include "pcilib.h" + + typedef struct { + char** names; + int names_size; + void* ctx; + struct pcilib_py_s *py; int shared; } Pcipywrap; + /*! * \brief Redirect pcilib standart log stream to exeption text. * Logger will accumulate errors untill get message, starts with "#E". @@ -83,4 +95,7 @@ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id); PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id); PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id); +PyObject* Pcipywrap_get_scripts_list(Pcipywrap *self); +PyObject* Pcipywrap_run_script(Pcipywrap *self, const char* script_name, PyObject* value); + #endif /* PCIPYWRAP_H */ -- cgit v1.2.3 From 9b947f32c3db96c3022afad401b1349205d22259 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 1 Mar 2016 16:42:48 +0100 Subject: 1. api-serer: - change multiprosessing work mechanism - add new pywrap functions handling 2. html-server: - now works through api-server --- pywrap/pcipywrap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pywrap/pcipywrap.h') diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index 2d9115b..cfb5651 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -28,7 +28,7 @@ typedef struct { * After that, logger will write last error, and all accumulated errors * to Python exeption text */ -void __redirect_logs_to_exeption(); +void redirect_logs_to_exeption(); /*! * \brief Wraps for pcilib_open function. -- cgit v1.2.3 From 269b0985bd5830e27f6dedb04a05d76f52acb68c Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 1 Mar 2016 17:17:46 +0100 Subject: update documentation --- pywrap/pcipywrap.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'pywrap/pcipywrap.h') diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index cfb5651..fa7e4f4 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -73,18 +73,55 @@ PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop); * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop); + + +/*! + * \brief Wrap for pcilib_get_register_list function. + * \param bank [in] bank - if set, only register within the specified bank will be returned + * \return list of registers, serialized to Python object + */ PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank); + +/*! + * \brief Returns the information about the specified register. Wrap for pcilib_get_register_info + * \param[in] reg the name of the register + * \param[in] bank indicates the bank where to look for register, autodetected if NULL is passed + * \return information about the specified register, serialized to Python object + */ PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank); + +/*! + * \brief Returns the list of properties available under the specified path. Wrap for pcilib_get_property_list + * \param[in] branch path or NULL to return the top-level properties + * \return the list of the properties, serialized to Python object + */ PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch); +/*! + * \brief Reads data from DMA until timeout is hit, a full DMA packet is read, or the specified number of bytes are read. + * Wrap for pcilib_read_dma. + * \param dma ID of DMA engine + * \param size specifies how many bytes should be read + * \return DMA data, serialierd to Python bytearray + * \warning This function has not been tested. + * \todo Test this fucntion + */ PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size); +/*! + * \brief Wrap for pcilib_lock_global + * \return 1, serialized to PyObject or NULL with exeption text, if failed. + */ PyObject* Pcipywrap_lock_global(Pcipywrap *self); + +/*! + * \brief Wrap for pcilib_unlock_global + */ void Pcipywrap_unlock_global(Pcipywrap *self); /*! * \brief Wrap for pcilib_lock - * \param lock_id lock identificator + * \param[in] 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/test_prop_mt.py * for example. @@ -92,10 +129,35 @@ void Pcipywrap_unlock_global(Pcipywrap *self); */ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id); +/*! + * \brief This function will try to take a lock for the mutex pointed by + * lockfunction to acquire a lock, but that returns immediatly if the lock can't be + * acquired on first try. Wrap for pcilib_try_lock. + * \param[in] lock_id lock id + * \return 1, serialized to PyObject or NULL with exeption text, if failed. + */ PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id); + +/*! + * \brief This function unlocks the lock with specified id. Wrap for pcilib_unlock. + * \param[in] lock_id lock id + * \return 1, serialized to PyObject or NULL with exeption text, if failed. + */ PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id); +/*! + * \brief Returns list with information about aviable scripts + * \return list with information about scripts, aviable in model + */ PyObject* Pcipywrap_get_scripts_list(Pcipywrap *self); + +/*! + * \brief Runs script with specified name + * \param script_name script name (with extension); name could be found by + * Pcipywrap_get_scripts_list fucntion + * \param[in] value input value + * \return value returned by script + */ PyObject* Pcipywrap_run_script(Pcipywrap *self, const char* script_name, PyObject* value); #endif /* PCIPYWRAP_H */ -- cgit v1.2.3 From 8719b84a95805d109e21c20f05a0164315e1b38a Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Wed, 2 Mar 2016 10:26:13 +0100 Subject: Move scripts handing code from py.c to Python wrap --- pywrap/pcipywrap.h | 79 +----------------------------------------------------- 1 file changed, 1 insertion(+), 78 deletions(-) (limited to 'pywrap/pcipywrap.h') diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index fa7e4f4..0258f04 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -5,23 +5,11 @@ #include "error.h" #include -#include "config.h" -#include "py.h" - -#include "pci.h" -#include "pcilib.h" - - typedef struct { - char** names; - int names_size; - void* ctx; - struct pcilib_py_s *py; int shared; } Pcipywrap; - /*! * \brief Redirect pcilib standart log stream to exeption text. * Logger will accumulate errors untill get message, starts with "#E". @@ -73,55 +61,18 @@ PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop); * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop); - - -/*! - * \brief Wrap for pcilib_get_register_list function. - * \param bank [in] bank - if set, only register within the specified bank will be returned - * \return list of registers, serialized to Python object - */ PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank); - -/*! - * \brief Returns the information about the specified register. Wrap for pcilib_get_register_info - * \param[in] reg the name of the register - * \param[in] bank indicates the bank where to look for register, autodetected if NULL is passed - * \return information about the specified register, serialized to Python object - */ PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank); - -/*! - * \brief Returns the list of properties available under the specified path. Wrap for pcilib_get_property_list - * \param[in] branch path or NULL to return the top-level properties - * \return the list of the properties, serialized to Python object - */ PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch); -/*! - * \brief Reads data from DMA until timeout is hit, a full DMA packet is read, or the specified number of bytes are read. - * Wrap for pcilib_read_dma. - * \param dma ID of DMA engine - * \param size specifies how many bytes should be read - * \return DMA data, serialierd to Python bytearray - * \warning This function has not been tested. - * \todo Test this fucntion - */ PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size); -/*! - * \brief Wrap for pcilib_lock_global - * \return 1, serialized to PyObject or NULL with exeption text, if failed. - */ PyObject* Pcipywrap_lock_global(Pcipywrap *self); - -/*! - * \brief Wrap for pcilib_unlock_global - */ void Pcipywrap_unlock_global(Pcipywrap *self); /*! * \brief Wrap for pcilib_lock - * \param[in] lock_id lock identificator + * \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/test_prop_mt.py * for example. @@ -129,35 +80,7 @@ void Pcipywrap_unlock_global(Pcipywrap *self); */ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id); -/*! - * \brief This function will try to take a lock for the mutex pointed by - * lockfunction to acquire a lock, but that returns immediatly if the lock can't be - * acquired on first try. Wrap for pcilib_try_lock. - * \param[in] lock_id lock id - * \return 1, serialized to PyObject or NULL with exeption text, if failed. - */ PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id); - -/*! - * \brief This function unlocks the lock with specified id. Wrap for pcilib_unlock. - * \param[in] lock_id lock id - * \return 1, serialized to PyObject or NULL with exeption text, if failed. - */ PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id); -/*! - * \brief Returns list with information about aviable scripts - * \return list with information about scripts, aviable in model - */ -PyObject* Pcipywrap_get_scripts_list(Pcipywrap *self); - -/*! - * \brief Runs script with specified name - * \param script_name script name (with extension); name could be found by - * Pcipywrap_get_scripts_list fucntion - * \param[in] value input value - * \return value returned by script - */ -PyObject* Pcipywrap_run_script(Pcipywrap *self, const char* script_name, PyObject* value); - #endif /* PCIPYWRAP_H */ -- cgit v1.2.3