diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py index 9287eca..09840fe 100644 --- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022-2023 Wind River Systems, Inc. +# Copyright (c) 2022-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -65,16 +65,17 @@ class CguHandler: def get_cgu_path_from_pci_addr(self): # Search for a cgu file using the given pci address - cgu_path = "/ice/ice/" + self.pci_addr + "/cgu" - if os.path.exists(cgu_path): - LOG.debug("PCI address %s has cgu path %s" % - (self.pci_addr, cgu_path)) - self.cgu_path = cgu_path - return - else: - LOG.error("Could not find cgu path for PCI address %s" % - self.pci_addr) - raise FileNotFoundError + if self.pci_addr: + cgu_path = "/ice/ice/" + self.pci_addr + "/cgu" + if os.path.exists(cgu_path): + LOG.debug("PCI address %s has cgu path %s" % + (self.pci_addr, cgu_path)) + self.cgu_path = cgu_path + return + else: + LOG.error("Could not find cgu path for PCI address %s" % + self.pci_addr) + raise FileNotFoundError def read_cgu(self): # Read a given cgu path and return the output in a parseable structure diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py index 43c9d16..3a8607a 100644 --- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022-2023 Wind River Systems, Inc. +# Copyright (c) 2022-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -15,6 +15,7 @@ class CguHandlerTests(unittest.TestCase): testCguHandler = CguHandler(testpath + "test_input_files/ts2phc_valid.conf") missingCguHandler = CguHandler("./no_such_file.conf") invalidCguHandler = CguHandler(testpath + "test_input_files/ts2phc_invalid.conf") + oldConfigCguHandler = CguHandler(testpath + "test_input_files/ts2phc_old.conf") def test_get_gnss_nmea_serialport(self): # Test success path @@ -57,6 +58,11 @@ class CguHandlerTests(unittest.TestCase): self.testCguHandler.get_cgu_path_from_pci_addr() self.assertEqual(self.testCguHandler.cgu_path, "/ice/ice/0000:18:00.0/cgu") + self.oldConfigCguHandler.get_gnss_nmea_serialport_from_ts2phc_config() + self.oldConfigCguHandler.convert_nmea_serialport_to_pci_addr() + self.oldConfigCguHandler.get_cgu_path_from_pci_addr() + self.assertEqual(self.oldConfigCguHandler.cgu_path, None) + mock_path.exists.return_value = False with self.assertRaises(FileNotFoundError): self.testCguHandler.get_cgu_path_from_pci_addr() diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_input_files/ts2phc_old.conf b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_input_files/ts2phc_old.conf new file mode 100644 index 0000000..e44c020 --- /dev/null +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_input_files/ts2phc_old.conf @@ -0,0 +1,25 @@ +[global] +## +## Default Data Set +## +leapfile /usr/share/zoneinfo/leap-seconds.list +logging_level 7 +ts2phc.nmea_serialport /dev/tty_GNSS_5100_0 +ts2phc.pulsewidth 100000000 + + +[ens1f0] +## +## Associated interface: oam0 +## +ts2phc.extts_polarity rising + + + + +[ens2f0] +## +## Associated interface: data0 +## +ts2phc.extts_polarity rising +