Ice driver 1.14.9.x support

Support the new NMEA serial port name, which changed
from /dev/ttyGNSS_XXXX_X to /dev/gnssX. The name
change impacted how the PCI address of the GNSS
device is derived.

Test plan:
PASS: Verify basic app operation (get status, subscribe,
list, delete, push notification.
PASS: Verify unit tests.

Story: 2011056
Task: 50884

Change-Id: I96b6285b385eb45c14650cda125ddfb702b06645
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
This commit is contained in:
Andre Mauricio Zelak 2024-08-20 22:36:38 -03:00
parent 3026d6305b
commit 945e51f069
4 changed files with 27 additions and 32 deletions

View File

@ -39,24 +39,27 @@ class CguHandler:
LOG.error(err)
raise
def convert_nmea_serialport_to_pci_addr(self, log_file="/logs/kern.log"):
def convert_nmea_serialport_to_pci_addr(self):
# Parse the nmea_serialport value into a PCI address so that we can
# later find the cgu
# Returns the address or None
pci_addr = None
# Get only the ttyGNSS_1800_0 portion of the path
# Remove the /dev portion of the path
nmea_serialport = self.nmea_serialport.split('/')[2]
LOG.debug("Looking for nmea_serialport value: %s" % nmea_serialport)
# Buld uevent path
uevent_file = '/sys/class/gnss/' + nmea_serialport + '/device/uevent'
with open(log_file, 'r') as file:
for line in file:
if nmea_serialport in line:
# Regex split to make any number of spaces the delimiter
# Eg.: ... ice 0000:18:00.0: ttyGNSS_1800_0 registered
# Becomes: 0000:18:00.0
pci_addr = re.split(' +', line)[7].strip(':')
LOG.debug("Found with PCI addr: %s" % pci_addr)
break
try:
with open(uevent_file, 'r') as file:
for line in file:
if 'PCI_SLOT_NAME' in line:
# Get the portion after the '=' sign
pci_addr = re.split('=', line)[1].strip('\n')
LOG.debug("Found with PCI addr: %s" % pci_addr)
break
except (FileNotFoundError, PermissionError) as err:
LOG.error(err)
self.pci_addr = pci_addr

View File

@ -19,7 +19,7 @@ class CguHandlerTests(unittest.TestCase):
def test_get_gnss_nmea_serialport(self):
# Test success path
self.testCguHandler.get_gnss_nmea_serialport_from_ts2phc_config()
self.assertEqual(self.testCguHandler.nmea_serialport, "/dev/ttyGNSS_1800_0")
self.assertEqual(self.testCguHandler.nmea_serialport, "/dev/gnss0")
# Test missing / incorrect config file path
with self.assertRaises(FileNotFoundError):
@ -33,14 +33,16 @@ class CguHandlerTests(unittest.TestCase):
def test_convert_nmea_serialport_to_pci_addr(self):
# Test success path
self.testCguHandler.get_gnss_nmea_serialport_from_ts2phc_config()
self.testCguHandler.convert_nmea_serialport_to_pci_addr(
testpath + "test_input_files/mock_kern.log")
with mock.patch('trackingfunctionsdk.common.helpers.cgu_handler.open',
new_callable=mock.mock_open,
read_data='PCI_SLOT_NAME=0000:18:00.0') as mock_open:
self.testCguHandler.convert_nmea_serialport_to_pci_addr()
mock_open.assert_called_with('/sys/class/gnss/gnss0/device/uevent', 'r')
self.assertEqual(self.testCguHandler.pci_addr, "0000:18:00.0")
# Test pci address not found
self.testCguHandler.nmea_serialport = "/dev/ttyGNSS_not_present"
self.testCguHandler.convert_nmea_serialport_to_pci_addr(
testpath + "test_input_files/mock_kern.log")
self.testCguHandler.nmea_serialport = "/dev/not_present"
self.testCguHandler.convert_nmea_serialport_to_pci_addr()
self.assertEqual(self.testCguHandler.pci_addr, None)
@mock.patch('trackingfunctionsdk.common.helpers.cgu_handler.os.path')
@ -48,8 +50,10 @@ class CguHandlerTests(unittest.TestCase):
# Setup mock
mock_path.exists.return_value = True
self.testCguHandler.get_gnss_nmea_serialport_from_ts2phc_config()
self.testCguHandler.convert_nmea_serialport_to_pci_addr(
testpath + "test_input_files/mock_kern.log")
with mock.patch('trackingfunctionsdk.common.helpers.cgu_handler.open',
new_callable=mock.mock_open,
read_data='PCI_SLOT_NAME=0000:18:00.0') as mock_open:
self.testCguHandler.convert_nmea_serialport_to_pci_addr()
self.testCguHandler.get_cgu_path_from_pci_addr()
self.assertEqual(self.testCguHandler.cgu_path, "/ice/0000:18:00.0/cgu")

View File

@ -1,12 +0,0 @@
2022-06-03T19:36:08.021 controller-0 kernel: info [ 11.122139] ice 0000:18:00.0: ttyGNSS_1800_0 registered
2022-06-03T19:36:08.021 controller-0 kernel: info [ 11.122142] ice 0000:18:00.0: GNSS TTY init successful
2022-06-03T19:36:08.021 controller-0 kernel: warning [ 11.134103] ice 0000:18:00.0: <DPLL0> state changed to: locked_ho_ack, pin GNSS-1PPS
2022-06-03T19:36:08.021 controller-0 kernel: warning [ 11.148040] ice 0000:18:00.0: <DPLL1> state changed to: locked_ho_ack, pin GNSS-1PPS
2022-06-03T19:36:08.022 controller-0 kernel: info [ 14.405736] ice 0000:1a:00.0: ttyGNSS_1a00_0 registered
2022-06-03T19:36:08.022 controller-0 kernel: info [ 14.405737] ice 0000:1a:00.0: GNSS TTY init successful
2022-06-03T19:50:05.958 controller-0 kernel: info [ 4.609339] ice 0000:18:00.0: ttyGNSS_1800_0 registered
2022-06-03T19:50:05.958 controller-0 kernel: info [ 4.609362] ice 0000:18:00.0: GNSS TTY init successful
2022-06-03T19:50:05.958 controller-0 kernel: warning [ 4.621518] ice 0000:18:00.0: <DPLL0> state changed to: locked_ho_ack, pin GNSS-1PPS
2022-06-03T19:50:05.959 controller-0 kernel: warning [ 4.635511] ice 0000:18:00.0: <DPLL1> state changed to: locked_ho_ack, pin GNSS-1PPS
2022-06-03T19:50:05.959 controller-0 kernel: info [ 7.995939] ice 0000:1a:00.0: ttyGNSS_1a00_0 registered
2022-06-03T19:50:05.959 controller-0 kernel: info [ 7.995941] ice 0000:1a:00.0: GNSS TTY init successful

View File

@ -4,7 +4,7 @@
##
leapfile /usr/share/zoneinfo/leap-seconds.list
logging_level 7
ts2phc.nmea_serialport /dev/ttyGNSS_1800_0
ts2phc.nmea_serialport /dev/gnss0
ts2phc.pulsewidth 100000000