Skip to content

Commit

Permalink
[Credo][Ycable] Fix for displaying 'N/A' firmware version when NIC en…
Browse files Browse the repository at this point in the history
…dpoint is power off (#366)

* [Credo][Ycable] Resolve the issue of being unable to obtain the firmware version of the self-side when the NIC end is power off

Signed-off-by: Xinyu <xinyu0123@gmail.com>

* [Credo][Ycable] call get_read_side() to handle exceptions

Signed-off-by: Xinyu <xinyu0123@gmail.com>

* [Credo][Ycable] Replace the hard-coded value with a constant variable for readability

Signed-off-by: Xinyu <xinyu0123@gmail.com>

---------

Signed-off-by: Xinyu <xinyu0123@gmail.com>
Co-authored-by: Prince George <45705344+prgeor@users.noreply.github.com>
  • Loading branch information
xinyulin and prgeor committed Sep 20, 2023
1 parent 0dafb55 commit 3d3bc1a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sonic_y_cable/credo/y_cable_credo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,12 @@ def get_firmware_version(self, target):
"""
if self.platform_chassis is not None:
read_side = self.get_read_side()

if read_side == YCable.EEPROM_ERROR:
self.log_error('Fail to get read side in get_firmware_version()')
return None

with self.rlock.acquire_timeout(RLocker.ACQUIRE_LOCK_TIMEOUT) as lock_status:
if lock_status:
vsc_req_form = [None] * (YCable.VSC_CMD_ATTRIBUTE_LENGTH)
Expand All @@ -1469,8 +1475,12 @@ def get_firmware_version(self, target):
status = self.send_vsc(vsc_req_form)

if status != YCable.MCU_EC_NO_ERROR:
self.log_error('Get firmware version error (error code:0x%04X)' % (status))
return None
''' should at least return local side fw version if nic is offline'''
if status == YCable.MCU_EC_FWUPD_UART_TIMEOUT and (read_side == target):
pass
else:
self.log_error('Get firmware version error (error code:0x%04X)' % (status))
return None

data = bytearray(YCable.FIRMWARE_INFO_PAYLOAD_SIZE)
for byte_idx in range(0, YCable.FIRMWARE_INFO_PAYLOAD_SIZE):
Expand Down

0 comments on commit 3d3bc1a

Please sign in to comment.