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
 
341
 
342
 
342
 
343
 class SrcFixedPDO(namedtuple("SrcFixedPDO", "dual_role_pwr usb_suspend "
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
     """A Source Fixed PDO
346
     """A Source Fixed PDO
346
 
347
 
347
     ``dual_role_pwr``, ``usb_suspend``, ``unconstrained_pwr``,
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
     __slots__ = ()
354
     __slots__ = ()
353
 
355
 
372
         if self.dual_role_data:
374
         if self.dual_role_data:
373
             s += "\tdual_role_data: 1\n"
375
             s += "\tdual_role_data: 1\n"
374
 
376
 
377
+        if self.unchunked_ext_msg:
378
+            s += "\tunchunked_ext_msg: 1\n"
379
+
375
         if self.peak_i:
380
         if self.peak_i:
376
             s += "\tpeak_i: {}\n".format(self.peak_i)
381
             s += "\tpeak_i: {}\n".format(self.peak_i)
377
 
382
 
411
         unconstrained_pwr = False
416
         unconstrained_pwr = False
412
         usb_comms = False
417
         usb_comms = False
413
         dual_role_data = False
418
         dual_role_data = False
419
+        unchunked_ext_msg = False
414
         peak_i = 0
420
         peak_i = 0
415
 
421
 
416
         # Load a SrcFixedPDO
422
         # Load a SrcFixedPDO
428
                 usb_comms = (fields[1] == b"1")
434
                 usb_comms = (fields[1] == b"1")
429
             elif fields[0] == b"dual_role_data":
435
             elif fields[0] == b"dual_role_data":
430
                 dual_role_data = (fields[1] == b"1")
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
             elif fields[0] == b"peak_i":
439
             elif fields[0] == b"peak_i":
432
                 peak_i = int(fields[1])
440
                 peak_i = int(fields[1])
433
             elif fields[0] == b"v":
441
             elif fields[0] == b"v":
442
                 unconstrained_pwr=unconstrained_pwr,
450
                 unconstrained_pwr=unconstrained_pwr,
443
                 usb_comms=usb_comms,
451
                 usb_comms=usb_comms,
444
                 dual_role_data=dual_role_data,
452
                 dual_role_data=dual_role_data,
453
+                unchunked_ext_msg=unchunked_ext_msg,
445
                 peak_i=peak_i,
454
                 peak_i=peak_i,
446
                 v=v,
455
                 v=v,
447
                 i=i)
456
                 i=i)

+ 20
- 17
test_pdbuddy/__init__.py View File

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

Loading…
Cancel
Save