From 1eb5cad4c8a6e8b07cf1d01e3f2d26214014c68f Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Mon, 12 Dec 2016 08:47:45 -0500 Subject: [PATCH] Intermediate commit for system version information refactor --- g2core/board/Archim/Archim-pinout.h | 3 +- g2core/board/Archim/board_stepper.cpp | 1 + g2core/board/Archim/board_stepper.h | 1 + g2core/board/Archim/board_xio.cpp | 1 + g2core/board/Archim/board_xio.h | 1 + g2core/board/Archim/hardware.cpp | 1 + g2core/board/Archim/hardware.h | 10 +++--- g2core/board/Archim/motate_pin_assignments.h | 3 +- g2core/board/G2v9/hardware.cpp | 38 +++++++++----------- g2core/board/G2v9/hardware.h | 23 ++++-------- g2core/board/sbv300/hardware.h | 5 --- g2core/config.h | 2 ++ g2core/config_app.cpp | 18 +++++++--- g2core/controller.cpp | 5 ++- g2core/controller.h | 7 ++-- g2core/g2core_info.h | 6 ++-- g2core/text_parser.cpp | 1 + 17 files changed, 64 insertions(+), 62 deletions(-) mode change 100755 => 100644 g2core/board/Archim/Archim-pinout.h mode change 100755 => 100644 g2core/board/Archim/board_stepper.cpp mode change 100755 => 100644 g2core/board/Archim/board_stepper.h mode change 100755 => 100644 g2core/board/Archim/board_xio.h mode change 100755 => 100644 g2core/board/Archim/hardware.cpp mode change 100755 => 100644 g2core/board/Archim/motate_pin_assignments.h mode change 100755 => 100644 g2core/board/G2v9/hardware.cpp mode change 100755 => 100644 g2core/controller.h diff --git a/g2core/board/Archim/Archim-pinout.h b/g2core/board/Archim/Archim-pinout.h old mode 100755 new mode 100644 index 1d49ac1a..a6dd4523 --- a/g2core/board/Archim/Archim-pinout.h +++ b/g2core/board/Archim/Archim-pinout.h @@ -1,5 +1,6 @@ /* - * motate_pin_assignments.h - pin assignments for the Archim boards + * motate_pin_assignments.h - pin assignments + * For: g2core Archim boards * This file is part of the g2core project * * Copyright (c) 2013 - 2016 Robert Giseburt diff --git a/g2core/board/Archim/board_stepper.cpp b/g2core/board/Archim/board_stepper.cpp old mode 100755 new mode 100644 index b4c254c5..0c02da3f --- a/g2core/board/Archim/board_stepper.cpp +++ b/g2core/board/Archim/board_stepper.cpp @@ -1,5 +1,6 @@ /* * board_stepper.cpp - board-specific code for stepper.cpp + * For: g2core Archim boards * This file is part of g2core project * * Copyright (c) 2016 Alden S. Hart, Jr. diff --git a/g2core/board/Archim/board_stepper.h b/g2core/board/Archim/board_stepper.h old mode 100755 new mode 100644 index d59d6a2c..952578a2 --- a/g2core/board/Archim/board_stepper.h +++ b/g2core/board/Archim/board_stepper.h @@ -1,5 +1,6 @@ /* * board_stepper.h - board-specific code for stepper.h + * For: g2core Archim boards * This file is part of g2core project * * Copyright (c) 2016 Alden S. Hart, Jr. diff --git a/g2core/board/Archim/board_xio.cpp b/g2core/board/Archim/board_xio.cpp index 87ab4dd3..00f4d55c 100644 --- a/g2core/board/Archim/board_xio.cpp +++ b/g2core/board/Archim/board_xio.cpp @@ -1,5 +1,6 @@ /* * board_xio.cpp - extended IO functions that are board-specific + * For: g2core Archim boards * This file is part of the g2core project * * Copyright (c) 2016 Alden S. Hart Jr. diff --git a/g2core/board/Archim/board_xio.h b/g2core/board/Archim/board_xio.h old mode 100755 new mode 100644 index 09f20fef..e948e18c --- a/g2core/board/Archim/board_xio.h +++ b/g2core/board/Archim/board_xio.h @@ -1,5 +1,6 @@ /* * board_xio.h - extended IO functions that are board-specific + * For: g2core Archim boards * This file is part of the g2core project * * Copyright (c) 2016 Alden S. Hart Jr. diff --git a/g2core/board/Archim/hardware.cpp b/g2core/board/Archim/hardware.cpp old mode 100755 new mode 100644 index 11d740ef..896e4ae3 --- a/g2core/board/Archim/hardware.cpp +++ b/g2core/board/Archim/hardware.cpp @@ -1,5 +1,6 @@ /* * hardware.cpp - general hardware support functions + * For: g2core Archim boards * This file is part of the g2core project * * Copyright (c) 2010 - 2015 Alden S. Hart, Jr. diff --git a/g2core/board/Archim/hardware.h b/g2core/board/Archim/hardware.h index 9e88aee5..02de6df8 100644 --- a/g2core/board/Archim/hardware.h +++ b/g2core/board/Archim/hardware.h @@ -1,6 +1,7 @@ /* * hardware.h - system hardware configuration - * THIS FILE IS HARDWARE PLATFORM SPECIFIC - ARM version + * For: g2core Archim boards + * THIS FILE IS HARDWARE PLATFORM SPECIFIC - ARM version * * This file is part of the g2core project * @@ -61,10 +62,9 @@ enum hwPlatform { #define COORDS 6 // number of supported coordinate systems (1-6) #define PWMS 2 // number of supported PWM channels - -//////////////////////////// -/////// ARM VERSION //////// -//////////////////////////// +/************************* + * Motate Setup * + *************************/ #include "MotatePins.h" #include "MotateTimers.h" // for TimerChanel<> and related... diff --git a/g2core/board/Archim/motate_pin_assignments.h b/g2core/board/Archim/motate_pin_assignments.h old mode 100755 new mode 100644 index 01226ae7..ecfef31d --- a/g2core/board/Archim/motate_pin_assignments.h +++ b/g2core/board/Archim/motate_pin_assignments.h @@ -1,5 +1,6 @@ /* - * motate_pin_assignments.h - pin assignments for the g2core Archim boards + * motate_pin_assignments.h + * For: g2core Archim boards * This file is part of the g2core project * * Copyright (c) 2013-2016 Robert Giseburt diff --git a/g2core/board/G2v9/hardware.cpp b/g2core/board/G2v9/hardware.cpp old mode 100755 new mode 100644 index 45d63c37..f17b9425 --- a/g2core/board/G2v9/hardware.cpp +++ b/g2core/board/G2v9/hardware.cpp @@ -94,15 +94,18 @@ void _get_id(char *id) ***********************************************************************************/ /* + * hw_get_fb() - get firmware build number + * hw_get_fv() - get firmware version number + * hw_get_hp() - get hardware platform string + * hw_get_hv() - get hardware version string * hw_get_fbs() - get firmware build string */ -stat_t hw_get_fbs(nvObj_t *nv) -{ - nv->valuetype = TYPE_STRING; - ritorno(nv_copy_string(nv, G2CORE_FIRMWARE_BUILD_STRING)); - return (STAT_OK); -} +stat_t hw_get_fb(nvObj_t *nv) { return (get_float(nv, cs.fw_build)); } +stat_t hw_get_fv(nvObj_t *nv) { return (get_float(nv, cs.fw_version)); } +stat_t hw_get_hp(nvObj_t *nv) { return (get_string(nv, cs.hw_platform)); } +stat_t hw_get_hv(nvObj_t *nv) { return (get_string(nv, cs.hw_version)); } +stat_t hw_get_fbs(nvObj_t *nv) { return (get_string(nv, G2CORE_FIRMWARE_BUILD_STRING)); } /* * hw_get_fbc() - get configuration settings file @@ -140,20 +143,13 @@ stat_t hw_get_id(nvObj_t *nv) /* * hw_flash() - invoke FLASH loader from command input */ + stat_t hw_flash(nvObj_t *nv) { hw_flash_loader(); return(STAT_OK); } -/* - * hw_set_hv() - set hardware version number - */ -stat_t hw_set_hv(nvObj_t *nv) -{ - return (STAT_OK); -} - /*********************************************************************************** * TEXT MODE SUPPORT @@ -163,21 +159,19 @@ stat_t hw_set_hv(nvObj_t *nv) #ifdef __TEXT_MODE static const char fmt_fb[] = "[fb] firmware build%18.2f\n"; +static const char fmt_fv[] = "[fv] firmware version%16.2f\n"; static const char fmt_fbs[] = "[fbs] firmware build \"%32s\"\n"; static const char fmt_fbc[] = "[fbc] firmware config \"%s\"\n"; -static const char fmt_fv[] = "[fv] firmware version%16.2f\n"; -static const char fmt_cv[] = "[cv] configuration version%11.2f\n"; -static const char fmt_hp[] = "[hp] hardware platform%15.2f\n"; -static const char fmt_hv[] = "[hv] hardware version%16.2f\n"; +static const char fmt_hp[] = "[hp] hardware platform%15s\n"; +static const char fmt_hv[] = "[hv] hardware version%16s\n"; static const char fmt_id[] = "[id] g2core ID%21s\n"; void hw_print_fb(nvObj_t *nv) { text_print(nv, fmt_fb);} // TYPE_FLOAT +void hw_print_fv(nvObj_t *nv) { text_print(nv, fmt_fv);} // TYPE_FLOAT void hw_print_fbs(nvObj_t *nv) { text_print(nv, fmt_fbs);} // TYPE_STRING void hw_print_fbc(nvObj_t *nv) { text_print(nv, fmt_fbc);} // TYPE_STRING -void hw_print_fv(nvObj_t *nv) { text_print(nv, fmt_fv);} // TYPE_FLOAT -void hw_print_cv(nvObj_t *nv) { text_print(nv, fmt_cv);} // TYPE_FLOAT -void hw_print_hp(nvObj_t *nv) { text_print(nv, fmt_hp);} // TYPE_FLOAT -void hw_print_hv(nvObj_t *nv) { text_print(nv, fmt_hv);} // TYPE_FLOAT +void hw_print_hp(nvObj_t *nv) { text_print(nv, fmt_hp);} // TYPE_STRING +void hw_print_hv(nvObj_t *nv) { text_print(nv, fmt_hv);} // TYPE_STRING void hw_print_id(nvObj_t *nv) { text_print(nv, fmt_id);} // TYPE_STRING #endif //__TEXT_MODE diff --git a/g2core/board/G2v9/hardware.h b/g2core/board/G2v9/hardware.h index 7668b21d..7d857a81 100644 --- a/g2core/board/G2v9/hardware.h +++ b/g2core/board/G2v9/hardware.h @@ -37,20 +37,8 @@ /*--- Hardware platform enumerations ---*/ -enum hwPlatform { - HM_PLATFORM_NONE = 0, - HW_PLATFORM_TINYG_XMEGA, // TinyG code base on Xmega boards. - HW_PLATFORM_G2_DUE, // G2 code base on native Arduino Due - HW_PLATFORM_V9 // G2 code base on v9 boards -}; - -#define HW_VERSION_TINYGV6 6 -#define HW_VERSION_TINYGV7 7 -#define HW_VERSION_TINYGV8 8 - -#define HW_VERSION_TINYGV9I 4 -#define HW_VERSION_TINYGV9K 5 - +#define G2CORE_HARDWARE_PLATFORM "g2v9" // cannot exceed 15 bytes!!! +#define G2CORE_HARDWARE_VERSION "k" // cannot exceed 15 bytes!!! /***** Axes, motors & PWM channels used by the application *****/ // Axes, motors & PWM channels must be defines (not enums) so expressions like this: @@ -177,6 +165,11 @@ stat_t hardware_periodic(); // callback from the main loop (time sensitive) void hw_hard_reset(void); stat_t hw_flash(nvObj_t *nv); +stat_t hw_get_fb(nvObj_t *nv); +stat_t hw_get_fv(nvObj_t *nv); +stat_t hw_get_hp(nvObj_t *nv); +stat_t hw_get_hv(nvObj_t *nv); + stat_t hw_get_fbs(nvObj_t *nv); stat_t hw_get_fbc(nvObj_t *nv); stat_t hw_set_hv(nvObj_t *nv); @@ -188,7 +181,6 @@ stat_t hw_get_id(nvObj_t *nv); void hw_print_fbs(nvObj_t *nv); void hw_print_fbc(nvObj_t *nv); void hw_print_fv(nvObj_t *nv); - void hw_print_cv(nvObj_t *nv); void hw_print_hp(nvObj_t *nv); void hw_print_hv(nvObj_t *nv); void hw_print_id(nvObj_t *nv); @@ -199,7 +191,6 @@ stat_t hw_get_id(nvObj_t *nv); #define hw_print_fbs tx_print_stub #define hw_print_fbc tx_print_stub #define hw_print_fv tx_print_stub - #define hw_print_cv tx_print_stub #define hw_print_hp tx_print_stub #define hw_print_hv tx_print_stub #define hw_print_id tx_print_stub diff --git a/g2core/board/sbv300/hardware.h b/g2core/board/sbv300/hardware.h index 0c1ce429..b98181c4 100644 --- a/g2core/board/sbv300/hardware.h +++ b/g2core/board/sbv300/hardware.h @@ -61,11 +61,6 @@ enum hwPlatform { #define COORDS 6 // number of supported coordinate systems (1-6) #define PWMS 2 // number of supported PWM channels - -//////////////////////////// -/////// ARM VERSION //////// -//////////////////////////// - #include "MotatePins.h" #include "MotateTimers.h" // for TimerChanel<> and related... #include "MotateServiceCall.h" // for ServiceCall<> diff --git a/g2core/config.h b/g2core/config.h index 3be9d07b..9695cef0 100644 --- a/g2core/config.h +++ b/g2core/config.h @@ -363,6 +363,8 @@ stat_t set_float_range(nvObj_t *nv, float &value, float low, float high); stat_t get_int(nvObj_t *nv, const uint8_t value); // boilerplate for retrieving an integer value stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high); +stat_t get_string(nvObj_t *nv, const char *str); + // diagnostics void nv_dump_nv(nvObj_t *nv); diff --git a/g2core/config_app.cpp b/g2core/config_app.cpp index 6d8f3a90..772c4b1a 100644 --- a/g2core/config_app.cpp +++ b/g2core/config_app.cpp @@ -102,13 +102,13 @@ static stat_t get_tick(nvObj_t *nv); // get system tick count * the %f in the corresponding format string to set text mode display precision */ const cfgItem_t cfgArray[] = { - // group token flags p, print_func, get_func, set_func, target for get/set, default value - { "sys", "fb", _fipn,2, hw_print_fb, get_flt, set_nul, (float *)&cs.fw_build, G2CORE_FIRMWARE_BUILD }, // MUST BE FIRST! + // group token flags p, print_func, get_func, set_func, get/set target, default value + { "sys", "fb", _fipn,2, hw_print_fb, hw_get_fb, set_nul, (float *)&cs.null, 0 }, // MUST BE FIRST for persistence checking! + { "sys", "fv", _fipn,2, hw_print_fv, hw_get_fv, set_nul, (float *)&cs.null, 0 }, { "sys", "fbs",_fn, 2, hw_print_fbs, hw_get_fbs, set_nul, (float *)&cs.null, 0 }, { "sys", "fbc",_fn, 2, hw_print_fbc, hw_get_fbc, set_nul, (float *)&cs.null, 0 }, - { "sys", "fv", _fipn,2, hw_print_fv, get_flt, set_nul, (float *)&cs.fw_version, G2CORE_FIRMWARE_VERSION }, - { "sys", "hp", _fipn,0, hw_print_hp, get_flt, set_nul, (float *)&cs.hw_platform, G2CORE_HARDWARE_PLATFORM }, - { "sys", "hv", _fipn,0, hw_print_hv, get_flt, set_nul, (float *)&cs.hw_version, G2CORE_HARDWARE_VERSION }, + { "sys", "hp", _fipn,0, hw_print_hp, hw_get_hp, set_nul, (float *)&cs.null, 0 }, + { "sys", "hv", _fipn,0, hw_print_hv, hw_get_hv, set_nul, (float *)&cs.null, 0 }, { "sys", "id", _fn, 0, hw_print_id, hw_get_id, set_nul, (float *)&cs.null, 0 }, // device ID (ASCII signature) // dynamic model attributes for reporting purposes (up front for speed) @@ -1106,7 +1106,15 @@ stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high) { return (STAT_OK); } +/* + * get_string() - boilerplate for retrieving a string value + */ +stat_t get_string(nvObj_t *nv, const char *str) +{ + nv->valuetype = TYPE_STRING; + return (nv_copy_string(nv, str)); +} /* * nv_group_is_prefixed() - hack diff --git a/g2core/controller.cpp b/g2core/controller.cpp index b41f37ff..3ac3fe02 100644 --- a/g2core/controller.cpp +++ b/g2core/controller.cpp @@ -95,7 +95,10 @@ void controller_init() cs.comm_mode = comm_mode; // restore parameters cs.fw_build = G2CORE_FIRMWARE_BUILD; // set up identification cs.fw_version = G2CORE_FIRMWARE_VERSION; - cs.hw_platform = G2CORE_HARDWARE_PLATFORM; // NB: HW version is set from EEPROM +// cs.hw_platform = G2CORE_HARDWARE_PLATFORM; + strncpy(cs.hw_platform, G2CORE_HARDWARE_PLATFORM, HARDWARE_STRING); + strncpy(cs.hw_version, G2CORE_HARDWARE_VERSION, HARDWARE_STRING); + cs.controller_state = CONTROLLER_STARTUP; // ready to run startup lines if (xio_connected()) { cs.controller_state = CONTROLLER_CONNECTED; diff --git a/g2core/controller.h b/g2core/controller.h old mode 100755 new mode 100644 index e7e2f01e..10d8b930 --- a/g2core/controller.h +++ b/g2core/controller.h @@ -32,6 +32,7 @@ #define SAVED_BUFFER_LEN 80 // saved buffer size (for reporting only) #define MAXED_BUFFER_LEN 255 // same as streaming RX buffer size as a worst case #define OUTPUT_BUFFER_LEN 512 // text buffer size +#define HARDWARE_STRING 16 // max length for hw platform and version is 15 chars #define LED_NORMAL_BLINK_RATE 3000 // blink rate for normal operation (in ms) #define LED_ALARM_BLINK_RATE 750 // blink rate for alarm state (in ms) @@ -54,8 +55,10 @@ typedef struct controllerSingleton { // main TG controller struct // system identification values float fw_build; // firmware build number float fw_version; // firmware version number - float hw_platform; // hardware compatibility - platform type - float hw_version; // hardware compatibility - platform revision +// float hw_platform; // hardware compatibility - platform type +// float hw_version; // hardware compatibility - platform revision + char hw_platform[HARDWARE_STRING]; // hardware compatibility - platform type + char hw_version[HARDWARE_STRING]; // hardware compatibility - platform revision // system state variables csControllerState controller_state; diff --git a/g2core/g2core_info.h b/g2core/g2core_info.h index f9a5344a..6f43755e 100644 --- a/g2core/g2core_info.h +++ b/g2core/g2core_info.h @@ -22,14 +22,12 @@ #define G2CORE_INFO_H_ONCE #define G2CORE_FIRMWARE_BUILD 100.12 // Changes to USB serial for SAMS70 and SAM8X targets +#define G2CORE_FIRMWARE_VERSION 0.99 // firmware major version + #ifdef GIT_VERSION #define G2CORE_FIRMWARE_BUILD_STRING GIT_VERSION #else #define G2CORE_FIRMWARE_BUILD_STRING "unknown" #endif -#define G2CORE_FIRMWARE_VERSION 0.99 // firmware major version -#define G2CORE_HARDWARE_PLATFORM HW_PLATFORM_V9 // hardware platform indicator (2 = Native Arduino Due) -#define G2CORE_HARDWARE_VERSION HW_VERSION_TINYGV9K // hardware platform revision number -#define G2CORE_HARDWARE_VERSION_MAX (G2CORE_HARDWARE_VERSION) #endif // G2CORE_INFO_H_ONCE diff --git a/g2core/text_parser.cpp b/g2core/text_parser.cpp index 7e085664..c8abcd85 100644 --- a/g2core/text_parser.cpp +++ b/g2core/text_parser.cpp @@ -282,6 +282,7 @@ void text_print(nvObj_t *nv, const char *format) { static const char fmt_tv[] = "[tv] text verbosity%15d [0=silent,1=verbose]\n"; void tx_print_tv(nvObj_t *nv) { text_print(nv, fmt_tv);} // TYPE_INT + /*********************************************************************************** * CONFIGURATION AND INTERFACE FUNCTIONS * Functions to get and set variables from the cfgArray table