Include git commit hash in ThingSet data objects
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
.vscode/.browse.c_cpp.db*
|
||||
src/config.cpp
|
||||
src/config.h
|
||||
src/version.h
|
||||
html
|
||||
memory.map
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Custom script to generate src/version.h file containing the git commit hash
|
||||
#
|
||||
# See also http://docs.platformio.org/en/latest/projectconf.html#extra-script
|
||||
#
|
||||
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
|
||||
except:
|
||||
commit_hash = ""
|
||||
|
||||
f = open("src/version.h","w+")
|
||||
f.write("/* Auto-generated file with git commit hash to be included by C code\n")
|
||||
f.write(" * Do not change this file manually!\n")
|
||||
f.write(" */\n")
|
||||
f.write("\n")
|
||||
f.write('#define COMMIT_HASH "' + commit_hash + '"\n')
|
||||
f.close
|
||||
+4
-2
@@ -11,7 +11,7 @@
|
||||
default_envs =
|
||||
# mppt-2420-lc-v0.10
|
||||
# mppt-1210-hus-v0.2
|
||||
mppt-1210-hus-v0.4
|
||||
# mppt-1210-hus-v0.4
|
||||
# mppt-1210-hus-v0.6
|
||||
# pwm-2420-lus-v0.1
|
||||
# pwm-2420-lus-v0.2
|
||||
@@ -46,7 +46,9 @@ build_flags =
|
||||
# -D MBED_BUILD_PROFILE_DEBUG
|
||||
|
||||
build_unflags = -std=gnu++98
|
||||
extra_scripts = linker_flags_newlib-nano.py
|
||||
extra_scripts =
|
||||
linker_flags_newlib-nano.py
|
||||
generate_version_file.py
|
||||
|
||||
lib_deps =
|
||||
https://github.com/ThingSet/thingset-cpp
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "pcb.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
|
||||
// can be used to configure custom data objects in separate file instead (e.g. data_objects_custom.cpp)
|
||||
#ifndef CUSTOM_DATA_OBJECTS_FILE
|
||||
@@ -45,6 +46,7 @@ const char* const manufacturer = "Libre Solar";
|
||||
const char* const device_type = DEVICE_TYPE;
|
||||
const char* const hardware_version = HARDWARE_VERSION;
|
||||
const char* const firmware_version = "0.1";
|
||||
const char* const firmware_commit = COMMIT_HASH;
|
||||
uint32_t device_id = DEVICE_ID; // from config.h
|
||||
|
||||
extern uint32_t timestamp;
|
||||
@@ -67,6 +69,7 @@ const data_object_t data_objects[] = {
|
||||
{0x1A, TS_INFO, TS_READ_ALL, TS_T_STRING, 0, (void*) device_type, "DeviceType"},
|
||||
{0x1B, TS_INFO, TS_READ_ALL, TS_T_STRING, 0, (void*) hardware_version, "HardwareVersion"},
|
||||
{0x1C, TS_INFO, TS_READ_ALL, TS_T_STRING, 0, (void*) firmware_version, "FirmwareVersion"},
|
||||
{0x1D, TS_INFO, TS_READ_ALL, TS_T_STRING, 0, (void*) firmware_commit, "FirmwareCommit"},
|
||||
|
||||
// CONFIGURATION //////////////////////////////////////////////////////////
|
||||
// using IDs >= 0x30 except for high priority data objects
|
||||
|
||||
Reference in New Issue
Block a user