DOIP-SDK
This is the Software Development Kit (SDK) for DOIP implementation in Python. It provides a template for DOIP servers as well as some utility methods to facilitate the implementation. Please check our documentation page.
Installation
This package requires Python version >=3.11. To install it, run:
# Using pip
$ pip install doip-sdk
# Using poetry
$ poetry add doip-sdk
Quick start
Server side
Suppose that we want to implement a server, which speaks DOIP. For that, we first need to create a handler. A handler is a component which handles incoming requests. Below is an example handler, which simply returns a success message.
from collections.abc import Iterator
from doip_sdk import DOIPHandler, ServerResponse, ResponseStatus, write_json_segment, write_empty_segment, DOIPServer
class ExampleHandler(DOIPHandler):
def hello(self, first_segment: dict, _: Iterator[bytearray]):
response = ServerResponse(status=ResponseStatus.SUCCESS)
write_json_segment(
socket=self.request,
message=response.model_dump(exclude_none=True)
)
write_empty_segment(socket=self.request)
if __name__ == '__main__':
HOST, PORT = 'localhost', 9999
service_id = 'test-server'
with DOIPServer(service_id, HOST, PORT, ExampleHandler) as server:
server.start()
On line 18, we create a server instance, which uses the ExampleHandler, and start it. According to the
DOIP Specification, all communication must take place over a secured channel. Therefore, if a private key and a
certificate are not provided, the DOIPServer generates a self-signed certificate and use it.
To stop the server, simply press ctrl + c.
The ExampleHandler above overrides the hello method, which is called when a 0.DOIP/Op.Hello operation is
received. Currently, these methods below can be overridden:
hellocreateretrieveupdatedeletesearchlist_operationextended_operation
All of them have the same signature, where the first parameter (except self) is the first segment in the request,
and the second parameter is an Iterator[bytearray], which can be used to read other segments in the message.
Each method will be called respectively based on the operationId from the client. If the operationId does not
refer to a basic operation, the extended_operation method will be triggered instead. It is not required to implement
all those methods. If the client asks for an unsupported operation, an error message will be automatically returned.
Client side
An example client for the server above can be implemented as follows:
from doip_sdk import send_request
if __name__ == '__main__':
host, port = 'localhost', 9999
data = {
'operationId': '0.DOIP/Op.Hello'
}
response = send_request(host=host, port=port, payload=[data])
for segment in response.content:
print(segment.decode('utf-8'))
The example client sends a request with the Hello operation and print out the response.
Metadata
Release files for doip_sdk 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| doip_sdk-0.0.9.tar.gz | 9.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| doip_sdk-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / doip_sdk-0.0.9.tar.gz
| Download URL | doip_sdk-0.0.9.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bacfeed072345ba47543a09881b01990da64a0a1d08b4c3c2eb18816c5880f63
|
|
BLAKE2b-256 checksum How to use checksums |
fe8c8627e6096db2df3bb50e9482a7779e26b43310d123bc740c75eb624e2380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.4 Darwin/23.6.0
|
Release files / doip_sdk-0.0.9-py3-none-any.whl
| Download URL | doip_sdk-0.0.9-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b0223a5bfb79bc8756bbc33edee8fa488992dd78ff78e7416c71a4551983a0f
|
|
BLAKE2b-256 checksum How to use checksums |
fbd0afb323c73960a4430c00084376935d88cb94f80d508bb0698c04945c8d04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.4 Darwin/23.6.0
|
Security for doip_sdk 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.