Skip to content

Bug in can.logger during rollover when file format .blf is defined #1316

@j-c-cook

Description

@j-c-cook

Describe the bug

The can.logger file is throwing an error when the .blf format is requested and a max file size is defined.

To Reproduce

Enable virtual can: sudo ip link add dev vcan0 type vcan && sudo ip link set up vcan0
Spam the virtual bus with random can messages 1 ms apart: cangen vcan0 -e -I 18EAFF26 -L i -v -v -v -g 1
Log the virtual bus: python -m can.logger -c vcan0 -i socketcan -b 250000 -f file.blf -s 50

Expected behavior

The can.logger should run without error until there is a keyboard interrupt. When the file.blf reaches 50 bytes then the file should be rolled over.

Additional context

OS and version: Ubuntu 20.04.4 LTS
Python version: Python 3.7.17
python-can version: 4.0.0
python-can interface/s (if applicable):

Traceback and logs
Connected to SocketcanBus: socketcan channel 'vcan0' Can Logger (Started on 2022-05-24 17:08:48.116783) Traceback (most recent call last): File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/logger.py", line 215, in main logger(msg) File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/listener.py", line 43, in __call__ self.on_message_received(msg) File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/logger.py", line 205, in on_message_received self.do_rollover() File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/logger.py", line 341, in do_rollover self._writer = self._get_new_writer(self.base_filename) File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/logger.py", line 221, in _get_new_writer self._writer.stop() File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/blf.py", line 565, in stop if self.file.seekable(): ValueError: I/O operation on closed file During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/agco/anaconda3/envs/ssb/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/home/agco/anaconda3/envs/ssb/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/logger.py", line 224, in <module> main() File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/logger.py", line 220, in main logger.stop() File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/logger.py", line 240, in stop self.writer.stop() File "/home/agco/anaconda3/envs/ssb/lib/python3.7/site-packages/can/io/blf.py", line 565, in stop if self.file.seekable(): ValueError: I/O operation on closed file 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions