pyxcp 0.22.25__tar.gz → 0.22.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyxcp might be problematic. Click here for more details.

Files changed (128) hide show
  1. {pyxcp-0.22.25 → pyxcp-0.22.27}/PKG-INFO +1 -1
  2. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyproject.toml +2 -1
  3. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/__init__.py +1 -1
  4. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/config/__init__.py +3 -1
  5. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/run_daq.py +0 -2
  6. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/master/errorhandler.py +7 -1
  7. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/__init__.py +7 -8
  8. pyxcp-0.22.27/pyxcp/recorder/converter/__init__.py +451 -0
  9. pyxcp-0.22.27/pyxcp/scripts/xmraw_converter.py +31 -0
  10. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/base.py +1 -1
  11. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/types.py +7 -1
  12. pyxcp-0.22.25/pyxcp/examples/ex_arrow.py +0 -109
  13. pyxcp-0.22.25/pyxcp/examples/ex_csv.py +0 -85
  14. pyxcp-0.22.25/pyxcp/examples/ex_excel.py +0 -95
  15. pyxcp-0.22.25/pyxcp/examples/ex_mdf.py +0 -124
  16. pyxcp-0.22.25/pyxcp/examples/ex_sqlite.py +0 -128
  17. pyxcp-0.22.25/pyxcp/recorder/converter/__init__.py +0 -37
  18. {pyxcp-0.22.25 → pyxcp-0.22.27}/CMakeLists.txt +0 -0
  19. {pyxcp-0.22.25 → pyxcp-0.22.27}/LICENSE +0 -0
  20. {pyxcp-0.22.25 → pyxcp-0.22.27}/README.md +0 -0
  21. {pyxcp-0.22.25 → pyxcp-0.22.27}/build_ext.py +0 -0
  22. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/EtasCANMonitoring.a2l +0 -0
  23. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/EtasCANMonitoring.aml +0 -0
  24. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCP_Common.aml +0 -0
  25. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCPonCAN.aml +0 -0
  26. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCPonEth.aml +0 -0
  27. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCPonFlx.aml +0 -0
  28. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCPonSxI.aml +0 -0
  29. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/XCPonUSB.aml +0 -0
  30. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/ifdata_CAN.a2l +0 -0
  31. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/ifdata_Eth.a2l +0 -0
  32. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/ifdata_Flx.a2l +0 -0
  33. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/ifdata_SxI.a2l +0 -0
  34. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/aml/ifdata_USB.a2l +0 -0
  35. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/asam/__init__.py +0 -0
  36. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/asam/types.py +0 -0
  37. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/asamkeydll.c +0 -0
  38. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/asamkeydll.sh +0 -0
  39. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/checksum.py +0 -0
  40. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cmdline.py +0 -0
  41. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/config/legacy.py +0 -0
  42. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/constants.py +0 -0
  43. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/__init__.py +0 -0
  44. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/bin.hpp +0 -0
  45. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/blockmem.hpp +0 -0
  46. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/daqlist.hpp +0 -0
  47. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/event.hpp +0 -0
  48. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/extension_wrapper.cpp +0 -0
  49. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/helper.hpp +0 -0
  50. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/mcobject.hpp +0 -0
  51. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/cpp_ext/tsqueue.hpp +0 -0
  52. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/__init__.py +0 -0
  53. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/optimize/__init__.py +0 -0
  54. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/optimize/binpacking.py +0 -0
  55. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/scheduler.cpp +0 -0
  56. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/scheduler.hpp +0 -0
  57. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/stim.cpp +0 -0
  58. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/stim.hpp +0 -0
  59. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/daq_stim/stim_wrapper.cpp +0 -0
  60. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/dllif.py +0 -0
  61. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/errormatrix.py +0 -0
  62. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_can.toml +0 -0
  63. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_can_user.toml +0 -0
  64. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_can_vector.json +0 -0
  65. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_can_vector.toml +0 -0
  66. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_eth.toml +0 -0
  67. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_nixnet.json +0 -0
  68. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_socket_can.toml +0 -0
  69. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_sxi.json +0 -0
  70. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/conf_sxi.toml +0 -0
  71. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcp_policy.py +0 -0
  72. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcp_read_benchmark.py +0 -0
  73. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcp_skel.py +0 -0
  74. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcp_unlock.py +0 -0
  75. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcp_user_supplied_driver.py +0 -0
  76. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcphello.py +0 -0
  77. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/examples/xcphello_recorder.py +0 -0
  78. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/master/__init__.py +0 -0
  79. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/master/master.py +0 -0
  80. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/py.typed +0 -0
  81. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/build_clang.cmd +0 -0
  82. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/build_clang.sh +0 -0
  83. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/build_gcc.cmd +0 -0
  84. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/build_gcc.sh +0 -0
  85. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/build_gcc_arm.sh +0 -0
  86. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/lz4.c +0 -0
  87. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/lz4.h +0 -0
  88. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/lz4hc.c +0 -0
  89. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/lz4hc.h +0 -0
  90. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/mio.hpp +0 -0
  91. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/reader.hpp +0 -0
  92. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/reco.py +0 -0
  93. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/recorder.rst +0 -0
  94. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/rekorder.cpp +0 -0
  95. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/rekorder.hpp +0 -0
  96. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/setup.py +0 -0
  97. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/test_reko.py +0 -0
  98. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/unfolder.hpp +0 -0
  99. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/wrap.cpp +0 -0
  100. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/recorder/writer.hpp +0 -0
  101. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/__init__.py +0 -0
  102. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -0
  103. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/xcp_examples.py +0 -0
  104. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/xcp_fetch_a2l.py +0 -0
  105. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/xcp_id_scanner.py +0 -0
  106. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/xcp_info.py +0 -0
  107. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/scripts/xcp_profile.py +0 -0
  108. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/stim/__init__.py +0 -0
  109. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_asam_types.py +0 -0
  110. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_binpacking.py +0 -0
  111. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_can.py +0 -0
  112. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_checksum.py +0 -0
  113. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_daq.py +0 -0
  114. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_frame_padding.py +0 -0
  115. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_master.py +0 -0
  116. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_transport.py +0 -0
  117. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/tests/test_utils.py +0 -0
  118. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/timing.py +0 -0
  119. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/__init__.py +0 -0
  120. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/base_transport.hpp +0 -0
  121. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/can.py +0 -0
  122. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/eth.py +0 -0
  123. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/sxi.py +0 -0
  124. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/transport_wrapper.cpp +0 -0
  125. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/transport/usb_transport.py +0 -0
  126. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/utils.py +0 -0
  127. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/vector/__init__.py +0 -0
  128. {pyxcp-0.22.25 → pyxcp-0.22.27}/pyxcp/vector/map.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyxcp
3
- Version: 0.22.25
3
+ Version: 0.22.27
4
4
  Summary: Universal Calibration Protocol for Python
5
5
  License: LGPLv3
6
6
  Keywords: automotive,ecu,xcp,asam,autosar
@@ -36,7 +36,7 @@ dynamic = ["license", "readme", "authors", "requires-python", "description", "cl
36
36
  [tool.poetry]
37
37
  authors = ["Christoph Schueler <cpu.gems@googlemail.com>"]
38
38
  name = "pyxcp"
39
- version = "0.22.25"
39
+ version = "0.22.27"
40
40
  readme = "README.md"
41
41
  description = "Universal Calibration Protocol for Python"
42
42
  keywords = ["automotive", "ecu", "xcp", "asam", "autosar"]
@@ -102,6 +102,7 @@ xcp-fetch-a2l = "pyxcp.scripts.xcp_fetch_a2l:main"
102
102
  xcp-info = "pyxcp.scripts.xcp_info:main"
103
103
  xcp-profile = "pyxcp.scripts.xcp_profile:main"
104
104
  xcp-examples = "pyxcp.scripts.xcp_examples:main"
105
+ xmraw-converter = "pyxcp.scripts.xmraw_converter:main"
105
106
 
106
107
  [tool.pytest]
107
108
  addopts = "--verbose --tb=short --junitxml=result.xml -o junit_family=xunit2"
@@ -17,4 +17,4 @@ tb_install(show_locals=True, max_frames=3) # Install custom exception handler.
17
17
 
18
18
  # if you update this manually, do not forget to update
19
19
  # .bumpversion.cfg and pyproject.toml.
20
- __version__ = "0.22.25"
20
+ __version__ = "0.22.27"
@@ -822,9 +822,11 @@ if there is no response to a command.""",
822
822
  class General(Configurable):
823
823
  """ """
824
824
 
825
- # loglevel = Unicode("INFO", help="Set the log level by value or name.").tag(config=True)
826
825
  disable_error_handling = Bool(False, help="Disable XCP error-handler for performance reasons.").tag(config=True)
827
826
  disconnect_response_optional = Bool(False, help="Ignore missing response on DISCONNECT request.").tag(config=True)
827
+ connect_retries = Integer(help="Number of CONNECT retries (None for infinite retries).", allow_none=True, default_value=3).tag(
828
+ config=True
829
+ )
828
830
  seed_n_key_dll = Unicode("", allow_none=False, help="Dynamic library used for slave resource unlocking.").tag(config=True)
829
831
  seed_n_key_dll_same_bit_width = Bool(False, help="").tag(config=True)
830
832
  seed_n_key_function = Callable(
@@ -137,8 +137,6 @@ with ap.run(policy=daq_parser) as x:
137
137
 
138
138
  x.cond_unlock("DAQ") # DAQ resource is locked in many cases.
139
139
 
140
- DAQ_LISTS[1].event_num = 0
141
-
142
140
  print("setup DAQ lists.")
143
141
  daq_parser.setup() # Execute setup procedures.
144
142
  print("start DAQ lists.")
@@ -356,6 +356,7 @@ class Executor(SingletonBase):
356
356
  self.arguments = arguments
357
357
  handler = Handler(inst, func, arguments)
358
358
  self.handlerStack.push(handler)
359
+ connect_retries = inst.config.connect_retries
359
360
  try:
360
361
  while True:
361
362
  try:
@@ -366,9 +367,14 @@ class Executor(SingletonBase):
366
367
  self.error_code = e.get_error_code()
367
368
  handler.error_code = self.error_code
368
369
  except XcpTimeoutError:
369
- # self.logger.error(f"XcpTimeoutError [{str(e)}]")
370
+ is_connect = func.__name__ == "connect"
371
+ self.logger.warning(f"XcpTimeoutError -- Service: {func.__name__!r}")
370
372
  self.error_code = XcpError.ERR_TIMEOUT
371
373
  handler.error_code = self.error_code
374
+ if is_connect and connect_retries is not None:
375
+ if connect_retries == 0:
376
+ raise XcpTimeoutError("Maximum CONNECT retries reached.")
377
+ connect_retries -= 1
372
378
  except TimeoutError:
373
379
  raise
374
380
  except can.CanError:
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  """XCP Frame Recording Facility.
3
3
  """
4
+
4
5
  from dataclasses import dataclass
5
6
  from typing import Union
6
7
 
@@ -16,15 +17,13 @@ else:
16
17
 
17
18
  from pyxcp.recorder.rekorder import DaqOnlinePolicy # noqa: F401
18
19
  from pyxcp.recorder.rekorder import (
19
- DaqRecorderPolicy,
20
- Deserializer,
21
- MeasurementParameters,
22
- ValueHolder,
23
- XcpLogFileDecoder,
24
- _PyXcpLogFileReader,
25
- _PyXcpLogFileWriter,
26
- data_types,
20
+ DaqRecorderPolicy, # noqa: F401
21
+ Deserializer, # noqa: F401
22
+ MeasurementParameters, # noqa: F401
23
+ ValueHolder, # noqa: F401
27
24
  )
25
+ from pyxcp.recorder.rekorder import XcpLogFileDecoder as _XcpLogFileDecoder
26
+ from pyxcp.recorder.rekorder import _PyXcpLogFileReader, _PyXcpLogFileWriter, data_types
28
27
 
29
28
 
30
29
  DATA_TYPES = data_types()
@@ -0,0 +1,451 @@
1
+ """Convert pyXCPs .xmraw files to common data formats.
2
+ """
3
+
4
+ import csv
5
+ import logging
6
+ import os
7
+ import sqlite3
8
+ from array import array
9
+ from dataclasses import dataclass, field
10
+ from mmap import PAGESIZE
11
+ from pathlib import Path
12
+ from typing import Any, List
13
+
14
+ import numpy as np
15
+ from rich.logging import RichHandler
16
+
17
+
18
+ try:
19
+ import pyarrow as pa
20
+ import pyarrow.parquet as pq
21
+
22
+ has_arrow = True
23
+ except ImportError:
24
+ has_arrow = False
25
+
26
+ try:
27
+ import h5py
28
+
29
+ has_h5py = True
30
+ except ImportError:
31
+ has_h5py = False
32
+
33
+ try:
34
+ from asammdf import MDF, Signal
35
+ from asammdf.blocks.v4_blocks import HeaderBlock
36
+ from asammdf.blocks.v4_constants import FLAG_HD_TIME_OFFSET_VALID
37
+
38
+ has_asammdf = True
39
+ except ImportError:
40
+ has_asammdf = False
41
+
42
+ try:
43
+ import xlsxwriter
44
+
45
+ has_xlsxwriter = True
46
+
47
+ except ImportError:
48
+ has_xlsxwriter = False
49
+
50
+ from pyxcp import console
51
+ from pyxcp.recorder.rekorder import XcpLogFileDecoder as _XcpLogFileDecoder
52
+
53
+
54
+ FORMAT = "%(message)s"
55
+ logging.basicConfig(level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()])
56
+
57
+ log = logging.getLogger("rich")
58
+
59
+ MAP_TO_ARRAY = {
60
+ "U8": "B",
61
+ "I8": "b",
62
+ "U16": "H",
63
+ "I16": "h",
64
+ "U32": "L",
65
+ "I32": "l",
66
+ "U64": "Q",
67
+ "I64": "q",
68
+ "F32": "f",
69
+ "F64": "d",
70
+ "F16": "f",
71
+ "BF16": "f",
72
+ }
73
+
74
+ MAP_TO_NP = {
75
+ "U8": np.uint8,
76
+ "I8": np.int8,
77
+ "U16": np.uint16,
78
+ "I16": np.int16,
79
+ "U32": np.uint32,
80
+ "I32": np.int32,
81
+ "U64": np.uint64,
82
+ "I64": np.int64,
83
+ "F32": np.float32,
84
+ "F64": np.float64,
85
+ "F16": np.float16,
86
+ "BF16": np.float16,
87
+ }
88
+
89
+
90
+ @dataclass
91
+ class Storage:
92
+ name: str
93
+ target_type: Any
94
+ arr: array
95
+
96
+
97
+ @dataclass
98
+ class StorageContainer:
99
+ name: str
100
+ arr: List[Storage] = field(default_factory=[])
101
+ ts0: List[int] = field(default_factory=lambda: array("Q"))
102
+ ts1: List[int] = field(default_factory=lambda: array("Q"))
103
+
104
+
105
+ class XcpLogFileDecoder(_XcpLogFileDecoder):
106
+ """"""
107
+
108
+ def __init__(
109
+ self,
110
+ recording_file_name: str,
111
+ out_file_suffix: str,
112
+ remove_file: bool = True,
113
+ target_type_map: dict = None,
114
+ target_file_name: str = "",
115
+ ):
116
+ super().__init__(recording_file_name)
117
+ self.logger = logging.getLogger("PyXCP")
118
+ self.logger.setLevel(logging.DEBUG)
119
+ self.out_file_name = Path(recording_file_name).with_suffix(out_file_suffix)
120
+ self.out_file_suffix = out_file_suffix
121
+ self.target_type_map = target_type_map or {}
122
+ if remove_file:
123
+ try:
124
+ os.unlink(self.out_file_name)
125
+ except FileNotFoundError:
126
+ pass
127
+
128
+ def initialize(self) -> None:
129
+ self.on_initialize()
130
+
131
+ def on_initialize(self) -> None:
132
+ self.setup_containers()
133
+
134
+ def finalize(self) -> None:
135
+ self.on_finalize()
136
+
137
+ def on_finalize(self) -> None:
138
+ pass
139
+
140
+ def setup_containers(self) -> None:
141
+ self.tables = []
142
+ for dl in self.daq_lists:
143
+ result = []
144
+ for name, type_str in dl.headers:
145
+ array_txpe = MAP_TO_ARRAY[type_str]
146
+ target_type = self.target_type_map.get(type_str)
147
+ sd = Storage(name, target_type, array(array_txpe))
148
+ result.append(sd)
149
+ sc = StorageContainer(dl.name, result)
150
+ self.tables.append(sc)
151
+ self.on_container(sc)
152
+
153
+ def on_container(self, sc: StorageContainer) -> None:
154
+ pass
155
+
156
+
157
+ class CollectRows:
158
+
159
+ def on_daq_list(self, daq_list_num: int, timestamp0: int, timestamp1: int, measurements: list) -> None:
160
+ storage_container = self.tables[daq_list_num]
161
+ storage_container.ts0.append(timestamp0)
162
+ storage_container.ts1.append(timestamp1)
163
+ for idx, elem in enumerate(measurements):
164
+ storage = storage_container.arr[idx]
165
+ storage.arr.append(elem)
166
+
167
+
168
+ class ArrowConverter(CollectRows, XcpLogFileDecoder):
169
+ """"""
170
+
171
+ MAP_TO_ARROW = {
172
+ "U8": pa.uint8(),
173
+ "I8": pa.int8(),
174
+ "U16": pa.uint16(),
175
+ "I16": pa.int16(),
176
+ "U32": pa.uint32(),
177
+ "I32": pa.int32(),
178
+ "U64": pa.uint64(),
179
+ "I64": pa.int64(),
180
+ "F32": pa.float32(),
181
+ "F64": pa.float64(),
182
+ "F16": pa.float16(),
183
+ "BF16": pa.float16(),
184
+ }
185
+
186
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
187
+ super().__init__(
188
+ recording_file_name=recording_file_name,
189
+ out_file_suffix=".parquet",
190
+ remove_file=False,
191
+ target_type_map=self.MAP_TO_ARROW,
192
+ target_file_name=target_file_name,
193
+ )
194
+
195
+ def on_initialize(self) -> None:
196
+ super().on_initialize()
197
+
198
+ def on_finalize(self) -> None:
199
+ result = []
200
+ for arr in self.tables:
201
+ timestamp0 = arr.ts0
202
+ timestamp1 = arr.ts1
203
+ names = ["timestamp0", "timestamp1"]
204
+ data = [timestamp0, timestamp1]
205
+ for sd in arr.arr:
206
+ adt = pa.array(sd.arr, type=sd.target_type)
207
+ names.append(sd.name)
208
+ data.append(adt)
209
+ table = pa.Table.from_arrays(data, names=names)
210
+ fname = f"{arr.name}{self.out_file_suffix}"
211
+ self.logger.info(f"Writing file {fname!r}")
212
+ pq.write_table(table, fname)
213
+ result.append(table)
214
+ return result
215
+
216
+
217
+ class CsvConverter(XcpLogFileDecoder):
218
+
219
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
220
+ super().__init__(
221
+ recording_file_name=recording_file_name, out_file_suffix=".csv", remove_file=False, target_file_name=target_file_name
222
+ )
223
+
224
+ def on_initialize(self) -> None:
225
+ self.csv_writers = []
226
+ super().on_initialize()
227
+
228
+ def on_container(self, sc: StorageContainer) -> None:
229
+ fname = f"{sc.name}{self.out_file_suffix}"
230
+ self.logger.info(f"Creating file {fname!r}.")
231
+ writer = csv.writer(open(fname, "w", newline=""), dialect="excel")
232
+ headers = ["ts0", "ts1"] + [e.name for e in sc.arr]
233
+ writer.writerow(headers)
234
+ self.csv_writers.append(writer)
235
+
236
+ def on_finalize(self) -> None:
237
+ self.logger.info("Done.")
238
+
239
+ def on_daq_list(self, daq_list_num: int, timestamp0: int, timestamp1: int, measurements: list) -> None:
240
+ writer = self.csv_writers[daq_list_num]
241
+ data = [timestamp0, timestamp1, *measurements]
242
+ writer.writerow(data)
243
+
244
+
245
+ class ExcelConverter(XcpLogFileDecoder):
246
+
247
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
248
+ super().__init__(recording_file_name=recording_file_name, out_file_suffix=".xlsx", target_file_name=target_file_name)
249
+
250
+ def on_initialize(self) -> None:
251
+ self.logger.info(f"Creating file {str(self.out_file_name)!r}.")
252
+ self.xls_workbook = xlsxwriter.Workbook(self.out_file_name)
253
+ self.xls_sheets = []
254
+ self.rows = []
255
+ super().on_initialize()
256
+
257
+ def on_container(self, sc: StorageContainer) -> None:
258
+ sheet = self.xls_workbook.add_worksheet(sc.name)
259
+ self.xls_sheets.append(sheet)
260
+ headers = ["ts0", "ts1"] + [e.name for e in sc.arr]
261
+ sheet.write_row(0, 0, headers)
262
+ self.rows.append(1)
263
+
264
+ def on_finalize(self) -> None:
265
+ self.xls_workbook.close()
266
+ self.logger.info("Done.")
267
+
268
+ def on_daq_list(self, daq_list_num: int, timestamp0: int, timestamp1: int, measurements: list) -> None:
269
+ sheet = self.xls_sheets[daq_list_num]
270
+ row = self.rows[daq_list_num]
271
+ data = [timestamp0, timestamp1] + measurements
272
+ sheet.write_row(row, 0, data)
273
+ self.rows[daq_list_num] += 1
274
+
275
+
276
+ class HdfConverter(CollectRows, XcpLogFileDecoder):
277
+
278
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
279
+ super().__init__(recording_file_name=recording_file_name, out_file_suffix=".h5", target_file_name=target_file_name)
280
+
281
+ def on_initialize(self) -> None:
282
+ self.logger.info(f"Creating file {str(self.out_file_name)!r}")
283
+ self.out_file = h5py.File(self.out_file_name, "w")
284
+ super().on_initialize()
285
+
286
+ def on_finalize(self) -> None:
287
+ for arr in self.tables:
288
+ timestamp0 = arr.ts0
289
+ timestamp1 = arr.ts1
290
+ self.out_file[f"/{arr.name}/timestamp0"] = timestamp0
291
+ self.out_file[f"/{arr.name}/timestamp1"] = timestamp1
292
+ for sd in arr.arr:
293
+ self.out_file[f"/{arr.name}/{sd.name}"] = sd.arr
294
+ self.logger.info(f"Writing table {arr.name!r}")
295
+ self.logger.info("Done.")
296
+ self.out_file.close()
297
+
298
+
299
+ class MdfConverter(CollectRows, XcpLogFileDecoder):
300
+
301
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
302
+ super().__init__(
303
+ recording_file_name=recording_file_name,
304
+ out_file_suffix=".mf4",
305
+ target_type_map=MAP_TO_NP,
306
+ target_file_name=target_file_name,
307
+ )
308
+
309
+ def on_initialize(self) -> None:
310
+ super().on_initialize()
311
+
312
+ def on_finalize(self) -> None:
313
+ timestamp_info = self.parameters.timestamp_info
314
+ hdr = HeaderBlock(
315
+ abs_time=timestamp_info.timestamp_ns,
316
+ tz_offset=timestamp_info.utc_offset,
317
+ daylight_save_time=timestamp_info.dst_offset,
318
+ time_flags=FLAG_HD_TIME_OFFSET_VALID,
319
+ )
320
+ hdr.comment = f"""<HDcomment><TX>Timezone: {timestamp_info.timezone}</TX></HDcomment>""" # Test-Comment.
321
+ mdf4 = MDF(version="4.10")
322
+ mdf4.header = hdr
323
+ for idx, arr in enumerate(self.tables):
324
+ signals = []
325
+ timestamps = arr.ts0
326
+ for sd in arr.arr:
327
+ signal = Signal(samples=sd.arr, name=sd.name, timestamps=timestamps)
328
+ signals.append(signal)
329
+ self.logger.info(f"Appending data-group {arr.name!r}")
330
+ mdf4.append(signals, acq_name=arr.name, comment="Created by pyXCP recorder")
331
+ self.logger.info(f"Writing {str(self.out_file_name)!r}")
332
+ mdf4.save(self.out_file_name, compression=2, overwrite=True)
333
+ self.logger.info("Done.")
334
+
335
+
336
+ class SqliteConverter(XcpLogFileDecoder):
337
+ """ """
338
+
339
+ MAP_TO_SQL = {
340
+ "U8": "INTEGER",
341
+ "I8": "INTEGER",
342
+ "U16": "INTEGER",
343
+ "I16": "INTEGER",
344
+ "U32": "INTEGER",
345
+ "I32": "INTEGER",
346
+ "U64": "INTEGER",
347
+ "I64": "INTEGER",
348
+ "F32": "FLOAT",
349
+ "F64": "FLOAT",
350
+ "F16": "FLOAT",
351
+ "BF16": "FLOAT",
352
+ }
353
+
354
+ def __init__(self, recording_file_name: str, target_file_name: str = ""):
355
+ super().__init__(
356
+ recording_file_name=recording_file_name,
357
+ out_file_suffix=".sq3",
358
+ target_type_map=self.MAP_TO_SQL,
359
+ target_file_name=target_file_name,
360
+ )
361
+
362
+ def on_initialize(self) -> None:
363
+ self.logger.info(f"Creating database {str(self.out_file_name)!r}.")
364
+ self.create_database(self.out_file_name)
365
+ self.insert_stmt = {}
366
+ super().on_initialize()
367
+
368
+ def on_container(self, sc: StorageContainer) -> None:
369
+ self.create_table(sc)
370
+ self.logger.info(f"Creating table {sc.name!r}.")
371
+ self.insert_stmt[sc.name] = (
372
+ f"""INSERT INTO {sc.name}({', '.join(['ts0', 'ts1'] + [r.name for r in sc.arr])}) VALUES({', '.join(["?" for _ in range(len(sc.arr) + 2)])})"""
373
+ )
374
+
375
+ def on_finalize(self) -> None:
376
+ self.conn.commit()
377
+ self.conn.close()
378
+ print("Done.")
379
+
380
+ def on_daq_list(self, daq_list_num: int, timestamp0: int, timestamp1: int, measurements: list) -> None:
381
+ sc = self.tables[daq_list_num]
382
+ insert_stmt = self.insert_stmt[sc.name]
383
+ data = [timestamp0, timestamp1, *measurements]
384
+ self.execute(insert_stmt, data)
385
+
386
+ def create_database(self, db_name: str) -> None:
387
+ self.conn = sqlite3.Connection(db_name)
388
+ self.cursor = self.conn.cursor()
389
+ self.execute("PRAGMA FOREIGN_KEYS=ON")
390
+ self.execute(f"PRAGMA PAGE_SIZE={PAGESIZE}")
391
+ self.execute("PRAGMA SYNCHRONOUS=OFF")
392
+ self.execute("PRAGMA LOCKING_MODE=EXCLUSIVE")
393
+ self.execute("PRAGMA TEMP_STORE=MEMORY")
394
+
395
+ timestamp_info = self.parameters.timestamp_info
396
+ self.execute(
397
+ "CREATE TABLE timestamp_info(timestamp_ns INTEGER, utc_offset INTEGER, dst_offset INTEGER, timezone VARCHAR(255))"
398
+ )
399
+ self.execute("CREATE TABLE table_names(name VARCHAR(255))")
400
+ self.execute(
401
+ "INSERT INTO timestamp_info VALUES(?, ?, ?, ?)",
402
+ [timestamp_info.timestamp_ns, timestamp_info.utc_offset, timestamp_info.dst_offset, timestamp_info.timezone],
403
+ )
404
+
405
+ def create_table(self, sc: StorageContainer) -> None:
406
+ columns = ["ts0 INTEGER", "ts1 INTEGER"]
407
+ for elem in sc.arr:
408
+ columns.append(f"{elem.name} {elem.target_type}")
409
+ ddl = f"CREATE TABLE {sc.name}({', '.join(columns)})"
410
+ self.execute(ddl)
411
+ self.execute("INSERT INTO table_names VALUES(?)", [sc.name])
412
+
413
+ def execute(self, *args: List[str]) -> None:
414
+ try:
415
+ self.cursor.execute(*args)
416
+ except Exception as e:
417
+ print(e)
418
+
419
+
420
+ CONVERTERS = {
421
+ "arrow": ArrowConverter,
422
+ "csv": CsvConverter,
423
+ "excel": ExcelConverter,
424
+ "hdf5": HdfConverter,
425
+ "mdf": MdfConverter,
426
+ "sqlite3": SqliteConverter,
427
+ }
428
+
429
+ CONVERTER_REQUIREMENTS = {
430
+ "arrow": (has_arrow, "pyarrow"),
431
+ "csv": (True, "csv"),
432
+ "excel": (has_xlsxwriter, "xlsxwriter"),
433
+ "hdf5": (has_h5py, "h5py"),
434
+ "mdf": (has_asammdf, "asammdf"),
435
+ "sqlite3": (True, "csv"),
436
+ }
437
+
438
+
439
+ def convert_xmraw(converter_name: str, recording_file_name: str, target_file_name: str, *args, **kwargs) -> None:
440
+ converter_class = CONVERTERS.get(converter_name.lower())
441
+ if converter_class is None:
442
+ console.print(f"Invalid converter name: {converter_name!r}")
443
+ return
444
+ available, pck_name = CONVERTER_REQUIREMENTS.get(converter_name.lower(), (True, ""))
445
+ if not available:
446
+ console.print(f"Converter {converter_name!r} requires package {pck_name!r}.")
447
+ console.print(f"Please run [green]pip install {pck_name}[/green] to install it.")
448
+ return
449
+ # Path(*p.parts[:-1], p.stem)
450
+ converter = converter_class(recording_file_name)
451
+ converter.run()
@@ -0,0 +1,31 @@
1
+ import argparse
2
+
3
+ from pyxcp.recorder.converter import convert_xmraw
4
+
5
+
6
+ parser = argparse.ArgumentParser(description="Convert .xmraw files.")
7
+
8
+ parser.add_argument(
9
+ "target_type",
10
+ help="target file type",
11
+ choices=[
12
+ "arrow",
13
+ "csv",
14
+ "excel",
15
+ "hdf5",
16
+ "mdf",
17
+ "sqlite3",
18
+ ],
19
+ )
20
+
21
+
22
+ def main():
23
+ parser.add_argument("xmraw_file", help=".xmraw file")
24
+ parser.add_argument("-t", "--taget-file-name", dest="target_file_name", help="target file name")
25
+ args = parser.parse_args()
26
+
27
+ convert_xmraw(args.target_type, args.xmraw_file, args.target_file_name)
28
+
29
+
30
+ if __name__ == "__main__":
31
+ main()
@@ -240,7 +240,7 @@ class BaseTransport(metaclass=abc.ABCMeta):
240
240
  xcpPDU = self.get()
241
241
  except EmptyFrameError:
242
242
  if not ignore_timeout:
243
- MSG = f"Response timed out (timeout={self.timeout}s)"
243
+ MSG = f"Response timed out (timeout={self.timeout / 1_000_000_000}s)"
244
244
  with self.policy_lock:
245
245
  self.policy.feed(types.FrameCategory.METADATA, self.counter_send, self.timestamp.value, bytes(MSG, "ascii"))
246
246
  raise types.XcpTimeoutError(MSG) from None
@@ -491,9 +491,15 @@ SetCalPageMode = BitStruct(
491
491
  "ecu" / Flag,
492
492
  )
493
493
 
494
+ PagProperties = BitStruct(
495
+ Padding(7),
496
+ "freezeSupported" / Flag,
497
+ )
498
+
499
+
494
500
  GetPagProcessorInfoResponse = Struct(
495
501
  "maxSegments" / Int8ul,
496
- "pagProperties" / Int8ul,
502
+ "pagProperties" / PagProperties,
497
503
  )
498
504
 
499
505
  GetSegmentInfoMode0Response = Struct(