From 5349163e93a107fdfea2ad58760f6149a8d749b0 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 5 Feb 2016 12:33:48 +0100 Subject: Add support for python script properties. Correct pcilib python wrapping. Update examples. Update cmakelists for work in shadow build mode. --- pcilib/xml.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 50aaa35..76ed38c 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -42,17 +42,19 @@ #include "view.h" #include "views/enum.h" #include "views/transform.h" +#include "views/script.h" #define BANKS_PATH ((xmlChar*)"/model/bank") /**< path to complete nodes of banks */ #define REGISTERS_PATH ((xmlChar*)"./register") /**< all standard registers nodes */ #define BIT_REGISTERS_PATH ((xmlChar*)"./field") /**< all bits registers nodes */ #define REGISTER_VIEWS_PATH ((xmlChar*)"./view") /**< supported register & field views */ -#define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform") /**< path to complete nodes of views */ +#define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform") /**< path to complete nodes of views */ +#define SCRIPT_VIEWS_PATH ((xmlChar*)"/model/script") /**< path to complete nodes of views */ #define ENUM_VIEWS_PATH ((xmlChar*)"/model/enum") /**< path to complete nodes of views */ #define ENUM_ELEMENTS_PATH ((xmlChar*)"./name") /**< all elements in the enum */ #define UNITS_PATH ((xmlChar*)"/model/unit") /**< path to complete nodes of units */ -#define UNIT_TRANSFORMS_PATH ((xmlChar*)"./transform") /**< all transforms of the unit */ +#define UNIT_TRANSFORMS_PATH ((xmlChar*)"./transform") /**< all transforms of the unit */ @@ -543,6 +545,51 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc return 0; } +static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { + int err; + xmlAttrPtr cur; + const char *value, *name; + pcilib_view_context_t *view_ctx; + + pcilib_access_mode_t mode = 0; + pcilib_script_view_description_t desc = {{0}}; + + desc.base.api = &pcilib_script_view_api; + desc.base.type = PCILIB_TYPE_DOUBLE; + desc.base.mode = PCILIB_ACCESS_RW; + desc.py_script_module = NULL; + desc.script_name = NULL; + + err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc); + if (err) return err; + + for (cur = node->properties; cur != NULL; cur = cur->next) { + if (!cur->children) continue; + if (!xmlNodeIsText(cur->children)) continue; + + name = (char*)cur->name; + value = (char*)cur->children->content; + if (!value) continue; + + if (!strcasecmp(name, "script")) { + //write script name to struct + desc.script_name = malloc(strlen(value)); + sprintf(desc.script_name, "%s", value); + //set read access + mode |= PCILIB_ACCESS_R; + } + } + + desc.base.mode &= mode; + + err = pcilib_add_views_custom(ctx, 1, (pcilib_view_description_t*)&desc, &view_ctx); + if (err) return err; + + view_ctx->xml = node; + return 0; +} + + static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { int err; xmlAttrPtr cur; @@ -822,14 +869,16 @@ static int pcilib_xml_create_unit(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDo */ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathContextPtr xpath) { int err; - xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL; + xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL, script_nodes = NULL; xmlNodeSetPtr nodeset; int i; bank_nodes = xmlXPathEvalExpression(BANKS_PATH, xpath); if (bank_nodes) transform_nodes = xmlXPathEvalExpression(TRANSFORM_VIEWS_PATH, xpath); - if (transform_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath); + if (transform_nodes) script_nodes = xmlXPathEvalExpression(SCRIPT_VIEWS_PATH, xpath); + if (script_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath); if (enum_nodes) unit_nodes = xmlXPathEvalExpression(UNITS_PATH, xpath); + if (!unit_nodes) { const unsigned char *expr = (enum_nodes?UNITS_PATH:(transform_nodes?ENUM_VIEWS_PATH:(bank_nodes?TRANSFORM_VIEWS_PATH:BANKS_PATH))); @@ -850,6 +899,14 @@ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathCon if (err) pcilib_error("Error (%i) creating unit", err); } } + + nodeset = script_nodes->nodesetval; + if(!xmlXPathNodeSetIsEmpty(nodeset)) { + for(i=0; i < nodeset->nodeNr; i++) { + err = pcilib_xml_create_script_view(ctx, xpath, doc, nodeset->nodeTab[i]); + if (err) pcilib_error("Error (%i) creating script transform", err); + } + } nodeset = transform_nodes->nodesetval; if (!xmlXPathNodeSetIsEmpty(nodeset)) { -- cgit v1.2.3 From e10e102b8b0ff3bf35f16b5276d56059d242e1fd Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Mon, 8 Feb 2016 11:55:33 +0100 Subject: Add support for setting register value to script transfrom. Add set_property and get_property functions to pcipywrap. Cleaning cmakelists from unused dependencies --- pcilib/xml.c | 60 +++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 76ed38c..2384e95 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -50,7 +50,6 @@ #define BIT_REGISTERS_PATH ((xmlChar*)"./field") /**< all bits registers nodes */ #define REGISTER_VIEWS_PATH ((xmlChar*)"./view") /**< supported register & field views */ #define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform") /**< path to complete nodes of views */ -#define SCRIPT_VIEWS_PATH ((xmlChar*)"/model/script") /**< path to complete nodes of views */ #define ENUM_VIEWS_PATH ((xmlChar*)"/model/enum") /**< path to complete nodes of views */ #define ENUM_ELEMENTS_PATH ((xmlChar*)"./name") /**< all elements in the enum */ #define UNITS_PATH ((xmlChar*)"/model/unit") /**< path to complete nodes of units */ @@ -575,8 +574,9 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath //write script name to struct desc.script_name = malloc(strlen(value)); sprintf(desc.script_name, "%s", value); - //set read access + //set read write access mode |= PCILIB_ACCESS_R; + mode |= PCILIB_ACCESS_W; } } @@ -589,7 +589,6 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath return 0; } - static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { int err; xmlAttrPtr cur; @@ -644,6 +643,46 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp return 0; } +static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { + int err; + xmlAttrPtr cur; + const char *name; + + int has_read_from_register = 0; + int has_write_to_register = 0; + int has_script = 0; + + //getting transform name in case of error + pcilib_view_description_t desc = {0}; + err = pcilib_xml_parse_view(ctx, xpath, doc, node, &desc); + + for (cur = node->properties; cur != NULL; cur = cur->next) { + if (!cur->children) continue; + if (!xmlNodeIsText(cur->children)) continue; + + name = (char*)cur->name; + + if (!strcasecmp(name, "read_from_register")) + has_read_from_register = 1; + if (!strcasecmp(name, "write_to_register")) + has_write_to_register = 1; + if (!strcasecmp(name, "script")) + has_script = 1; + } + + if (has_script && (has_read_from_register || has_write_to_register)) { + pcilib_error("Invalid transform group attributes specified in XML property (%s)." + "Transform could not contains both script and read_from_register" + " or write_to_register attributes at same time.", desc.name); + return PCILIB_ERROR_INVALID_DATA; + } + + if(has_script) + return pcilib_xml_create_script_view(ctx, xpath, doc, node); + else + return pcilib_xml_create_transform_view(ctx, xpath, doc, node); +} + static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_register_value_name_t *desc) { xmlAttr *cur; @@ -869,14 +908,13 @@ static int pcilib_xml_create_unit(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDo */ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathContextPtr xpath) { int err; - xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL, script_nodes = NULL; + xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL; xmlNodeSetPtr nodeset; int i; bank_nodes = xmlXPathEvalExpression(BANKS_PATH, xpath); if (bank_nodes) transform_nodes = xmlXPathEvalExpression(TRANSFORM_VIEWS_PATH, xpath); - if (transform_nodes) script_nodes = xmlXPathEvalExpression(SCRIPT_VIEWS_PATH, xpath); - if (script_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath); + if (transform_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath); if (enum_nodes) unit_nodes = xmlXPathEvalExpression(UNITS_PATH, xpath); @@ -899,19 +937,11 @@ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathCon if (err) pcilib_error("Error (%i) creating unit", err); } } - - nodeset = script_nodes->nodesetval; - if(!xmlXPathNodeSetIsEmpty(nodeset)) { - for(i=0; i < nodeset->nodeNr; i++) { - err = pcilib_xml_create_script_view(ctx, xpath, doc, nodeset->nodeTab[i]); - if (err) pcilib_error("Error (%i) creating script transform", err); - } - } nodeset = transform_nodes->nodesetval; if (!xmlXPathNodeSetIsEmpty(nodeset)) { for(i=0; i < nodeset->nodeNr; i++) { - err = pcilib_xml_create_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]); + err = pcilib_xml_create_script_or_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]); if (err) pcilib_error("Error (%i) creating register transform", err); } } -- cgit v1.2.3 From dce856c1a16098fe7a1df2338df60073261da94a Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 9 Feb 2016 17:32:11 +0100 Subject: Add write_register python wrap. Add no_set_check attribute to pcilib_view_t type --- pcilib/xml.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 2384e95..099da76 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -492,6 +492,8 @@ static int pcilib_xml_create_bank(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDo static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_view_description_t *desc) { xmlAttrPtr cur; const char *value, *name; + + int register_no_chk = 0; for (cur = node->properties; cur != NULL; cur = cur->next) { if (!cur->children) continue; @@ -539,7 +541,15 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc return PCILIB_ERROR_INVALID_DATA; } } - } + else if (!strcasecmp(name, "no_set_check")) { + if (!strcasecmp(value, "1")) + register_no_chk = 1; + } + } + if(register_no_chk) + { + desc->mode |= PCILIB_REGISTER_NO_CHK; + } return 0; } @@ -550,7 +560,7 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath const char *value, *name; pcilib_view_context_t *view_ctx; - pcilib_access_mode_t mode = 0; + pcilib_access_mode_t mode = PCILIB_REGISTER_NO_CHK; pcilib_script_view_description_t desc = {{0}}; desc.base.api = &pcilib_script_view_api; @@ -595,7 +605,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp const char *value, *name; pcilib_view_context_t *view_ctx; - pcilib_access_mode_t mode = 0; + pcilib_access_mode_t mode = PCILIB_REGISTER_NO_CHK; pcilib_transform_view_description_t desc = {{0}}; desc.base.api = &pcilib_transform_view_api; -- cgit v1.2.3 From d9a31945a92a76e590657dc2e65bb20b6ea95d90 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 11 Feb 2016 10:37:24 +0100 Subject: Merge script and transform view. Add get register and properties info to python wrap. --- pcilib/xml.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 099da76..f21480c 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -42,7 +42,7 @@ #include "view.h" #include "views/enum.h" #include "views/transform.h" -#include "views/script.h" +#include "py.h" #define BANKS_PATH ((xmlChar*)"/model/bank") /**< path to complete nodes of banks */ @@ -559,15 +559,15 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath xmlAttrPtr cur; const char *value, *name; pcilib_view_context_t *view_ctx; + - pcilib_access_mode_t mode = PCILIB_REGISTER_NO_CHK; - pcilib_script_view_description_t desc = {{0}}; + pcilib_access_mode_t mode = 0; + pcilib_transform_view_description_t desc = {{0}}; - desc.base.api = &pcilib_script_view_api; + desc.base.api = &pcilib_transform_view_api; desc.base.type = PCILIB_TYPE_DOUBLE; desc.base.mode = PCILIB_ACCESS_RW; - desc.py_script_module = NULL; - desc.script_name = NULL; + desc.script = NULL; err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc); if (err) return err; @@ -580,14 +580,16 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath value = (char*)cur->children->content; if (!value) continue; - if (!strcasecmp(name, "script")) { + if (!strcasecmp(name, "script")) + { //write script name to struct - desc.script_name = malloc(strlen(value)); - sprintf(desc.script_name, "%s", value); - //set read write access - mode |= PCILIB_ACCESS_R; - mode |= PCILIB_ACCESS_W; - } + char* script_name = malloc(strlen(value)); + sprintf(script_name, "%s", value); + + err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode); + if(err) return err; + mode |= PCILIB_REGISTER_NO_CHK; + } } desc.base.mode &= mode; @@ -611,6 +613,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp desc.base.api = &pcilib_transform_view_api; desc.base.type = PCILIB_TYPE_DOUBLE; desc.base.mode = PCILIB_ACCESS_RW; + desc.script = NULL; err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc); if (err) return err; @@ -641,7 +644,15 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp } desc.write_to_reg = value; if ((value)&&(*value)) mode |= PCILIB_ACCESS_W; - } + } else if (!strcasecmp(name, "script")) { + char* script_name = malloc(strlen(value)); + sprintf(script_name, "%s", value); + + err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode); + if(err) return err; + mode |= PCILIB_REGISTER_NO_CHK; + break; + } } desc.base.mode &= mode; @@ -654,6 +665,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp } static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { + /* int err; xmlAttrPtr cur; const char *name; @@ -688,9 +700,11 @@ static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathCon } if(has_script) + return pcilib_xml_create_script_view(ctx, xpath, doc, node); else - return pcilib_xml_create_transform_view(ctx, xpath, doc, node); + */ + return pcilib_xml_create_transform_view(ctx, xpath, doc, node); } -- cgit v1.2.3 From 76ee5a167add1c169a982ab59aa0544f827cb365 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 11 Feb 2016 12:28:37 +0100 Subject: Solve errors in serialing register_info function. Clear unused code --- pcilib/xml.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index f21480c..38bb917 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -554,53 +554,6 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc return 0; } -static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { - int err; - xmlAttrPtr cur; - const char *value, *name; - pcilib_view_context_t *view_ctx; - - - pcilib_access_mode_t mode = 0; - pcilib_transform_view_description_t desc = {{0}}; - - desc.base.api = &pcilib_transform_view_api; - desc.base.type = PCILIB_TYPE_DOUBLE; - desc.base.mode = PCILIB_ACCESS_RW; - desc.script = NULL; - - err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc); - if (err) return err; - - for (cur = node->properties; cur != NULL; cur = cur->next) { - if (!cur->children) continue; - if (!xmlNodeIsText(cur->children)) continue; - - name = (char*)cur->name; - value = (char*)cur->children->content; - if (!value) continue; - - if (!strcasecmp(name, "script")) - { - //write script name to struct - char* script_name = malloc(strlen(value)); - sprintf(script_name, "%s", value); - - err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode); - if(err) return err; - mode |= PCILIB_REGISTER_NO_CHK; - } - } - - desc.base.mode &= mode; - - err = pcilib_add_views_custom(ctx, 1, (pcilib_view_description_t*)&desc, &view_ctx); - if (err) return err; - - view_ctx->xml = node; - return 0; -} - static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { int err; xmlAttrPtr cur; -- cgit v1.2.3 From d7fc669bf0dbe37f46d2efec4940feb8504017c2 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 11 Feb 2016 14:24:01 +0100 Subject: Change no_set_check parameter name. Move Python wrap to separate directory. --- pcilib/xml.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 38bb917..ca07ad3 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -493,7 +493,7 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc xmlAttrPtr cur; const char *value, *name; - int register_no_chk = 0; + int register_incosistent = 0; for (cur = node->properties; cur != NULL; cur = cur->next) { if (!cur->children) continue; @@ -541,14 +541,17 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc return PCILIB_ERROR_INVALID_DATA; } } - else if (!strcasecmp(name, "no_set_check")) { - if (!strcasecmp(value, "1")) - register_no_chk = 1; + else if (!strcasecmp(name, "write_verification")) { + if (!strcasecmp(value, "0")) + { + register_incosistent = 1; + } } } - if(register_no_chk) + + if(register_incosistent) { - desc->mode |= PCILIB_REGISTER_NO_CHK; + desc->mode |= PCILIB_REGISTER_INCONSISTENT; } return 0; @@ -560,7 +563,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp const char *value, *name; pcilib_view_context_t *view_ctx; - pcilib_access_mode_t mode = PCILIB_REGISTER_NO_CHK; + pcilib_access_mode_t mode = PCILIB_REGISTER_INCONSISTENT; pcilib_transform_view_description_t desc = {{0}}; desc.base.api = &pcilib_transform_view_api; @@ -603,7 +606,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode); if(err) return err; - mode |= PCILIB_REGISTER_NO_CHK; + mode |= PCILIB_REGISTER_INCONSISTENT; break; } } -- cgit v1.2.3 From 55eab7196d0104c71e40136b3b22e9501d234e17 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 12 Feb 2016 14:43:20 +0100 Subject: 1. Cmakelists - move copy xml folder command to root file 2. - Move set python paths code to python module init funtction - pci.c move python module init block code after checking model to get paths before it runs. - Fix set python path code to work with PYTHONPATH - Update pci run script to work with PYTHONPATH - Fix python finalize code 3. Change pcilib_script_s interacting method. Now it stores in hash. 4. Change names of some fucntions to more unified ones 5. Remove old unused function pcilib_xml_create_script_or_transform_view 6. cli - disable reading register after set if write_verification flag is off 7. Remove uninformative error messages fro Python wrap. 8. - Server.py - add read/write property/register command handling - Add help message - Correcting paths --- pcilib/xml.c | 53 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index ca07ad3..f118491 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -569,7 +569,6 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp desc.base.api = &pcilib_transform_view_api; desc.base.type = PCILIB_TYPE_DOUBLE; desc.base.mode = PCILIB_ACCESS_RW; - desc.script = NULL; err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc); if (err) return err; @@ -601,10 +600,10 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp desc.write_to_reg = value; if ((value)&&(*value)) mode |= PCILIB_ACCESS_W; } else if (!strcasecmp(name, "script")) { - char* script_name = malloc(strlen(value)); - sprintf(script_name, "%s", value); + desc.module = malloc(strlen(value)); + sprintf(desc.module, "%s", value); - err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode); + err = pcilib_py_init_script(ctx, desc.module, &mode); if(err) return err; mode |= PCILIB_REGISTER_INCONSISTENT; break; @@ -620,50 +619,6 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp return 0; } -static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) { - /* - int err; - xmlAttrPtr cur; - const char *name; - - int has_read_from_register = 0; - int has_write_to_register = 0; - int has_script = 0; - - //getting transform name in case of error - pcilib_view_description_t desc = {0}; - err = pcilib_xml_parse_view(ctx, xpath, doc, node, &desc); - - for (cur = node->properties; cur != NULL; cur = cur->next) { - if (!cur->children) continue; - if (!xmlNodeIsText(cur->children)) continue; - - name = (char*)cur->name; - - if (!strcasecmp(name, "read_from_register")) - has_read_from_register = 1; - if (!strcasecmp(name, "write_to_register")) - has_write_to_register = 1; - if (!strcasecmp(name, "script")) - has_script = 1; - } - - if (has_script && (has_read_from_register || has_write_to_register)) { - pcilib_error("Invalid transform group attributes specified in XML property (%s)." - "Transform could not contains both script and read_from_register" - " or write_to_register attributes at same time.", desc.name); - return PCILIB_ERROR_INVALID_DATA; - } - - if(has_script) - - return pcilib_xml_create_script_view(ctx, xpath, doc, node); - else - */ - return pcilib_xml_create_transform_view(ctx, xpath, doc, node); -} - - static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_register_value_name_t *desc) { xmlAttr *cur; char *value, *name; @@ -921,7 +876,7 @@ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathCon nodeset = transform_nodes->nodesetval; if (!xmlXPathNodeSetIsEmpty(nodeset)) { for(i=0; i < nodeset->nodeNr; i++) { - err = pcilib_xml_create_script_or_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]); + err = pcilib_xml_create_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]); if (err) pcilib_error("Error (%i) creating register transform", err); } } -- cgit v1.2.3 From 1b3342649294c6ce99aeb82664a29eac47687ee5 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 12 Feb 2016 17:50:57 +0100 Subject: 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 --- pcilib/xml.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'pcilib/xml.c') 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); -- cgit v1.2.3 From ed9d8f285f4d81e1ce8bb5e7a5b9e471a73c1590 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 16 Feb 2016 16:30:40 +0100 Subject: 1. Add python thread initialization to pcilib_init_py() -Fix pcilib_script_run_func() work in multithread mode 2. pcilib_close() - Move free_py() code after free views to make view destructors work properly 3. Move script hash to pcilib_py_s 4. Move pcilib_get_logger() pcilib_get_logger_min_prio() and pcilib_get_logger_argument() declarations to error.h 5. Refactor pcilib_get_value_as_pyobject pcilib_set_value_from_pyobject to more unified form 6. Add more memory checks. Fix some string memory allocations. 7. Refactor pcilib_py_s member names. 8. Merge pcilib_script_read() and pcilib_script_write() to pcilib_script_run_func() 9. Update test_pywrap views scripts --- pcilib/xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index 4e95437..adca34e 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -600,7 +600,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp desc.write_to_reg = value; if ((value)&&(*value)) mode |= PCILIB_ACCESS_W; } else if (!strcasecmp(name, "script")) { - desc.module = malloc(strlen(value)); + desc.module = strdup(value); sprintf(desc.module, "%s", value); break; } -- cgit v1.2.3 From 3269dce32883e14b45cc490a0cc0037b4c808a68 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Wed, 17 Feb 2016 11:01:22 +0100 Subject: 1. Add cmake BUILD_PYTHON_MODULES option. 2. Rename log options getting functions. 3. py: - pcilib_init_py() - extract pcilib_py_add_script_dir() - pcilib_py_init_script() - extract view-specialized code to pcilib_py_get_transform_script_properties() 3. pcilib_open(): - move pcilib_init_py() to previous position. - add extract pcilib_py_add_script_dir() 4. pcilib_script_s - change hash key. Now it is (const char*) and contains script file name with extension 5. pcipywrap: - Add pcipywrap.h to remove swig generated file complile warnings - remove -includeall swig flag to prevent crash in multi-thread scripts - change set python expetion mechanic --- pcilib/xml.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pcilib/xml.c') diff --git a/pcilib/xml.c b/pcilib/xml.c index adca34e..35721aa 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -600,8 +600,7 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp desc.write_to_reg = value; if ((value)&&(*value)) mode |= PCILIB_ACCESS_W; } else if (!strcasecmp(name, "script")) { - desc.module = strdup(value); - sprintf(desc.module, "%s", value); + desc.module = value; break; } } -- cgit v1.2.3