From 4cb1f383e2ee2f6b7c630219d8cb05bb5bf5345f Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:59:10 -0400 Subject: [PATCH] Modify DBC file placement to project specific paths (#191) * Modify DBC file placement to be project specific * Address pull request feedback --- .gitignore | 2 +- firmware/dbcs/VEH_TEST_CAN.dbc | 60 ------------------- firmware/projects/Demo/CAN/Bar/config.yaml | 2 +- firmware/projects/Demo/CAN/Foo/config.yaml | 2 +- firmware/{dbcs => projects/Demo/CAN}/demo.dbc | 0 .../projects/EV5/FrontController/config.yaml | 4 +- .../projects/EV5/LVController/config.yaml | 2 +- firmware/projects/EV5/TMS/config.yaml | 2 +- .../debug/FrontControllerSimple/config.yaml | 4 +- .../EV5/debug/IoCheckoutFc}/io.dbc | 0 .../EV5/debug/MotorDebug}/pedal.dbc | 0 firmware/{dbcs => projects/EV5}/pt.dbc | 0 firmware/{dbcs => projects/EV5}/veh.dbc | 0 scripts/cangen/main.py | 5 +- 14 files changed, 12 insertions(+), 71 deletions(-) delete mode 100644 firmware/dbcs/VEH_TEST_CAN.dbc rename firmware/{dbcs => projects/Demo/CAN}/demo.dbc (100%) rename firmware/{dbcs => projects/EV5/debug/IoCheckoutFc}/io.dbc (100%) rename firmware/{dbcs => projects/EV5/debug/MotorDebug}/pedal.dbc (100%) rename firmware/{dbcs => projects/EV5}/pt.dbc (100%) rename firmware/{dbcs => projects/EV5}/veh.dbc (100%) diff --git a/.gitignore b/.gitignore index b0b4cd211..3909b5d16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .DS_STORE -.vscode +.vscode \ No newline at end of file diff --git a/firmware/dbcs/VEH_TEST_CAN.dbc b/firmware/dbcs/VEH_TEST_CAN.dbc deleted file mode 100644 index ff81403ba..000000000 --- a/firmware/dbcs/VEH_TEST_CAN.dbc +++ /dev/null @@ -1,60 +0,0 @@ -VERSION "" - - -NS_ : - NS_DESC_ - CM_ - BA_DEF_ - BA_ - VAL_ - CAT_DEF_ - CAT_ - FILTER - BA_DEF_DEF_ - EV_DATA_ - ENVVAR_DATA_ - SGTYPE_ - SGTYPE_VAL_ - BA_DEF_SGTYPE_ - BA_SGTYPE_ - SIG_TYPE_REF_ - VAL_TABLE_ - SIG_GROUP_ - SIG_VALTYPE_ - SIGTYPE_VALTYPE_ - BO_TX_BU_ - BA_DEF_REL_ - BA_REL_ - BA_DEF_DEF_REL_ - BU_SG_REL_ - BU_EV_REL_ - BU_BO_REL_ - SG_MUL_VAL_ - -BS_: - -BU_: speedgoat front_controller - - -BO_ 257 speedGoat_tx: 1 speedgoat - SG_ sg_driverSpeaker : 1|1@1- (1,0) [0|1] "" front_controller - SG_ sg_brakeLightEn : 0|1@1- (1,0) [0|1] "" front_controller - -BO_ 256 fc_tx: 8 front_controller - SG_ vd_RFWheelSpeed : 60|12@1- (1,0) [-2048|2047] "" speedgoat - SG_ vd_LFWheelSpeed : 48|12@1- (1,0) [-2048|2047] "" speedgoat - SG_ fc_hvilStatus : 41|1@1- (1,0) [0|1] "" speedgoat - SG_ fc_startButton : 40|1@1- (1,0) [0|1] "" speedgoat - SG_ fc_steeringAngle : 32|8@1+ (0.005,0) [0|1] "" speedgoat - SG_ fc_bpps2 : 24|8@1+ (0.005,0) [0|1] "" speedgoat - SG_ fc_bpps1 : 16|8@1+ (0.005,0) [0|1] "" speedgoat - SG_ fc_apps2 : 8|8@1+ (0.005,0) [0|1] "" speedgoat - SG_ fc_apps1 : 0|8@1+ (0.005,0) [0|1] "" speedgoat - - - -BA_DEF_ "MultiplexExtEnabled" ENUM "No","Yes"; -BA_DEF_ "BusType" STRING ; -BA_DEF_DEF_ "MultiplexExtEnabled" "No"; -BA_DEF_DEF_ "BusType" "CAN"; - diff --git a/firmware/projects/Demo/CAN/Bar/config.yaml b/firmware/projects/Demo/CAN/Bar/config.yaml index c8f1cf7d5..23f7a4e2e 100644 --- a/firmware/projects/Demo/CAN/Bar/config.yaml +++ b/firmware/projects/Demo/CAN/Bar/config.yaml @@ -3,4 +3,4 @@ canGen: busses: - busName: veh dbcFiles: - - "demo.dbc" + - "../demo.dbc" diff --git a/firmware/projects/Demo/CAN/Foo/config.yaml b/firmware/projects/Demo/CAN/Foo/config.yaml index 211791b93..b1b143053 100644 --- a/firmware/projects/Demo/CAN/Foo/config.yaml +++ b/firmware/projects/Demo/CAN/Foo/config.yaml @@ -3,4 +3,4 @@ canGen: busses: - busName: veh dbcFiles: - - "demo.dbc" \ No newline at end of file + - "../demo.dbc" \ No newline at end of file diff --git a/firmware/dbcs/demo.dbc b/firmware/projects/Demo/CAN/demo.dbc similarity index 100% rename from firmware/dbcs/demo.dbc rename to firmware/projects/Demo/CAN/demo.dbc diff --git a/firmware/projects/EV5/FrontController/config.yaml b/firmware/projects/EV5/FrontController/config.yaml index 9884b2f9b..d2135f17f 100644 --- a/firmware/projects/EV5/FrontController/config.yaml +++ b/firmware/projects/EV5/FrontController/config.yaml @@ -3,7 +3,7 @@ canGen: busses: - busName: veh dbcFiles: - - "veh.dbc" + - "../veh.dbc" - busName: pt dbcFiles: - - "pt.dbc" + - "../pt.dbc" diff --git a/firmware/projects/EV5/LVController/config.yaml b/firmware/projects/EV5/LVController/config.yaml index 0abdafc5a..3a30623c2 100644 --- a/firmware/projects/EV5/LVController/config.yaml +++ b/firmware/projects/EV5/LVController/config.yaml @@ -3,4 +3,4 @@ canGen: busses: - busName: veh dbcFiles: - - "veh.dbc" \ No newline at end of file + - "../veh.dbc" \ No newline at end of file diff --git a/firmware/projects/EV5/TMS/config.yaml b/firmware/projects/EV5/TMS/config.yaml index b5b92a229..ca6c88649 100644 --- a/firmware/projects/EV5/TMS/config.yaml +++ b/firmware/projects/EV5/TMS/config.yaml @@ -3,4 +3,4 @@ canGen: busses: - busName: veh dbcFiles: - - "veh.dbc" + - "../veh.dbc" diff --git a/firmware/projects/EV5/debug/FrontControllerSimple/config.yaml b/firmware/projects/EV5/debug/FrontControllerSimple/config.yaml index 9884b2f9b..44d67931a 100644 --- a/firmware/projects/EV5/debug/FrontControllerSimple/config.yaml +++ b/firmware/projects/EV5/debug/FrontControllerSimple/config.yaml @@ -3,7 +3,7 @@ canGen: busses: - busName: veh dbcFiles: - - "veh.dbc" + - "../../veh.dbc" - busName: pt dbcFiles: - - "pt.dbc" + - "../../pt.dbc" diff --git a/firmware/dbcs/io.dbc b/firmware/projects/EV5/debug/IoCheckoutFc/io.dbc similarity index 100% rename from firmware/dbcs/io.dbc rename to firmware/projects/EV5/debug/IoCheckoutFc/io.dbc diff --git a/firmware/dbcs/pedal.dbc b/firmware/projects/EV5/debug/MotorDebug/pedal.dbc similarity index 100% rename from firmware/dbcs/pedal.dbc rename to firmware/projects/EV5/debug/MotorDebug/pedal.dbc diff --git a/firmware/dbcs/pt.dbc b/firmware/projects/EV5/pt.dbc similarity index 100% rename from firmware/dbcs/pt.dbc rename to firmware/projects/EV5/pt.dbc diff --git a/firmware/dbcs/veh.dbc b/firmware/projects/EV5/veh.dbc similarity index 100% rename from firmware/dbcs/veh.dbc rename to firmware/projects/EV5/veh.dbc diff --git a/scripts/cangen/main.py b/scripts/cangen/main.py index f050215e3..16294bdec 100644 --- a/scripts/cangen/main.py +++ b/scripts/cangen/main.py @@ -15,7 +15,6 @@ DIR_FIRMWARE = os.path.join(DIR_THIS_FILE, os.pardir, os.pardir, "firmware") DIR_PROJECTS = os.path.join(DIR_FIRMWARE, "projects") -DIR_DBCS = os.path.join(DIR_FIRMWARE, "dbcs") CONFIG_FILE_NAME = "config.yaml" DEFAULT_OUTPUT_DIR = "generated/can" @@ -63,6 +62,8 @@ def parse(): with open(CONFIG_FILE_NAME, "r") as file: config = yaml.safe_load(file) + config_file_path = os.path.abspath(CONFIG_FILE_NAME) + our_node = config["canGen"]["ourNode"].upper() bus_list = config["canGen"]["busses"] output_path = config["canGen"].get("outputPath", DEFAULT_OUTPUT_DIR) @@ -74,7 +75,7 @@ def parse(): bus_name = bus['busName'].capitalize() dbc_files = bus['dbcFiles'] - dbc_file_paths = [os.path.join(DIR_DBCS, dbc) for dbc in dbc_files] + dbc_file_paths = [os.path.normpath(os.path.join(os.path.dirname(config_file_path), dbc)) for dbc in dbc_files] can_messages_template_path = os.path.join( DIR_TEMPLATES, CAN_MESSAGES_TEMPLATE_FILENAME