python-can icon indicating copy to clipboard operation
python-can copied to clipboard

How do I use TRC file version 1.1? default it's using 2.1.

Open ArcticBeat05 opened this issue 1 year ago • 2 comments

Describe the bug

If i modify my code to use

logger = TRCWriter(f'{folder_path}_can_log_{now}.trc', file_version=TRCFileVersion.V1_1)

i get an error. I suppose I am calling the version incorrectly or it might be a bug.

To Reproduce

This is what my current code looks like, which is running fine.

def create_logger():
    now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
    logger = TRCWriter(f'{folder_path}_can_log_{now}.trc') 
    return logger

def log_can_messages(): # define a function for logging
    try:
        logger = create_logger() # create a new logger
        start_time = time.time() # record the start time
        for msg in can_bus: # or rename can_bus to bus
            logger.on_message_received(msg)
            #print(msg)
            elapsed_time = time.time() - start_time # check the elapsed time
            if elapsed_time >= 60: # if 1 minutes have passed
                logger.stop() # stop the current logger
                logger = create_logger() # create a new logger
                start_time = time.time() # reset the start time
    finally:
        logger.stop()

Expected behavior

Additional context

OS and version: Windows 10 Python version: 3.11.1 python-can version: 4.2.1 python-can interface/s (if applicable): PCAN

Traceback and logs
def func():
    return "hello, world!"

ArcticBeat05 avatar May 19 '23 15:05 ArcticBeat05

Hi @ArcticBeat05, Please provide an exception trace of your error.

lumagi avatar Jun 09 '23 20:06 lumagi

Hi @ArcticBeat05 , i wrote the first version of the trc file reader and writer. The way you call this is basically correct, but switching the file version was never implemented i think. I prepared it but there will be some work to support it. Is there any specific need for the 1.1 version or can you handle with the 2.1 as well?

pkess avatar Sep 14 '23 12:09 pkess