diff --git a/.gitmodules b/.gitmodules index a8bb90d..2899f5d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,3 +11,6 @@ [submodule "bin/pcb-tools"] path = bin/pcb-tools url = https://github.com/curtacircuitos/pcb-tools.git +[submodule "board_id/libfirmware"] + path = board_id/libfirmware + url = https://github.com/rusefi/libfirmware/ diff --git a/board_id/gen_board_ids_h.py b/board_id/gen_board_ids_h.py new file mode 100644 index 0000000..010693e --- /dev/null +++ b/board_id/gen_board_ids_h.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +############################################################################################ +# Hellen-One: Generates a header file containing the list of Board-IDs. +# The result is stored in 'libfirmware/board_id/boards_id.h' folder. +# (c) andreika +############################################################################################ + +import csv, sys, os, re, datetime + +board_ids_csv = "board_ids.csv" +libdir = "libfirmware/board_id" +board_ids_h = libdir + "/boards_id.h" + +date_time = datetime.datetime.now() + +def getBoardName(str): + str = str.replace("-", "_") + return str.upper() + +def readCsv(fileName): + rows = list() + with open(fileName, 'rt') as f: + reader = csv.reader(f, delimiter=',') + for row in reader: + # skip empty lines and comments (this is not strictly CSV-compliant, but useful for our purposes) + if (len(row) < 1 or row[0].startswith("#")): + continue + rows.append(row) + return rows + +def saveH(fileName, rows): + with open (fileName, 'wt') as new_f: + new_f.write("//\n// was generated automatically by Hellen Board-ID generation tool gen_board_ids_h.py " + str(date_time) + "\n//\n\n#pragma once\n\n") + for row in rows: + new_f.write("#define BOARD_ID_" + getBoardName(row[3]) + "\t\t\t" + row[0] + "\n") + +if not os.path.isdir(libdir): + print ("Error! Cannot find the destination folder " + libdir + "! Please make sure that 'libfirmware' submodule was initialized by calling 'git submodule update'") + sys.exit(1) + +print ("Reading board ID list from " + board_ids_csv + "...") +boardIdList = readCsv(board_ids_csv) + +print ("Saving the header file to " + board_ids_h + "...") +saveH(board_ids_h, boardIdList) + +print ("Done!") diff --git a/board_id/libfirmware b/board_id/libfirmware new file mode 160000 index 0000000..cd215a9 --- /dev/null +++ b/board_id/libfirmware @@ -0,0 +1 @@ +Subproject commit cd215a965cca31aff98a18a786d5ad626e853b15