Skip to content

Commit 02cba3b

Browse files
authored
Merge pull request #469 from ludobouan/feature/asctimestamp
Better ASCWriter timestamps
2 parents 0027384 + b2b5341 commit 02cba3b

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

CHANGELOG.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Major features
77
* Adds support for developing `asyncio` applications with `python-can` more easily. This can be useful
88
when implementing protocols that handles simultaneous connections to many nodes since you can write
99
synchronous looking code without handling multiple threads and locking mechanisms. #388
10-
* New can viewer terminal application. #390
10+
* New can viewer terminal application. (`python -m can.viewer`) #390
1111
* More formally adds task management responsibility to the `Bus`. By default tasks created with
1212
`bus.send_periodic` will have a reference held by the bus - this means in many cases the user
1313
doesn't need to keep the task in scope for their periodic messages to continue being sent. If
@@ -18,11 +18,10 @@ Major features
1818
Breaking changes
1919
----------------
2020

21-
- Interfaces should no longer override `send_periodic` and instead implement
22-
`_send_periodic_internal` #426
23-
- writing to closed writers is not supported any more (it was supported only for some)
24-
- the method `Listener.on_message_received()` is now abstract (using `@abc.abstractmethod`)
25-
- the file in the reader/writer is now always stored in the attribute uniformly called `file`, and not in
21+
* Interfaces should no longer override `send_periodic` and instead implement
22+
`_send_periodic_internal` to allow the Bus base class to manage tasks. #426
23+
* writing to closed writers is not supported any more (it was supported only for some)
24+
* the file in the reader/writer is now always stored in the attribute uniformly called `file`, and not in
2625
something like `fp`, `log_file` or `output_file`. Changed the name of the first parameter of the
2726
read/writer constructors from `filename` to `file`.
2827

@@ -31,8 +30,9 @@ Other notable changes
3130
---------------------
3231

3332
* can.Message class updated #413
34-
- Addition of a Message.equals method.
33+
- Addition of a `Message.equals` method.
3534
- Deprecate id_type in favor of is_extended_id
35+
- Initializer parameter extended_id deprecated in favor of is_extended_id
3636
- documentation, testing and example updates
3737
- Addition of support for various builtins: __repr__, __slots__, __copy__
3838
* IO module updates to bring consistency to the different CAN message writers and readers. #348
@@ -50,13 +50,14 @@ Other notable changes
5050
and only buffers messages up to a certain limit before writing/committing to the database.
5151
- the unused `header_line` attribute from `CSVReader` has been removed
5252
- privatized some attributes that are only to be used internally in the classes
53+
- the method `Listener.on_message_received()` is now abstract (using `@abc.abstractmethod`)
5354
* Start testing against Python 3.7 #380
5455
* All scripts have been moved into `can/scripts`. #370, #406
5556
* Added support for additional sections to the config #338
5657
* Code coverage reports added. #346, #374
5758
* Bug fix to thread safe bus. #397
5859

59-
General fixes, cleanup and docs changes: (#347, #348, #367, #368, #370, #371, #373, #420, #417, #419)
60+
General fixes, cleanup and docs changes: (#347, #348, #367, #368, #370, #371, #373, #420, #417, #419, #432)
6061

6162
Backend Specific Changes
6263
------------------------
@@ -94,7 +95,7 @@ serial
9495
socketcan
9596
~~~~~~~~~
9697

97-
* socketcan tasks now reuse a bcm socket
98+
* socketcan tasks now reuse a bcm socket #404, #425, #426,
9899
* socketcan bugfix to receive error frames #384
99100

100101
vector

can/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import logging
1010

11-
__version__ = "3.0.0-dev"
11+
__version__ = "3.0.0"
1212

1313
log = logging.getLogger('can')
1414

can/io/asc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class ASCWriter(BaseIOHandler, Listener):
132132

133133
FORMAT_MESSAGE = "{channel} {id:<15} Rx {dtype} {data}"
134134
FORMAT_DATE = "%a %b %m %I:%M:%S %p %Y"
135-
FORMAT_EVENT = "{timestamp: 9.4f} {message}\n"
135+
FORMAT_EVENT = "{timestamp: 9.6f} {message}\n"
136136

137137
def __init__(self, file, channel=1):
138138
"""
@@ -181,8 +181,8 @@ def log_event(self, message, timestamp=None):
181181
self.header_written = True
182182
self.log_event("Start of measurement") # caution: this is a recursive call!
183183

184-
# figure out the correct timestamp
185-
if timestamp is None or timestamp < self.last_timestamp:
184+
# Use last known timestamp if unknown
185+
if timestamp is None:
186186
timestamp = self.last_timestamp
187187

188188
# turn into relative timestamps if necessary

0 commit comments

Comments
 (0)