Skip to content

Commit 70d71f9

Browse files
authored
[Mellanox] Credo Y-cable | add more log info, checks, fix exception message (#10779)
- Why I did it Script fails when there is an exception while reading - How I did it Add more logs and checks. Fix wrong variable naming and messages. - How to verify it Provoke exception while read_eeprom() and check that it is handled properly
1 parent 910e1c6 commit 70d71f9

File tree

1 file changed

+5
-2
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+5
-2
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def write_mlxreg_eeprom(self, num_bytes, dword, device_address, page):
187187
--set {} -y".format(self.mst_pci_device, self.slot_id, self.sdk_index, device_address, page, num_bytes, dword)
188188
subprocess.check_call(cmd, shell=True, universal_newlines=True, stdout=subprocess.DEVNULL)
189189
except subprocess.CalledProcessError as e:
190-
logger.log_error("Error! Unable to write data for {} port, page {} offset {}, rc = {}, err msg: {}".format(self.sdk_index, page, device_address, e.returncode, e.output))
190+
logger.log_error("Error! Unable to write data dword={} for {} port, page {} offset {}, rc = {}, err msg: {}".format(dword, self.sdk_index, page, device_address, e.returncode, e.output))
191191
return False
192192
return True
193193

@@ -198,11 +198,14 @@ def read_mlxred_eeprom(self, offset, page, num_bytes):
198198
--get".format(self.mst_pci_device, self.slot_id, self.sdk_index, offset, page, num_bytes)
199199
result = subprocess.check_output(cmd, universal_newlines=True, shell=True)
200200
except subprocess.CalledProcessError as e:
201-
logger.log_error("Error! Unable to write data for {} port, page {} offset {}, rc = {}, err msg: {}".format(self.sdk_index, page, device_address, e.returncode, e.output))
201+
logger.log_error("Error! Unable to read data for {} port, page {} offset {}, rc = {}, err msg: {}".format(self.sdk_index, page, offset, e.returncode, e.output))
202202
return None
203203
return result
204204

205205
def parse_mlxreg_read_output(self, read_output, num_bytes):
206+
if not read_output:
207+
return None
208+
206209
res = ""
207210
dword_num = num_bytes // BYTES_IN_DWORD
208211
used_bytes_in_dword = num_bytes % BYTES_IN_DWORD

0 commit comments

Comments
 (0)