Skip to content

Commit

Permalink
wait for specified duration during LPmode on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
AnoopKamath authored Sep 30, 2024
1 parent daeed65 commit 6a2cfbe
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,14 @@ def set_lpmode(self, lpmode):
lpmode_val = lpmode_val | (1 << CmisApi.LowPwrRequestSW)
self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val)
time.sleep(0.1)
start_time = time.time()
pwroff_duration = self.get_module_pwr_down_duration()/1000
# Loop until the power-off duration has elapsed
while (time.time() - start_time) < pwroff_duration:
if self.get_lpmode():
return self.get_lpmode()
# Sleep for a short interval before the next check
time.sleep(0.1)
return self.get_lpmode()
else:
# Force transition from LowPwr to HighPower state under SW control.
Expand All @@ -1092,8 +1100,15 @@ def set_lpmode(self, lpmode):
lpmode_val = lpmode_val & ~(1 << CmisApi.LowPwrAllowRequestHW)
self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val)
time.sleep(1)
mstate = self.get_module_state()
return True if mstate == 'ModuleReady' else False
start_time = time.time()
# Loop until the power-on duration has elapsed
pwron_duration = self.get_module_pwr_up_duration()/1000
while (time.time() - start_time) < pwron_duration:
mstate = self.get_module_state()
if mstate == 'ModuleReady':
return True
# Sleep for a short interval before the next check
time.sleep(0.1)
return False

def get_loopback_capability(self):
Expand Down

0 comments on commit 6a2cfbe

Please sign in to comment.