-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9393624
commit 3612bff
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
############################################################################################ | ||
|
||
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!") |
Submodule libfirmware
added at
cd215a