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