From 2c2a714e0615d6aff3773fabfd3b93e8672a40a1 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Mon, 22 Feb 2016 12:21:04 +0100 Subject: Add device html server --- pywrap/pcipywrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pywrap/pcipywrap.c') diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index 11e3ce7..df5f194 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -303,7 +303,7 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist if(listItem.values[j].description) pcilib_pydict_set_item(valuesItem, - PyString_FromString("name"), + PyString_FromString("description"), PyString_FromString(listItem.values[j].description)); pcilib_pylist_append(values, valuesItem); -- cgit v1.2.3 From 5085fbed88cec0bdc1b339daf9cd888e184cc32c Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Wed, 24 Feb 2016 14:57:16 +0100 Subject: 1. Http server add tree view 2. Pcipywrap - add lock function wraps - add dma read wrap 3. Api server implement locking functionality --- pywrap/pcipywrap.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'pywrap/pcipywrap.c') diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index df5f194..a22dea9 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -1,4 +1,5 @@ #include "pcipywrap.h" +#include "locking.h" char* full_log = NULL; @@ -501,3 +502,104 @@ PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch) return pyList; } + +PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size) +{ + int err; + void* buf = NULL; + size_t real_size; + + err = pcilib_read_dma(self->ctx, dma, (uintptr_t)NULL, size, buf, &real_size); + if(err) + { + set_python_exception("Failed pcilib_read_dma", err); + return NULL; + } + + + PyObject* py_buf = PyByteArray_FromStringAndSize((const char*)buf, real_size); + if(buf) + free(buf); + + return py_buf; +} + +PyObject* Pcipywrap_lock_global(Pcipywrap *self) +{ + int err; + + err = pcilib_lock_global(self->ctx); + if(err) + { + set_python_exception("Failed pcilib_lock_global"); + return NULL; + } + + return PyInt_FromLong((long)1); +} + +void Pcipywrap_unlock_global(Pcipywrap *self) +{ + pcilib_unlock_global(self->ctx); + return; +} + +PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id) +{ + pcilib_lock_t* lock = pcilib_get_lock(self->ctx, + PCILIB_LOCK_FLAG_PERSISTENT, + lock_id); + if(!lock) + { + set_python_exception("Failed pcilib_get_lock"); + return NULL; + } + + + int err = pcilib_lock(lock); + if(err) + { + set_python_exception("Failed pcilib_lock"); + return NULL; + } + + return PyInt_FromLong((long)1); +} + +PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id) +{ + pcilib_lock_t* lock = pcilib_get_lock(self->ctx, + PCILIB_LOCK_FLAGS_DEFAULT, + lock_id); + if(!lock) + { + set_python_exception("Failed pcilib_get_lock"); + return NULL; + } + + int err = pcilib_try_lock(lock); + if(err) + { + set_python_exception("Failed pcilib_try_lock"); + return NULL; + } + + return PyInt_FromLong((long)1); +} + +PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id) +{ + pcilib_lock_t* lock = pcilib_get_lock(self->ctx, + PCILIB_LOCK_FLAGS_DEFAULT, + lock_id); + if(!lock) + { + set_python_exception("Failed pcilib_get_lock"); + return NULL; + } + + pcilib_unlock(lock); + return PyInt_FromLong((long)1); +} + + -- cgit v1.2.3 From ed7a7ff66c64cc2e164070865306e7d79652063a Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 25 Feb 2016 09:22:31 +0100 Subject: Set value description content to NULL in pcilib_xml_parse_value_name --- pywrap/pcipywrap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pywrap/pcipywrap.c') diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c index fe53966..64e059a 100644 --- a/pywrap/pcipywrap.c +++ b/pywrap/pcipywrap.c @@ -232,6 +232,7 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist PyString_FromString("bank"), PyString_FromString(listItem.bank)); + //serialize modes PyObject* modes = PyList_New(0); @@ -278,8 +279,9 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist if(listItem.values) { - PyObject* values = PyList_New(0); + PyObject* values = PyList_New(0); + for (int j = 0; listItem.values[j].name; j++) { PyObject* valuesItem = PyDict_New(); @@ -301,12 +303,13 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist pcilib_pydict_set_item(valuesItem, PyString_FromString("name"), PyString_FromString(listItem.values[j].name)); - if(listItem.values[j].description) + { pcilib_pydict_set_item(valuesItem, PyString_FromString("description"), PyString_FromString(listItem.values[j].description)); - + + } pcilib_pylist_append(values, valuesItem); } @@ -316,6 +319,7 @@ PyObject * pcilib_convert_register_info_to_pyobject(pcilib_t* ctx, pcilib_regist } return pylistItem; + } Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model) @@ -456,11 +460,12 @@ 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 < 10/*((pcilib_t*)self->ctx)->num_reg*/; i++) + 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; @@ -544,7 +549,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_FLAG_PERSISTENT, + PCILIB_LOCK_FLAGS_DEFAULT, lock_id); if(!lock) { -- cgit v1.2.3