Skip to content

Commit c6a41cf

Browse files
Wen-Shih Chaoaigarius
authored andcommitted
feat: update to 2.18.10
1 parent 60c0c74 commit c6a41cf

5 files changed

Lines changed: 179 additions & 13 deletions

File tree

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
ARG BASE_IMAGE=alpine:3.17
1+
ARG BASE_IMAGE=alpine:3.20
2+
23
FROM ${BASE_IMAGE}
34

45
ARG LIBDLT_VERSION=v2.18.8
56

67
RUN set -ex \
78
&& apk add --no-cache build-base musl-dev linux-headers git cmake ninja \
8-
wget curl dbus zlib \
9+
wget curl dbus zlib zlib-dev \
910
python3 python3-dev py3-pip py3-tox \
1011
&& git clone https://github.com/GENIVI/dlt-daemon \
1112
&& cd /dlt-daemon \

Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Non released dlt-daemon version based on 2.18.8
2-
LIBDLT_VERSION=v2.18.8
1+
# Non released dlt-daemon version based on 2.18.10
2+
LIBDLT_VERSION=v2.18.10
33

44
IMAGE=python-dlt/python-dlt-unittest
55
TAG?=latest
@@ -13,13 +13,6 @@ all:
1313
@echo " make build-image -- Build docker image for the usage of 'make unit-test'"
1414
@echo " make clean -- Remove all temporary files"
1515

16-
.PHONY: test
17-
test:
18-
mkdir -p junit_reports;
19-
nosetests --no-byte-compile \
20-
--with-xunit --xunit-file=junit_reports/python-dlt_tests.xml \
21-
tests
22-
2316
.PHONY: unit-test
2417
unit-test:
2518
${DK_CMD} ${IMAGE}:${TAG} tox ${TEST_ARGS}

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ primarily created for use with BMW's test execution framework. However,
55
the implementation is independent and the API makes few assumptions about
66
the intended use.
77

8-
Note: This is only tested with libdlt version v2.18.5 (33fbad18c814e13bd7ba2053525d8959fee437d1) and v2.18.8,
8+
Note: This is only tested with libdlt version v2.18.8 and v2.18.10,
99
later versions might require adaptations. The package will not support previous libdlt
1010
versions from python-dlt v2.0. Also only GENIVI DLT daemon produced traces
1111
have been tested.
@@ -119,3 +119,25 @@ The DLTBroker abstracts out the management of 2 (multiprocessing) queues:
119119
example, via a request from `DLTContext`). This is run as a separate thread in
120120
the `DLTBroker` process. The code for this is in
121121
`dlt.dlt_broker_handlers.DLTContextHandler`.
122+
123+
## Running tox on a local machine
124+
125+
In order to run tox command for this repository, please perform the following:
126+
127+
1. Build a docker image from the `Dockerfile` provided using:
128+
129+
```commandline
130+
$ docker build -t python-dlt -f Dockerfile .
131+
```
132+
133+
2. Run the tox in the docker container using:
134+
135+
```commandline
136+
$ docker run -it --rm --volume $(pwd):/workspace python-dlt /bin/sh -xc "tox -e py3,lint"
137+
```
138+
139+
3. [Special Case] Getting an interactive shell inside the docker container to run arbitrary commands:
140+
141+
```commandline
142+
$ docker run -it --rm --volume $(pwd):/workspace --entrypoint sh python-dlt
143+
```

dlt/core/core_21810.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Copyright (C) 2022. BMW CTW PT. All rights reserved.
2+
"""v2.18.8 specific class definitions"""
3+
import ctypes
4+
import logging
5+
6+
from dlt.core.core_base import dltlib
7+
8+
# DltClientMode from dlt_client.h
9+
DLT_CLIENT_MODE_UNDEFINED = -1
10+
DLT_CLIENT_MODE_TCP = 0
11+
DLT_CLIENT_MODE_SERIAL = 1
12+
DLT_CLIENT_MODE_UNIX = 2
13+
DLT_CLIENT_MODE_UDP_MULTICAST = 3
14+
15+
# DltReceiverType from dlt_common.h
16+
DLT_RECEIVE_SOCKET = 0
17+
DLT_RECEIVE_UDP_SOCKET = 1
18+
DLT_RECEIVE_FD = 2
19+
DLT_ID_SIZE = 4
20+
DLT_FILTER_MAX = 30 # Maximum number of filters
21+
DLT_RETURN_ERROR = -1
22+
23+
# Return value for DLTFilter.add() - exceeded maximum number of filters
24+
MAX_FILTER_REACHED = 1
25+
# Return value for DLTFilter.add() - specified filter already exists
26+
REPEATED_FILTER = 2
27+
28+
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
29+
30+
31+
class sockaddr_in(ctypes.Structure): # pylint: disable=invalid-name
32+
"""Auxiliary definition for cDltReceiver. Defined in netinet/in.h header"""
33+
34+
_fields_ = [
35+
("sa_family", ctypes.c_ushort), # sin_family
36+
("sin_port", ctypes.c_ushort),
37+
("sin_addr", ctypes.c_byte * 4),
38+
("__pad", ctypes.c_byte * 8),
39+
] # struct sockaddr_in is 16
40+
41+
42+
class cDltReceiver(ctypes.Structure): # pylint: disable=invalid-name
43+
"""The structure is used to organise the receiving of data including buffer handling.
44+
This structure is used by the corresponding functions.
45+
46+
typedef struct
47+
{
48+
int32_t lastBytesRcvd; /**< bytes received in last receive call */
49+
int32_t bytesRcvd; /**< received bytes */
50+
int32_t totalBytesRcvd; /**< total number of received bytes */
51+
char *buffer; /**< pointer to receiver buffer */
52+
char *buf; /**< pointer to position within receiver buffer */
53+
char *backup_buf; /** pointer to the buffer with partial messages if any **/
54+
int fd; /**< connection handle */
55+
DltReceiverType type; /**< type of connection handle */
56+
int32_t buffersize; /**< size of receiver buffer */
57+
struct sockaddr_in addr; /**< socket address information */
58+
} DltReceiver;
59+
"""
60+
61+
_fields_ = [
62+
("lastBytesRcvd", ctypes.c_int32),
63+
("bytesRcvd", ctypes.c_int32),
64+
("totalBytesRcvd", ctypes.c_int32),
65+
("buffer", ctypes.POINTER(ctypes.c_char)),
66+
("buf", ctypes.POINTER(ctypes.c_char)),
67+
("backup_buf", ctypes.POINTER(ctypes.c_char)),
68+
("fd", ctypes.c_int),
69+
("type", ctypes.c_int),
70+
("buffersize", ctypes.c_int32),
71+
("addr", sockaddr_in),
72+
]
73+
74+
75+
class cDltClient(ctypes.Structure): # pylint: disable=invalid-name
76+
"""
77+
typedef struct
78+
{
79+
DltReceiver receiver; /**< receiver pointer to dlt receiver structure */
80+
int sock; /**< sock Connection handle/socket */
81+
char *servIP; /**< servIP IP adress/Hostname of TCP/IP interface */
82+
char *hostip; /**< IP multicast address of group */
83+
int port; /**< Port for TCP connections (optional) */
84+
char *serialDevice; /**< serialDevice Devicename of serial device */
85+
char *socketPath; /**< socketPath Unix socket path */
86+
char ecuid[4]; /**< ECUiD */
87+
speed_t baudrate; /**< baudrate Baudrate of serial interface, as speed_t */
88+
DltClientMode mode; /**< mode DltClientMode */
89+
int send_serial_header; /**< (Boolean) Send DLT messages with serial header */
90+
int resync_serial_header; /**< (Boolean) Resync to serial header on all connection */
91+
} DltClient;
92+
"""
93+
94+
_fields_ = [
95+
("receiver", cDltReceiver),
96+
("sock", ctypes.c_int),
97+
("servIP", ctypes.c_char_p),
98+
("hostip", ctypes.c_char_p),
99+
("port", ctypes.c_int),
100+
("serialDevice", ctypes.c_char_p),
101+
("socketPath", ctypes.c_char_p),
102+
("ecuid", ctypes.c_char * 4),
103+
("baudrate", ctypes.c_uint),
104+
("mode", ctypes.c_int),
105+
("send_serial_header", ctypes.c_int),
106+
("resync_serial_header", ctypes.c_int),
107+
]
108+
109+
110+
class cDLTFilter(ctypes.Structure): # pylint: disable=invalid-name
111+
"""
112+
typedef struct
113+
{
114+
char apid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< application id */
115+
char ctid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< context id */
116+
int log_level[DLT_FILTER_MAX]; /**< log level */
117+
int32_t payload_max[DLT_FILTER_MAX]; /**< upper border for payload */
118+
int32_t payload_min[DLT_FILTER_MAX]; /**< lower border for payload */
119+
int counter; /**< number of filters */
120+
} DltFilter;
121+
"""
122+
123+
_fields_ = [
124+
("apid", (ctypes.c_char * DLT_ID_SIZE) * DLT_FILTER_MAX),
125+
("ctid", (ctypes.c_char * DLT_ID_SIZE) * DLT_FILTER_MAX),
126+
("log_level", ctypes.c_int * DLT_FILTER_MAX),
127+
("payload_max", (ctypes.c_int32 * DLT_FILTER_MAX)),
128+
("payload_min", (ctypes.c_int32 * DLT_FILTER_MAX)),
129+
("counter", ctypes.c_int),
130+
]
131+
132+
# pylint: disable=too-many-arguments
133+
def add(self, apid, ctid, log_level=0, payload_min=0, payload_max=ctypes.c_uint32(-1).value // 2):
134+
"""Add new filter pair"""
135+
if isinstance(apid, str):
136+
apid = bytes(apid, "ascii")
137+
if isinstance(ctid, str):
138+
ctid = bytes(ctid, "ascii")
139+
if (
140+
dltlib.dlt_filter_add(
141+
ctypes.byref(self), apid or b"", ctid or b"", log_level, payload_min, payload_max, self.verbose
142+
)
143+
== DLT_RETURN_ERROR
144+
):
145+
if self.counter >= DLT_FILTER_MAX:
146+
logger.error("Maximum number (%d) of allowed filters reached, ignoring filter!\n", DLT_FILTER_MAX)
147+
return MAX_FILTER_REACHED
148+
logger.debug("Filter ('%s', '%s') already exists", apid, ctid)
149+
return REPEATED_FILTER
150+
return 0

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ deps =
2626
ruff
2727
mypy
2828
commands =
29-
ruff .
29+
ruff check ./dlt ./tests
3030

3131
[testenv:black]
3232
skip_install = True

0 commit comments

Comments
 (0)