summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-12 17:50:57 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-12 17:50:57 +0100
commit1b3342649294c6ce99aeb82664a29eac47687ee5 (patch)
treefb34ee89e1edc4dd3e27c2a1416a435192c7ae6b /pcilib
parent55eab7196d0104c71e40136b3b22e9501d234e17 (diff)
downloadpcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.gz
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.bz2
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.xz
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.zip
Move python module init code to transfom view constructor
Update python logger and python exeption messages Change serialization method in create_pcilib_instance set_pcilib functions
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/pci.c3
-rw-r--r--pcilib/py.c12
-rw-r--r--pcilib/view.c2
-rw-r--r--pcilib/view.h2
-rw-r--r--pcilib/xml.c5
5 files changed, 10 insertions, 14 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index cc2a67a..c38097f 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -192,12 +192,14 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
return NULL;
}
+
xmlerr = pcilib_init_xml(ctx, ctx->model);
if ((xmlerr)&&(xmlerr != PCILIB_ERROR_NOTFOUND)) {
pcilib_error("Error (%i) initializing XML subsystem for model %s", xmlerr, ctx->model);
pcilib_close(ctx);
return NULL;
}
+
// We have found neither standard model nor XML
if ((err)&&(xmlerr)) {
@@ -219,7 +221,6 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
pcilib_close(ctx);
return NULL;
}
-
err = pcilib_init_event_engine(ctx);
if (err) {
pcilib_error("Error (%i) initializing event engine\n", err);
diff --git a/pcilib/py.c b/pcilib/py.c
index 7b1ae79..e448d21 100644
--- a/pcilib/py.c
+++ b/pcilib/py.c
@@ -244,11 +244,11 @@ void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val)
switch(val->type)
{
case PCILIB_TYPE_INVALID:
- pcilib_error("Invalid register output type (PCILIB_TYPE_INVALID)");
+ pcilib_warning("Invalid register output type (PCILIB_TYPE_INVALID)");
return NULL;
case PCILIB_TYPE_STRING:
- pcilib_error("Invalid register output type (PCILIB_TYPE_STRING)");
+ pcilib_warning("Invalid register output type (PCILIB_TYPE_STRING)");
return NULL;
case PCILIB_TYPE_LONG:
@@ -258,7 +258,7 @@ void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val)
if(err)
{
- pcilib_error("Failed: pcilib_get_value_as_int (%i)", err);
+ pcilib_error("Failed: pcilib_get_value_as_int (%i)", err);
return NULL;
}
return (PyObject*)PyInt_FromLong((long) ret);
@@ -271,14 +271,14 @@ void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val)
if(err)
{
- pcilib_error("Failed: pcilib_get_value_as_int (%i)", err);
+ pcilib_error("Failed: pcilib_get_value_as_int (%i)", err);
return NULL;
}
return (PyObject*)PyFloat_FromDouble((double) ret);
}
default:
- pcilib_error("Invalid register output type (unknown)");
+ pcilib_warning("Invalid register output type (unknown)");
return NULL;
}
}
@@ -360,7 +360,7 @@ int pcilib_py_init_script(pcilib_t *ctx, char* module_name, pcilib_access_mode_t
//setting pcilib_t instance
PyObject_CallMethodObjArgs(pcipywrap_module,
PyUnicode_FromString("set_pcilib"),
- PyByteArray_FromStringAndSize((const char*)&ctx, sizeof(pcilib_t*)),
+ PyCObject_FromVoidPtr(ctx, NULL),
NULL);
}
diff --git a/pcilib/view.c b/pcilib/view.c
index e31fdba..797f4ae 100644
--- a/pcilib/view.c
+++ b/pcilib/view.c
@@ -70,7 +70,7 @@ int pcilib_add_views_custom(pcilib_t *ctx, size_t n, const pcilib_view_descripti
}
if (v->api->init)
- view_ctx = v->api->init(ctx);
+ view_ctx = v->api->init(ctx, v);
else {
view_ctx = (pcilib_view_context_t*)malloc(sizeof(pcilib_view_context_t));
if (view_ctx) memset(view_ctx, 0, sizeof(pcilib_view_context_t));
diff --git a/pcilib/view.h b/pcilib/view.h
index 33d4d96..1a1d277 100644
--- a/pcilib/view.h
+++ b/pcilib/view.h
@@ -19,7 +19,7 @@ typedef enum {
typedef struct {
pcilib_version_t version; /**< Version */
size_t description_size; /**< The actual size of the description */
- pcilib_view_context_t *(*init)(pcilib_t *ctx); /**< Optional function which should allocated context used by read/write functions */
+ pcilib_view_context_t *(*init)(pcilib_t *ctx, const pcilib_view_description_t *desc); /**< Optional function which should allocated context used by read/write functions */
void (*free)(pcilib_t *ctx, pcilib_view_context_t *view); /**< Optional function which should clean context */
void (*free_description)(pcilib_t *ctx, pcilib_view_description_t *view); /**< Optional function which shoud clean required parts of the extended description if non-static memory was used to initialize it */
int (*read_from_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t regval, pcilib_value_t *val); /**< Function which computes view value based on the passed the register value (view-based properties should not use register value) */
diff --git a/pcilib/xml.c b/pcilib/xml.c
index f118491..4e95437 100644
--- a/pcilib/xml.c
+++ b/pcilib/xml.c
@@ -602,14 +602,9 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp
} else if (!strcasecmp(name, "script")) {
desc.module = malloc(strlen(value));
sprintf(desc.module, "%s", value);
-
- err = pcilib_py_init_script(ctx, desc.module, &mode);
- if(err) return err;
- mode |= PCILIB_REGISTER_INCONSISTENT;
break;
}
}
-
desc.base.mode &= mode;
err = pcilib_add_views_custom(ctx, 1, (pcilib_view_description_t*)&desc, &view_ctx);