@@ -291,7 +291,7 @@ def steps_TC_CGEN_2_2(self) -> list[TestStep]:
291
291
TestStep (33 , 'TH1 waits for PIXIT.CGEN.FailsafeExpiryLengthSeconds.' ),
292
292
TestStep (34 , 'TH1 reads the TrustedRootCertificates attribute from the Node Operational Credentials cluster.' ),
293
293
# TestStep(35, '''TH2 sends ArmFailSafe command to the DUT with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds
294
- # and the Breadcrumb value as 1.'''),
294
+ # and the Breadcrumb value as 1.'''),
295
295
TestStep (36 , 'TH1 sends ArmFailSafe command to the DUT with ExpiryLengthSeconds field set to 0.' ),
296
296
TestStep (37 , 'TH1 sends ArmFailSafe command to the DUT with ExpiryLengthSeconds field set to maxFailsafe.' ),
297
297
TestStep (38 , 'TH1 saves the current wall time clock in seconds as Tstart,' ),
@@ -382,9 +382,14 @@ async def test_TC_CGEN_2_2(self):
382
382
383
383
# Get the start time to measure the elapsed time
384
384
start_time = time .time ()
385
+ target_time = start_time + (maxFailsafe + .5 )
385
386
386
387
# Wait for the full duration of the maxFailsafe time with an additional 0.5-second buffer
387
- await asyncio .sleep (maxFailsafe + 0.5 )
388
+ while time .time () < target_time :
389
+ try :
390
+ await asyncio .sleep (0.1 )
391
+ except asyncio .CancelledError :
392
+ continue
388
393
389
394
# Calculate and log the elapsed time since the start of the wait
390
395
elapsed_time = time .time () - start_time
@@ -686,10 +691,9 @@ async def test_TC_CGEN_2_2(self):
686
691
# Wait the half of the maximum failsafe time using a while loop
687
692
while time .time () < target_time :
688
693
try :
689
- await asyncio .sleep (0.1 ) # Esperar un tiempo pequeño en cada iteración
694
+ await asyncio .sleep (0.1 )
690
695
except asyncio .CancelledError :
691
- # Si se lanza el TimeoutError, simplemente lo ignoramos
692
- continue # Ignoramos el error y seguimos esperando hasta que se cumpla el tiempo objetivo
696
+ continue
693
697
694
698
elapsed_time = time .time () - start_time
695
699
logger .info (f'Step #33: { run_type } - Elapsed time: { elapsed_time } seconds after waiting for half of the maxFailsafe.' )
@@ -720,12 +724,10 @@ async def test_TC_CGEN_2_2(self):
720
724
target_time = start_time + maxFailsafe + 1
721
725
while time .time () < target_time :
722
726
try :
723
- await asyncio .sleep (0.1 ) # Esperar un tiempo pequeño en cada iteración
727
+ await asyncio .sleep (0.1 )
724
728
except asyncio .CancelledError :
725
- # Si se lanza el TimeoutError, simplemente lo ignoramos
726
- continue # Ignoramos el error y seguimos esperando hasta que se cumpla el tiempo objetivo
729
+ continue
727
730
728
- # await asyncio.sleep(maxFailsafe + 1)
729
731
elapsed_time = time .time () - start_time
730
732
logger .info (f'Step #33: { run_type } - Failsafe timer (max_fail_safe) expired after { elapsed_time } seconds.' )
731
733
@@ -747,10 +749,8 @@ async def test_TC_CGEN_2_2(self):
747
749
# self.step(35)
748
750
# cmd = Clusters.GeneralCommissioning.Commands.ArmFailSafe(expiryLengthSeconds=maxFailsafe, breadcrumb=1)
749
751
# resp = await self.send_single_cmd(
750
- # dev_ctrl=self.default_controller,
751
- # node_id=self.dut_node_id,
752
- # # dev_ctrl=TH2,
753
- # # node_id=newNodeId+1,
752
+ # dev_ctrl=TH2,
753
+ # node_id=newNodeId+1,
754
754
# cmd=cmd)
755
755
# # Verify that the DUT responds with ArmFailSafeResponse with ErrorCode as 'BusyWithOtherAdmin'(4)
756
756
# logger.info(f'Step #35 - TH2 ArmFailSafeResponse with ErrorCode as BusyWithOtherAdmin ({resp.errorCode})')
@@ -826,7 +826,7 @@ async def test_TC_CGEN_2_2(self):
826
826
target_time = start_time + (maxFailsafe / 2 )
827
827
# Make TH1 wait until the current time is greater than or equal to the target time
828
828
while time .time () < target_time :
829
- time .sleep (0.1 ) # Wait for 100ms to avoid excessive CPU usage
829
+ await asyncio .sleep (0.1 )
830
830
831
831
# Check if the elapsed time since start_time has reached or exceeded half of the maxFailsafe time (maxFailsafe / 2).
832
832
# If the current time surpasses the start time by at least half of the maxFailsafe time, the TH1 process is allowed to proceed.
@@ -879,7 +879,7 @@ async def test_TC_CGEN_2_2(self):
879
879
880
880
# Make TH1 wait until the current time is greater than or equal to the target time
881
881
while time .time () < target_time :
882
- time .sleep (0.1 ) # Wait for 100ms to avoid excessive CPU usage
882
+ await asyncio .sleep (0.1 )
883
883
884
884
# Checks if the elapsed time from start_time has met or exceeded maxFailsafe
885
885
# If the current time has passed the start time by at least maxFailsafe, the TH1 process can proceed
0 commit comments