From 532f97be081a4aea3c83f99c8b350e1413bdffb2 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Fri, 15 Mar 2024 14:45:02 +0100 Subject: [PATCH 01/16] Warn and relax global j1939 if non-extended IDs present --- src/asammdf/mdf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/asammdf/mdf.py b/src/asammdf/mdf.py index 9f9f0ffde..089b9f234 100644 --- a/src/asammdf/mdf.py +++ b/src/asammdf/mdf.py @@ -4755,6 +4755,14 @@ def _extract_can_logging( messages = {(message.arbitration_id.id, message.arbitration_id.extended): message for message in dbc} global_is_j1939 = dbc.attributes.get("ProtocolType", "").lower() == "j1939" + not_extended = [msg for msg in dbc if not msg.arbitration_id.extended] + if global_is_j1939 and not_extended: + logger.warning( + f"Not all j1939 messages in <{dbc_name}> seem to use extended addressing. Disabling global j1939 flag..." + ) + for msg in not_extended: + logger.warning(f" {msg} with id {msg.arbitration_id}") + global_is_j1939 = False # Relax req on j1939 adressing j1939_messages = { ( From 34c9c05a0cf0d2a840ef85066c9715b6113e75b4 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 16:20:44 +0200 Subject: [PATCH 02/16] Add test case and testdata for mixed 29/11 bit IDs --- test/almost-J1939.dbc | 117 ++++++++++++++++++++++++++++++++++ test/test_CAN_bus_loogging.py | 29 +++++++++ 2 files changed, 146 insertions(+) create mode 100644 test/almost-J1939.dbc diff --git a/test/almost-J1939.dbc b/test/almost-J1939.dbc new file mode 100644 index 000000000..9e87a25c4 --- /dev/null +++ b/test/almost-J1939.dbc @@ -0,0 +1,117 @@ +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_: VCM + + +BO_ 2364540158 EEC1: 8 Vector__XXX + SG_ EngineSpeed : 24|16@1+ (0.125,0) [0|8031.875] "rpm" Vector__XXX + +BO_ 2566844926 CCVS1: 8 Vector__XXX + SG_ WheelBasedVehicleSpeed : 8|16@1+ (0.00390625,0) [0|250.996] "km/h" Vector__XXX + +BO_ 1791 VCM_NetVer_C01: 8 VCM + SG_ VCMNetVer_C01_Major : 8|16@1+ (1,0) [0|65535] "Not Applicable" Vector__XXX + SG_ VCMNetVer_C01_Patch : 40|16@1+ (1,0) [0|65535] "Not Applicable" Vector__XXX + SG_ VCMNetVer_C01_NetID : 0|8@1+ (1,0) [0|255] "NotApplicable" Vector__XXX + SG_ VCMNetVer_C01_Minor : 24|16@1+ (1,0) [0|65535] "Not Applicable" Vector__XXX + SG_ VCMNetVer_C01_Dirty : 56|8@1+ (1,0) [0|255] "NotApplicable" Vector__XXX + + +CM_ BO_ 2364540158 "Electronic Engine Controller 1"; +CM_ SG_ 2364540158 EngineSpeed "Actual engine speed which is calculated over a minimum crankshaft angle of 720 degrees divided by the number of cylinders.…"; +CM_ BO_ 2566844926 "Cruise Control/Vehicle Speed 1"; +CM_ SG_ 2566844926 WheelBasedVehicleSpeed "Wheel-Based Vehicle Speed: Speed of the vehicle as calculated from wheel or tailshaft speed."; +CM_ BO_ 1791 "Version stuff"; +CM_ SG_ 1791 VCMNetVer_C01_Major "Version stuff"; +CM_ SG_ 1791 VCMNetVer_C01_Patch "Version stuff"; +CM_ SG_ 1791 VCMNetVer_C01_NetID "Version stuff"; +CM_ SG_ 1791 VCMNetVer_C01_Minor "Version stuff"; +CM_ SG_ 1791 VCMNetVer_C01_Dirty "Version stuff"; +BA_DEF_ SG_ "SPN" INT 0 524287; +BA_DEF_ BO_ "VFrameFormat" ENUM "StandardCAN","ExtendedCAN","reserved","J1939PG"; +BA_DEF_ BO_ "GenMsgSendType" ENUM "Cyclic","NotUsed","NotUsed","NotUsed","NotUsed","NotUsed","NotUsed","IfActive","NoMsgSendType","NotUsed"; +BA_DEF_ BO_ "GenMsgCycleTime" INT 0 0; +BA_DEF_ "DatabaseVersion" STRING ; +BA_DEF_ "BusType" STRING ; +BA_DEF_ "ProtocolType" STRING ; +BA_DEF_ "DatabaseCompiler" STRING ; +BA_DEF_ SG_ "GenSigCycleTimeActive" INT 0 0; +BA_DEF_ SG_ "GenSigCycleTime" INT 0 0; +BA_DEF_ SG_ "GenSigStartValue" INT 0 0; +BA_DEF_ SG_ "GenSigSendType" ENUM "Cyclic","OnWrite","OnWriteWithRepetition","OnChange","OnChangeWithRepetition","IfActive","IfActiveWithRepetition","NoSigSendType","NotUsed","NotUsed","NotUsed","NotUsed","NotUsed"; + +BA_DEF_DEF_ "SPN" 0; +BA_DEF_DEF_ "VFrameFormat" "J1939PG"; +BA_DEF_DEF_ "DatabaseVersion" ""; +BA_DEF_DEF_ "BusType" ""; +BA_DEF_DEF_ "ProtocolType" ""; +BA_DEF_DEF_ "DatabaseCompiler" ""; +BA_DEF_DEF_ "GenMsgSendType" "Cyclic"; +BA_DEF_DEF_ "GenMsgCycleTime" 0; +BA_DEF_DEF_ "GenSigCycleTimeActive" 0; +BA_DEF_DEF_ "GenSigCycleTime" 0; +BA_DEF_DEF_ "GenSigSendType" "Cyclic"; +BA_DEF_DEF_ "GenSigStartValue" 0; + +BA_ "ProtocolType" "J1939"; +BA_ "BusType" "CAN"; +BA_ "DatabaseCompiler" "CSS ELECTRONICS (WWW.CSSELECTRONICS.COM)"; +BA_ "DatabaseVersion" "1.0.0"; +BA_ "VFrameFormat" BO_ 2364540158 3; +BA_ "VFrameFormat" BO_ 2566844926 3; +BA_ "VFrameFormat" BO_ 1791 0; +BA_ "GenMsgSendType" BO_ 1791 0; +BA_ "GenMsgCycleTime" BO_ 1791 1000; +BA_ "SPN" SG_ 2364540158 EngineSpeed 190; +BA_ "SPN" SG_ 2566844926 WheelBasedVehicleSpeed 84; +BA_ "GenSigSendType" SG_ 1791 VCMNetVer_C01_Major 0; +BA_ "GenSigCycleTime" SG_ 1791 VCMNetVer_C01_Major 100; +BA_ "GenSigCycleTimeActive" SG_ 1791 VCMNetVer_C01_Major 100; +BA_ "GenSigStartValue" SG_ 1791 VCMNetVer_C01_Major 2; +BA_ "GenSigSendType" SG_ 1791 VCMNetVer_C01_Patch 0; +BA_ "GenSigCycleTime" SG_ 1791 VCMNetVer_C01_Patch 100; +BA_ "GenSigCycleTimeActive" SG_ 1791 VCMNetVer_C01_Patch 100; +BA_ "GenSigSendType" SG_ 1791 VCMNetVer_C01_NetID 0; +BA_ "GenSigCycleTime" SG_ 1791 VCMNetVer_C01_NetID 100; +BA_ "GenSigCycleTimeActive" SG_ 1791 VCMNetVer_C01_NetID 100; +BA_ "GenSigStartValue" SG_ 1791 VCMNetVer_C01_NetID 1; +BA_ "GenSigSendType" SG_ 1791 VCMNetVer_C01_Minor 0; +BA_ "GenSigCycleTime" SG_ 1791 VCMNetVer_C01_Minor 100; +BA_ "GenSigCycleTimeActive" SG_ 1791 VCMNetVer_C01_Minor 100; +BA_ "GenSigStartValue" SG_ 1791 VCMNetVer_C01_Minor 7; +BA_ "GenSigSendType" SG_ 1791 VCMNetVer_C01_Dirty 0; +BA_ "GenSigCycleTime" SG_ 1791 VCMNetVer_C01_Dirty 100; +BA_ "GenSigCycleTimeActive" SG_ 1791 VCMNetVer_C01_Dirty 100; diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 45b714377..f53d193db 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import os from pathlib import Path import tempfile import unittest @@ -78,6 +79,34 @@ def test_j1939_extract(self): self.assertTrue(np.array_equal(values, target)) + + def test_almost_j1939_extract(self): + print("non-standard J1939 extract") + + temp_dir = Path(TestCANBusLogging.tempdir_j1939.name) + + mdf = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".mf4"][0] + + mdf = MDF(mdf) + + # dbc = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".dbc"][0] + # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... + # else it is identical to the CSS Electronics demo file in test package + dbc = os.path.join(os.path.abspath("."),"test","almost-J1939.dbc") + + signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] + + out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]}) + + for signal in signals: + name = signal.stem + + target = np.load(signal) + values = out.get(name).samples + + self.assertTrue(np.array_equal(values, target)) + + def test_j1939_get_can_signal(self): print("J1939 get CAN signal") From 65636f5ba2161567924a239441d0d76e6cb1cd72 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 16:29:08 +0200 Subject: [PATCH 03/16] Black... --- test/test_CAN_bus_loogging.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index f53d193db..688254030 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -79,7 +79,6 @@ def test_j1939_extract(self): self.assertTrue(np.array_equal(values, target)) - def test_almost_j1939_extract(self): print("non-standard J1939 extract") @@ -92,7 +91,7 @@ def test_almost_j1939_extract(self): # dbc = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".dbc"][0] # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package - dbc = os.path.join(os.path.abspath("."),"test","almost-J1939.dbc") + dbc = os.path.join(os.path.abspath("."), "test", "almost-J1939.dbc") signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] @@ -106,7 +105,6 @@ def test_almost_j1939_extract(self): self.assertTrue(np.array_equal(values, target)) - def test_j1939_get_can_signal(self): print("J1939 get CAN signal") From f41d5fbe7faf81cd0df1feed0650aa943b0fa130 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 17:59:44 +0200 Subject: [PATCH 04/16] Trying to second-guess CI working dir to get test file :) --- test/test_CAN_bus_loogging.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 688254030..71f74d0ba 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -91,7 +91,10 @@ def test_almost_j1939_extract(self): # dbc = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".dbc"][0] # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package - dbc = os.path.join(os.path.abspath("."), "test", "almost-J1939.dbc") + # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! + dbc = os.path.join(os.path.abspath("."), "test", "almost-J1939.dbc") # Local tests + if not os.path.exists(dbc): + dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] From 94476565a23b170072ab1254613771173990d7be Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 19:10:01 +0200 Subject: [PATCH 05/16] More digging in CI env --- test/test_CAN_bus_loogging.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 71f74d0ba..d6243fff5 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -96,6 +96,10 @@ def test_almost_j1939_extract(self): if not os.path.exists(dbc): dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? + # What is really present in current dir in CI env...? + content = ", ".join(os.listdir(".")) + assert( content == "Foo") + signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] out = mdf.extract_bus_logging({"CAN": [(dbc, 0)]}) From 6c50104a3ae5fb78050f9824a66bc4006ac8a6ee Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 19:33:16 +0200 Subject: [PATCH 06/16] Looking at test dir in CI... --- test/test_CAN_bus_loogging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index d6243fff5..cfb31cafc 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -97,7 +97,7 @@ def test_almost_j1939_extract(self): dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? # What is really present in current dir in CI env...? - content = ", ".join(os.listdir(".")) + content = ", ".join(os.listdir(os.path.join(".", "test"))) assert( content == "Foo") signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] From ae043d7711ea506dde752520204b09152429970d Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 19:55:35 +0200 Subject: [PATCH 07/16] Drop abspath --- test/test_CAN_bus_loogging.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index cfb31cafc..06fd856f5 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -92,13 +92,13 @@ def test_almost_j1939_extract(self): # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! - dbc = os.path.join(os.path.abspath("."), "test", "almost-J1939.dbc") # Local tests - if not os.path.exists(dbc): - dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? + dbc = os.path.join(".", "test", "almost-J1939.dbc") # Local tests + #if not os.path.exists(dbc): + # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? # What is really present in current dir in CI env...? - content = ", ".join(os.listdir(os.path.join(".", "test"))) - assert( content == "Foo") + #content = ", ".join(os.listdir(os.path.join(".", "test"))) + #assert( content == "Foo") signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] From 1c7a53634e758650a2d5fb8628bcce8c46347010 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 20:08:12 +0200 Subject: [PATCH 08/16] black again --- test/test_CAN_bus_loogging.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 06fd856f5..47d72df35 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -93,12 +93,12 @@ def test_almost_j1939_extract(self): # else it is identical to the CSS Electronics demo file in test package # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! dbc = os.path.join(".", "test", "almost-J1939.dbc") # Local tests - #if not os.path.exists(dbc): + # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? # What is really present in current dir in CI env...? - #content = ", ".join(os.listdir(os.path.join(".", "test"))) - #assert( content == "Foo") + # content = ", ".join(os.listdir(os.path.join(".", "test"))) + # assert( content == "Foo") signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"] From 8e5b3eb49f940bea582b5ce26343d8bbf72670c6 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Tue, 9 Apr 2024 23:06:56 +0200 Subject: [PATCH 09/16] More CI info --- test/test_CAN_bus_loogging.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 47d72df35..039e2b166 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -92,7 +92,9 @@ def test_almost_j1939_extract(self): # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! - dbc = os.path.join(".", "test", "almost-J1939.dbc") # Local tests + dbc = os.path.join("test", "almost-J1939.dbc") # Local tests + print(f"{dbc=} exists? {os.path.exists(dbc)}") + print(f"content of test subdir: {os.listdir('test')}") # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From e9f2d502c61d97b24b9b7f814d8ef8e4fc9e6f48 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 08:30:43 +0200 Subject: [PATCH 10/16] More CI info2 --- test/test_CAN_bus_loogging.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 039e2b166..de69eac63 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -94,7 +94,10 @@ def test_almost_j1939_extract(self): # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! dbc = os.path.join("test", "almost-J1939.dbc") # Local tests print(f"{dbc=} exists? {os.path.exists(dbc)}") - print(f"content of test subdir: {os.listdir('test')}") + print(f"working dir for tests: {os.path.abspath('.')}") + print(f"content of working dir: {os.listdir('.')}") + print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") + print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From f2cb1b60438f16e471e3bea169c023bb4f740afe Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 14:17:32 +0200 Subject: [PATCH 11/16] Using __file__ for location --- test/test_CAN_bus_loogging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index de69eac63..e3f8976be 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -92,12 +92,16 @@ def test_almost_j1939_extract(self): # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! - dbc = os.path.join("test", "almost-J1939.dbc") # Local tests + d = os.abspath(__file__) + print(f"dir for running testfile: {d}") + dbc = os.path.join(d, "test", "almost-J1939.dbc") # Local tests print(f"{dbc=} exists? {os.path.exists(dbc)}") print(f"working dir for tests: {os.path.abspath('.')}") print(f"content of working dir: {os.listdir('.')}") print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") + assert(False) # We want fail and output of prints above + # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From d9f05bac03d58bd1dccdae0b3211fae103cdbec4 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 15:07:14 +0200 Subject: [PATCH 12/16] corrected getting dir --- test/test_CAN_bus_loogging.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index e3f8976be..81f7fccd0 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -92,16 +92,16 @@ def test_almost_j1939_extract(self): # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! - d = os.abspath(__file__) + d = os.path.dirname(__file__) print(f"dir for running testfile: {d}") - dbc = os.path.join(d, "test", "almost-J1939.dbc") # Local tests + dbc = os.path.join(d, "almost-J1939.dbc") # Local tests print(f"{dbc=} exists? {os.path.exists(dbc)}") print(f"working dir for tests: {os.path.abspath('.')}") print(f"content of working dir: {os.listdir('.')}") print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") assert(False) # We want fail and output of prints above - + # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From 80e4757c57fbe081e3e1c4cd708828ebf451dd1f Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 15:15:51 +0200 Subject: [PATCH 13/16] Black... --- test/test_CAN_bus_loogging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 81f7fccd0..71cdee4f2 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -100,7 +100,7 @@ def test_almost_j1939_extract(self): print(f"content of working dir: {os.listdir('.')}") print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") - assert(False) # We want fail and output of prints above + assert False # We want fail and output of prints above # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From 2e54717a071a69d2e1941fddf5c59334989929ad Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 16:01:09 +0200 Subject: [PATCH 14/16] Drop intentionally failing assert --- test/test_CAN_bus_loogging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 71cdee4f2..daaa81259 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -100,7 +100,7 @@ def test_almost_j1939_extract(self): print(f"content of working dir: {os.listdir('.')}") print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") - assert False # We want fail and output of prints above + # assert False # We want fail and output of prints above # if not os.path.exists(dbc): # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? From 44e8b66a1f75d58c463a86da2de2e2b1da0a9899 Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 16:06:02 +0200 Subject: [PATCH 15/16] Less verbose --- test/test_CAN_bus_loogging.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index daaa81259..22b32b288 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -96,10 +96,10 @@ def test_almost_j1939_extract(self): print(f"dir for running testfile: {d}") dbc = os.path.join(d, "almost-J1939.dbc") # Local tests print(f"{dbc=} exists? {os.path.exists(dbc)}") - print(f"working dir for tests: {os.path.abspath('.')}") - print(f"content of working dir: {os.listdir('.')}") - print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") - print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") + # print(f"working dir for tests: {os.path.abspath('.')}") + # print(f"content of working dir: {os.listdir('.')}") + # print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") + # print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") # assert False # We want fail and output of prints above # if not os.path.exists(dbc): From 6ff52f7ad9670d3d338c0be1d896d26b713c666f Mon Sep 17 00:00:00 2001 From: "Klint Anders (Consultant)" Date: Wed, 10 Apr 2024 16:45:40 +0200 Subject: [PATCH 16/16] Clean up --- test/test_CAN_bus_loogging.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/test/test_CAN_bus_loogging.py b/test/test_CAN_bus_loogging.py index 22b32b288..c4cb7007a 100644 --- a/test/test_CAN_bus_loogging.py +++ b/test/test_CAN_bus_loogging.py @@ -91,23 +91,8 @@ def test_almost_j1939_extract(self): # dbc = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".dbc"][0] # This dbc throws exception without the suggested changes in branch "relaxed_j1939"... # else it is identical to the CSS Electronics demo file in test package - # NB: This fiddöing with optional "test" in path not needed if test file included in test .zip! d = os.path.dirname(__file__) - print(f"dir for running testfile: {d}") - dbc = os.path.join(d, "almost-J1939.dbc") # Local tests - print(f"{dbc=} exists? {os.path.exists(dbc)}") - # print(f"working dir for tests: {os.path.abspath('.')}") - # print(f"content of working dir: {os.listdir('.')}") - # print(f"content of working dir (abspath): {os.listdir(os.path.abspath('.'))}") - # print(f"content of ./test subdir: {os.listdir(os.path.join('.','test'))}") - # assert False # We want fail and output of prints above - - # if not os.path.exists(dbc): - # dbc = os.path.join(os.path.abspath("."), "almost-J1939.dbc") # CI env? - - # What is really present in current dir in CI env...? - # content = ", ".join(os.listdir(os.path.join(".", "test"))) - # assert( content == "Foo") + dbc = os.path.join(d, "almost-J1939.dbc") # Pls replace with file from expanded zip file signals = [input_file for input_file in temp_dir.iterdir() if input_file.suffix == ".npy"]