diff options
Diffstat (limited to 'pywrap')
-rw-r--r-- | pywrap/CMakeLists.txt | 1 | ||||
-rw-r--r-- | pywrap/pcilib.py | 4 | ||||
-rw-r--r-- | pywrap/pcipywrap.c | 40 | ||||
-rw-r--r-- | pywrap/pcipywrap.h | 36 | ||||
-rw-r--r-- | pywrap/pcipywrap.i | 8 | ||||
-rw-r--r-- | pywrap/test_pcilib.py | 6 |
6 files changed, 47 insertions, 48 deletions
diff --git a/pywrap/CMakeLists.txt b/pywrap/CMakeLists.txt index 4cc51da..033298e 100644 --- a/pywrap/CMakeLists.txt +++ b/pywrap/CMakeLists.txt @@ -22,6 +22,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pcipywrap.py DESTINATION ${PYTHON_INST install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pcilib.py DESTINATION ${PYTHON_INSTALL_DIR}) if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pcilib.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_pcilib.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) diff --git a/pywrap/pcilib.py b/pywrap/pcilib.py index 7696524..f4976bf 100644 --- a/pywrap/pcilib.py +++ b/pywrap/pcilib.py @@ -2,9 +2,9 @@ from pcipywrap import * import os import sys -class Pcilib(Pcipywrap): +class pcilib(pcipywrap): def __init__(s, *args): - Pcipywrap.__init__(s, *args) + pcipywrap.__init__(s, *args) #load scripts scripts_dir = os.environ.get('PCILIB_SCRIPTS_DIR') diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index a1092be..cb99ce2 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -322,7 +322,7 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist } -Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model) +pcipywrap *new_pcipywrap(const char* fpga_device, const char* model) { //opening device pcilib_t* ctx = pcilib_open(fpga_device, model); @@ -331,14 +331,14 @@ Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model) set_python_exception("Failed pcilib_open(%s, %s)", fpga_device, model); return NULL; } - Pcipywrap *self; - self = (Pcipywrap *) malloc(sizeof(Pcipywrap)); + pcipywrap *self; + self = (pcipywrap *) malloc(sizeof(pcipywrap)); self->shared = 0; self->ctx = ctx; return self; } -Pcipywrap *create_Pcipywrap(PyObject* ctx) +pcipywrap *create_pcipywrap(PyObject* ctx) { if(!PyCapsule_CheckExact(ctx)) { @@ -346,22 +346,22 @@ Pcipywrap *create_Pcipywrap(PyObject* ctx) return NULL; } - Pcipywrap *self; - self = (Pcipywrap *) malloc(sizeof(Pcipywrap)); + pcipywrap *self; + self = (pcipywrap *) malloc(sizeof(pcipywrap)); self->shared = 1; self->ctx = PyCapsule_GetPointer(ctx, PyCapsule_GetName(ctx)); return self; } -void delete_Pcipywrap(Pcipywrap *self) { +void delete_pcipywrap(pcipywrap *self) { if(!self->shared) pcilib_close(self->ctx); free(self); } -PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const char *bank) +PyObject* pcipywrap_read_register(pcipywrap *self, const char *regname, const char *bank) { pcilib_value_t val = {0}; pcilib_register_value_t reg_value; @@ -385,7 +385,7 @@ PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const ch return pcilib_get_value_as_pyobject(self->ctx, &val, NULL); } -PyObject* Pcipywrap_write_register(Pcipywrap *self, PyObject* val, const char *regname, const char *bank) +PyObject* pcipywrap_write_register(pcipywrap *self, PyObject* val, const char *regname, const char *bank) { pcilib_value_t val_internal = {0}; pcilib_register_value_t reg_value; @@ -419,7 +419,7 @@ PyObject* Pcipywrap_write_register(Pcipywrap *self, PyObject* val, const char *r return PyLong_FromLong((long)1); } -PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop) +PyObject* pcipywrap_get_property(pcipywrap *self, const char *prop) { int err; pcilib_value_t val = {0}; @@ -435,7 +435,7 @@ PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop) return pcilib_get_value_as_pyobject(self->ctx, &val, NULL); } -PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop) +PyObject* pcipywrap_set_property(pcipywrap *self, PyObject* val, const char *prop) { int err; @@ -457,7 +457,7 @@ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *pro return PyLong_FromLong((long)1); } -PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank) +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); @@ -477,7 +477,7 @@ PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank) return pyList; } -PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank) +PyObject* pcipywrap_get_register_info(pcipywrap *self, const char* reg,const char *bank) { pcilib_register_info_t *info = pcilib_get_register_info(self->ctx, bank, reg, PCILIB_LIST_FLAGS_DEFAULT); @@ -493,7 +493,7 @@ PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const cha return py_info; } -PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch) +PyObject* pcipywrap_get_property_list(pcipywrap *self, const char* branch) { pcilib_property_info_t *list = pcilib_get_property_list(self->ctx, branch, PCILIB_LIST_FLAGS_DEFAULT); @@ -511,7 +511,7 @@ PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch) return pyList; } -PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size) +PyObject* pcipywrap_read_dma(pcipywrap *self, unsigned char dma, size_t size) { int err; void* buf = NULL; @@ -532,7 +532,7 @@ PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size) return py_buf; } -PyObject* Pcipywrap_lock_global(Pcipywrap *self) +PyObject* pcipywrap_lock_global(pcipywrap *self) { int err; @@ -546,13 +546,13 @@ PyObject* Pcipywrap_lock_global(Pcipywrap *self) return PyLong_FromLong((long)1); } -void Pcipywrap_unlock_global(Pcipywrap *self) +void pcipywrap_unlock_global(pcipywrap *self) { pcilib_unlock_global(self->ctx); return; } -PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) +PyObject* pcipywrap_lock(pcipywrap *self, const char *lock_id) { pcilib_lock_t* lock = pcilib_get_lock(self->ctx, PCILIB_LOCK_FLAG_PERSISTENT, @@ -574,7 +574,7 @@ PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) return PyLong_FromLong((long)1); } -PyObject* Pcipywrap_try_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_FLAG_PERSISTENT, @@ -595,7 +595,7 @@ PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id) return PyLong_FromLong((long)1); } -PyObject* Pcipywrap_unlock(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_FLAG_PERSISTENT, diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h index 0258f04..1b71a56 100644 --- a/pywrap/pcipywrap.h +++ b/pywrap/pcipywrap.h @@ -8,7 +8,7 @@ typedef struct { void* ctx; int shared; -} Pcipywrap; +} pcipywrap; /*! * \brief Redirect pcilib standart log stream to exeption text. @@ -26,9 +26,9 @@ void redirect_logs_to_exeption(); */ PyObject* create_pcilib_instance(const char *fpga_device, const char *model); -Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model); -Pcipywrap *create_Pcipywrap(PyObject* ctx); -void delete_Pcipywrap(Pcipywrap *self); +pcipywrap *new_pcipywrap(const char* fpga_device, const char* model); +pcipywrap *create_pcipywrap(PyObject* ctx); +void delete_pcipywrap(pcipywrap *self); /*! * \brief Reads register value. Wrap for pcilib_read_register function. @@ -36,7 +36,7 @@ void delete_Pcipywrap(Pcipywrap *self); * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise * \return register value, can be integer or float type; NULL with exeption text, if failed. */ -PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const char *bank); +PyObject* pcipywrap_read_register(pcipywrap *self, const char *regname, const char *bank); /*! * \brief Writes value to register. Wrap for pcilib_write_register function. @@ -45,14 +45,14 @@ PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const ch * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ -PyObject* Pcipywrap_write_register(Pcipywrap *self, PyObject* val, const char *regname, const char *bank); +PyObject* pcipywrap_write_register(pcipywrap *self, PyObject* val, const char *regname, const char *bank); /*! * \brief Reads propety value. Wrap for pcilib_get_property function. * \param[in] prop property name (full name including path) * \return property value, can be integer or float type; NULL with exeption text, if failed. */ -PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop); +PyObject* pcipywrap_get_property(pcipywrap *self, const char *prop); /*! * \brief Writes value to property. Wrap for pcilib_set_property function. @@ -60,27 +60,27 @@ PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop); * \param[in] val Property value, that needs to be set. Can be int, float or string. * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ -PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop); -PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank); -PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank); -PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch); +PyObject* pcipywrap_set_property(pcipywrap *self, PyObject* val, const char *prop); +PyObject* pcipywrap_get_registers_list(pcipywrap *self, const char *bank); +PyObject* pcipywrap_get_register_info(pcipywrap *self, const char* reg,const char *bank); +PyObject* pcipywrap_get_property_list(pcipywrap *self, const char* branch); -PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size); +PyObject* pcipywrap_read_dma(pcipywrap *self, unsigned char dma, size_t size); -PyObject* Pcipywrap_lock_global(Pcipywrap *self); -void Pcipywrap_unlock_global(Pcipywrap *self); +PyObject* pcipywrap_lock_global(pcipywrap *self); +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/test_prop_mt.py + * Otherwise it will stuck with more than 1 threads. See /xml/test/test_prop4.py * for example. * \return 1, serialized to PyObject or NULL with exeption text, if failed. */ -PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id); +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_try_lock(pcipywrap *self, const char *lock_id); +PyObject* pcipywrap_unlock(pcipywrap *self, const char *lock_id); #endif /* PCIPYWRAP_H */ diff --git a/pywrap/pcipywrap.i b/pywrap/pcipywrap.i index 7749a67..5ee1bd1 100644 --- a/pywrap/pcipywrap.i +++ b/pywrap/pcipywrap.i @@ -8,9 +8,9 @@ extern void redirect_logs_to_exeption(); typedef struct { %extend { - Pcipywrap(const char* fpga_device = "/dev/fpga0", const char* model = NULL); - Pcipywrap(PyObject* ctx){return create_Pcipywrap(ctx);} - ~Pcipywrap(); + pcipywrap(const char* fpga_device = "/dev/fpga0", const char* model = NULL); + pcipywrap(PyObject* ctx){return create_pcipywrap(ctx);} + ~pcipywrap(); PyObject* read_register(const char *regname = NULL, const char *bank = NULL); PyObject* write_register(PyObject* val, const char *regname, const char *bank = NULL); @@ -30,4 +30,4 @@ typedef struct { PyObject* try_lock(const char *lock_id); PyObject* unlock(const char *lock_id); } -} Pcipywrap; +} pcipywrap; diff --git a/pywrap/test_pcilib.py b/pywrap/test_pcilib.py index aed2dc3..398d975 100644 --- a/pywrap/test_pcilib.py +++ b/pywrap/test_pcilib.py @@ -35,7 +35,7 @@ class test_pcilib(): #create pcilib_instance self.device = device self.model = model - self.pcilib = pcilib.Pcilib(device, model) + self.pcilib = pcilib.pcilib(device, model) self.num_threads = num_threads self.write_percentage = write_percentage self.register = register @@ -83,7 +83,7 @@ class test_pcilib(): try: while(1): val = long(random.randint(0, 8096)) - self.pcilib = pcilib.Pcilib(self.device, self.model) + self.pcilib = pcilib.pcilib(self.device, self.model) print(self.pcilib.get_property_list(self.branch)) print(self.pcilib.get_register_info(self.register)) print(self.pcilib.get_registers_list()) @@ -145,7 +145,7 @@ if __name__ == '__main__': type="string", dest="device", default=str('/dev/fpga0'), help="FPGA device (/dev/fpga0)") parser.add_option("-m", "--model", action="store", - type="string", dest="model", default=None, + type="string", dest="model", default=str('test'), help="Memory model (autodetected)") parser.add_option("-t", "--threads", action="store", type="int", dest="threads", default=150, |