From 8774733b212914ed7ac959aa9a68a7254bd0a2f5 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 5 May 2016 15:39:41 -0600 Subject: [PATCH 01/29] Reworked external interface. The interface has calls to validate the configuration and calls that write the configuration to a boards. --- src/libs/ultimarc.c | 205 +++++++++++++++++++++++++------------------- src/libs/ultimarc.h | 45 +++++++--- 2 files changed, 154 insertions(+), 96 deletions(-) diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index 6a6d99c..fa08072 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -6,7 +6,7 @@ Copyright : Copyright 2014 Robert Abram, Katie Snow Description : Ultimarc main configuration library ============================================================================ -*/ + */ /* Unix */ #include @@ -24,134 +24,167 @@ #include "ipacultimate.h" #include "dbg.h" - -void loadUltimarcConfigurations (int argc, char **argv) +int +ulValidateConfig (json_object* bcfg, ulobject* ulobj) { - int idx; - int inner_idx; - - const char* fileStr = NULL; + int retCode = 0; - json_object *jobj = NULL; - json_object *innerobj = NULL; - json_object *item = NULL; - - for (idx = 1; idx < argc; ++idx) + if (bcfg) { - jobj = json_object_from_file (argv[idx]); - if (jobj) - { - log_info ("Loading %s...", argv[idx]); + retCode = ulGetProdAndVersion (bcfg, ulobj); - if (json_object_object_get_ex(jobj, "configurations", &innerobj)) + if (retCode == 0) + { + if ((ulobj->ipac = isIPACConfig (ulobj->pStr, ulobj->version, bcfg)) + || (ulobj->ultimate = isIPACUltimateConfig (ulobj->pStr, + ulobj->version, bcfg)) + || (ulobj->pacDrive = isPACDriveConfig (ulobj->pStr, ulobj->version, + bcfg)) || (ulobj->pacLED = + isPACLED64Config (ulobj->pStr, ulobj->version, bcfg)) + || (ulobj->ultistik = isUltistikConfig (ulobj->pStr, ulobj->version, + bcfg))) { - printf ("\n"); - for (inner_idx = 0; inner_idx < json_object_array_length(innerobj); ++ inner_idx) - { - item = json_object_array_get_idx(innerobj, inner_idx); - fileStr = json_object_get_string(item); - item = json_object_from_file (fileStr); - - if (item) - { - log_info ("Loading %s...", fileStr); - updateUltimarcBoard(item); - } - else - { - log_err ("%s. Format invalid\n", fileStr); - } - } + log_info("Configuration is %s. [Validated]", ulobj->pStr); } else { - updateUltimarcBoard(jobj); + log_err("Configuration is '%s'. [Not validated].", ulobj->pStr); } } else { - log_err ("%s. Format invalid\n", argv[idx]); + log_err("Configuration is '%s'. [Not validated].", ulobj->pStr); } } + else + { + retCode = -1; + log_err("JSON format invalid"); + } + + return retCode; } -bool updateUltimarcBoard (json_object* jobj) +int +ulValidateConfigFileStr (const char* file, ulobject* ulobj) { - bool ret = false; + json_object *bcfg = json_object_from_file (file); + + return ulValidateConfig (bcfg, ulobj); +} - const char* prodstr = NULL; - int version = 0; +int +ulWriteToBoard (json_object* bcfg, ulobject* ulobj) +{ + int retCode = 0; + + if (bcfg && ulobj) + { + if (ulobj->ipac) + { + retCode = updateBoardIPAC (bcfg); + } + else if (ulobj->ultimate) + { + log_info("Updating IPAC Ultimate board..."); + retCode = updateBoardIPacUltimate (bcfg); + } + else if (ulobj->pacDrive) + { + log_info("Updating PAC Drive board..."); + retCode = updateBoardPacDrive (bcfg); + } + else if (ulobj->pacLED) + { + log_info("Updating PAC LED 64 board..."); + retCode = updateBoardPacLED (bcfg); + } + else if (ulobj->ultistik) + { + log_info("Updating Ultistik board..."); + retCode = updateBoardULTISTIK (bcfg); + } + + if (retCode) + { + log_info("Board update successful."); + } + else + { + log_info("Board update failed."); + } + } + else + { + retCode = -1; + log_info("Board update failed."); + } + + return retCode; +} + +int +ulWriteToBoardFileStr (const char* file, ulobject* ulobj) +{ + json_object *bcfg = json_object_from_file (file); + + return ulWriteToBoard (bcfg, ulobj); +} + +int +ulGetProdAndVersion (json_object* jobj, ulobject* ulobj) +{ + int retCode = 0; json_object* prodobj = NULL; json_object* verobj = NULL; - if (json_object_object_get_ex(jobj, "product", &prodobj) && - json_object_get_type(prodobj) == json_type_string) + if (jobj && ulobj) { - if (json_object_object_get_ex(jobj, "version", &verobj) && - json_object_get_type(verobj) == json_type_int) + if (json_object_object_get_ex (jobj, "product", &prodobj)) { - prodstr = json_object_get_string(prodobj); - version = json_object_get_int(verobj); - - if (isIPACConfig(prodstr, version, jobj)) - { - ret = updateBoardIPAC(jobj); - } - else if (isIPACUltimateConfig(prodstr, version, jobj)) - { - log_info ("Updating IPAC Ultimate board..."); - ret = updateBoardIPacUltimate(jobj); - } - else if (isPACDriveConfig(prodstr, version, jobj)) - { - log_info ("Updating PAC Drive board..."); - ret = updateBoardPacDrive(jobj); - } - else if (isPACLED64Config(prodstr, version, jobj)) + if (json_object_get_type (prodobj) == json_type_string) { - log_info ("Updating PAC LED 64 board..."); - ret = updateBoardPacLED(jobj); + ulobj->pStr = json_object_get_string (prodobj); } - else if (isUltistikConfig(prodstr, version, jobj)) + else { - log_info ("Updating Ultistik board..."); - ret = updateBoardULTISTIK(jobj); + log_err("'product' is not defined as a string"); + ulobj->pStr = ""; + retCode = 1; } } else { - if (json_object_object_get_ex(jobj, "version", &verobj)) + log_err("'product' is not defined in the configuration file"); + ulobj->pStr = ""; + retCode = 1; + } + + if (json_object_object_get_ex (jobj, "version", &verobj)) + { + if (json_object_get_type (verobj) == json_type_int) { - log_err ("'version' is not defined as a integer"); + ulobj->version = json_object_get_int (verobj); } else { - log_err ("'version' is not defined in the configuration file"); + log_err("'version' is not defined as a integer"); + ulobj->version = -1; + retCode = 1; } } - } - else - { - if (json_object_object_get_ex(jobj, "product", &prodobj)) - { - log_err ("'product' is not defined as a string"); - } else { - log_err ("'product' is not defined in the configuration file"); + log_err("'version' is not defined in the configuration file"); + ulobj->version = -1; + retCode = 1; } } - - if (ret) - { - log_info ("Update done.\n"); - } else { - log_info ("Update failed!\n"); + log_err("JSON_Object is null"); } - json_object_put(jobj); - return ret; + return retCode; } diff --git a/src/libs/ultimarc.h b/src/libs/ultimarc.h index 9d8031c..1f81364 100644 --- a/src/libs/ultimarc.h +++ b/src/libs/ultimarc.h @@ -6,30 +6,55 @@ Copyright : Copyright 2014 Robert Abram, Katie Snow Description : Ultimarc main configuration library ============================================================================ -*/ + */ #ifndef __ULTIMARC_H_ #define __ULTIMARC_H_ - /* Unix */ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif typedef struct json_object json_object; -extern void loadUltimarcConfigurations(int argc, char **argv); +typedef struct ulobject +{ + const char* pStr; + int version; + bool ipac; + bool ultimate; + bool pacDrive; + bool pacLED; + bool ultistik; +} ulobject; + +/** + * ulValidateConfig + * Validates the configuration + */ +extern int +ulValidateConfig (json_object* bcfg, ulobject* ulobj); +extern int +ulValidateConfigFileStr (const char* file, ulobject* ulobj); + +/** + * ulWriteToBoard + * Writes the configuration provided out to the Ultimarc hardware + */ +extern int +ulWriteToBoard (json_object* bcfg, ulobject* ulobj); +extern int +ulWriteToBoardFileStr (const char* file, ulobject* ulobj); -/* - * updateUltimarcBoard - * Updates a board. The board is selected based on the json file contents - * Paramter: json object - * Returns: true if successfully updated a board, false otherwise +/** + * Populates the ulobj with the product and version in the json_object */ -bool updateUltimarcBoard(json_object* jobj); +int +ulGetProdAndVersion (json_object* jobj, ulobject* ulobj); #ifdef __cplusplus } From 9b3be75ca28c85d1b0d9e999a120eb195ae2d501 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 5 May 2016 15:43:03 -0600 Subject: [PATCH 02/29] Renamed command line tool from umtool.out to umtool. Updated .gitignore with umtool. --- .gitignore | 1 + src/umtool/Makefile.am | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0df5f09..e0709fa 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ *.dylib # Executables +umtool *.exe *.out *.app diff --git a/src/umtool/Makefile.am b/src/umtool/Makefile.am index 61aee7a..363589e 100644 --- a/src/umtool/Makefile.am +++ b/src/umtool/Makefile.am @@ -4,8 +4,8 @@ AM_CFLAGS = $(JSON_CFLAGS) $(LIBUSB_CFLAGS) AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS) -bin_PROGRAMS=umtool.out -umtool_out_SOURCES=main.c -umtool_out_CPPFLAGS = -I$(top_srcdir)/src -umtool_out_LDADD = ../libs/libultimarc-0.1.la +bin_PROGRAMS=umtool +umtool_SOURCES=main.c +umtool_CPPFLAGS = -I$(top_srcdir)/src +umtool_LDADD = ../libs/libultimarc-0.1.la From 9c3342f65d4a020e19ca0154671f5cf46de40754 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 5 May 2016 17:22:14 -0600 Subject: [PATCH 03/29] Reworked argument checking and use new library functions. --- src/umtool/main.c | 65 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/src/umtool/main.c b/src/umtool/main.c index f303f32..62b42c1 100644 --- a/src/umtool/main.c +++ b/src/umtool/main.c @@ -14,25 +14,48 @@ #include -int main(int argc, char **argv) { - int idx; - int retVal; - - for (idx = 1; idx < argc; ++idx) - { - if (strcmp(argv[idx], "-h") == 0 || - strcmp(argv[idx], "--help") == 0) - { - printf ("umtool [-h] [--help] [config files...]\n"); - printf ("-h | --help\t\t Prints this information\n"); - printf ("config files\t\t JSON Configuration files to be processed\n"); - retVal = EXIT_SUCCESS; - goto exit; - } - } - - loadUltimarcConfigurations(argc, argv); - - exit: - return retVal; +typedef struct args +{ + int help; +} args; + +int +main (int argc, char **argv) +{ + int idx; + int retVal; + + ulobject ulObj; + + args args; + args.help = 0; + + for (idx = 1; idx < argc; ++idx) + { + if (strcmp (argv[idx], "-h") == 0 || strcmp (argv[idx], "--help") == 0) + args.help = 1; + } + + if (args.help) + { + printf ("umtool [-h] [--help] [-m] [--m] [config files...]\n"); + printf ("-h | --help\t\t Prints this information\n"); + printf ("-m | --m\t\t File provided has multiple configuration\n"); + printf ("config files\t\t JSON Configuration files to be processed\n"); + retVal = EXIT_SUCCESS; + goto exit; + } + + for (idx = 1; idx < argc; ++idx) + { + printf ("Loading %s...\n", argv[idx]); + retVal = ulValidateConfigFileStr (argv[idx], &ulObj); + + if (retVal == 0) + { + retVal = ulWriteToBoardFileStr(argv[idx], &ulObj); + } + } + + exit: return retVal; } From 80dbd051e6a8d3b2976b9adc7f0254d6cc0eabcc Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 10 May 2016 22:21:50 -0600 Subject: [PATCH 04/29] Add new file to library. A structure for holding board information that is common between all the boards. --- src/libs/Makefile.am | 4 +-- src/libs/ulboard.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ src/libs/ulboard.h | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 src/libs/ulboard.c create mode 100644 src/libs/ulboard.h diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am index c604c94..f78e874 100644 --- a/src/libs/Makefile.am +++ b/src/libs/Makefile.am @@ -5,8 +5,8 @@ AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS) lib_LTLIBRARIES = libultimarc-0.1.la -libultimarc_0_1_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c +libultimarc_0_1_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c otherincludedir = $(includedir)/ultimarc -otherinclude_HEADERS = ultimarc.h ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h +otherinclude_HEADERS = ultimarc.h ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h ulboard.h diff --git a/src/libs/ulboard.c b/src/libs/ulboard.c new file mode 100644 index 0000000..dccfd98 --- /dev/null +++ b/src/libs/ulboard.c @@ -0,0 +1,65 @@ +/* + ============================================================================ + Name : ulboard.c + Author : Katie Snow + Version : + Copyright : Copyright 2014 Robert Abram, Katie Snow + Description : Ultimarc board type and version + ============================================================================ + */ +#include + +#include "ulboard.h" +#include "dbg.h" + +#define ULSIZE(a) (sizeof(a)/sizeof(a[0])) +const char* ulBoardTypeName[] = + { "null", "IPAC2", "IPAC4", "JPAC", "MINIPAC", "ULTIMATE", + "PACDRIVE", "PACLED64", "ULTISTIK" }; + +const char* ulBoardVersionName[] = + { "null", "PRE2015", "2015" }; + +const char* +ulBoardTypeToString (ulboard_type bType) +{ + int _bType = (int) bType; + + if (_bType < 0 || _bType >= (int)ULSIZE(ulBoardTypeName)) + { + log_err ("Board type %d is out of range [0,%d]", bType, + (int)ULSIZE(ulBoardTypeName)); + return NULL; + } + + return ulBoardTypeName[_bType]; +} + +ulboard_type +ulStringToBoardType (const char* bStr) +{ + int pos = 0; + for (pos = 0; pos < (int)ULSIZE(ulBoardTypeName); pos++) + { + debug ("'%s' = '%s'", bStr, ulBoardTypeName[pos]); + if (!strcasecmp (bStr, ulBoardTypeName[pos])) + { + return (ulboard_type) pos; + } + } + + return ulboard_type_null; +} + +ulboard_version +ulIntToBoardVersion (int bVersion) +{ + if (bVersion < 0 || bVersion >= (int)ULSIZE(ulBoardVersionName)) + { + log_err ("Board version %d is out of range [0,%d]", bVersion, + (int)ULSIZE(ulBoardVersionName)); + return ulboard_version_null; + } + + return (ulboard_version) bVersion; +} diff --git a/src/libs/ulboard.h b/src/libs/ulboard.h new file mode 100644 index 0000000..314098d --- /dev/null +++ b/src/libs/ulboard.h @@ -0,0 +1,59 @@ +/* + ============================================================================ + Name : ulboard.h + Author : Katie Snow + Version : + Copyright : Copyright 2014 Robert Abram, Katie Snow + Description : Ultimarc board types and structures + ============================================================================ + */ + +#ifndef ULTIMARCBOARD_H_ +#define ULTIMARCBOARD_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* All the supported board types */ +typedef enum ulboard_type +{ + ulboard_type_null, + ulboard_type_ipac2, + ulboard_type_ipac4, + ulboard_type_jpac, + ulboard_type_minipac, + ulboard_type_ultimate, + ulboard_type_pacDrive, + ulboard_type_pacLED, + ulboard_type_ultistik +} ulboard_type; + +/* Supported versions */ +typedef enum ulboard_version +{ + ulboard_version_null, + ulboard_version_pre2015, + ulboard_version_2015 +} ulboard_version; + +/* Data structure */ +typedef struct ulboard +{ + ulboard_type type; + ulboard_version version; +} ulboard; + +extern const char* ulBoardTypeToString (ulboard_type bType); + +extern ulboard_type ulStringToBoardType (const char* bStr); + +extern ulboard_version ulIntToBoardVersion (int bVersion); + +#ifdef __cplusplus +} +#endif + + +#endif /* ULTIMARCBOARD_H_ */ From 2e7b79b7469657afebd3a4f3c63db821251a1e62 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 12 May 2016 21:52:57 -0600 Subject: [PATCH 05/29] Use the ulboard structures Use the ulboard structures throughout the external functions and verification function for the IPAC boards. --- src/libs/ipac.c | 65 +++++++++++++++++++----------------------- src/libs/ipac.h | 26 ++++------------- src/libs/ultimarc.c | 69 +++++++++++++++++++++++---------------------- src/libs/ultimarc.h | 21 ++++---------- src/umtool/main.c | 7 +++-- 5 files changed, 80 insertions(+), 108 deletions(-) diff --git a/src/libs/ipac.c b/src/libs/ipac.c index 844cfd0..aa44047 100644 --- a/src/libs/ipac.c +++ b/src/libs/ipac.c @@ -18,44 +18,37 @@ #include /* Local */ +#include "ulboard.h" #include "common.h" #include "ipac.h" #include "ipacseries.h" #include "dbg.h" -struct ipac pIPAC; - -bool isIPACConfig (const char* prodStr, int version, json_object* jobj) +bool isIPACConfig (json_object* jobj, ulboard* board) { bool isBoardCfg = false; - pIPAC.version = version; - pIPAC.ipac2 = (strcmp(prodStr, IPAC_STR_2) == 0); - pIPAC.minipac = (strcmp(prodStr, IPAC_STR_M) == 0); - pIPAC.ipac4 = (strcmp(prodStr, IPAC_STR_4) == 0); - pIPAC.jpac = (strcmp(prodStr, JPAC_STR) == 0); - - if (pIPAC.ipac2) +if (board->type == ulboard_type_ipac2) { - isBoardCfg = validateIPACData(jobj, 32); + isBoardCfg = validateIPACData(jobj, 32, board); } - else if (pIPAC.ipac4) + else if (board->type == ulboard_type_ipac4) { - isBoardCfg = validateIPAC4Data(jobj); + isBoardCfg = validateIPAC4Data(jobj, board); } - else if (pIPAC.minipac) + else if (board->type == ulboard_type_minipac) { - isBoardCfg = validateIPACData(jobj, 32); + isBoardCfg = validateIPACData(jobj, 32, board); } - else if (pIPAC.jpac) + else if (board->type == ulboard_type_jpac) { - isBoardCfg = validateIPACData(jobj, 30); + isBoardCfg = validateIPACData(jobj, 30, board); } return isBoardCfg; } -bool validateIPACData(json_object* jobj, int size) +bool validateIPACData(json_object* jobj, int size, ulboard* board) { bool valid = true; json_object* tmp = NULL; @@ -119,12 +112,12 @@ bool validateIPACData(json_object* jobj, int size) } } - valid = validateIPACMacros(jobj, valid); + valid = validateIPACMacros(jobj, valid, board); return valid; } -bool validateIPAC4Data (json_object* jobj) +bool validateIPAC4Data (json_object* jobj, ulboard* board) { bool valid = true; @@ -203,12 +196,12 @@ bool validateIPAC4Data (json_object* jobj) } } - valid = validateIPACMacros(jobj, valid); + valid = validateIPACMacros(jobj, valid, board); return valid; } -bool validateIPACMacros(json_object* jobj, bool validState) +bool validateIPACMacros(json_object* jobj, bool validState, ulboard* board) { bool valid = validState; @@ -253,7 +246,7 @@ bool validateIPACMacros(json_object* jobj, bool validState) } else { - if (pIPAC.version == 1) + if (board->version == ulboard_version_pre2015) { if (json_object_array_length(macro) != maxKeyCount) { @@ -289,12 +282,12 @@ bool validateIPACMacros(json_object* jobj, bool validState) } } - if ((pIPAC.version == 1) && (macroCount > maxMacroCount)) + if ((board->version == ulboard_version_pre2015) && (macroCount > maxMacroCount)) { log_err("The number of macros defined is '%i'. 4 macro entries are allowed.", macroCount); valid = false; } - else if (pIPAC.version == 2) + else if (board->version == ulboard_version_2015) { if (macroCount2015 > maxMacroCount2015) { @@ -314,16 +307,16 @@ bool validateIPACMacros(json_object* jobj, bool validState) return valid; } -bool updateBoardIPAC (json_object *jobj) +bool updateBoardIPAC (json_object *jobj, ulboard *board) { bool result = false; int bprod = 0; unsigned char* barray = NULL; - switch (pIPAC.version) + switch (board->version) { - case 1: - if (pIPAC.ipac2) + case ulboard_version_pre2015: + if (board->type == ulboard_type_ipac2) { log_info ("Updating IPAC2 board..."); barray = calloc(IPAC_SIZE_PRE_2015, sizeof(unsigned char)); @@ -338,7 +331,7 @@ bool updateBoardIPAC (json_object *jobj) } } - if (pIPAC.minipac) + if (board->type == ulboard_type_minipac) { log_info ("Updating MinIPAC board..."); barray = calloc(IPAC_SIZE_PRE_2015, sizeof(unsigned char)); @@ -353,7 +346,7 @@ bool updateBoardIPAC (json_object *jobj) } } - if (pIPAC.ipac4) + if (board->type == ulboard_type_jpac) { log_info ("Updating IPAC4 board..."); barray = calloc((IPAC_SIZE_PRE_2015 * 2), sizeof(unsigned char)); @@ -370,32 +363,32 @@ bool updateBoardIPAC (json_object *jobj) } break; - case 2: + case ulboard_version_2015: barray = calloc(IPACSERIES_SIZE, sizeof(unsigned char)); if (barray != NULL) { - if (pIPAC.ipac2) + if (board->type == ulboard_type_ipac2) { log_info ("Updating IPAC2 board..."); bprod = IPAC_2_PRODUCT; update2015IPAC2Board(jobj, barray); } - else if (pIPAC.minipac) + else if (board->type == ulboard_type_minipac) { log_info ("Updating MinIPAC board..."); bprod = IPAC_M_PRODUCT; update2015MinIPACBoard(jobj, barray); } - else if (pIPAC.ipac4) + else if (board->type == ulboard_type_ipac4) { log_info ("Updating IPAC4 board..."); bprod = IPAC_4_PRODUCT; update2015IPAC4Board(jobj, barray); } - else if (pIPAC.jpac) + else if (board->type == ulboard_type_jpac) { log_info ("Updating JPAC board..."); bprod = JPAC_PRODUCT; diff --git a/src/libs/ipac.h b/src/libs/ipac.h index eaac080..c89c174 100644 --- a/src/libs/ipac.h +++ b/src/libs/ipac.h @@ -17,12 +17,6 @@ extern "C" { #endif -/* Required items in the json file for IPAC2, MINIPAC, IPAC4 and JPAC cards */ -#define IPAC_STR_2 "ipac2" -#define IPAC_STR_M "minipac" -#define IPAC_STR_4 "ipac4" -#define JPAC_STR "jpac" - /* Required items for writing out through the USB port */ #define IPAC_VENDOR_PRE_2015 0xD208 #define IPAC_VENDOR_2015 0xD209 @@ -35,19 +29,11 @@ extern "C" { #define IPAC_INTERFACE 2 typedef struct json_object json_object; +typedef struct ulboard ulboard; -struct ipac -{ - int version; - bool minipac; - bool ipac2; - bool ipac4; - bool jpac; -}; - -bool isIPACConfig (const char* prodStr, int version, json_object* jobj); -bool validateIPACData(json_object* jobj, int size); -bool validateIPAC4Data(json_object* jobj); +bool isIPACConfig (json_object* jobj, ulboard* board); +bool validateIPACData(json_object* jobj, int size, ulboard* board); +bool validateIPAC4Data(json_object* jobj, ulboard* board); /* * macros are optional. @@ -59,12 +45,12 @@ bool validateIPAC4Data(json_object* jobj); * limit of 85 bytes for the complete macro group (2015 boards) * */ -bool validateIPACMacros(json_object* jobj, bool valid); +bool validateIPACMacros(json_object* jobj, bool valid, ulboard* board); /* * Writes the data out to the board. */ -bool updateBoardIPAC (json_object *jobj); +bool updateBoardIPAC (json_object *jobj, ulboard* board); void updatePre2015IPAC2Board (json_object *jobj, unsigned char* barray); diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index fa08072..a43b17f 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -17,6 +17,7 @@ #include #include "ultimarc.h" +#include "ulboard.h" #include "ipac.h" #include "pacLED.h" #include "ultistik.h" @@ -25,35 +26,34 @@ #include "dbg.h" int -ulValidateConfig (json_object* bcfg, ulobject* ulobj) +ulValidateConfig (json_object* bcfg, ulboard* ulcfg) { int retCode = 0; - if (bcfg) + if (bcfg && ulcfg) { - retCode = ulGetProdAndVersion (bcfg, ulobj); + retCode = ulGetProdAndVersion (bcfg, ulcfg); if (retCode == 0) { - if ((ulobj->ipac = isIPACConfig (ulobj->pStr, ulobj->version, bcfg)) - || (ulobj->ultimate = isIPACUltimateConfig (ulobj->pStr, - ulobj->version, bcfg)) - || (ulobj->pacDrive = isPACDriveConfig (ulobj->pStr, ulobj->version, - bcfg)) || (ulobj->pacLED = - isPACLED64Config (ulobj->pStr, ulobj->version, bcfg)) - || (ulobj->ultistik = isUltistikConfig (ulobj->pStr, ulobj->version, - bcfg))) + if (isIPACConfig (bcfg, ulcfg) + || isIPACUltimateConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isPACDriveConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isPACLED64Config (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isUltistikConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg)) { - log_info("Configuration is %s. [Validated]", ulobj->pStr); + log_info("Configuration is %s. [Validated]", ulBoardTypeToString(ulcfg->type)); } else { - log_err("Configuration is '%s'. [Not validated].", ulobj->pStr); + retCode = -1; + log_err("Configuration is '%s'. [Not validated].", ulBoardTypeToString(ulcfg->type)); } } else { - log_err("Configuration is '%s'. [Not validated].", ulobj->pStr); + retCode = -1; + log_err("Configuration is '%s'. [Not validated].", ulBoardTypeToString(ulcfg->type)); } } else @@ -66,40 +66,40 @@ ulValidateConfig (json_object* bcfg, ulobject* ulobj) } int -ulValidateConfigFileStr (const char* file, ulobject* ulobj) +ulValidateConfigFileStr (const char* file, ulboard* board) { json_object *bcfg = json_object_from_file (file); - return ulValidateConfig (bcfg, ulobj); + return ulValidateConfig (bcfg, board); } int -ulWriteToBoard (json_object* bcfg, ulobject* ulobj) +ulWriteToBoard (json_object* bcfg, ulboard* board) { int retCode = 0; - if (bcfg && ulobj) + if (bcfg && board) { - if (ulobj->ipac) + if (board->type == ulboard_type_ipac2) { - retCode = updateBoardIPAC (bcfg); + retCode = updateBoardIPAC (bcfg, board); } - else if (ulobj->ultimate) + else if (board->type == ulboard_type_ultimate) { log_info("Updating IPAC Ultimate board..."); retCode = updateBoardIPacUltimate (bcfg); } - else if (ulobj->pacDrive) + else if (board->type == ulboard_type_pacDrive) { log_info("Updating PAC Drive board..."); retCode = updateBoardPacDrive (bcfg); } - else if (ulobj->pacLED) + else if (board->type == ulboard_type_pacLED) { log_info("Updating PAC LED 64 board..."); retCode = updateBoardPacLED (bcfg); } - else if (ulobj->ultistik) + else if (board->type == ulboard_type_ultistik) { log_info("Updating Ultistik board..."); retCode = updateBoardULTISTIK (bcfg); @@ -124,40 +124,41 @@ ulWriteToBoard (json_object* bcfg, ulobject* ulobj) } int -ulWriteToBoardFileStr (const char* file, ulobject* ulobj) +ulWriteToBoardFileStr (const char* file, ulboard* board) { json_object *bcfg = json_object_from_file (file); - return ulWriteToBoard (bcfg, ulobj); + return ulWriteToBoard (bcfg, board); } int -ulGetProdAndVersion (json_object* jobj, ulobject* ulobj) +ulGetProdAndVersion (json_object* jobj, ulboard* ulcfg) { int retCode = 0; + int version = 0; json_object* prodobj = NULL; json_object* verobj = NULL; - if (jobj && ulobj) + if (jobj && ulcfg) { if (json_object_object_get_ex (jobj, "product", &prodobj)) { if (json_object_get_type (prodobj) == json_type_string) { - ulobj->pStr = json_object_get_string (prodobj); + ulcfg->type = ulStringToBoardType(json_object_get_string (prodobj)); } else { log_err("'product' is not defined as a string"); - ulobj->pStr = ""; + ulcfg->type = ulboard_type_null; retCode = 1; } } else { log_err("'product' is not defined in the configuration file"); - ulobj->pStr = ""; + ulcfg->type = ulboard_type_null; retCode = 1; } @@ -165,19 +166,19 @@ ulGetProdAndVersion (json_object* jobj, ulobject* ulobj) { if (json_object_get_type (verobj) == json_type_int) { - ulobj->version = json_object_get_int (verobj); + ulcfg->version = ulIntToBoardVersion(json_object_get_int (verobj)); } else { log_err("'version' is not defined as a integer"); - ulobj->version = -1; + ulcfg->version = ulboard_version_null; retCode = 1; } } else { log_err("'version' is not defined in the configuration file"); - ulobj->version = -1; + ulcfg->version = ulboard_version_null; retCode = 1; } } diff --git a/src/libs/ultimarc.h b/src/libs/ultimarc.h index 1f81364..d468587 100644 --- a/src/libs/ultimarc.h +++ b/src/libs/ultimarc.h @@ -21,40 +21,31 @@ extern "C" typedef struct json_object json_object; -typedef struct ulobject -{ - const char* pStr; - int version; - bool ipac; - bool ultimate; - bool pacDrive; - bool pacLED; - bool ultistik; -} ulobject; +typedef struct ulboard ulboard; /** * ulValidateConfig * Validates the configuration */ extern int -ulValidateConfig (json_object* bcfg, ulobject* ulobj); +ulValidateConfig (json_object* bcfg, ulboard* ulobj); extern int -ulValidateConfigFileStr (const char* file, ulobject* ulobj); +ulValidateConfigFileStr (const char* file, ulboard* ulobj); /** * ulWriteToBoard * Writes the configuration provided out to the Ultimarc hardware */ extern int -ulWriteToBoard (json_object* bcfg, ulobject* ulobj); +ulWriteToBoard (json_object* bcfg, ulboard* ulobj); extern int -ulWriteToBoardFileStr (const char* file, ulobject* ulobj); +ulWriteToBoardFileStr (const char* file, ulboard* ulobj); /** * Populates the ulobj with the product and version in the json_object */ int -ulGetProdAndVersion (json_object* jobj, ulobject* ulobj); +ulGetProdAndVersion (json_object* jobj, ulboard* ulobj); #ifdef __cplusplus } diff --git a/src/umtool/main.c b/src/umtool/main.c index 62b42c1..357ed5f 100644 --- a/src/umtool/main.c +++ b/src/umtool/main.c @@ -13,6 +13,7 @@ #include #include +#include typedef struct args { @@ -25,7 +26,7 @@ main (int argc, char **argv) int idx; int retVal; - ulobject ulObj; + ulboard board; args args; args.help = 0; @@ -49,11 +50,11 @@ main (int argc, char **argv) for (idx = 1; idx < argc; ++idx) { printf ("Loading %s...\n", argv[idx]); - retVal = ulValidateConfigFileStr (argv[idx], &ulObj); + retVal = ulValidateConfigFileStr (argv[idx], &board); if (retVal == 0) { - retVal = ulWriteToBoardFileStr(argv[idx], &ulObj); + retVal = ulWriteToBoardFileStr(argv[idx], &board); } } From b0e377ccfb99361325be5944ec0683c620a4cc9b Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Mon, 16 May 2016 22:40:13 -0600 Subject: [PATCH 06/29] Update ultistik code to use the ulboard structure --- src/libs/ultimarc.c | 4 ++-- src/libs/ultistik.c | 39 ++++++++++++++++----------------------- src/libs/ultistik.h | 21 +++++---------------- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index a43b17f..526fcd7 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -40,7 +40,7 @@ ulValidateConfig (json_object* bcfg, ulboard* ulcfg) || isIPACUltimateConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) || isPACDriveConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) || isPACLED64Config (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) - || isUltistikConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg)) + || isUltistikConfig (bcfg, ulcfg)) { log_info("Configuration is %s. [Validated]", ulBoardTypeToString(ulcfg->type)); } @@ -102,7 +102,7 @@ ulWriteToBoard (json_object* bcfg, ulboard* board) else if (board->type == ulboard_type_ultistik) { log_info("Updating Ultistik board..."); - retCode = updateBoardULTISTIK (bcfg); + retCode = updateBoardULTISTIK (bcfg, board); } if (retCode) diff --git a/src/libs/ultistik.c b/src/libs/ultistik.c index 0efb616..0d43d6a 100644 --- a/src/libs/ultistik.c +++ b/src/libs/ultistik.c @@ -20,25 +20,21 @@ #include "common.h" #include "ultistik.h" #include "dbg.h" +#include "ulboard.h" -struct Ultistik ustik; - -bool isUltistikConfig (const char* prodStr, int version, json_object* jobj) +bool isUltistikConfig (json_object* jobj, ulboard* board) { bool isBoardCfg = false; - ustik.version = version; - - if (strcmp(prodStr, USTIK_PRODUCT_STR) == 0 || - strcmp(prodStr, USTIK_STR) == 0) + if (board->type == ulboard_type_ultistik) { - isBoardCfg = validateUltistikData(jobj); + isBoardCfg = validateUltistikData(jobj, board); } return isBoardCfg; } -bool validateUltistikData(json_object* jobj) +bool validateUltistikData(json_object* jobj, ulboard* board) { int idx = 0; bool valid = false; @@ -49,8 +45,6 @@ bool validateUltistikData(json_object* jobj) json_object* tmp = NULL; json_object* key = NULL; - ustik.controllerIDUpdate = false; - if (checkBoardID(jobj, "controller id")) { /* Must have a valid controller id in the configuration file to even attempt to say @@ -170,7 +164,6 @@ bool validateUltistikData(json_object* jobj) { if (checkBoardID(jobj, "new controller id")) { - ustik.controllerIDUpdate = true; valid = true; } else @@ -226,7 +219,7 @@ convertULTISTIK (json_object *jobj) return retval; } -bool updateBoardULTISTIK (json_object* jobj) +bool updateBoardULTISTIK (json_object* jobj, ulboard* board) { int idx = 0; int itemidx = 0; @@ -248,7 +241,7 @@ bool updateBoardULTISTIK (json_object* jobj) memset(data, 0, sizeof(data)); - if (ustik.controllerIDUpdate == false) + if (json_object_object_get_ex(jobj, "controller id", &innerobj)) { data[0] = 0x50; @@ -261,13 +254,13 @@ bool updateBoardULTISTIK (json_object* jobj) /* Flash: false RAM(0xFF), true FLASH(0x00) */ json_object_object_get_ex(jobj, "flash", &innerobj); - switch (ustik.version) + switch (board->version) { - case 1: + case ulboard_version_pre2015: data[95] = (json_object_get_boolean(innerobj)? 0x00 : 0xFF); break; - case 2: + case ulboard_version_2015: /* 2015 and newer boards this value is zero */ data[95] = 0; break; @@ -297,9 +290,9 @@ bool updateBoardULTISTIK (json_object* jobj) json_object_object_get_ex(jobj, "controller id", &innerobj); controlCur = json_object_get_int(innerobj); - switch (ustik.version) + switch (board->version) { - case 1: + case ulboard_version_pre2015: product = USTIK_PRODUCT_PRE_2015; product += (controlCur - 1); @@ -354,7 +347,7 @@ bool updateBoardULTISTIK (json_object* jobj) closeUSB(ctx, handle, USTIK_INTERFACE_PRE_2015); break; - case 2: + case ulboard_version_2015: product = USTIK_PRODUCT; product += (controlCur - 1); @@ -397,9 +390,9 @@ bool updateBoardULTISTIK (json_object* jobj) json_object_object_get_ex(jobj, "current controller id", &innerobj); controlCur = json_object_get_int(innerobj); - switch (ustik.version) + switch (board->version) { - case 1: + case ulboard_version_pre2015: product = USTIK_PRODUCT_PRE_2015; product += (controlCur - 1); @@ -450,7 +443,7 @@ bool updateBoardULTISTIK (json_object* jobj) closeUSB(ctx, handle, USTIK_INTERFACE_PRE_2015); break; - case 2: + case ulboard_version_2015: product = USTIK_PRODUCT; product += (controlCur - 1); diff --git a/src/libs/ultistik.h b/src/libs/ultistik.h index 7597021..6dd5c2c 100644 --- a/src/libs/ultistik.h +++ b/src/libs/ultistik.h @@ -17,12 +17,6 @@ extern "C" { #endif -/* Required items in the json file for Ultistik card*/ -#define USTIK_VERSION 1 -#define USTIK_CONFIG_VERSION 2 -#define USTIK_PRODUCT_STR "0501" -#define USTIK_STR "ultistik" - /* Required items for writing out through the USB port */ #define USTIK_VENDOR 0xD209 #define USTIK_PRODUCT_PRE_2015 0x0501 @@ -42,24 +36,19 @@ extern "C" { #define USTIK_CONFIG_BASE 0x51 typedef struct json_object json_object; +typedef struct ulboard ulboard; -struct Ultistik -{ - int version; - bool controllerIDUpdate; -}; - -bool isUltistikConfig (const char* prodStr, int version, json_object* jobj); +bool isUltistikConfig (json_object* jobj, ulboard* board); -bool validateUltistikData(json_object* jobj); +bool validateUltistikData(json_object* jobj, ulboard* board); /* - * Convert the JSON keys data into IPAC data + * Convert the JSON keys data into Ultistik data * This is done one array element at a time */ char convertULTISTIK (json_object* jobj); -bool updateBoardULTISTIK (json_object* jobj); +bool updateBoardULTISTIK (json_object* jobj, ulboard* board); #ifdef __cplusplus } From 56ee38392805fb71b0071c88c38305a775bcc461 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Mon, 16 May 2016 22:51:27 -0600 Subject: [PATCH 07/29] Update PACLED64 to use the ulboard struct --- src/libs/pacLED.c | 21 ++++----------------- src/libs/pacLED.h | 9 ++------- src/libs/ultimarc.c | 2 +- src/umtool/pacLED.json | 2 +- src/umtool/pacLED_all.json | 4 ++-- src/umtool/pacLED_config.json | 2 +- 6 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/libs/pacLED.c b/src/libs/pacLED.c index 8111d99..f35f713 100644 --- a/src/libs/pacLED.c +++ b/src/libs/pacLED.c @@ -20,35 +20,22 @@ #include "common.h" #include "pacLED.h" #include "dbg.h" +#include "ulboard.h" struct pacLED pLED; -bool isPACLED64Config(const char* prodStr, int version, json_object* jobj) +bool isPACLED64Config(json_object* jobj, ulboard* board) { bool isBoardCfg = false; - if (strcmp(prodStr, PACLED_PRODUCT_STR) == 0 || - strcmp(prodStr, PACLED_STR) == 0) + if (board->type == ulboard_type_pacLED) { - if (version == PACLED_VERSION) - { - isBoardCfg = validatePacLED64Data(jobj); - } + isBoardCfg = validatePacLED64Data(jobj); } return isBoardCfg; } -const char* getPacLED64ProductStr () -{ - return PACLED_PRODUCT_STR; -} - -int getPacLED64Version() -{ - return PACLED_VERSION; -} - bool validatePacLED64Data(json_object* jobj) { bool valid = false; diff --git a/src/libs/pacLED.h b/src/libs/pacLED.h index 15336cd..6ed22ab 100644 --- a/src/libs/pacLED.h +++ b/src/libs/pacLED.h @@ -17,10 +17,6 @@ extern "C" { #endif -#define PACLED_VERSION 1 -#define PACLED_PRODUCT_STR "1401" -#define PACLED_STR "PACLED64" - /* Required items for writing out through the USB port */ #define PACLED_VENDOR 0xD209 #define PACLED_PRODUCT 0x1401 @@ -34,6 +30,7 @@ extern "C" { #define PACLED_FADE_ALL_BASE 4 typedef struct json_object json_object; +typedef struct ulboard ulboard; struct pacLED { @@ -48,9 +45,7 @@ struct pacLED /* * Determine if the json file is an pacLED configuration */ -bool isPACLED64Config(const char* prodStr, int version, json_object* jobj); -const char* getPacLED64ProductStr (); -int getPacLED64Version(); +bool isPACLED64Config(json_object* jobj, ulboard* board); bool validatePacLED64Data(json_object* jobj); bool updateBoardPacLED (json_object* jobj); diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index 526fcd7..4880c36 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -39,7 +39,7 @@ ulValidateConfig (json_object* bcfg, ulboard* ulcfg) if (isIPACConfig (bcfg, ulcfg) || isIPACUltimateConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) || isPACDriveConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) - || isPACLED64Config (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isPACLED64Config (bcfg, ulcfg) || isUltistikConfig (bcfg, ulcfg)) { log_info("Configuration is %s. [Validated]", ulBoardTypeToString(ulcfg->type)); diff --git a/src/umtool/pacLED.json b/src/umtool/pacLED.json index b786cf1..217bdd8 100644 --- a/src/umtool/pacLED.json +++ b/src/umtool/pacLED.json @@ -1,6 +1,6 @@ { "version": 1, - "product": "1401", + "product": "pacled64", "board id" : 1, "fade" : [ {"led": 0, "fade" : 4 }, diff --git a/src/umtool/pacLED_all.json b/src/umtool/pacLED_all.json index 984c45b..1149bea 100644 --- a/src/umtool/pacLED_all.json +++ b/src/umtool/pacLED_all.json @@ -1,7 +1,7 @@ { "version": 1, - "product": "1401", + "product": "PACLED64", "board id" : 1, "LED fade all" : 4, "LED intensity all" : 255 -} \ No newline at end of file +} diff --git a/src/umtool/pacLED_config.json b/src/umtool/pacLED_config.json index 81c261d..939a6ef 100644 --- a/src/umtool/pacLED_config.json +++ b/src/umtool/pacLED_config.json @@ -1,6 +1,6 @@ { "version" : 1, - "product" : "1401", + "product" : "pacled64", "current board id" : 1, "new board id" : 3 } \ No newline at end of file From fc9e567daff326fe9b88477a19da42bf2fe19ac7 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 17 May 2016 16:42:08 -0600 Subject: [PATCH 08/29] Update pacdrive to use the ulboard struct. --- src/libs/pacdrive.c | 22 ++++------------------ src/libs/pacdrive.h | 9 ++------- src/libs/ultimarc.c | 2 +- src/umtool/pacdrive.json | 4 ++-- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/libs/pacdrive.c b/src/libs/pacdrive.c index 3f71db8..34b7e62 100644 --- a/src/libs/pacdrive.c +++ b/src/libs/pacdrive.c @@ -21,33 +21,19 @@ /* Local */ #include "common.h" #include "dbg.h" +#include "ulboard.h" -bool isPACDriveConfig(const char* prodStr, int version, json_object* jobj) +bool isPACDriveConfig(json_object* jobj, ulboard* board) { bool isBoardCfg = false; - - if (strcmp(prodStr, PACDRIVE_PRODUCT_STR) == 0 || - strcmp(prodStr, PACDRIVE_STR) == 0) + if (board->type == ulboard_type_pacDrive) { - if (version == PACDRIVE_VERSION) - { - isBoardCfg = validatePacDriveData(jobj); - } + isBoardCfg = validatePacDriveData(jobj); } return isBoardCfg; } -const char* getPacDriveProductStr () -{ - return PACDRIVE_PRODUCT_STR; -} - -int getPacDriveVersion() -{ - return PACDRIVE_VERSION; -} - bool validatePacDriveData(json_object* jobj) { bool valid = true; diff --git a/src/libs/pacdrive.h b/src/libs/pacdrive.h index 0d26056..50ff39c 100644 --- a/src/libs/pacdrive.h +++ b/src/libs/pacdrive.h @@ -17,10 +17,6 @@ extern "C" { #endif -#define PACDRIVE_VERSION 1 -#define PACDRIVE_PRODUCT_STR "1500" -#define PACDRIVE_STR "PACDrive" - /* Required items for writing out through the USB port */ #define PACDRIVE_VENDOR 0xD209 #define PACDRIVE_PRODUCT 0x1500 @@ -32,13 +28,12 @@ extern "C" { #define PACDRIVE_INTERFACE 0 typedef struct json_object json_object; +typedef struct ulboard ulboard; /* * Determine if the json file is an PAC drive configuration */ -bool isPACDriveConfig(const char* prodStr, int version, json_object* jobj); -const char* getPacDriveProductStr (); -int getPacDriveVersion(); +bool isPACDriveConfig(json_object* jobj, ulboard* board); bool validatePacDriveData(json_object* jobj); bool updateBoardPacDrive (json_object* jobj); diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index 4880c36..04a232c 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -38,7 +38,7 @@ ulValidateConfig (json_object* bcfg, ulboard* ulcfg) { if (isIPACConfig (bcfg, ulcfg) || isIPACUltimateConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) - || isPACDriveConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isPACDriveConfig (bcfg, ulcfg) || isPACLED64Config (bcfg, ulcfg) || isUltistikConfig (bcfg, ulcfg)) { diff --git a/src/umtool/pacdrive.json b/src/umtool/pacdrive.json index ac4bc24..357ffa2 100644 --- a/src/umtool/pacdrive.json +++ b/src/umtool/pacdrive.json @@ -1,6 +1,6 @@ { "version": 1, - "product": "1500", + "product": "pacdrive", "board id" : 1, "led" : [1, 3, 9, 11] -} \ No newline at end of file +} From 78961d9c4b6e5df4f155ab9483f317a50aa1b401 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Wed, 18 May 2016 22:49:47 -0600 Subject: [PATCH 09/29] Update code for IPAC Ultimate board to use ulboard structure --- src/libs/ipacultimate.c | 25 ++++--------------------- src/libs/ipacultimate.h | 10 ++-------- src/libs/ultimarc.c | 2 +- src/umtool/ipacultimate_config.json | 2 +- src/umtool/ipacultimate_led.json | 2 +- src/umtool/ipacultimate_pins.json | 4 ++-- 6 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/libs/ipacultimate.c b/src/libs/ipacultimate.c index 884b361..c573e78 100644 --- a/src/libs/ipacultimate.c +++ b/src/libs/ipacultimate.c @@ -20,39 +20,22 @@ #include "ipacultimate.h" #include "ipacseries.h" #include "dbg.h" +#include "ulboard.h" struct ipacultimate pLED; -bool isIPACUltimateConfig(const char* prodStr, int version, json_object* jobj) +bool isIPACUltimateConfig(json_object* jobj, ulboard* board) { bool isBoardCfg = false; - if (strcmp(prodStr, IPACULTIMATE_PRODUCT_STR) == 0 || - strcmp(prodStr, IPACULTIMATE_STR) == 0) + if (board->type == ulboard_type_ultimate) { - if (version >= IPACULTIMATE_VERSION_MIN && - version <= IPACULTIMATE_VERSION_MAX) - { - if (version == 1) - { - isBoardCfg = validateIPacUltimateData(jobj); - } - } + isBoardCfg = validateIPacUltimateData(jobj); } return isBoardCfg; } -const char* getIPacUltimateProductStr () -{ - return IPACULTIMATE_PRODUCT_STR; -} - -int getIPacUltimateVersion() -{ - return IPACULTIMATE_VERSION_MIN; -} - bool validateIPacUltimateData(json_object* jobj) { const char invalidKey = 0x00; diff --git a/src/libs/ipacultimate.h b/src/libs/ipacultimate.h index a3108c3..5a3cc3e 100644 --- a/src/libs/ipacultimate.h +++ b/src/libs/ipacultimate.h @@ -17,11 +17,6 @@ extern "C" { #endif -#define IPACULTIMATE_VERSION_MIN 1 -#define IPACULTIMATE_VERSION_MAX 2 -#define IPACULTIMATE_PRODUCT_STR "0410" -#define IPACULTIMATE_STR "ULTIMATE" - /* Required items for writing out through the USB port */ #define IPACULTIMATE_VENDOR 0xD209 #define IPACULTIMATE_PRODUCT 0x0410 @@ -31,6 +26,7 @@ extern "C" { #define IPACULTIMATE_DATA_SIZE 260 typedef struct json_object json_object; +typedef struct ulboard ulboard; struct ipacultimate { @@ -45,9 +41,7 @@ struct ipacultimate /* * Determine if the json file is an IPac Ultimate configuration */ -bool isIPACUltimateConfig(const char* prodStr, int version, json_object* jobj); -const char* getIPacUltimateProductStr (); -int getIPacUltimateVersion(); +bool isIPACUltimateConfig(json_object* jobj, ulboard* board); bool validateIPacUltimateData(json_object* jobj); /** populates the data array from the json configuration file */ diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index 04a232c..a263982 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -37,7 +37,7 @@ ulValidateConfig (json_object* bcfg, ulboard* ulcfg) if (retCode == 0) { if (isIPACConfig (bcfg, ulcfg) - || isIPACUltimateConfig (ulBoardTypeToString(ulcfg->type), ulcfg->version, bcfg) + || isIPACUltimateConfig (bcfg, ulcfg) || isPACDriveConfig (bcfg, ulcfg) || isPACLED64Config (bcfg, ulcfg) || isUltistikConfig (bcfg, ulcfg)) diff --git a/src/umtool/ipacultimate_config.json b/src/umtool/ipacultimate_config.json index 01e325f..12afc54 100644 --- a/src/umtool/ipacultimate_config.json +++ b/src/umtool/ipacultimate_config.json @@ -1,6 +1,6 @@ { "version" : 1, - "product" : "0410", + "product" : "ultimate", "current board id" : 1, "new board id" : 2 } \ No newline at end of file diff --git a/src/umtool/ipacultimate_led.json b/src/umtool/ipacultimate_led.json index 86a29b2..4e8dbb4 100644 --- a/src/umtool/ipacultimate_led.json +++ b/src/umtool/ipacultimate_led.json @@ -1,6 +1,6 @@ { "version": 1, - "product": "0410", + "product": "ultimate", "board id" : 1, "LED states random" : true, "intensity" : [ diff --git a/src/umtool/ipacultimate_pins.json b/src/umtool/ipacultimate_pins.json index 92a76ea..9d75987 100644 --- a/src/umtool/ipacultimate_pins.json +++ b/src/umtool/ipacultimate_pins.json @@ -1,6 +1,6 @@ { "version": 1, - "product": "0410", + "product": "ultimate", "board id" : 1, "intensity" : [ {"led": 0, "intensity" : 10 }, @@ -58,4 +58,4 @@ ], "x threshold" : 15, "y threshold" : 127 -} \ No newline at end of file +} From 28f9b54923106b3521544f0d29f014bc16129e81 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Sun, 22 May 2016 23:29:13 -0600 Subject: [PATCH 10/29] Use libtool versioning Update Makefile.am in src/libs to use libtool versioning funcutionality. Also update src/umtool Makefile.am because of name changes in src/libs. Lastly updated documentation for validate functions. --- configure.ac | 4 ++-- src/libs/Makefile.am | 7 ++++--- src/libs/ultimarc.h | 3 ++- src/umtool/Makefile.am | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 329cfd1..82cff4a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(Ultimarc-linux, 0.1) +AC_INIT(Ultimarc-linux, 1.0) AC_CANONICAL_HOST AM_INIT_AUTOMAKE() @@ -29,7 +29,7 @@ CPPFLAGS="-I$KERNEL_HEADERS_DIR/include" AX_PKG_CHECK_MODULES([JSON], [], [json-c >= 0.11]) AX_PKG_CHECK_MODULES([LIBUSB], [], [libusb-1.0 >= 1.0.18]) -AC_SUBST([ULTIMARC_LIB_VERSION], [0.1]) +AC_SUBST([ULTIMARC_LIB_VERSION], [1.0]) AC_CONFIG_FILES([Makefile src/libs/Makefile diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am index f78e874..6ef090a 100644 --- a/src/libs/Makefile.am +++ b/src/libs/Makefile.am @@ -4,9 +4,10 @@ AM_CFLAGS = $(JSON_CFLAGS) $(LIBUSB_CFLAGS) AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS) -lib_LTLIBRARIES = libultimarc-0.1.la -libultimarc_0_1_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c +lib_LTLIBRARIES = libultimarc.la +libultimarc_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h +libultimarc_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 otherincludedir = $(includedir)/ultimarc -otherinclude_HEADERS = ultimarc.h ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h ulboard.h +otherinclude_HEADERS = ultimarc.h ulboard.h diff --git a/src/libs/ultimarc.h b/src/libs/ultimarc.h index d468587..afe0421 100644 --- a/src/libs/ultimarc.h +++ b/src/libs/ultimarc.h @@ -25,7 +25,8 @@ typedef struct ulboard ulboard; /** * ulValidateConfig - * Validates the configuration + * Validates the configuration. + * Populates ulboard structure */ extern int ulValidateConfig (json_object* bcfg, ulboard* ulobj); diff --git a/src/umtool/Makefile.am b/src/umtool/Makefile.am index 363589e..dada4f4 100644 --- a/src/umtool/Makefile.am +++ b/src/umtool/Makefile.am @@ -7,5 +7,5 @@ AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS) bin_PROGRAMS=umtool umtool_SOURCES=main.c umtool_CPPFLAGS = -I$(top_srcdir)/src -umtool_LDADD = ../libs/libultimarc-0.1.la +umtool_LDADD = ../libs/libultimarc.la From ebaf97d816e52ef786ee5b9df6ad67bc657bfc81 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Wed, 15 Jun 2016 22:22:34 -0600 Subject: [PATCH 11/29] Fix formatting --- src/libs/ipac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ipac.c b/src/libs/ipac.c index aa44047..8757f83 100644 --- a/src/libs/ipac.c +++ b/src/libs/ipac.c @@ -28,7 +28,7 @@ bool isIPACConfig (json_object* jobj, ulboard* board) { bool isBoardCfg = false; -if (board->type == ulboard_type_ipac2) + if (board->type == ulboard_type_ipac2) { isBoardCfg = validateIPACData(jobj, 32, board); } From 6a937aab48fc472175e08d540235af2b3d3bf6b0 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Fri, 24 Jun 2016 22:01:58 -0600 Subject: [PATCH 12/29] Correct error on what libraries are required to build. Changed libusb-dev to libusb-1.0. Version required still the same. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 608f366..e152990 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This library and command line utility support 2012 through 2015 boards. If you #### Required Libraries To build this tool the following libraries need to be install on your system. * json-c (0.11), -* libusb-dev (1.0.18) +* libusb-1.0 (1.0.18) * libtool #### UDEV Rule: From c415c39d6b6ad5d7af67782da132f0309c58b9f6 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Fri, 24 Jun 2016 22:03:53 -0600 Subject: [PATCH 13/29] Add USBButton to the enumeration and string array --- src/libs/ulboard.c | 2 +- src/libs/ulboard.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ulboard.c b/src/libs/ulboard.c index dccfd98..cb99205 100644 --- a/src/libs/ulboard.c +++ b/src/libs/ulboard.c @@ -15,7 +15,7 @@ #define ULSIZE(a) (sizeof(a)/sizeof(a[0])) const char* ulBoardTypeName[] = { "null", "IPAC2", "IPAC4", "JPAC", "MINIPAC", "ULTIMATE", - "PACDRIVE", "PACLED64", "ULTISTIK" }; + "PACDRIVE", "PACLED64", "ULTISTIK", "USBBUTTON" }; const char* ulBoardVersionName[] = { "null", "PRE2015", "2015" }; diff --git a/src/libs/ulboard.h b/src/libs/ulboard.h index 314098d..f1c210a 100644 --- a/src/libs/ulboard.h +++ b/src/libs/ulboard.h @@ -27,7 +27,8 @@ typedef enum ulboard_type ulboard_type_ultimate, ulboard_type_pacDrive, ulboard_type_pacLED, - ulboard_type_ultistik + ulboard_type_ultistik, + ulboard_type_usbbutton } ulboard_type; /* Supported versions */ From 355b4528b0f209cff5353dcd731e184d9f9fd465 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Fri, 24 Jun 2016 22:12:56 -0600 Subject: [PATCH 14/29] Add .autotools to list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e0709fa..9341548 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ config.guess config.sub depcomp ltmain.sh +.autotools m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 From cfd4a4b59bf21a278d7f68f04e63e9d1675b61cb Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Fri, 24 Jun 2016 22:16:20 -0600 Subject: [PATCH 15/29] Removing generated from source control --- .autotools | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 .autotools diff --git a/.autotools b/.autotools deleted file mode 100644 index 39db8f3..0000000 --- a/.autotools +++ /dev/null @@ -1,42 +0,0 @@ - - - - - From b02e680f76e150750ffb41304ac8bd64bc9c67dc Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Mon, 27 Jun 2016 14:38:55 -0600 Subject: [PATCH 16/29] Update content --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e152990..9ef4547 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ This library and command line utility support 2012 through 2015 boards. If you #### Required Libraries To build this tool the following libraries need to be install on your system. -* json-c (0.11), -* libusb-1.0 (1.0.18) +* json-c (0.11), site +* libusb-1.0 (1.0.18), site * libtool #### UDEV Rule: @@ -19,6 +19,7 @@ This utility requires folder permission changes to the usb device directories be #### Building Utility: To build this project, at the base directory run the following commands +* ./autogen.sh * ./configure * make @@ -27,7 +28,7 @@ If you need extra debug statements for the IPac boards then run the following * make The executable will be in src/umtool directory and named umtool.out. -* ./umtool.out ipac2.json +* ./umtool ipac2.json #### Donations: Click here to lend your support to: Ultimarc-Linux and make a donation at pledgie.com ! From c6feb7943a8af0eb654b4c882ae049d92465c85f Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Mon, 27 Jun 2016 14:41:53 -0600 Subject: [PATCH 17/29] Fix link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ef4547..e0db87d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This library and command line utility support 2012 through 2015 boards. If you #### Required Libraries To build this tool the following libraries need to be install on your system. * json-c (0.11), site -* libusb-1.0 (1.0.18), site +* libusb-1.0 (1.0.18), site * libtool #### UDEV Rule: From 8dde151f1238691b827e8aae6980a7e52bc50842 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Sun, 31 Jul 2016 22:16:17 -0600 Subject: [PATCH 18/29] Add USBButton functionality to libaray. --- 21-ultimarc.rules | 1 + src/libs/Makefile.am | 2 +- src/libs/ultimarc.c | 9 +- src/libs/usbbutton.c | 469 +++++++++++++++++++++++++++++++++++++++++++ src/libs/usbbutton.h | 42 ++++ 5 files changed, 521 insertions(+), 2 deletions(-) create mode 100644 src/libs/usbbutton.c create mode 100644 src/libs/usbbutton.h diff --git a/21-ultimarc.rules b/21-ultimarc.rules index 74688c5..c4c942b 100644 --- a/21-ultimarc.rules +++ b/21-ultimarc.rules @@ -8,6 +8,7 @@ ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="05 ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0502", MODE:="666" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0503", MODE:="666" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0504", MODE:="666" +ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1200", MODE:="666" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1401", MODE:="666" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1402", MODE:="666" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1403", MODE:="666" diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am index 6ef090a..ddafbf2 100644 --- a/src/libs/Makefile.am +++ b/src/libs/Makefile.am @@ -5,7 +5,7 @@ AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS) lib_LTLIBRARIES = libultimarc.la -libultimarc_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h +libultimarc_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c usbbutton.c ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h usbbutton.h libultimarc_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 otherincludedir = $(includedir)/ultimarc diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index a263982..b7c2b55 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -23,6 +23,7 @@ #include "ultistik.h" #include "pacdrive.h" #include "ipacultimate.h" +#include "usbbutton.h" #include "dbg.h" int @@ -40,7 +41,8 @@ ulValidateConfig (json_object* bcfg, ulboard* ulcfg) || isIPACUltimateConfig (bcfg, ulcfg) || isPACDriveConfig (bcfg, ulcfg) || isPACLED64Config (bcfg, ulcfg) - || isUltistikConfig (bcfg, ulcfg)) + || isUltistikConfig (bcfg, ulcfg) + || isUSBButtonConfig(bcfg, ulcfg)) { log_info("Configuration is %s. [Validated]", ulBoardTypeToString(ulcfg->type)); } @@ -104,6 +106,11 @@ ulWriteToBoard (json_object* bcfg, ulboard* board) log_info("Updating Ultistik board..."); retCode = updateBoardULTISTIK (bcfg, board); } + else if (board->type == ulboard_type_usbbutton) + { + log_info("Updating USBButton..."); + retCode = updateUSBButton (bcfg, board); + } if (retCode) { diff --git a/src/libs/usbbutton.c b/src/libs/usbbutton.c new file mode 100644 index 0000000..60684d5 --- /dev/null +++ b/src/libs/usbbutton.c @@ -0,0 +1,469 @@ +/* + ============================================================================ + Name : usbbutton.c + Author : Katie Snow + Version : + Copyright : Copyright 2014 Robert Abram, Katie Snow + Description : USBButton configuration library + ============================================================================ + */ + +/* C */ +#include +#include +#include + +/* Unix */ +#include +#include + +/* Local */ +#include "ulboard.h" +#include "common.h" +#include "usbbutton.h" +#include "dbg.h" + +bool isUSBButtonConfig(json_object *jobj, ulboard* board) +{ + bool result = false; + + result = validateUSBButtonData(jobj, board); + + return result; +} + +bool validateUSBButtonData(json_object* jobj, ulboard* board) +{ + bool result = true; + json_object* tmp = NULL; + json_object* color = NULL; + json_object* entries = NULL; + json_object* row = NULL; + + /* Required */ + if (json_object_object_get_ex(jobj, "action", &tmp)) + { + if (!json_object_is_type(tmp, json_type_string)) + { + log_err("'action' needs to be of type string"); + result = false; + } + } + else + { + log_err("'action' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(jobj, "pressed", &tmp)) + { + if (!json_object_is_type(tmp, json_type_object)) + { + log_err("'pressed' needs to be of type object"); + result = false; + } + else + { + if (json_object_object_get_ex(tmp, "red", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'red' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'red' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(tmp, "green", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'green' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'green' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(tmp, "blue", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'blue' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'blue' is not defined in the configuration"); + result = false; + } + } + } + else + { + log_err("'pressed' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(jobj, "released", &tmp)) + { + if (!json_object_is_type(tmp, json_type_object)) + { + log_err("'released' needs to be of type object"); + result = false; + } + else + { + if (json_object_object_get_ex(tmp, "red", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'red' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'red' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(tmp, "green", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'green' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'green' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(tmp, "blue", &color)) + { + if(!json_object_is_type(color, json_type_int)) + { + log_err("'blue' needs to be of type integer"); + result = false; + } + } + else + { + log_err("'blue' is not defined in the configuration"); + result = false; + } + } + } + else + { + log_err("'released' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(jobj, "keys", &tmp)) + { + if (!json_object_is_type(tmp, json_type_object)) + { + log_err("'keys' needs to be of type object"); + result = false; + } + else + { + if (json_object_object_get_ex(tmp, "primary", &entries)) + { + if (!json_object_is_type(entries, json_type_object)) + { + log_err("'primary' needs to be of type object"); + result = false; + } + else + { + result = validateUSBButtonRowData (entries, "row 1", result); + result = validateUSBButtonRowData (entries, "row 2", result); + result = validateUSBButtonRowData (entries, "row 3", result); + result = validateUSBButtonRowData (entries, "row 4", result); + } + } + else + { + log_err("'primary' is not defined in the configuration"); + result = false; + } + + if (json_object_object_get_ex(tmp, "secondary", &entries)) + { + if (!json_object_is_type(entries, json_type_object)) + { + log_err("'secondary' needs to be of type object"); + result = false; + } + else + { + result = validateUSBButtonRowData (entries, "row 1", result); + result = validateUSBButtonRowData (entries, "row 2", result); + result = validateUSBButtonRowData (entries, "row 3", result); + result = validateUSBButtonRowData (entries, "row 4", result); + } + } + else + { + log_err("'secondary' is not defined in the configuration"); + result = false; + } + } + } + else + { + log_err("'keys' is not defined in the configuration"); + result = false; + } + + return result; +} + +#define USBBTN_ROW_SIZE 6 + +bool validateUSBButtonRowData(json_object* entries, const char* rowStr, bool curResult) +{ + bool result = curResult; + + int pos = 0; + + json_object* row = NULL; + json_object* item = NULL; + + if (json_object_object_get_ex(entries, rowStr, &row)) + { + if (!json_object_is_type(row, json_type_array)) + { + log_err("'%s' needs to be of type array", rowStr); + result = false; + } + else + { + if (json_object_array_length(row) != USBBTN_ROW_SIZE) + { + log_err("'%s' array size was %i, but needs to be %i", + rowStr, json_object_array_length(row), + USBBTN_ROW_SIZE); + result = false; + } + else + { + for (pos = 0; pos < USBBTN_ROW_SIZE; ++pos) + { + item = json_object_array_get_idx(row, pos); + + if (!json_object_is_type(item, json_type_string)) + { + log_err("'%s' 'index %i' needs to be of type string", + rowStr, pos); + result = false; + } + } + } + } + } + else + { + log_err("'%s' is not defined in the configuration", + rowStr); + result = false; + } + + return result; +} + +int usbKeyLookupTable[8][6] = { +/* Primary */ +/* Row 1 */ +{10, 11, 12, 13, 14, 15}, +/* Row 2 */ +{16, 17, 18, 19, 20, 21}, +/* Row 3 */ +{22, 23, 24, 25, 26, 27}, +/* Row 4 */ +{28, 29, 30, 31, 32, 33}, + +/* Secondary */ +/* Row 1 */ +{34, 35, 36, 37, 38, 39}, +/* Row 2 */ +{40, 41, 42, 43, 44, 45}, +/* Row 3 */ +{46, 47, 48, 49, 50, 51}, +/* Row 4 */ +{52, 53, 54, 55, 56, 57} + +}; + +bool updateUSBButton (json_object* bcfg, ulboard* board) +{ + bool result = false; + + json_object* val = NULL; + json_object* tmp = NULL; + json_object* keys = NULL; + json_object* color = NULL; + + const char* str = NULL; + + unsigned char barray[60]; + memset (&barray, 0, sizeof(barray)); + + /* Header */ + barray[0] = 0x50; + barray[1] = 0xdd; + + /* Action */ + json_object_object_get_ex(bcfg, "action", &val); + str = json_object_get_string(val); + if (!strcasecmp(str, "alternate")) + { + barray[2] = 0; + } + else if (!strcasecmp(str, "extended")) + { + barray[2] = 0x01; + } + else if (!strcasecmp(str, "both")) + { + barray[2] = 0x02; + } + + /* Release Colors */ + json_object_object_get_ex(bcfg, "released", &val); + json_object_object_get_ex(val, "red", &color); + barray[4] = convertDecimalToHex(json_object_get_int(color)); + + json_object_object_get_ex(val, "green", &color); + barray[5] = convertDecimalToHex(json_object_get_int(color)); + + json_object_object_get_ex(val, "blue", &color); + barray[6] = convertDecimalToHex(json_object_get_int(color)); + + /* Press Colors */ + json_object_object_get_ex(bcfg, "pressed", &val); + json_object_object_get_ex(val, "red", &color); + barray[7] = convertDecimalToHex(json_object_get_int(color)); + + json_object_object_get_ex(val, "green", &color); + barray[8] = convertDecimalToHex(json_object_get_int(color)); + + json_object_object_get_ex(val, "blue", &color); + barray[9] = convertDecimalToHex(json_object_get_int(color)); + + json_object_object_get_ex(bcfg, "keys", &tmp); + + /* Primary Keys*/ + json_object_object_get_ex(tmp, "primary", &val); + json_object_object_get_ex(val, "row 1", &keys); + populateUSBKeys(keys, 0, barray); + + json_object_object_get_ex(val, "row 2", &keys); + populateUSBKeys(keys, 1, barray); + + json_object_object_get_ex(val, "row 3", &keys); + populateUSBKeys(keys, 2, barray); + + json_object_object_get_ex(val, "row 4", &keys); + populateUSBKeys(keys, 3, barray); + + /* Secondary Keys */ + json_object_object_get_ex(tmp, "secondary", &val); + json_object_object_get_ex(val, "row 1", &keys); + populateUSBKeys(keys, 4, barray); + + json_object_object_get_ex(val, "row 2", &keys); + populateUSBKeys(keys, 5, barray); + + json_object_object_get_ex(val, "row 3", &keys); + populateUSBKeys(keys, 6, barray); + + json_object_object_get_ex(val, "row 4", &keys); + populateUSBKeys(keys, 7, barray); + + result = writeUSBButton(barray, 1, true); + + return result; +} + +void populateUSBKeys(json_object* keys, int row, unsigned char* barray) +{ + int pos = 0; + json_object* key = NULL; + + for(; pos < json_object_array_length(keys); ++pos) + { + key = json_object_array_get_idx(keys, pos); + barray[usbKeyLookupTable[row][pos]] = convertIPACSeries(key); + } +} + +bool writeUSBButton(unsigned char* barray, int autoconnect, bool transfer) +{ + libusb_context *ctx = NULL; + struct libusb_device_handle *handle = NULL; + unsigned char mesg[USBBTN_MESG_LENGTH] = {0,0,0,0}; + + bool result = true; + + int pos = 0; + int ret = 0; + + if (transfer) + { + handle = openUSB(ctx, USBBTN_VENDOR, USBBTN_PRODUCT, USBBTN_INTERFACE, autoconnect); + + if (!handle) + { + result = false; + goto error; + } + } + + while (pos < USBBTN_SIZE) + { + memcpy(&mesg[0], &barray[pos], 4); + + debug ("Writing (%i): %x, %x, %x, %x", pos, mesg[0], mesg[1], mesg[2], mesg[3]); + if (transfer) + { + ret = libusb_control_transfer(handle, + UM_REQUEST_TYPE, + UM_REQUEST, + USBBTN_VALUE, + USBBTN_INTERFACE, + mesg, + USBBTN_MESG_LENGTH, + UM_TIMEOUT); + debug ("Write result: %i", ret); + } + pos+=USBBTN_MESG_LENGTH; + } + +exit: + if (transfer) + { + closeUSB(ctx, handle, USBBTN_INTERFACE); + } + else + { + log_info ("board array was not written out!!!"); + } + return result; + +error: + return result; +} diff --git a/src/libs/usbbutton.h b/src/libs/usbbutton.h new file mode 100644 index 0000000..2c0b214 --- /dev/null +++ b/src/libs/usbbutton.h @@ -0,0 +1,42 @@ +/* + ============================================================================ + Name : usbbutton.h + Author : Katie Snow + Version : + Copyright : Copyright 2015 Robert Abram, Katie Snow + Description : USB Button configuration library + ============================================================================ + */ + +#ifndef USBBUTTON_H_ +#define USBBUTTON_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define USBBTN_VENDOR 0xD209 +#define USBBTN_PRODUCT 0x1200 +#define USBBTN_INTERFACE 0 +#define USBBTN_VALUE 0x0200 +#define USBBTN_MESG_LENGTH 4 +#define USBBTN_SIZE 60 + +typedef struct json_object json_object; +typedef struct ulboard ulboard; + +bool isUSBButtonConfig(json_object *jobj, ulboard* board); +bool validateUSBButtonData(json_object* jobj, ulboard* board); +bool validateUSBButtonRowData(json_object* entries, const char* rowStr, bool curResult); + +bool updateUSBButton(json_object* bcfg, ulboard* board); +void populateUSBKeys(json_object* keys, int row, unsigned char* barray); + +bool writeUSBButton(unsigned char* barray, int autoconnect, bool transfer); +#ifdef __cplusplus +} +#endif + +#endif /* USBBUTTON_H_ */ From 3156bb68a98d7ae02d0b02b69ad4b51a2d20dd37 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 2 Aug 2016 12:51:47 -0600 Subject: [PATCH 19/29] Replace magic number with USBBTN_SIZE define --- src/libs/usbbutton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/usbbutton.c b/src/libs/usbbutton.c index 60684d5..2bd519e 100644 --- a/src/libs/usbbutton.c +++ b/src/libs/usbbutton.c @@ -319,7 +319,7 @@ bool updateUSBButton (json_object* bcfg, ulboard* board) const char* str = NULL; - unsigned char barray[60]; + unsigned char barray[USBBTN_SIZE]; memset (&barray, 0, sizeof(barray)); /* Header */ From fcb1f30b4b8693207ff3b9a05174b9fcffbc35e0 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 2 Aug 2016 12:55:20 -0600 Subject: [PATCH 20/29] Change USBBTN_SIZE from 60 to 64. Fixes writing to device problem. Was not filling the devices buffer completely so the data from the next write would be placed in the incorrect locations on the device. --- src/libs/usbbutton.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/usbbutton.h b/src/libs/usbbutton.h index 2c0b214..6545f8b 100644 --- a/src/libs/usbbutton.h +++ b/src/libs/usbbutton.h @@ -22,7 +22,7 @@ extern "C" { #define USBBTN_INTERFACE 0 #define USBBTN_VALUE 0x0200 #define USBBTN_MESG_LENGTH 4 -#define USBBTN_SIZE 60 +#define USBBTN_SIZE 64 typedef struct json_object json_object; typedef struct ulboard ulboard; From 03a09f36236b5e373dc40977c269f56277dacf56 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 2 Aug 2016 12:56:52 -0600 Subject: [PATCH 21/29] Add USBButton key codes into the convertIPACSeries function. --- src/libs/ipacseries.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/libs/ipacseries.c b/src/libs/ipacseries.c index 610b257..832abd6 100644 --- a/src/libs/ipacseries.c +++ b/src/libs/ipacseries.c @@ -142,6 +142,8 @@ convertIPACSeries (json_object* jobj) retval = 0x2F; if (!strcasecmp(str, "]")) retval = 0x30; + if (!strcasecmp(str, "non US #")) + retval = 0x32; if (!strcasecmp(str, "'")) retval = 0x34; if (!strcasecmp(str, "`")) @@ -238,7 +240,7 @@ convertIPACSeries (json_object* jobj) retval = 0x62; if (!strcasecmp(str, "KP .")) retval = 0x63; - if (!strcasecmp(str, "\\")) + if (!strcasecmp(str, "\\") || !strcasecmp(str, "NON US \\")) retval = 0x64; if (!strcasecmp(str, "APP")) retval = 0x65; @@ -252,6 +254,8 @@ convertIPACSeries (json_object* jobj) retval = 0x71; if (!strcasecmp(str, "ALT L")) retval = 0x72; + if (!strcasecmp(str, "WIN L")) + retval = 0x73; if (!strcasecmp(str, "CTRL R")) retval = 0x74; if (!strcasecmp(str, "SHIFT R")) @@ -376,15 +380,15 @@ convertIPACSeries (json_object* jobj) retval = 0xe0; if (!strcasecmp(str, "m2")) retval = 0xe1; - if (!strcasecmp(str, "m3")) + if (!strcasecmp(str, "m3") || !strcasecmp(str, "MUTE")) retval = 0xe2; - if (!strcasecmp(str, "m4")) + if (!strcasecmp(str, "m4") || !strcasecmp(str, "PLAY/PAUSE")) retval = 0xe3; - if (!strcasecmp(str, "m5")) + if (!strcasecmp(str, "m5") || !strcasecmp(str, "NEXT")) retval = 0xe4; - if (!strcasecmp(str, "m6")) + if (!strcasecmp(str, "m6") || !strcasecmp(str, "PREV")) retval = 0xe5; - if (!strcasecmp(str, "m7")) + if (!strcasecmp(str, "m7") || !strcasecmp(str, "STOP")) retval = 0xe6; if (!strcasecmp(str, "m8")) retval = 0xe7; @@ -404,35 +408,35 @@ convertIPACSeries (json_object* jobj) retval = 0xee; if (!strcasecmp(str, "m16")) retval = 0xef; - if (!strcasecmp(str, "m17")) + if (!strcasecmp(str, "m17") || !strcasecmp(str, "EMAIL")) retval = 0xf0; - if (!strcasecmp(str, "m18")) + if (!strcasecmp(str, "m18") || !strcasecmp(str, "SEARCH")) retval = 0xf1; - if (!strcasecmp(str, "m19")) + if (!strcasecmp(str, "m19") || !strcasecmp(str, "BOOKMARKS")) retval = 0xf2; - if (!strcasecmp(str, "m20")) + if (!strcasecmp(str, "m20") || !strcasecmp(str, "OPEN BROWSER")) retval = 0xf3; - if (!strcasecmp(str, "m21")) + if (!strcasecmp(str, "m21") || !strcasecmp(str, "WEB BACK")) retval = 0xf4; - if (!strcasecmp(str, "m22")) + if (!strcasecmp(str, "m22") || !strcasecmp(str, "WEB FORWARD")) retval = 0xf5; - if (!strcasecmp(str, "m23")) + if (!strcasecmp(str, "m23") || !strcasecmp(str, "WEB STOP")) retval = 0xf6; - if (!strcasecmp(str, "m24")) + if (!strcasecmp(str, "m24") || !strcasecmp(str, "WEB REFRESH")) retval = 0xf7; - if (!strcasecmp(str, "m25")) + if (!strcasecmp(str, "m25") || !strcasecmp(str, "MEDIA PLAYER")) retval = 0xf8; if (!strcasecmp(str, "m26")) retval = 0xf9; - if (!strcasecmp(str, "m27")) + if (!strcasecmp(str, "m27") || !strcasecmp(str, "CALCULATOR")) retval = 0xfa; if (!strcasecmp(str, "m28")) retval = 0xfb; - if (!strcasecmp(str, "m29")) + if (!strcasecmp(str, "m29") || !strcasecmp(str, "EXPLORER")) retval = 0xfc; if (!strcasecmp(str, "m30")) retval = 0xfd; - if (!strcasecmp(str, "m31")) + if (!strcasecmp(str, "m31") || !strcasecmp(str, "WAIT 3 SEC")) retval = 0xfe; } From 31545846dd3c6589306770b014afb5307fb1e9d2 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 11 Aug 2016 15:53:28 -0600 Subject: [PATCH 22/29] Fix pre2015 ipac4 if statment --- src/libs/ipac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ipac.c b/src/libs/ipac.c index 8757f83..99fc54e 100644 --- a/src/libs/ipac.c +++ b/src/libs/ipac.c @@ -346,7 +346,7 @@ bool updateBoardIPAC (json_object *jobj, ulboard *board) } } - if (board->type == ulboard_type_jpac) + if (board->type == ulboard_type_ipac4) { log_info ("Updating IPAC4 board..."); barray = calloc((IPAC_SIZE_PRE_2015 * 2), sizeof(unsigned char)); From 590db297ddedc4286ac2a4c9cd51062c544283e7 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Thu, 11 Aug 2016 15:55:43 -0600 Subject: [PATCH 23/29] Add IPAC enumeration values to ulWriteToBoard if statement. --- src/libs/ultimarc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index b7c2b55..6e0764f 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -82,7 +82,10 @@ ulWriteToBoard (json_object* bcfg, ulboard* board) if (bcfg && board) { - if (board->type == ulboard_type_ipac2) + if (board->type == ulboard_type_ipac2 || + board->type == ulboard_type_ipac4 || + board->type == ulboard_type_jpac || + board->type == ulboard_type_minipac) { retCode = updateBoardIPAC (bcfg, board); } From 2e03cd4339535f0242919bec70eee83de55005cc Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 25 Oct 2016 21:34:37 -0600 Subject: [PATCH 24/29] Add check to isUSBButtonConfig function. Only validate if type is USBButton. --- src/libs/usbbutton.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/usbbutton.c b/src/libs/usbbutton.c index 2bd519e..3d24126 100644 --- a/src/libs/usbbutton.c +++ b/src/libs/usbbutton.c @@ -27,7 +27,10 @@ bool isUSBButtonConfig(json_object *jobj, ulboard* board) { bool result = false; - result = validateUSBButtonData(jobj, board); + if (board->type == ulboard_type_usbbutton) + { + result = validateUSBButtonData(jobj, board); + } return result; } From 7402f9dd8457a4aac0308557c0b8d5baa641c096 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 25 Oct 2016 21:42:08 -0600 Subject: [PATCH 25/29] Removed errno reference in error and warn. --- src/libs/dbg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/dbg.h b/src/libs/dbg.h index fb1d57f..2b3f072 100644 --- a/src/libs/dbg.h +++ b/src/libs/dbg.h @@ -24,9 +24,9 @@ #define clean_errno() (errno == 0 ? "None" : strerror(errno)) -#define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__) +#define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) -#define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__) +#define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) #define log_info(M, ...) fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) From f775af73d9eff9206bd82a3963344ac99e7e5e78 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 25 Oct 2016 21:43:57 -0600 Subject: [PATCH 26/29] Fixed analog mode entry validation. Issue #36 --- src/libs/ultistik.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ultistik.c b/src/libs/ultistik.c index 0d43d6a..ccf616c 100644 --- a/src/libs/ultistik.c +++ b/src/libs/ultistik.c @@ -40,7 +40,7 @@ bool validateUltistikData(json_object* jobj, ulboard* board) bool valid = false; char data; - const char invalidKey = 0x00; + const char invalidKey = 0xFF; json_object* tmp = NULL; json_object* key = NULL; @@ -63,7 +63,7 @@ bool validateUltistikData(json_object* jobj, ulboard* board) { key = json_object_array_get_idx(tmp, idx); data = convertULTISTIK (key); - if (strcmp(&invalidKey, &data) == 0) + if (strcmp(&invalidKey, &data) == -1) { log_err ("Error at index %i in 'map' array, entry is '%s'", idx, json_object_get_string(key)); valid = false; @@ -187,7 +187,7 @@ bool validateUltistikData(json_object* jobj, ulboard* board) char convertULTISTIK (json_object *jobj) { - char retval = 0x00; + char retval = 0xFF; const char* str = json_object_get_string(jobj); if (strlen(str) > 0) From a947f2ac29c0e229f095d32f2d9e17750ef7cb0d Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Tue, 25 Oct 2016 22:17:03 -0600 Subject: [PATCH 27/29] Add USBButton configuration file --- src/umtool/usbbutton.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/umtool/usbbutton.json diff --git a/src/umtool/usbbutton.json b/src/umtool/usbbutton.json new file mode 100644 index 0000000..a97741a --- /dev/null +++ b/src/umtool/usbbutton.json @@ -0,0 +1,30 @@ +{ + "version" : 1, + "product" : "usbbutton", + "board id" : 1, + "action" : "alternate", + "pressed" : { + "red" : 255, + "green" : 0, + "blue" : 0 + }, + "released" : { + "red" : 0, + "green" : 0, + "blue" : 255 + }, + "keys" : { + "primary" : { + "row 1" : ["U", "l", "t", "i", "m", "a"], + "row 2" : ["r", "c", "-", "l", "i", "n"], + "row 3" : ["u", "x", "space", "l", "i", "b"], + "row 4" : ["r", "a", "r", "y", "space", ""] + }, + "secondary" : { + "row 1" : ["shift l", "u", "s", "b", "b", ""], + "row 2" : ["u", "t", "t", "o", "n", "space"], + "row 3" : ["", "", "", "", "", ""], + "row 4" : ["", "", "", "", "", ""] + } + } +} From a8a9d3eda974521bc3f98c7b6d7fb84633d16fc8 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Wed, 2 Nov 2016 22:22:38 -0600 Subject: [PATCH 28/29] Re-add loading of multiple configurations through one config file Added ulMultiConfigurationsFileStr function. Validates and writes to boards if possible. This function is not exposed as an external function. --- src/libs/ultimarc.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ src/libs/ultimarc.h | 8 +++++++ src/umtool/main.c | 25 ++++++++++++++++---- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/libs/ultimarc.c b/src/libs/ultimarc.c index 6e0764f..b48d312 100644 --- a/src/libs/ultimarc.c +++ b/src/libs/ultimarc.c @@ -141,6 +141,62 @@ ulWriteToBoardFileStr (const char* file, ulboard* board) return ulWriteToBoard (bcfg, board); } +void +ulMultiConfigurationsFileStr (const char* file) +{ + ulboard board; + + json_object *bcfg = NULL; + json_object *jobj = NULL; + json_object *mcfg = json_object_from_file (file); + + int valid = true; + int idx = 0; + + const char* fileStr = NULL; + + if (mcfg) + { + if (json_object_object_get_ex(mcfg, "list", &bcfg)) + { + if (!json_object_is_type(bcfg, json_type_array)) + { + log_err ("'list' needs to be of type array"); + valid = false; + } + else + { + for (idx = 0; idx < json_object_array_length(bcfg); ++ idx) + { + log_info ("-------"); + jobj = json_object_array_get_idx(bcfg, idx); + fileStr = json_object_get_string (jobj); + jobj = json_object_from_file (fileStr); + + if (jobj) + { + log_info ("Loading %s...", fileStr); + if (ulValidateConfig(jobj, &board) == 0) + { + ulWriteToBoard(jobj, &board); + } + } + } + } + } + else + { + log_err ("'list' is not defined in the configuration"); + valid = false; + } + + if (!valid) + { + log_err ("Configuration. [Not validated]"); + } + } +} + int ulGetProdAndVersion (json_object* jobj, ulboard* ulcfg) { diff --git a/src/libs/ultimarc.h b/src/libs/ultimarc.h index afe0421..8496873 100644 --- a/src/libs/ultimarc.h +++ b/src/libs/ultimarc.h @@ -42,6 +42,14 @@ ulWriteToBoard (json_object* bcfg, ulboard* ulobj); extern int ulWriteToBoardFileStr (const char* file, ulboard* ulobj); +/** + * ulMultiConfigurationsFileStr + * Loads multiple configuration. + * Performs both validate and write functions. + */ +void +ulMultiConfigurationsFileStr (const char* file); + /** * Populates the ulobj with the product and version in the json_object */ diff --git a/src/umtool/main.c b/src/umtool/main.c index 357ed5f..ef807db 100644 --- a/src/umtool/main.c +++ b/src/umtool/main.c @@ -18,6 +18,7 @@ typedef struct args { int help; + int multi; } args; int @@ -30,19 +31,35 @@ main (int argc, char **argv) args args; args.help = 0; + args.multi = 0; + + if (argc == 1) + { + args.help = 1; + } for (idx = 1; idx < argc; ++idx) { if (strcmp (argv[idx], "-h") == 0 || strcmp (argv[idx], "--help") == 0) args.help = 1; + if (strcmp (argv[idx], "-m") == 0 || strcmp (argv[idx], "--multi") == 0) + args.multi = 1; } if (args.help) { - printf ("umtool [-h] [--help] [-m] [--m] [config files...]\n"); - printf ("-h | --help\t\t Prints this information\n"); - printf ("-m | --m\t\t File provided has multiple configuration\n"); - printf ("config files\t\t JSON Configuration files to be processed\n"); + printf ("umtool [-h] [--help] [-m config file] [--multi config file] [config files...]\n"); + printf ("-h | --help\t Prints this information\n"); + printf ("-m | --multi\t File provided has multiple configuration\n"); + printf ("config files\t JSON Configuration files to be processed\n"); + retVal = EXIT_SUCCESS; + goto exit; + } + + if (args.multi) + { + printf ("Loading multiple configurations from file %s...\n", argv[2]); + ulMultiConfigurationsFileStr(argv[2]); retVal = EXIT_SUCCESS; goto exit; } From 73c7a2041b1dd047169fc498cdd169d774b208e0 Mon Sep 17 00:00:00 2001 From: Katie Snow Date: Wed, 2 Nov 2016 22:23:21 -0600 Subject: [PATCH 29/29] Updated configuration file to match functionality --- src/umtool/multiple.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/umtool/multiple.json b/src/umtool/multiple.json index 1d2e198..f722786 100644 --- a/src/umtool/multiple.json +++ b/src/umtool/multiple.json @@ -1,6 +1,6 @@ { - "configurations" : [ + "list" : [ "pacLED.json", - "ultistik.json" + "ultistik_2015_map2way.json" ] -} \ No newline at end of file +}