Skip to content

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

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

Closed
j-c-cook opened this issue May 24, 2022 · 0 comments · Fixed by #1317
Closed

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

j-c-cook opened this issue May 24, 2022 · 0 comments · Fixed by #1317
Labels

Comments

@j-c-cook
Copy link
Contributor

j-c-cook commented May 24, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant