eclipse / kiso-testing

https://kiso-testing.readthedocs.io/
Other
38 stars 42 forks source link

Support trace for simple CAN #387

Closed valesQQ closed 10 months ago

valesQQ commented 11 months ago

Hello, As a developer I use pyKiso to test my embedded C software. All my communication are done using "simple" CAN and not CAN_FD. I noticed that if I activate the logs to generate a .trc, the test crash when using the parameter `is_fd: False. With CAN_FD, logs are properly generated.

It was something about "1.1 version of trace which was not supported". I don't have access to my setup until next week, I will try to provide the exact error message asap.

I stay available if you have any questions or if I can give any info to help :)

sebastianpfischer commented 11 months ago

Hi @valesQQ,

Thanks for the info! :) Just to make sure, you are using / will use a peak-can dongle right?

@sebclrsn, @Pog3k fyi

sebclrsn commented 11 months ago

Hi @valesQQ, could you maybe send us the header of the created PCAN trc file so that we can check which version it has?

valesQQ commented 11 months ago

Hi @sebastianpfischer, @sebclrsn,

Yes, we use peak-can dongle to perform the tests. Below you can find the header of the .trc when running test in CAN_FD.

;$FILEVERSION=2.0
;$STARTTIME=45203.7157523148
;$COLUMNS=N,O,T,I,d,L,D
;
;   .\20231004151041_PCAN_USBBUS1_1.trc
;   Start time: 04.10.2023 15:10:41.907.7
;   Driver version: 
;   Generated by PCAN-Basic API, version 4.7.1.818
;-------------------------------------------------------------------------------
;   Connection                 Bit rate
;   PCAN_USBBUS1               f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=4,data_tseg1=7,data_tseg2=2,data_sjw=2
;-------------------------------------------------------------------------------
; Glossary:
;   Direction of Message:
;     Rx: The frame was received
;     Tx: The frame was transmitted

When running test in CAN, no trace is generated at all so I don't have any header to provide, sorry

gregtwice commented 11 months ago

Hi, Here is the error produced by pykiso when running:

Traceback (most recent call last):  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\lib\connectors\cc_pcan_can\trc_handler.py", line 243, in _format_message_init    self._msg_fmt_string = self.FILE_VERSION_TO_FORMAT[self.file_version]  
KeyError: <TRCFileVersion.V1_1: 101>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
  File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main  
    return _run_code(code, main_globals, None,  
  File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code  
    exec(code, run_globals)  
  File "C:\Work\Prj\01_Tests\.venv\Scripts\pykiso.exe\__main__.py", line 7, in <module>  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\click\core.py", line 1157, in __call__  
    return self.main(*args, **kwargs)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\click\core.py", line 1078, in main  
    rv = self.invoke(ctx)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\click\core.py", line 1434, in invoke  
    return ctx.invoke(self.callback, **ctx.params)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\click\core.py", line 783, in invoke  
    return __callback(*args, **kwargs)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\click\decorators.py", line 33, in new_func  
    return f(get_current_context(), *args, **kwargs)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\global_config.py", line 158, in grab_inner  
    return func(click_context, *args, **kwargs)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\cli.py", line 240, in main  
    with ConfigRegistry.provide_auxiliaries(cfg_dict):  
  File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 142, in __exit__  
    next(self.gen)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\test_setup\config_registry.py", line 225, in provide_auxiliaries  
    cls.delete_aux_con()  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\test_setup\config_registry.py", line 207, in delete_aux_con  
    cls._linker.uninstall()  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\test_setup\dynamic_loader.py", line 364, in uninstall  
    self._con_cache.delete_all_instances()  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\test_setup\dynamic_loader.py", line 238, in delete_all_instances  
    instance.shutdown()  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\lib\connectors\cc_pcan_can\cc_pcan_can.py", line 495, in shutdown  
    self._merge_trc()  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\lib\connectors\cc_pcan_can\cc_pcan_can.py", line 439, in _merge_trc  
    writer.on_message_received(msg, self.trc_start_time.timestamp())  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\lib\connectors\cc_pcan_can\trc_handler.py", line 328, in on_message_received   
    serialized = self._format_message(msg, channel)  
  File "C:\Work\Prj\01_Tests\.venv\lib\site-packages\pykiso\lib\connectors\cc_pcan_can\trc_handler.py", line 245, in _format_message_init    raise NotImplementedError(f"File format {e} is not supported")  
NotImplementedError: File format <TRCFileVersion.V1_1: 101> is not supported

Here is the Yaml config used:

auxiliaries:
  proxy_aux:
    connectors:
        com: can_channel
    config:
        aux_list : [aux1, aux2]
        activate_trace : False
        trace_dir: ./suite_proxy
        trace_name: can_trace
        # if False create the auxiliary instance but don't start it, an
        # additional call of start method has to be performed.
        # By default, auto_start flag is set to True and "normal" ITF aux
        # creation mechanism is used.
        auto_start: False
    type: pykiso.lib.auxiliaries.proxy_auxiliary:ProxyAuxiliary
  aux1:
    connectors:
        com: proxy_com1
    config:
      auto_start: False
    type: pykiso.lib.auxiliaries.communication_auxiliary:CommunicationAuxiliary
  aux2:
    connectors:
        com: proxy_com2
    config:
      auto_start: False
    type: pykiso.lib.auxiliaries.communication_auxiliary:CommunicationAuxiliary

#__________________________ Connectors section _________________________
connectors:
  proxy_com1:
    config: ~
    type: pykiso.lib.connectors.cc_proxy:CCProxy
  proxy_com2:
    config: ~
    type: pykiso.lib.connectors.cc_proxy:CCProxy
  can_channel:
    config:
      interface : 'pcan'
      channel: 'PCAN_USBBUS2'
      state: 'ACTIVE'
      remote_id : 0x0CFF4203
      is_fd: False
      is_extended_id : True
      logging_activated: False
      can_filters: 
        - {"can_id": 0x18FFCF47, "can_mask": 0x1fffffff}
    type: pykiso.lib.connectors.cc_pcan_can:CCPCanCan

The error happens no matter wether there are already traces files in the directory of if there are none

valesQQ commented 11 months ago

Hello, I checked with @TedRio and his fix seems to work ! Thanks a lot :)