Browse Source

Add unchunked_ext_msg to SrcFixedPDO

Clara Hobbs 6 years ago
parent
commit
c2871a64e8
2 changed files with 33 additions and 21 deletions
  1. 13
    4
      pdbuddy/__init__.py
  2. 20
    17
      test_pdbuddy/__init__.py

+ 13
- 4
pdbuddy/__init__.py View File

@@ -341,13 +341,15 @@ class UnknownPDO(namedtuple("UnknownPDO", "value")):
341 341
 
342 342
 
343 343
 class SrcFixedPDO(namedtuple("SrcFixedPDO", "dual_role_pwr usb_suspend "
344
-        "unconstrained_pwr usb_comms dual_role_data peak_i v i")):
344
+        "unconstrained_pwr usb_comms dual_role_data unchunked_ext_msg peak_i "
345
+        "v i")):
345 346
     """A Source Fixed PDO
346 347
 
347 348
     ``dual_role_pwr``, ``usb_suspend``, ``unconstrained_pwr``,
348
-    ``usb_comms``, and ``dual_role_data`` should be booleans.  ``peak_i``
349
-    should be an integer in the range [0, 3].  ``v`` is the voltage in
350
-    millivolts, and ``i`` is the maximum current in milliamperes.
349
+    ``usb_comms``, ``dual_role_data``, and ``unchunked_ext_msg`` should be
350
+    booleans.  ``peak_i`` should be an integer in the range [0, 3].  ``v``
351
+    is the voltage in millivolts, and ``i`` is the maximum current in
352
+    milliamperes.
351 353
     """
352 354
     __slots__ = ()
353 355
 
@@ -372,6 +374,9 @@ class SrcFixedPDO(namedtuple("SrcFixedPDO", "dual_role_pwr usb_suspend "
372 374
         if self.dual_role_data:
373 375
             s += "\tdual_role_data: 1\n"
374 376
 
377
+        if self.unchunked_ext_msg:
378
+            s += "\tunchunked_ext_msg: 1\n"
379
+
375 380
         if self.peak_i:
376 381
             s += "\tpeak_i: {}\n".format(self.peak_i)
377 382
 
@@ -411,6 +416,7 @@ def read_pdo(text):
411 416
         unconstrained_pwr = False
412 417
         usb_comms = False
413 418
         dual_role_data = False
419
+        unchunked_ext_msg = False
414 420
         peak_i = 0
415 421
 
416 422
         # Load a SrcFixedPDO
@@ -428,6 +434,8 @@ def read_pdo(text):
428 434
                 usb_comms = (fields[1] == b"1")
429 435
             elif fields[0] == b"dual_role_data":
430 436
                 dual_role_data = (fields[1] == b"1")
437
+            elif fields[0] == b"unchunked_ext_msg":
438
+                unchunked_ext_msg = (fields[1] == b"1")
431 439
             elif fields[0] == b"peak_i":
432 440
                 peak_i = int(fields[1])
433 441
             elif fields[0] == b"v":
@@ -442,6 +450,7 @@ def read_pdo(text):
442 450
                 unconstrained_pwr=unconstrained_pwr,
443 451
                 usb_comms=usb_comms,
444 452
                 dual_role_data=dual_role_data,
453
+                unchunked_ext_msg=unchunked_ext_msg,
445 454
                 peak_i=peak_i,
446 455
                 v=v,
447 456
                 i=i)

+ 20
- 17
test_pdbuddy/__init__.py View File

@@ -262,15 +262,16 @@ class SrcFixedPDOTestCase(unittest.TestCase):
262 262
 
263 263
     def setUp(self):
264 264
         self.obj_everything = pdbuddy.SrcFixedPDO(True, True, True, True, True,
265
-                3, 20000, 5000)
265
+                True, 3, 20000, 5000)
266 266
         self.obj_minimal = pdbuddy.SrcFixedPDO(False, False, False, False,
267
-                False, 0, 5000, 1500)
267
+                False, False, 0, 5000, 1500)
268 268
 
269 269
     def test_str_everything(self):
270 270
         self.assertEqual(str(self.obj_everything),
271 271
                 "fixed\n\tdual_role_pwr: 1\n\tusb_suspend: 1\n"
272 272
                 "\tunconstrained_pwr: 1\n\tusb_comms: 1\n\tdual_role_data: 1\n"
273
-                "\tpeak_i: 3\n\tv: 20.00 V\n\ti: 5.00 A")
273
+                "\tunchunked_ext_msg: 1\n\tpeak_i: 3\n\tv: 20.00 V\n"
274
+                "\ti: 5.00 A")
274 275
 
275 276
     def test_str_minimal(self):
276 277
         self.assertEqual(str(self.obj_minimal),
@@ -290,9 +291,9 @@ class ReadPDOTestCase(unittest.TestCase):
290 291
 
291 292
     def setUp(self):
292 293
         self.src_fixed_everything = pdbuddy.SrcFixedPDO(True, True, True, True,
293
-                True, 3, 20000, 5000)
294
+                True, True, 3, 20000, 5000)
294 295
         self.src_fixed_minimal = pdbuddy.SrcFixedPDO(False, False, False,
295
-                False, False, 0, 5000, 1500)
296
+                False, False, False, 0, 5000, 1500)
296 297
         self.unknown_zero = pdbuddy.UnknownPDO(value=0x00000000)
297 298
         self.unknown_notzero = pdbuddy.UnknownPDO(value=0xFFFFFFFF)
298 299
         self.typec_virtual = pdbuddy.TypeCVirtualPDO(1500)
@@ -304,6 +305,7 @@ class ReadPDOTestCase(unittest.TestCase):
304 305
                 b"\tunconstrained_pwr: 1",
305 306
                 b"\tusb_comms: 1",
306 307
                 b"\tdual_role_data: 1",
308
+                b"\tunchunked_ext_msg: 1",
307 309
                 b"\tpeak_i: 3",
308 310
                 b"\tv: 20.00 V",
309 311
                 b"\ti: 5.00 A"])
@@ -343,9 +345,9 @@ class ReadPDOListTestCase(unittest.TestCase):
343 345
 
344 346
     def setUp(self):
345 347
         self.src_fixed_everything = pdbuddy.SrcFixedPDO(True, True, True, True,
346
-                True, 3, 20000, 5000)
348
+                True, True, 3, 20000, 5000)
347 349
         self.src_fixed_minimal = pdbuddy.SrcFixedPDO(False, False, False,
348
-                False, False, 0, 5000, 1500)
350
+                False, False, False, 0, 5000, 1500)
349 351
         self.unknown_zero = pdbuddy.UnknownPDO(value=0x00000000)
350 352
         self.unknown_notzero = pdbuddy.UnknownPDO(value=0xFFFFFFFF)
351 353
         self.typec_virtual = pdbuddy.TypeCVirtualPDO(1500)
@@ -359,6 +361,7 @@ class ReadPDOListTestCase(unittest.TestCase):
359 361
                 b"\tunconstrained_pwr: 1",
360 362
                 b"\tusb_comms: 1",
361 363
                 b"\tdual_role_data: 1",
364
+                b"\tunchunked_ext_msg: 1",
362 365
                 b"\tpeak_i: 3",
363 366
                 b"\tv: 20.00 V",
364 367
                 b"\ti: 5.00 A",
@@ -382,25 +385,25 @@ class PDOListCalculationsTestCase(unittest.TestCase):
382 385
 
383 386
     def setUp(self):
384 387
         self.src_fixed_5v_1p5a = pdbuddy.SrcFixedPDO(False, False, True,
385
-                False, False, 0, 5000, 1500)
388
+                False, False, False, 0, 5000, 1500)
386 389
         self.src_fixed_5v_3a = pdbuddy.SrcFixedPDO(False, False, True, False,
387
-                False, 0, 5000, 3000)
390
+                False, False, 0, 5000, 3000)
388 391
         self.src_fixed_9v_1p6a = pdbuddy.SrcFixedPDO(False, False, False,
389
-                False, False, 0, 9000, 1600)
392
+                False, False, False, 0, 9000, 1600)
390 393
         self.src_fixed_9v_3a = pdbuddy.SrcFixedPDO(False, False, False, False,
391
-                False, 0, 9000, 3000)
394
+                False, False, 0, 9000, 3000)
392 395
         self.src_fixed_10v_1p5a = pdbuddy.SrcFixedPDO(False, False, False,
393
-                False, False, 0, 10000, 1500)
396
+                False, False, False, 0, 10000, 1500)
394 397
         self.src_fixed_12v_5a = pdbuddy.SrcFixedPDO(False, False, False, False,
395
-                False, 0, 12000, 5000)
398
+                False, False, 0, 12000, 5000)
396 399
         self.src_fixed_15v_1p8a = pdbuddy.SrcFixedPDO(False, False, False,
397
-                False, False, 0, 15000, 1800)
400
+                False, False, False, 0, 15000, 1800)
398 401
         self.src_fixed_15v_3a = pdbuddy.SrcFixedPDO(False, False, False, False,
399
-                False, 0, 15000, 3000)
402
+                False, False, 0, 15000, 3000)
400 403
         self.src_fixed_20v_2p25a = pdbuddy.SrcFixedPDO(False, False, False,
401
-                False, False, 0, 20000, 2250)
404
+                False, False, False, 0, 20000, 2250)
402 405
         self.src_fixed_20v_5a = pdbuddy.SrcFixedPDO(False, False, False, False,
403
-                False, 0, 20000, 5000)
406
+                False, False, 0, 20000, 5000)
404 407
         self.typec_virtual_1p5a = pdbuddy.TypeCVirtualPDO(1500)
405 408
 
406 409
     def test_calculate_pdp_typec_virtual(self):

Loading…
Cancel
Save