27
27
# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --int-arg PIXIT.RVCRUNM.MODE_A:1 PIXIT.RVCRUNM.MODE_B:2
28
28
# === END CI TEST ARGUMENTS ===
29
29
30
+ import enum
30
31
from time import sleep
31
32
32
33
import chip .clusters as Clusters
37
38
# Run the test with
38
39
# --int-arg PIXIT.RVCRUNM.MODE_A:<mode id> PIXIT.RVCRUNM.MODE_B:<mode id>
39
40
41
+ class RvcStatusEnum (enum .IntEnum ):
42
+ # TODO remove this class once InvalidInMode response code is implemented in python SDK
43
+ Success = 0x0
44
+ UnsupportedMode = 0x1
45
+ GenericFailure = 0x2
46
+ InvalidInMode = 0x3
47
+
40
48
41
49
def error_enum_to_text (error_enum ):
42
50
try :
43
51
return f'{ Clusters .RvcRunMode .Enums .ModeTag (error_enum ).name } 0x{ error_enum :02x} '
44
52
except AttributeError :
45
- if error_enum == 0 :
53
+ if error_enum == RvcStatusEnum . Success :
46
54
return "Success(0x00)"
47
- elif error_enum == 0x1 :
55
+ elif error_enum == RvcStatusEnum . UnsupportedMode :
48
56
return "UnsupportedMode(0x01)"
49
- elif error_enum == 0x2 :
57
+ elif error_enum == RvcStatusEnum . GenericFailure :
50
58
return "GenericFailure(0x02)"
51
- elif error_enum == 0x3 :
59
+ elif error_enum == RvcStatusEnum . InvalidInMode :
52
60
return "InvalidInMode(0x03)"
53
61
54
62
raise AttributeError ("Unknown Enum value" )
@@ -122,6 +130,9 @@ async def test_TC_RVCRUNM_2_2(self):
122
130
"PIXIT.RVCRUNM.MODE_A:<mode id> \n "
123
131
"PIXIT.RVCRUNM.MODE_B:<mode id>" )
124
132
133
+ # TODO Replace 0x8000 with python object of RVCRUN FEATURE bit when implemented
134
+ # 0x8000 corresponds to 16 bit DIRECTMODECH Feature map
135
+ self .directmodech_bit_map = 0x8000
125
136
self .endpoint = self .matter_test_config .endpoint
126
137
self .is_ci = self .check_pics ("PICS_SDK_CI_ONLY" )
127
138
self .mode_a = self .matter_test_config .global_test_params ['PIXIT.RVCRUNM.MODE_A' ]
@@ -193,15 +204,23 @@ async def test_TC_RVCRUNM_2_2(self):
193
204
asserts .assert_true (idle_tag_present , "The device must be in a mode with the Idle (0x4000) mode tag." )
194
205
195
206
self .print_step (5 , "Send ChangeToMode MODE_A command" )
196
- await self .send_change_to_mode_with_check (self .mode_a , 0 )
207
+ await self .send_change_to_mode_with_check (self .mode_a , RvcStatusEnum . Success )
197
208
# This step is not described in the test plan, but it ought to be
198
209
await self .read_current_mode_with_check (self .mode_a )
199
210
200
- self .print_step (6 , "Send ChangeToMode MODE_B command" )
201
- await self .send_change_to_mode_with_check (self .mode_b , 3 )
211
+ self .print_step ("6a" , "Read Attribute FeatureMap" )
212
+ directmodech = await self .read_mod_attribute_expect_success (cluster = Clusters .RvcRunMode ,
213
+ attribute = Clusters .RvcRunMode .Attributes .FeatureMap )
214
+ directmode_enabled = directmodech & self .directmodech_bit_map
215
+
216
+ self .print_step ('6b' , "Send ChangeToMode MODE_B command" )
217
+ if directmode_enabled :
218
+ await self .send_change_to_mode_with_check (self .mode_b , RvcStatusEnum .Success )
219
+ else :
220
+ await self .send_change_to_mode_with_check (self .mode_b , RvcStatusEnum .InvalidInMode )
202
221
203
222
self .print_step (7 , "Send ChangeToMode idle command" )
204
- await self .send_change_to_mode_with_check (self .idle_mode_dut , 0 )
223
+ await self .send_change_to_mode_with_check (self .idle_mode_dut , RvcStatusEnum . Success )
205
224
# This step is not described in the test plan, but it ought to be
206
225
await self .read_current_mode_with_check (self .idle_mode_dut )
207
226
@@ -228,12 +247,12 @@ async def test_TC_RVCRUNM_2_2(self):
228
247
"Expected RVCOPSTATE's OperationalState attribute to be one of Stopped(0x00), Paused(0x02), Charging(0x41) or Docked(0x42)" )
229
248
230
249
self .print_step (11 , "Send ChangeToMode MODE_B command" )
231
- await self .send_change_to_mode_with_check (self .mode_b , 0 )
250
+ await self .send_change_to_mode_with_check (self .mode_b , RvcStatusEnum . Success )
232
251
# This step is not described in the test plan, but it ought to be
233
252
await self .read_current_mode_with_check (self .mode_b )
234
253
235
254
self .print_step (12 , "Send ChangeToMode idle command" )
236
- await self .send_change_to_mode_with_check (self .idle_mode_dut , 0 )
255
+ await self .send_change_to_mode_with_check (self .idle_mode_dut , RvcStatusEnum . Success )
237
256
# This step is not described in the test plan, but it ought to be
238
257
await self .read_current_mode_with_check (self .idle_mode_dut )
239
258
0 commit comments