# usbpdpy
Python bindings for the [`usbpd`](https://crates.io/crates/usbpd) Rust crate.
## Installation
```bash
pip install usbpdpy
```
## Usage
```python
import usbpdpy
# Parse message from bytes
message = usbpdpy.parse_pd_message(b'\x61\x11')
print(f"Type: {message.header.message_type}")
print(f"Name: {usbpdpy.get_message_type_name(message.header.message_type)}")
# Convert hex to bytes
data = usbpdpy.hex_to_bytes("1161")
message = usbpdpy.parse_pd_message(data)
```
## API
### Functions
- `parse_pd_message(data: bytes) -> PyPdMessage`
- `parse_pd_messages(messages: List[bytes]) -> List[PyPdMessage]`
- `get_message_type_name(msg_type: int) -> str`
- `hex_to_bytes(hex_str: str) -> bytes`
- `bytes_to_hex(data: bytes) -> str`
### Classes
**PyPdMessage**
- `header: PyPdHeader`
- `data_objects: List[PyPdDataObject]`
- `raw_bytes: List[int]`
- `get_hex() -> str`
**PyPdHeader**
- `message_type: int`
- `port_data_role: str` ("UFP"/"DFP")
- `port_power_role: str` ("Sink"/"Source")
- `message_id: int`
- `number_of_data_objects: int`
- `extended: bool`
**PyPdDataObject**
- `raw: int`
- `object_type: str`
- `parsed_data: Optional[str]`
## Requirements
- Python 3.8+
- No runtime dependencies
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/okhsunrog/usbpdpy",
"name": "usbpdpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "usb, usb-pd, power-delivery, protocol, parsing, hardware",
"author": null,
"author_email": "Danila Gornushko <me@okhsunrog.dev>",
"download_url": "https://files.pythonhosted.org/packages/34/b3/d1b3be578a28b99ce42ea80215bbd7a71252ff3b9dd625de86206ec16889/usbpdpy-0.1.0.tar.gz",
"platform": null,
"description": "# usbpdpy\n\nPython bindings for the [`usbpd`](https://crates.io/crates/usbpd) Rust crate.\n\n## Installation\n\n```bash\npip install usbpdpy\n```\n\n## Usage\n\n```python\nimport usbpdpy\n\n# Parse message from bytes\nmessage = usbpdpy.parse_pd_message(b'\\x61\\x11')\nprint(f\"Type: {message.header.message_type}\")\nprint(f\"Name: {usbpdpy.get_message_type_name(message.header.message_type)}\")\n\n# Convert hex to bytes\ndata = usbpdpy.hex_to_bytes(\"1161\")\nmessage = usbpdpy.parse_pd_message(data)\n```\n\n## API\n\n### Functions\n\n- `parse_pd_message(data: bytes) -> PyPdMessage`\n- `parse_pd_messages(messages: List[bytes]) -> List[PyPdMessage]`\n- `get_message_type_name(msg_type: int) -> str`\n- `hex_to_bytes(hex_str: str) -> bytes`\n- `bytes_to_hex(data: bytes) -> str`\n\n### Classes\n\n**PyPdMessage**\n- `header: PyPdHeader`\n- `data_objects: List[PyPdDataObject]` \n- `raw_bytes: List[int]`\n- `get_hex() -> str`\n\n**PyPdHeader**\n- `message_type: int`\n- `port_data_role: str` (\"UFP\"/\"DFP\")\n- `port_power_role: str` (\"Sink\"/\"Source\")\n- `message_id: int`\n- `number_of_data_objects: int`\n- `extended: bool`\n\n**PyPdDataObject**\n- `raw: int`\n- `object_type: str`\n- `parsed_data: Optional[str]`\n\n## Requirements\n\n- Python 3.8+\n- No runtime dependencies\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python bindings for the usbpd Rust crate - fast USB Power Delivery message parsing",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/okhsunrog/usbpdpy#readme",
"Homepage": "https://github.com/okhsunrog/usbpdpy",
"Issues": "https://github.com/okhsunrog/usbpdpy/issues",
"Repository": "https://github.com/okhsunrog/usbpdpy"
},
"split_keywords": [
"usb",
" usb-pd",
" power-delivery",
" protocol",
" parsing",
" hardware"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "92bec9e2f4b5458411087ca4fb73b5bba1d3328733b681aa0bcefc6e88926832",
"md5": "b8b4c854a95e9e51be28210bfaade96b",
"sha256": "d8f29313274eaabf411a3e609564c8dce39ce74d5bb2fa878605eb23969f3572"
},
"downloads": -1,
"filename": "usbpdpy-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl",
"has_sig": false,
"md5_digest": "b8b4c854a95e9e51be28210bfaade96b",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.8",
"size": 233024,
"upload_time": "2025-09-04T15:48:07",
"upload_time_iso_8601": "2025-09-04T15:48:07.404052Z",
"url": "https://files.pythonhosted.org/packages/92/be/c9e2f4b5458411087ca4fb73b5bba1d3328733b681aa0bcefc6e88926832/usbpdpy-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "34b3d1b3be578a28b99ce42ea80215bbd7a71252ff3b9dd625de86206ec16889",
"md5": "8d9aa00996e2ea87901893b304b3ae0d",
"sha256": "d90e6a149ca6384230ccf3ef4ff1636867944873b7c9a0639bfb33ae512f702b"
},
"downloads": -1,
"filename": "usbpdpy-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "8d9aa00996e2ea87901893b304b3ae0d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 7232,
"upload_time": "2025-09-04T15:48:09",
"upload_time_iso_8601": "2025-09-04T15:48:09.336998Z",
"url": "https://files.pythonhosted.org/packages/34/b3/d1b3be578a28b99ce42ea80215bbd7a71252ff3b9dd625de86206ec16889/usbpdpy-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-04 15:48:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "okhsunrog",
"github_project": "usbpdpy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "usbpdpy"
}