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

The actual playback time is much larger than the timestamp

Open zixuan-su opened this issue 3 years ago • 2 comments

Describe the bug

I have a 120 s long message ,then I find that It takes me 324.2 s to play. The Timestamp is still about 120 s, but the difference from the actual playback time is nearly 2.7 times . The file is https://github.com/hardbyte/python-can/blob/develop/can/player.py image

To Reproduce

Expected behavior

The actual time spent is the same as the timestamp duration

Additional context

OS and version: Ubuntu 1804 Python version: 3.9.9 python-can version: 4.0.0 python-can interface/s (if applicable):

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

zixuan-su avatar Aug 12 '22 08:08 zixuan-su

Could you replace this https://github.com/hardbyte/python-can/blob/3a7c80eb24d253b092b038f45be9d36942c2ab2d/can/io/player.py#L154

with this

            if sleep_period > 1e-3:
                sleep(sleep_period)

and check if it gets better? You have a very high message rate, i assume the sleep() call slows you down too much.

zariiii9003 avatar Aug 12 '22 11:08 zariiii9003

try this branch please: https://github.com/zariiii9003/python-can/tree/message_sync

zariiii9003 avatar Aug 14 '22 13:08 zariiii9003

Could you replace this

https://github.com/hardbyte/python-can/blob/3a7c80eb24d253b092b038f45be9d36942c2ab2d/can/io/player.py#L154

with this

            if sleep_period > 1e-3:
                sleep(sleep_period)

and check if it gets better? You have a very high message rate, i assume the sleep() call slows you down too much.

I replace

with _create_bus(results, **additional_config) as bus: with LogReader(results.infile, **additional_config) as reader:

        in_sync = MessageSync(
            cast(Iterable[Message], reader),
            timestamps=results.timestamps,
            gap=results.gap,
            skip=results.skip,
        )

with

Msg_List = list(BLFReader(results.infile))

print(f"Can LogReader (Started on {datetime.now()})")
     
try:
    for message in Msg_List:
        #print(message)  
        if message.is_error_frame and not error_frames:
            continue        
        if verbosity >= 3:

It only takes 44 s to play a 120 s BLF file
image

Then I will try your suggestion

zixuan-su avatar Aug 15 '22 03:08 zixuan-su

try this branch please: https://github.com/zariiii9003/python-can/tree/message_sync

I follow your suggestion,that`s cool !!!
image

zixuan-su avatar Aug 15 '22 06:08 zixuan-su

Thank you for your feedback, then i'll merge it into develop.

zariiii9003 avatar Aug 15 '22 06:08 zariiii9003