1

I have a .blf file, I have to convert that to a .asc file so that my ASCREADER is able to read the data.

from can.io.blf import BLFReader
blf_file = "/home/ranjeet/Downloads/CAN/BLF_Files/input.blf"
with BLFReader(blf_file) as can_log:
    for msg in can_log:
        print(msg)

I've tried this so far. Able to read BLF File, need to write data as per .asc file

Ranjeet R Patil
  • 453
  • 6
  • 10
  • 1
    Have you tried anything so far? Please [edit] your question to say what isn't working. Do you see an error message? If so, what is it? It is not producing the expected output? If not, what output do you see and what output do you expect? – Muhammad Mohsin Khan Jan 18 '22 at 14:18
  • @MuhammadMohsinKhan I have added some more details. – Ranjeet R Patil Jan 18 '22 at 14:26

1 Answers1

2

Very similar to my other answer you should read your blf file in binary mode then write the messages in the asc one:

import can

with open(blf_file, 'rb') as f_in:
    log_in = can.io.BLFReader(f_in)

    with open("file_out.asc", 'w') as f_out:
        log_out = can.io.ASCWriter(f_out)
        for msg in log_in:
            log_out.on_message_received(msg)
        log_out.stop()
Tranbi
  • 11,407
  • 6
  • 16
  • 33
  • @RanjeetRPatil please let us know if it solved your problem by accepting the answer or editing your question with the specific issue you're facing. – Tranbi Jan 22 '22 at 07:23