From 667ddbca9db43c4270067c188b372bb8b642f12a Mon Sep 17 00:00:00 2001 From: Doron Barashi Date: Wed, 3 Jan 2024 17:43:17 +0000 Subject: [PATCH] fix sysfs reading that gets garbage end of line using strip update file header to 2024 --- .../mlnx-platform-api/sonic_platform/modules_mgmt.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py b/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py index 470b39acb3df..72034c9ba8b5 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/modules_mgmt.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. +# Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. # Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -279,14 +279,11 @@ def run(self): module_fd_path = module_obj.module_power_good_fd_path self.fds_events_count_dict[module_obj.port_num][fd_name] += 1 try: - val = module_fd.read() + val = module_fd.read().strip() module_fd.seek(0) logger.log_info("dynamic detection got module_obj {} with port {} from fd number {} path {} val {} count {}" .format(module_obj, module_obj.port_num, fd, module_fd_path , val, self.fds_events_count_dict[module_obj.port_num])) - # workaround for garbage received after the 0 or 1 value of sysfs i.e. 0#012 or 1#012 - if len(val) > 1: - val = val[0] if self.is_dummy_event(int(val), module_obj): logger.log_info(f"dynamic detection dummy event port {module_obj.port_num} from fd number {fd}") continue