Skip to content

Fix ASC Reader start time #1788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
# python-version: "3.13.0-alpha - 3.13.0"
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down Expand Up @@ -139,9 +139,9 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
Expand All @@ -155,43 +155,40 @@ jobs:
- name: Run doctest
run: |
python -m sphinx -b doctest -W --keep-going doc build
- uses: actions/upload-artifact@v3
with:
name: sphinx-out
path: ./build/
retention-days: 5

build:
name: Packaging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Build wheel and sdist
run: pipx run build
- name: Check build artifacts
run: pipx run twine check --strict dist/*
- name: Save artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-can-dist
name: release
path: ./dist

upload_pypi:
needs: [build]
name: Release to PyPi
runs-on: ubuntu-latest
permissions:
id-token: write

# upload to PyPI only on release
if: github.event.release && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: python-can-dist
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
Version 4.4.0
=============

Features
--------

* TRC 1.3 Support: Added support for .trc log files as generated by PCAN Explorer v5 and other tools, expanding compatibility with common log file formats (#1753).
* ASCReader refactor: improved the ASCReader code (#1717).
* SYSTEC Interface Enhancements: Added the ability to pass an explicit DLC value to the send() method when using the SYSTEC interface, enhancing flexibility for message definitions (#1756).
* Socketcand Beacon Detection: Introduced a feature for detecting socketcand beacons, facilitating easier connection and configuration with socketcand servers (#1687).
* PCAN Driver Echo Frames: Enabled echo frames in the PCAN driver when receive_own_messages is set, improving feedback for message transmissions (#1723).
* CAN FD Bus Connection for VectorBus: Enabled connecting to CAN FD buses without specifying bus timings, simplifying the connection process for users (#1716).
* Neousys Configs Detection: Updated the detection mechanism for available Neousys configurations, ensuring more accurate and comprehensive configuration discovery (#1744).


Bug Fixes
---------

* Send Periodic Messages: Fixed an issue where fixed-duration periodic messages were sent one extra time beyond their intended count (#1713).
* Vector Interface on Windows 11: Addressed compatibility issues with the Vector interface on Windows 11, ensuring stable operation across the latest OS version (#1731).
* ASCWriter Millisecond Handling: Corrected the handling of milliseconds in ASCWriter, ensuring accurate time representation in log files (#1734).
* Various minor bug fixes: Addressed several minor bugs to improve overall stability and performance.

Miscellaneous
-------------

* Invert default value logic for BusABC._is_shutdown. (#1774)
* Implemented various logging enhancements to provide more detailed and useful operational insights (#1703).
* Updated CI to use OIDC for connecting GitHub Actions to PyPi, improving security and access control for CI workflows.
* Fix CI to work for MacOS (#1772).
*
The release also includes various other minor enhancements and bug fixes aimed at improving the reliability and performance of the software.


Version 4.3.1
=============

Expand Down
2 changes: 1 addition & 1 deletion can/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging
from typing import Any, Dict

__version__ = "4.3.1"
__version__ = "4.4.0-rc.1"
__all__ = [
"ASCReader",
"ASCWriter",
Expand Down
26 changes: 13 additions & 13 deletions can/io/asc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
# TODO - what is this used for? The ASC Writer only prints `absolute`
self.timestamps_format: Optional[str] = None
self.internal_events_logged = False
self._extract_header()

def _extract_header(self) -> None:
for _line in self.file:
Expand Down Expand Up @@ -110,9 +111,18 @@ def _extract_header(self) -> None:

if events_match:
self.internal_events_logged = events_match.group("no_events") is None
break
continue

break
if trigger_match := ASC_TRIGGER_REGEX.match(line):
datetime_str = trigger_match.group("datetime_string")
self.start_time = (
0.0
if self.timestamps_format == "relative"
else self._datetime_to_timestamp(datetime_str)
)
# attribute `start_timestamp` for unified as BLFReader
self.start_timestamp = self.start_time
break

@staticmethod
def _datetime_to_timestamp(datetime_string: str) -> float:
Expand Down Expand Up @@ -260,20 +270,10 @@ def _process_fd_can_frame(self, line: str, msg_kwargs: Dict[str, Any]) -> Messag
return Message(**msg_kwargs)

def __iter__(self) -> Generator[Message, None, None]:
self._extract_header()

for _line in self.file:
line = _line.strip()

if trigger_match := ASC_TRIGGER_REGEX.match(line):
datetime_str = trigger_match.group("datetime_string")
self.start_time = (
0.0
if self.relative_timestamp
else self._datetime_to_timestamp(datetime_str)
)
continue

if not ASC_MESSAGE_REGEX.match(line):
# line might be a comment, chip status,
# J1939 message or some other unsupported event
Expand All @@ -282,7 +282,7 @@ def __iter__(self) -> Generator[Message, None, None]:
msg_kwargs: Dict[str, Union[float, bool, int]] = {}
try:
_timestamp, channel, rest_of_message = line.split(None, 2)
timestamp = float(_timestamp) + self.start_time
timestamp = float(_timestamp) + self.start_timestamp
msg_kwargs["timestamp"] = timestamp
if channel == "CANFD":
msg_kwargs["is_fd"] = True
Expand Down
Loading