@@ -296,6 +296,7 @@ def print_header():
296
296
*
297
297
*******************************************************************************
298
298
* Automatically generated from {}
299
+ * CubeMX DB version {} release {}
299
300
*/
300
301
#include "Arduino.h"
301
302
#include "{}.h"
@@ -314,6 +315,8 @@ def print_header():
314
315
""" .format (
315
316
datetime .datetime .now ().year ,
316
317
os .path .basename (input_file_name ),
318
+ cubemx_db_version ,
319
+ cubemx_db_release ,
317
320
re .sub ("\\ .c$" , "" , out_c_filename ),
318
321
)
319
322
out_c_file .write (s )
@@ -976,20 +979,18 @@ def parse_pins():
976
979
config_file = open (config_filename , "w" , newline = "\n " )
977
980
if sys .platform .startswith ("win32" ):
978
981
print ("Platform is Windows" )
979
- cubemxdir = (
980
- "C:\\ Program Files\\ STMicroelectronics\\ STM32Cube\\ STM32CubeMX\\ db\\ mcu"
981
- )
982
+ cubemxdir = "C:\\ Program Files\\ STMicroelectronics\\ STM32Cube\\ STM32CubeMX"
982
983
elif sys .platform .startswith ("linux" ):
983
984
print ("Platform is Linux" )
984
- cubemxdir = os .getenv ("HOME" ) + "/STM32CubeMX/db/mcu "
985
+ cubemxdir = os .getenv ("HOME" ) + "/STM32CubeMX"
985
986
elif sys .platform .startswith ("darwin" ):
986
987
print ("Platform is Mac OSX" )
987
988
cubemxdir = (
988
- "/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources/db/mcu "
989
+ "/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
989
990
)
990
991
else :
991
992
print ("Platform unknown" )
992
- cubemxdir = "<Set CubeMX install directory>/db/mcu "
993
+ cubemxdir = "<Set CubeMX install directory>"
993
994
config_file .write (json .dumps ({"CUBEMX_DIRECTORY" : cubemxdir }))
994
995
config_file .close ()
995
996
exit (1 )
@@ -1049,21 +1050,33 @@ def parse_pins():
1049
1050
)
1050
1051
quit ()
1051
1052
1052
- cubemxdirIP = os .path .join (cubemxdir , "IP" )
1053
+ cubemxdirMCU = os .path .join (cubemxdir , "db" , "mcu" )
1054
+ cubemxdirIP = os .path .join (cubemxdirMCU , "IP" )
1055
+ version_file = os .path .join (cubemxdir , "db" , "package.xml" )
1056
+ cubemx_db_version = "Unknown"
1057
+ cubemx_db_release = "Unknown"
1058
+ xml_file = parse (version_file )
1059
+ Package_item = xml_file .getElementsByTagName ("Package" )
1060
+ for item in Package_item :
1061
+ cubemx_db_version = item .attributes ["DBVersion" ].value
1062
+ PackDescription_item = xml_file .getElementsByTagName ("PackDescription" )
1063
+ for item in PackDescription_item :
1064
+ cubemx_db_release = item .attributes ["Release" ].value
1065
+ print ("CubeMX DB version {} release {}\n " .format (cubemx_db_version , cubemx_db_release ))
1053
1066
1054
1067
if args .mcu :
1055
1068
# check input file exists
1056
- if not (os .path .isfile (os .path .join (cubemxdir , args .mcu ))):
1069
+ if not (os .path .isfile (os .path .join (cubemxdirMCU , args .mcu ))):
1057
1070
print ("\n " + args .mcu + " file not found" )
1058
- print ("\n Check in " + cubemxdir + " the correct name of this file" )
1071
+ print ("\n Check in " + cubemxdirMCU + " the correct name of this file" )
1059
1072
print ("\n You may use double quotes for file containing special characters" )
1060
1073
quit ()
1061
1074
mcu_list .append (args .mcu )
1062
1075
else :
1063
- mcu_list = fnmatch .filter (os .listdir (cubemxdir ), "STM32*.xml" )
1076
+ mcu_list = fnmatch .filter (os .listdir (cubemxdirMCU ), "STM32*.xml" )
1064
1077
1065
1078
if args .list :
1066
- print ("Available xml files description: {}" . format ( mcu_list ) )
1079
+ print ("Available xml files description:" )
1067
1080
for f in mcu_list :
1068
1081
print (f )
1069
1082
quit ()
@@ -1074,7 +1087,7 @@ def parse_pins():
1074
1087
out_c_filename , out_h_filename , mcu_file
1075
1088
)
1076
1089
)
1077
- input_file_name = os .path .join (cubemxdir , mcu_file )
1090
+ input_file_name = os .path .join (cubemxdirMCU , mcu_file )
1078
1091
out_path = os .path .join (
1079
1092
cur_dir ,
1080
1093
"Arduino" ,
0 commit comments