Skip to content
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

BLFWriter append messages to an existing log file does not take effect #1751

Closed
tocatch opened this issue Mar 6, 2024 · 2 comments
Closed
Labels

Comments

@tocatch
Copy link

tocatch commented Mar 6, 2024

Describe the bug

when i use BLFWriter to append messages to an existing log file,it does not take effect

To Reproduce

  1. I use the following code to append data to the output.blf file
import can

def generate_blf_file(messages, file): 
   
    blf_writer = can.BLFWriter(file=file, append=True)

    
    for message in messages:
        
        blf_writer.on_message_received(message)

   
    blf_writer.stop()



can_messages = [
    can.Message(
        timestamp=2.5010,
        arbitration_id=0xC8,
        is_extended_id=False,
        is_rx=False,
        channel=1,
        dlc=8,
        data=[9, 8, 7, 6, 5, 4, 3, 2],
    ),
    can.Message(
        timestamp=3.876708,
        arbitration_id=0x6F9,
        is_extended_id=False,
        channel=0,
        dlc=0x8,
        data=[5, 0xC, 0, 0, 0, 0, 0, 0],
    )
]

can_messages_append = [
    can.Message(
        timestamp=4.5010,
        arbitration_id=0xC8,
        is_extended_id=False,
        is_rx=False,
        channel=1,
        dlc=8,
        data=[9, 8, 7, 6, 5, 4, 3, 2],
    ),
    can.Message(
        timestamp=5.876708,
        arbitration_id=0x6F9,
        is_extended_id=False,
        channel=0,
        dlc=0x8,
        data=[5, 0xC, 0, 0, 0, 0, 0, 0],
    )
]

blf_output_file = 'blf-files/output.blf' 

generate_blf_file(can_messages, blf_output_file)

generate_blf_file(can_messages_append, blf_output_file)
  1. the result is only two pieces of data in the file in output.blf, The two pieces of data are two pieces of data in can_messages_append, It means that the file content is overwritten instead of appended.

Expected behavior

  1. What I expected is that there are four pieces of data in the output.blf file. That is to say, I wrote 2 pieces of data to the file twice, which should be the effect of appending data.

Additional context

OS and version: windows 10
Python version:3.9
python-can version:4.3.1
python-can interface/s (if applicable):

@tocatch tocatch added the bug label Mar 6, 2024
@tocatch tocatch closed this as completed Mar 7, 2024
@tocatch
Copy link
Author

tocatch commented Mar 7, 2024

In fact, the content is appended, but I use canoe to run this file, and there is a problem with data reading. Sometimes only the last two items are read.

@tocatch
Copy link
Author

tocatch commented Mar 7, 2024

My problem, actually this problem does not exist, I made a mistake, the current problem has been solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant