You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use either of the USB ports for PD communications, import the Host or Device classes. To assist with the creation of a message import the helper.
684
+
683
685
```python
684
686
from pd import Host, Device
685
687
```
686
688
687
-
Then create the objects,
689
+
Then create the objects,
690
+
688
691
```python
689
692
usb_in = Device()
690
693
usb_out = Host()
691
694
```
692
695
693
696
Check the connection state and send a message
697
+
694
698
```python
695
699
if usb_out.pd_enabled():
696
700
usb_out.send_vendor_msg(data, length)
697
701
```
698
702
699
-
700
703
### Methods
701
704
702
705
Both the Host and Device ports support the following methods.
@@ -748,6 +751,7 @@ pdh.device_send_badge_id()
748
751
```
749
752
750
753
### Usage
754
+
751
755
The helper can be used as follows to create the headers required for a discover identity command.
752
756
753
757
```python
@@ -768,13 +772,13 @@ usb_out.send_prime_msg(
768
772
769
773
<!-- prettier-ignore -->
770
774
| Method | Description | Arguments | Returns |
771
-
| ------ | ----------- | --------- | ------- |
775
+
| ------ | ----------- | --------- | ------- |
772
776
| device_send_badge_id | Sends the id used to detect another badge on the USB in port | None | None |
773
777
| host_disc_id_dbl_prime | Sends the discover identity command to a cables plug | None | None |
774
-
| host_disc_id_prime | None | None |
778
+
| host_disc_id_prime |Sends the discover identity command to a cables plug |None | None |
775
779
| host_send_badge_id | Sends the id used to detect another badge on the USB out port | None | None |
776
780
| pd_header | Create a message header with space for the badge to fill in physical layer info |`message_type`(`int`): see dataType and cmdType below, `no_objects`(`int`): number of 4 byte objects, optional, default 0 |`header`(`int`): 16 bit header |
777
-
| vdm_structured_header | Creates a structured vendor header |`command`(`int`): see vdmCmd below, `SVID`(`int`): Standard or Vendor ID, optional, default 0xFF00, `obj_pos`(`int`):For the Enter Mode, Exit Mode and Attention Commands, optional, default 0, `version`(`int`): Structured VDM Version, optional, default 0, |`vendor_header`(`int`): 32 bit vendor header |
781
+
| vdm_structured_header | Creates a structured vendor header |`command`(`int`): see vdmCmd below, `SVID`(`int`): Standard or Vendor ID, optional, default 0xFF00, `obj_pos`(`int`):For the Enter Mode, Exit Mode and Attention Commands, optional, default 0, `version`(`int`): Structured VDM Version, optional, default 0, |`vendor_header`(`int`): 32 bit vendor header |
778
782
| vdm_unstructured_header | Creates an unstructured vendor header |`SVID`(`int`): optional, default 0xFF00, `data`(`int`): 15 bits of vendor defined data |`vendor_header`(`int`): 32 bit vendor header |
779
783
| vdm_header_extract | extract the fields of a vendor header |`vendor_header`(`int`): 32 bit vendor header |`vendor_header`(`dict`): dictionary containing each field of the header |
780
784
@@ -783,8 +787,8 @@ usb_out.send_prime_msg(
783
787
The following constants are available for use in the two headers.
0 commit comments