Skip to content

Commit 54af5d2

Browse files
authored
Merge branch 'main' into CC-2174_over8_adaptations
2 parents 6960e51 + 8e685ac commit 54af5d2

35 files changed

+966
-463
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,14 @@ jobs:
131131
- name: Set up Python
132132
uses: actions/setup-python@v5
133133
with:
134-
python-version: "3.10"
134+
python-version: "3.12"
135135
- name: Install dependencies
136136
run: |
137137
python -m pip install --upgrade pip
138-
pip install -e .[canalystii,gs_usb,mf4]
139-
pip install -r doc/doc-requirements.txt
138+
pip install tox
140139
- name: Build documentation
141140
run: |
142-
python -m sphinx -Wan --keep-going doc build
143-
- name: Run doctest
144-
run: |
145-
python -m sphinx -b doctest -W --keep-going doc build
141+
tox -e docs
146142
147143
build:
148144
name: Packaging

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-22.04
1111
tools:
12-
python: "3.10"
12+
python: "3.12"
1313

1414
# Build documentation in the docs/ directory with Sphinx
1515
sphinx:

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
Version 4.5.0
2+
=============
3+
4+
Features
5+
--------
6+
7+
* gs_usb command-line support (and documentation updates and stability fixes) by @BenGardiner in https://github.com/hardbyte/python-can/pull/1790
8+
* Faster and more general MF4 support by @cssedev in https://github.com/hardbyte/python-can/pull/1892
9+
* ASCWriter speed improvement by @pierreluctg in https://github.com/hardbyte/python-can/pull/1856
10+
* Faster Message string representation by @pierreluctg in https://github.com/hardbyte/python-can/pull/1858
11+
* Added Netronic's CANdo and CANdoISO adapters interface by @belliriccardo in https://github.com/hardbyte/python-can/pull/1887
12+
* Add autostart option to BusABC.send_periodic() to fix issue #1848 by @SWolfSchunk in https://github.com/hardbyte/python-can/pull/1853
13+
* Improve TestBusConfig by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1804
14+
* Improve speed of TRCReader by @lebuni in https://github.com/hardbyte/python-can/pull/1893
15+
16+
Bug Fixes
17+
---------
18+
19+
* Fix Kvaser timestamp by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1878
20+
* Set end_time in ThreadBasedCyclicSendTask.start() by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1871
21+
* Fix regex in _parse_additional_config() by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1868
22+
* Fix for #1849 (PCAN fails when PCAN_ERROR_ILLDATA is read via ReadFD) by @bures in https://github.com/hardbyte/python-can/pull/1850
23+
* Period must be >= 1ms for BCM using Win32 API by @pierreluctg in https://github.com/hardbyte/python-can/pull/1847
24+
* Fix ASCReader Crash on "Start of Measurement" Line by @RitheeshBaradwaj in https://github.com/hardbyte/python-can/pull/1811
25+
* Resolve AttributeError within NicanError by @vijaysubbiah20 in https://github.com/hardbyte/python-can/pull/1806
26+
27+
28+
Miscellaneous
29+
-------------
30+
31+
* Fix CI by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1889
32+
* Update msgpack dependency by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1875
33+
* Add tox environment for doctest by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1870
34+
* Use typing_extensions.TypedDict on python < 3.12 for pydantic support by @NickCao in https://github.com/hardbyte/python-can/pull/1845
35+
* Replace PyPy3.8 with PyPy3.10 by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1838
36+
* Fix slcan tests by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1834
37+
* Test on Python 3.13 by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1833
38+
* Stop notifier in examples by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1814
39+
* Use setuptools_scm by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1810
40+
* Added extra info for Kvaser dongles by @FedericoSpada in https://github.com/hardbyte/python-can/pull/1797
41+
* Socketcand: show actual response as well as expected in error by @liamkinne in https://github.com/hardbyte/python-can/pull/1807
42+
* Refactor CLI filter parsing, add tests by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1805
43+
* Add zlgcan to docs by @zariiii9003 in https://github.com/hardbyte/python-can/pull/1839
44+
45+
146
Version 4.4.2
247
=============
348

CONTRIBUTORS.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,12 @@ Felix Nieuwenhuizen
8383
@felixn
8484
@Tbruno25
8585
@RitheeshBaradwaj
86+
@vijaysubbiah20
87+
@liamkinne
88+
@RitheeshBaradwaj
89+
@BenGardiner
90+
@bures
91+
@NickCao
92+
@SWolfSchunk
93+
@belliriccardo
94+
@cssedev

can/broadcastmanager.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def __init__(
182182
"""
183183
super().__init__(messages, period)
184184
self.duration = duration
185+
self.end_time: Optional[float] = None
185186

186187

187188
class RestartableCyclicTaskABC(CyclicSendTaskABC, abc.ABC):
@@ -276,6 +277,7 @@ def __init__(
276277
period: float,
277278
duration: Optional[float] = None,
278279
on_error: Optional[Callable[[Exception], bool]] = None,
280+
autostart: bool = True,
279281
modifier_callback: Optional[Callable[[Message], None]] = None,
280282
) -> None:
281283
"""Transmits `messages` with a `period` seconds for `duration` seconds on a `bus`.
@@ -298,9 +300,6 @@ def __init__(
298300
self.send_lock = lock
299301
self.stopped = True
300302
self.thread: Optional[threading.Thread] = None
301-
self.end_time: Optional[float] = (
302-
time.perf_counter() + duration if duration else None
303-
)
304303
self.on_error = on_error
305304
self.modifier_callback = modifier_callback
306305

@@ -324,7 +323,8 @@ def __init__(
324323
stacklevel=1,
325324
)
326325

327-
self.start()
326+
if autostart:
327+
self.start()
328328

329329
def stop(self) -> None:
330330
self.stopped = True
@@ -339,6 +339,10 @@ def start(self) -> None:
339339
self.thread = threading.Thread(target=self._run, name=name)
340340
self.thread.daemon = True
341341

342+
self.end_time: Optional[float] = (
343+
time.perf_counter() + self.duration if self.duration else None
344+
)
345+
342346
if self.event and PYWIN32:
343347
PYWIN32.set_timer(self.event, self.period_ms)
344348

@@ -354,6 +358,7 @@ def _run(self) -> None:
354358

355359
while not self.stopped:
356360
if self.end_time is not None and time.perf_counter() >= self.end_time:
361+
self.stop()
357362
break
358363

359364
try:

can/bus.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def send_periodic(
215215
period: float,
216216
duration: Optional[float] = None,
217217
store_task: bool = True,
218+
autostart: bool = True,
218219
modifier_callback: Optional[Callable[[Message], None]] = None,
219220
) -> can.broadcastmanager.CyclicSendTaskABC:
220221
"""Start sending messages at a given period on this bus.
@@ -237,6 +238,10 @@ def send_periodic(
237238
:param store_task:
238239
If True (the default) the task will be attached to this Bus instance.
239240
Disable to instead manage tasks manually.
241+
:param autostart:
242+
If True (the default) the sending task will immediately start after creation.
243+
Otherwise, the task has to be started by calling the
244+
tasks :meth:`~can.RestartableCyclicTaskABC.start` method on it.
240245
:param modifier_callback:
241246
Function which should be used to modify each message's data before
242247
sending. The callback modifies the :attr:`~can.Message.data` of the
@@ -272,7 +277,9 @@ def send_periodic(
272277
# Create a backend specific task; will be patched to a _SelfRemovingCyclicTask later
273278
task = cast(
274279
_SelfRemovingCyclicTask,
275-
self._send_periodic_internal(msgs, period, duration, modifier_callback),
280+
self._send_periodic_internal(
281+
msgs, period, duration, autostart, modifier_callback
282+
),
276283
)
277284
# we wrap the task's stop method to also remove it from the Bus's list of tasks
278285
periodic_tasks = self._periodic_tasks
@@ -299,6 +306,7 @@ def _send_periodic_internal(
299306
msgs: Union[Sequence[Message], Message],
300307
period: float,
301308
duration: Optional[float] = None,
309+
autostart: bool = True,
302310
modifier_callback: Optional[Callable[[Message], None]] = None,
303311
) -> can.broadcastmanager.CyclicSendTaskABC:
304312
"""Default implementation of periodic message sending using threading.
@@ -312,6 +320,10 @@ def _send_periodic_internal(
312320
:param duration:
313321
The duration between sending each message at the given rate. If
314322
no duration is provided, the task will continue indefinitely.
323+
:param autostart:
324+
If True (the default) the sending task will immediately start after creation.
325+
Otherwise, the task has to be started by calling the
326+
tasks :meth:`~can.RestartableCyclicTaskABC.start` method on it.
315327
:return:
316328
A started task instance. Note the task can be stopped (and
317329
depending on the backend modified) by calling the
@@ -328,6 +340,7 @@ def _send_periodic_internal(
328340
messages=msgs,
329341
period=period,
330342
duration=duration,
343+
autostart=autostart,
331344
modifier_callback=modifier_callback,
332345
)
333346
return task

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ def _send_periodic_internal(
155155
msgs: Union[Sequence[Message], Message],
156156
period: float,
157157
duration: Optional[float] = None,
158+
autostart: bool = True,
158159
modifier_callback: Optional[Callable[[Message], None]] = None,
159160
) -> CyclicSendTaskABC:
160161
return self.bus._send_periodic_internal(
161-
msgs, period, duration, modifier_callback
162+
msgs, period, duration, autostart, modifier_callback
162163
)
163164

164165
def shutdown(self) -> None:

can/interfaces/ixxat/canlib_vcinpl.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ def _send_periodic_internal(
793793
msgs: Union[Sequence[Message], Message],
794794
period: float,
795795
duration: Optional[float] = None,
796+
autostart: bool = True,
796797
modifier_callback: Optional[Callable[[Message], None]] = None,
797798
) -> CyclicSendTaskABC:
798799
"""Send a message using built-in cyclic transmit list functionality."""
@@ -807,7 +808,12 @@ def _send_periodic_internal(
807808
self._scheduler_resolution = caps.dwClockFreq / caps.dwCmsDivisor
808809
_canlib.canSchedulerActivate(self._scheduler, constants.TRUE)
809810
return CyclicSendTask(
810-
self._scheduler, msgs, period, duration, self._scheduler_resolution
811+
self._scheduler,
812+
msgs,
813+
period,
814+
duration,
815+
self._scheduler_resolution,
816+
autostart=autostart,
811817
)
812818

813819
# fallback to thread based cyclic task
@@ -821,6 +827,7 @@ def _send_periodic_internal(
821827
msgs=msgs,
822828
period=period,
823829
duration=duration,
830+
autostart=autostart,
824831
modifier_callback=modifier_callback,
825832
)
826833

@@ -863,7 +870,15 @@ def state(self) -> BusState:
863870
class CyclicSendTask(LimitedDurationCyclicSendTaskABC, RestartableCyclicTaskABC):
864871
"""A message in the cyclic transmit list."""
865872

866-
def __init__(self, scheduler, msgs, period, duration, resolution):
873+
def __init__(
874+
self,
875+
scheduler,
876+
msgs,
877+
period,
878+
duration,
879+
resolution,
880+
autostart: bool = True,
881+
):
867882
super().__init__(msgs, period, duration)
868883
if len(self.messages) != 1:
869884
raise ValueError(
@@ -883,7 +898,8 @@ def __init__(self, scheduler, msgs, period, duration, resolution):
883898
self._msg.uMsgInfo.Bits.dlc = self.messages[0].dlc
884899
for i, b in enumerate(self.messages[0].data):
885900
self._msg.abData[i] = b
886-
self.start()
901+
if autostart:
902+
self.start()
887903

888904
def start(self):
889905
"""Start transmitting message (add to list if needed)."""

can/interfaces/ixxat/canlib_vcinpl2.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ def _send_periodic_internal(
937937
msgs: Union[Sequence[Message], Message],
938938
period: float,
939939
duration: Optional[float] = None,
940+
autostart: bool = True,
940941
modifier_callback: Optional[Callable[[Message], None]] = None,
941942
) -> CyclicSendTaskABC:
942943
"""Send a message using built-in cyclic transmit list functionality."""
@@ -953,7 +954,12 @@ def _send_periodic_internal(
953954
) # TODO: confirm
954955
_canlib.canSchedulerActivate(self._scheduler, constants.TRUE)
955956
return CyclicSendTask(
956-
self._scheduler, msgs, period, duration, self._scheduler_resolution
957+
self._scheduler,
958+
msgs,
959+
period,
960+
duration,
961+
self._scheduler_resolution,
962+
autostart=autostart,
957963
)
958964

959965
# fallback to thread based cyclic task
@@ -967,6 +973,7 @@ def _send_periodic_internal(
967973
msgs=msgs,
968974
period=period,
969975
duration=duration,
976+
autostart=autostart,
970977
modifier_callback=modifier_callback,
971978
)
972979

@@ -983,7 +990,15 @@ def shutdown(self):
983990
class CyclicSendTask(LimitedDurationCyclicSendTaskABC, RestartableCyclicTaskABC):
984991
"""A message in the cyclic transmit list."""
985992

986-
def __init__(self, scheduler, msgs, period, duration, resolution):
993+
def __init__(
994+
self,
995+
scheduler,
996+
msgs,
997+
period,
998+
duration,
999+
resolution,
1000+
autostart: bool = True,
1001+
):
9871002
super().__init__(msgs, period, duration)
9881003
if len(self.messages) != 1:
9891004
raise ValueError(
@@ -1003,7 +1018,8 @@ def __init__(self, scheduler, msgs, period, duration, resolution):
10031018
self._msg.uMsgInfo.Bits.dlc = self.messages[0].dlc
10041019
for i, b in enumerate(self.messages[0].data):
10051020
self._msg.abData[i] = b
1006-
self.start()
1021+
if autostart:
1022+
self.start()
10071023

10081024
def start(self):
10091025
"""Start transmitting message (add to list if needed)."""

0 commit comments

Comments
 (0)