pyxcp 0.21.9__tar.gz → 0.21.11__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 (147) hide show
  1. {pyxcp-0.21.9 → pyxcp-0.21.11}/PKG-INFO +1 -1
  2. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyproject.toml +1 -1
  3. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/__init__.py +1 -1
  4. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cmdline.py +5 -0
  5. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/logger.py +0 -3
  6. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/master/master.py +55 -13
  7. pyxcp-0.21.11/pyxcp/scripts/xcp_info.py +89 -0
  8. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/types.py +8 -0
  9. pyxcp-0.21.9/pyxcp/scripts/xcp_info.py +0 -74
  10. {pyxcp-0.21.9 → pyxcp-0.21.11}/LICENSE +0 -0
  11. {pyxcp-0.21.9 → pyxcp-0.21.11}/README.md +0 -0
  12. {pyxcp-0.21.9 → pyxcp-0.21.11}/build_ext.py +0 -0
  13. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/EtasCANMonitoring.a2l +0 -0
  14. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/EtasCANMonitoring.aml +0 -0
  15. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCP_Common.aml +0 -0
  16. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCPonCAN.aml +0 -0
  17. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCPonEth.aml +0 -0
  18. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCPonFlx.aml +0 -0
  19. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCPonSxI.aml +0 -0
  20. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/XCPonUSB.aml +0 -0
  21. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/ifdata_CAN.a2l +0 -0
  22. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/ifdata_Eth.a2l +0 -0
  23. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/ifdata_Flx.a2l +0 -0
  24. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/ifdata_SxI.a2l +0 -0
  25. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/aml/ifdata_USB.a2l +0 -0
  26. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/asam/__init__.py +0 -0
  27. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/asam/types.py +0 -0
  28. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/asamkeydll.c +0 -0
  29. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/asamkeydll.sh +0 -0
  30. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/checksum.py +0 -0
  31. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/config.py +0 -0
  32. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/constants.py +0 -0
  33. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/asynchiofactory.hpp +0 -0
  34. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/blocking_client.cpp +0 -0
  35. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/blocking_socket.cpp +0 -0
  36. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/blocking_socket.hpp +0 -0
  37. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/concurrent_queue.hpp +0 -0
  38. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/eth.hpp +0 -0
  39. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/exceptions.hpp +0 -0
  40. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/iasyncioservice.hpp +0 -0
  41. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/iresource.hpp +0 -0
  42. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/isocket.hpp +0 -0
  43. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/linux/epoll.cpp +0 -0
  44. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/linux/epoll.hpp +0 -0
  45. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/linux/lit_tester.cpp +0 -0
  46. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/linux/socket.hpp +0 -0
  47. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/linux/timeout.hpp +0 -0
  48. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/memoryblock.hpp +0 -0
  49. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/pool.hpp +0 -0
  50. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/poolmgr.cpp +0 -0
  51. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/poolmgr.hpp +0 -0
  52. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/test_queue.cpp +0 -0
  53. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/timestamp.hpp +0 -0
  54. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/utils.cpp +0 -0
  55. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/utils.hpp +0 -0
  56. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/iocp.cpp +0 -0
  57. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/iocp.hpp +0 -0
  58. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/perhandledata.hpp +0 -0
  59. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/periodata.hpp +0 -0
  60. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/socket.hpp +0 -0
  61. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/cxx/win/timeout.hpp +0 -0
  62. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/dllif.py +0 -0
  63. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/errormatrix.py +0 -0
  64. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_can.json +0 -0
  65. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_can.toml +0 -0
  66. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_can_user.toml +0 -0
  67. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_can_vector.json +0 -0
  68. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_can_vector.toml +0 -0
  69. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_eth.json +0 -0
  70. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_eth.toml +0 -0
  71. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_nixnet.json +0 -0
  72. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_socket_can.toml +0 -0
  73. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_sxi.json +0 -0
  74. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/conf_sxi.toml +0 -0
  75. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcp_policy.py +0 -0
  76. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcp_read_benchmark.py +0 -0
  77. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcp_skel.py +0 -0
  78. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcp_unlock.py +0 -0
  79. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcp_user_supplied_driver.py +0 -0
  80. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcphello.py +0 -0
  81. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/examples/xcphello_recorder.py +0 -0
  82. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/master/__init__.py +0 -0
  83. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/master/errorhandler.py +0 -0
  84. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/__init__.py +0 -0
  85. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/build_clang.cmd +0 -0
  86. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/build_clang.sh +0 -0
  87. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/build_gcc.cmd +0 -0
  88. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/build_gcc.sh +0 -0
  89. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/build_gcc_arm.sh +0 -0
  90. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/lz4.c +0 -0
  91. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/lz4.h +0 -0
  92. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/lz4hc.c +0 -0
  93. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/lz4hc.h +0 -0
  94. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/mio.hpp +0 -0
  95. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/reco.py +0 -0
  96. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/recorder.rst +0 -0
  97. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/rekorder.cpp +0 -0
  98. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/rekorder.hpp +0 -0
  99. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/setup.py +0 -0
  100. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/test_reko.py +0 -0
  101. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/recorder/wrap.cpp +0 -0
  102. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/scripts/__init__.py +0 -0
  103. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -0
  104. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/scripts/xcp_fetch_a2l.py +0 -0
  105. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/scripts/xcp_id_scanner.py +0 -0
  106. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_asam_types.py +0 -0
  107. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_can.py +0 -0
  108. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_checksum.py +0 -0
  109. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_config.py +0 -0
  110. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_frame_padding.py +0 -0
  111. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_master.py +0 -0
  112. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_transport.py +0 -0
  113. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/tests/test_utils.py +0 -0
  114. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/timing.py +0 -0
  115. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/__init__.py +0 -0
  116. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/base.py +0 -0
  117. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/can.py +0 -0
  118. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/__init__.py +0 -0
  119. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_canalystii.py +0 -0
  120. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_etas.py +0 -0
  121. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_gsusb.py +0 -0
  122. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_iscan.py +0 -0
  123. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_ixxat.py +0 -0
  124. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_kvaser.py +0 -0
  125. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_neovi.py +0 -0
  126. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_nican.py +0 -0
  127. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_nixnet.py +0 -0
  128. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_pcan.py +0 -0
  129. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_seeed.py +0 -0
  130. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_serial.py +0 -0
  131. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_slcan.py +0 -0
  132. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_socketcan.py +0 -0
  133. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_systec.py +0 -0
  134. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_usb2can.py +0 -0
  135. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/pc_vector.py +0 -0
  136. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/candriver/python_can.py +0 -0
  137. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/cxx_ext/CMakeLists.txt +0 -0
  138. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/cxx_ext/setup.py +0 -0
  139. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/cxx_ext/tests/test_basic_socket.cpp +0 -0
  140. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/cxx_ext/tests/test_pool.cpp +0 -0
  141. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/cxx_ext/tests/test_timestamp.cpp +0 -0
  142. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/eth.py +0 -0
  143. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/sxi.py +0 -0
  144. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/transport/usb_transport.py +0 -0
  145. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/utils.py +0 -0
  146. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/vector/__init__.py +0 -0
  147. {pyxcp-0.21.9 → pyxcp-0.21.11}/pyxcp/vector/map.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyxcp
3
- Version: 0.21.9
3
+ Version: 0.21.11
4
4
  Summary: Universal Calibration Protocol for Python
5
5
  Keywords: automotive,ecu,xcp,asam,autosar
6
6
  Author: Christoph Schueler
@@ -92,7 +92,7 @@ dependencies = [
92
92
  "traitlets>=5.9.0",
93
93
  ]
94
94
  name = "pyxcp"
95
- version = "0.21.9"
95
+ version = "0.21.11"
96
96
  readme = "README.md"
97
97
  description = "Universal Calibration Protocol for Python"
98
98
  keywords = [
@@ -25,4 +25,4 @@ from .transport import SxI
25
25
  from .transport import Usb
26
26
 
27
27
  # if you update this manually, do not forget to update .bumpversion.cfg and pyproject.toml
28
- __version__ = "0.21.9"
28
+ __version__ = "0.21.11"
@@ -5,12 +5,14 @@ Parse (transport-layer specific) command line parameters
5
5
  and create a XCP master instance.
6
6
  """
7
7
  import argparse
8
+ import logging
8
9
 
9
10
  from pyxcp.config import readConfiguration
10
11
  from pyxcp.master import Master
11
12
  from pyxcp.transport.can import registered_drivers
12
13
  from pyxcp.transport.can import try_to_install_system_supplied_drivers
13
14
 
15
+
14
16
  try_to_install_system_supplied_drivers()
15
17
 
16
18
  CAN_DRIVERS = registered_drivers()
@@ -51,6 +53,9 @@ class ArgumentParser:
51
53
 
52
54
  def run(self, policy=None):
53
55
  """"""
56
+ # Create a default logging context if run as command line
57
+ logging.basicConfig()
58
+
54
59
  self._args = self.parser.parse_args()
55
60
  args = self.args
56
61
  if args.conf is None:
@@ -2,9 +2,6 @@
2
2
  # -*- coding: utf-8 -*-
3
3
  import logging
4
4
 
5
- logging.basicConfig()
6
-
7
-
8
5
  class Logger(object):
9
6
 
10
7
  LOGGER_BASE_NAME = "pyxcp"
@@ -8,17 +8,17 @@
8
8
  .. [1] XCP Specification, Part 2 - Protocol Layer Specification
9
9
  """
10
10
  import functools
11
- import logging
12
11
  import struct
13
12
  import traceback
14
13
  import warnings
15
14
  from time import sleep
15
+ from typing import Any
16
16
  from typing import Callable
17
17
  from typing import Collection
18
18
  from typing import Dict
19
19
  from typing import List
20
20
  from typing import Optional
21
- from typing import Union
21
+ from typing import Tuple
22
22
 
23
23
  from pyxcp import checksum
24
24
  from pyxcp import types
@@ -33,6 +33,7 @@ from pyxcp.constants import makeWordPacker
33
33
  from pyxcp.constants import makeWordUnpacker
34
34
  from pyxcp.constants import PackerType
35
35
  from pyxcp.constants import UnpackerType
36
+ from pyxcp.logger import Logger
36
37
  from pyxcp.master.errorhandler import disable_error_handling
37
38
  from pyxcp.master.errorhandler import wrapped
38
39
  from pyxcp.transport.base import createTransport
@@ -92,8 +93,7 @@ class Master:
92
93
  self.ctr = 0
93
94
  self.succeeded = True
94
95
  self.config = Configuration(self.PARAMETER_MAP or {}, config or {})
95
- self.logger = logging.getLogger("pyXCP")
96
- self.logger.setLevel(self.config.get("LOGLEVEL"))
96
+ self.logger = Logger("master.Master", level=self.config.get("LOGLEVEL"))
97
97
  disable_error_handling(self.config.get("DISABLE_ERROR_HANDLING"))
98
98
 
99
99
  self.transport = createTransport(transportName, config, policy)
@@ -124,6 +124,7 @@ class Master:
124
124
  self.disconnect_response_optional = self.config.get("DISCONNECT_RESPONSE_OPTIONAL")
125
125
  self.slaveProperties = SlaveProperties()
126
126
  self.slaveProperties.pgmProcessor = SlaveProperties()
127
+ self.slaveProperties.transport_layer = self.transport_name.upper()
127
128
 
128
129
  def __enter__(self):
129
130
  """Context manager entry part."""
@@ -1790,12 +1791,13 @@ class Master:
1790
1791
  length = result.length
1791
1792
  if length == 0:
1792
1793
  continue
1793
- if length > MAX_PAYLOAD:
1794
- remaining = length - len(seed)
1795
- while remaining > 0:
1796
- result = self.getSeed(types.XcpGetSeedMode.REMAINING, resource_value)
1797
- seed.extend(list(result.seed))
1798
- remaining = result.length
1794
+
1795
+ while length - len(seed) > 0:
1796
+ result = self.getSeed(types.XcpGetSeedMode.REMAINING, resource_value)
1797
+ seed.extend(list(result.seed))
1798
+
1799
+ seed = seed[:length] # maybe there are some padding bytes
1800
+
1799
1801
  result, key = getKey(
1800
1802
  self.logger,
1801
1803
  self.seedNKeyDLL,
@@ -1809,9 +1811,8 @@ class Master:
1809
1811
  offset = 0
1810
1812
  while offset < total_length:
1811
1813
  data = key[offset : offset + MAX_PAYLOAD]
1812
- key_length = len(data)
1813
- offset += key_length
1814
- self.unlock(key_length, data)
1814
+ self.unlock(total_length - offset, data)
1815
+ offset += len(data)
1815
1816
  else:
1816
1817
  raise SeedNKeyError("SeedAndKey DLL returned: {}".format(SeedNKeyResult(result).name))
1817
1818
 
@@ -1903,6 +1904,47 @@ class Master:
1903
1904
  result[name] = response
1904
1905
  return result
1905
1906
 
1907
+ def try_command(self, cmd: Callable, *args, **kws) -> Tuple[types.TryCommandResult, Any]:
1908
+ """Call master functions and handle XCP errors more gracefuly.
1909
+
1910
+ Parameter
1911
+ ---------
1912
+ cmd: Callable
1913
+ args: list
1914
+ variable length arguments to `cmd`.
1915
+ kws: dict
1916
+ keyword arguments to `cmd`.
1917
+
1918
+ `extra_msg`: str
1919
+ Additional info to log message (not passed to `cmd`).
1920
+
1921
+ Returns
1922
+ -------
1923
+
1924
+ Note
1925
+ ----
1926
+ Mainly used for plug-and-play applications, e.g. `id_scanner` may confronted with `ERR_OUT_OF_RANGE` errors, which
1927
+ is normal for this kind of applications -- or to test for optional commands.
1928
+ Use carefuly not to hide serious error causes.
1929
+ """
1930
+ try:
1931
+ extra_msg: Optional[str] = kws.get("extra_msg")
1932
+ if extra_msg:
1933
+ kws.pop("extra_msg")
1934
+ res = cmd(*args, **kws)
1935
+ except SystemExit as e:
1936
+ if e.error_code == types.XcpError.ERR_CMD_UNKNOWN:
1937
+ # This is a rather common use-case, so let the user know that there is some functionality missing.
1938
+ if extra_msg:
1939
+ self.logger.warning(f"Optional command {cmd.__name__!r} not implemented -- {extra_msg!r}")
1940
+ else:
1941
+ self.logger.warning(f"Optional command {cmd.__name__!r} not implemented.")
1942
+ return (types.TryCommandResult.XCP_ERROR, e)
1943
+ except Exception as e:
1944
+ return (types.TryCommandResult.OTHER_ERROR, e)
1945
+ else:
1946
+ return (types.TryCommandResult.OK, res)
1947
+
1906
1948
 
1907
1949
  def ticks_to_seconds(ticks, resolution):
1908
1950
  """Convert DAQ timestamp/tick value to seconds.
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env python
2
+ """XCP info/exploration tool.
3
+ """
4
+ from pprint import pprint
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+ from pyxcp.types import TryCommandResult
8
+
9
+
10
+ ap = ArgumentParser(description="XCP info/exploration tool.")
11
+
12
+ with ap.run() as x:
13
+ x.connect()
14
+ if x.slaveProperties.optionalCommMode:
15
+ x.try_command(x.getCommModeInfo, extra_msg="availability signaled by CONNECT, this may be a slave configuration error.")
16
+ print("\nSlave Properties:")
17
+ print("=================")
18
+ pprint(x.slaveProperties)
19
+
20
+ # result = x.id_scanner()
21
+ # print("\n")
22
+ # print("Implemented IDs:")
23
+ # print("================")
24
+ # for key, value in result.items():
25
+ # print(f"{key}: {value}", end="\n\n")
26
+ cps = x.getCurrentProtectionStatus()
27
+ print("\nProtection Status")
28
+ print("=================")
29
+ for k, v in cps.items():
30
+ print(f" {k:6s}: {v}")
31
+ x.cond_unlock()
32
+ print("\nDAQ Info:")
33
+ print("=========")
34
+ daq_info = x.getDaqInfo()
35
+ pprint(daq_info)
36
+
37
+ daq_pro = daq_info["processor"]
38
+ daq_properties = daq_pro["properties"]
39
+ if x.slaveProperties.transport_layer == "CAN":
40
+ print("")
41
+ if daq_properties["pidOffSupported"]:
42
+ print("*** pidOffSupported -- i.e. one CAN-ID per DAQ-list.")
43
+ else:
44
+ print("*** NO support for PID_OFF")
45
+ num_predefined = daq_pro["minDaq"]
46
+ print("\nPredefined DAQ-Lists")
47
+ print("====================")
48
+ if num_predefined > 0:
49
+ print(f"There are {num_predefined} predefined DAQ-lists")
50
+ for idx in range(num_predefined):
51
+ print(f"DAQ-List #{idx}\n____________\n")
52
+ status, dm = x.try_command(x.getDaqListMode, idx)
53
+ if status == TryCommandResult.OK:
54
+ print(dm)
55
+ status, di = x.try_command(x.getDaqListInfo, idx)
56
+ if status == TryCommandResult.OK:
57
+ print(di)
58
+ else:
59
+ print("*** NO Predefined DAQ-Lists")
60
+ print("\nPAG Info:")
61
+ print("=========")
62
+ if x.slaveProperties.supportsCalpag:
63
+ status, pag = x.try_command(x.getPagProcessorInfo)
64
+ if status == TryCommandResult.OK:
65
+ print(pag)
66
+ # for idx in range(pag.maxSegments):
67
+ # x.getSegmentInfo(0x01, idx, 0, 0)
68
+ else:
69
+ print("*** PAGING IS NOT SUPPORTED.")
70
+
71
+ print("\nPGM Info:")
72
+ print("=========")
73
+ if x.slaveProperties.supportsPgm:
74
+ status, pgm = x.try_command(x.getPgmProcessorInfo)
75
+ if status == TryCommandResult.OK:
76
+ print(pgm)
77
+ else:
78
+ print("*** FLASH PROGRAMMING IS NOT SUPPORTED.")
79
+
80
+ if x.slaveProperties.transport_layer == "CAN":
81
+ # print("OK, CAN!!!")
82
+ for idx in range(num_predefined):
83
+ status, daq_id = x.try_command(x.getDaqId, idx)
84
+ if status != TryCommandResult.OK:
85
+ break
86
+ print(f"DAQ-ID #{idx}", daq_id)
87
+ x.disconnect()
88
+
89
+ print("\nDone.")
@@ -942,3 +942,11 @@ class FrameCategory(enum.IntEnum):
942
942
  SERV = 5
943
943
  DAQ = 6
944
944
  STIM = 7
945
+
946
+
947
+ class TryCommandResult(enum.IntEnum):
948
+ """ """
949
+
950
+ OK = 0
951
+ XCP_ERROR = 1
952
+ OTHER_ERROR = 2
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- """Very basic hello-world example.
4
- """
5
- from pprint import pprint
6
-
7
- from pyxcp.cmdline import ArgumentParser
8
-
9
- daq_info = False
10
-
11
-
12
- def callout(master, args):
13
- global daq_info
14
- if args.daq_info:
15
- daq_info = True
16
-
17
-
18
- ap = ArgumentParser(description="pyXCP hello world.", callout=callout)
19
- ap.parser.add_argument(
20
- "-d",
21
- "--daq-info",
22
- dest="daq_info",
23
- help="Display DAQ-info",
24
- default=False,
25
- action="store_true",
26
- )
27
- with ap.run() as x:
28
- x.connect()
29
- if x.slaveProperties.optionalCommMode:
30
- x.getCommModeInfo()
31
- identifier = x.identifier(0x01)
32
- print("\nSlave Properties:")
33
- print("=================")
34
- print(f"ID: '{identifier}'")
35
- pprint(x.slaveProperties)
36
- cps = x.getCurrentProtectionStatus()
37
- print("\nProtection Status")
38
- print("=================")
39
- for k, v in cps.items():
40
- print(f" {k:6s}: {v}")
41
- if daq_info:
42
- dqp = x.getDaqProcessorInfo()
43
- print("\nDAQ Processor Info:")
44
- print("===================")
45
- print(dqp)
46
- print("\nDAQ Events:")
47
- print("===========")
48
- for idx in range(dqp.maxEventChannel):
49
- evt = x.getDaqEventInfo(idx)
50
- length = evt.eventChannelNameLength
51
- name = x.pull(length).decode("utf-8")
52
- dq = "DAQ" if evt.daqEventProperties.daq else ""
53
- st = "STIM" if evt.daqEventProperties.stim else ""
54
- dq_st = dq + " " + st
55
- print(f' [{idx:04}] "{name:s}"')
56
- print(f" dir: {dq_st}")
57
- print(f" packed: {evt.daqEventProperties.packed}")
58
- PFX_CONS = "CONSISTENCY_"
59
- print(f" consistency: {evt.daqEventProperties.consistency.strip(PFX_CONS)}")
60
- print(f" max. DAQ lists: {evt.maxDaqList}")
61
- PFX_TU = "EVENT_CHANNEL_TIME_UNIT_"
62
- print(f" unit: {evt.eventChannelTimeUnit.strip(PFX_TU)}")
63
- print(f" cycle: {evt.eventChannelTimeCycle or 'SPORADIC'}")
64
- print(f" priority {evt.eventChannelPriority}")
65
-
66
- dqr = x.getDaqResolutionInfo()
67
- print("\nDAQ Resolution Info:")
68
- print("====================")
69
- print(dqr)
70
- for idx in range(dqp.maxDaq):
71
- print(f"\nDAQ List Info #{idx}")
72
- print("=================")
73
- print(f"{x.getDaqListInfo(idx)}")
74
- x.disconnect()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes