pyxcp 0.21.6__cp39-cp39-macosx_10_9_x86_64.whl → 0.21.9__cp39-cp39-macosx_10_9_x86_64.whl

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.

pyxcp/__init__.py CHANGED
@@ -24,5 +24,5 @@ from .transport import Eth
24
24
  from .transport import SxI
25
25
  from .transport import Usb
26
26
 
27
- # if you update this manually, do not forget to update .bumpversion.cfg
28
- __version__ = "0.21.6"
27
+ # if you update this manually, do not forget to update .bumpversion.cfg and pyproject.toml
28
+ __version__ = "0.21.9"
pyxcp/master/master.py CHANGED
@@ -218,17 +218,20 @@ class Master:
218
218
  self.DWORD_unpack = makeDWordUnpacker(byteOrderPrefix)
219
219
  self.DLONG_pack = makeDLongPacker(byteOrderPrefix)
220
220
  self.DLONG_unpack = makeDLongUnpacker(byteOrderPrefix)
221
-
221
+ self.slaveProperties.bytesPerElement = None # Download/Upload commands are using element- not byte-count.
222
222
  if self.slaveProperties.addressGranularity == types.AddressGranularity.BYTE:
223
223
  self.AG_pack = struct.Struct("<B").pack
224
224
  self.AG_unpack = struct.Struct("<B").unpack
225
+ self.slaveProperties.bytesPerElement = 1
225
226
  elif self.slaveProperties.addressGranularity == types.AddressGranularity.WORD:
226
227
  self.AG_pack = self.WORD_pack
227
228
  self.AG_unpack = self.WORD_unpack
229
+ self.slaveProperties.bytesPerElement = 2
228
230
  elif self.slaveProperties.addressGranularity == types.AddressGranularity.DWORD:
229
231
  self.AG_pack = self.DWORD_pack
230
232
  self.AG_unpack = self.DWORD_unpack
231
- # self.connected = True
233
+ self.slaveProperties.bytesPerElement = 4
234
+ # self.connected = True
232
235
  return result
233
236
 
234
237
  @wrapped
@@ -431,6 +434,7 @@ class Master:
431
434
  Parameters
432
435
  ----------
433
436
  length : int
437
+ Number of elements (address granularity).
434
438
 
435
439
  Note
436
440
  ----
@@ -440,24 +444,23 @@ class Master:
440
444
  -------
441
445
  bytes
442
446
  """
443
-
447
+ byte_count = length * self.slaveProperties.bytesPerElement
444
448
  response = self.transport.request(types.Command.UPLOAD, length)
445
- if length > (self.slaveProperties.maxCto - 1):
446
- block_response = self.transport.block_receive(length_required=(length - len(response)))
449
+ if byte_count > (self.slaveProperties.maxCto - 1):
450
+ block_response = self.transport.block_receive(length_required=(byte_count - len(response)))
447
451
  response += block_response
448
452
  elif self.transport_name == "can":
449
453
  # larger sizes will send in multiple CAN messages
450
454
  # each valid message will start with 0xFF followed by the upload bytes
451
455
  # the last message might be padded to the required DLC
452
- rem = length - len(response)
456
+ rem = byte_count - len(response)
453
457
  while rem:
454
458
  if len(self.transport.resQueue):
455
459
  data = self.transport.resQueue.popleft()
456
460
  response += data[1 : rem + 1]
457
- rem = length - len(response)
461
+ rem = byte_count - len(response)
458
462
  else:
459
463
  sleep(SHORT_SLEEP)
460
-
461
464
  return response
462
465
 
463
466
  @wrapped
@@ -467,6 +470,8 @@ class Master:
467
470
 
468
471
  Parameters
469
472
  ----------
473
+ length : int
474
+ Number of elements (address granularity).
470
475
  address : int
471
476
  addressExt : int
472
477
 
@@ -475,7 +480,12 @@ class Master:
475
480
  bytes
476
481
  """
477
482
  addr = self.DWORD_pack(address)
478
- return self.transport.request(types.Command.SHORT_UPLOAD, length, 0, addressExt, *addr)
483
+ byte_count = length * self.slaveProperties.bytesPerElement
484
+ max_byte_count = self.slaveProperties.maxCto - 1
485
+ if byte_count > max_byte_count:
486
+ self.logger.warn(f"SHORT_UPLOAD: {byte_count} bytes exceeds the maximum value of {max_byte_count}.")
487
+ response = self.transport.request(types.Command.SHORT_UPLOAD, length, 0, addressExt, *addr)
488
+ return response[:byte_count]
479
489
 
480
490
  @wrapped
481
491
  def buildChecksum(self, blocksize: int):
pyxcp/transport/can.py CHANGED
@@ -321,7 +321,7 @@ class Can(BaseTransport):
321
321
  self.processResponse(
322
322
  payload,
323
323
  len(payload),
324
- counter=self.counterReceived + 1,
324
+ counter=(self.counterReceived + 1) & 0xffff,
325
325
  recv_timestamp=recv_timestamp,
326
326
  )
327
327
 
@@ -8,6 +8,9 @@ from time import perf_counter
8
8
  from time import sleep
9
9
  from time import time
10
10
 
11
+ import usb.backend.libusb1 as libusb1
12
+ import usb.backend.libusb0 as libusb0
13
+ import usb.backend.openusb as openusb
11
14
  import usb.core
12
15
  import usb.util
13
16
 
@@ -29,6 +32,7 @@ class Usb(BaseTransport):
29
32
  "reply_endpoint_number": (int, True, 1),
30
33
  "vendor_id": (int, False, 0),
31
34
  "product_id": (int, False, 0),
35
+ "library": (str, False, "") # absolute path to USB shared library
32
36
  }
33
37
  HEADER = struct.Struct("<2H")
34
38
  HEADER_SIZE = HEADER.size
@@ -43,6 +47,7 @@ class Usb(BaseTransport):
43
47
  self.interface_number = self.config.get("interface_number")
44
48
  self.command_endpoint_number = self.config.get("command_endpoint_number")
45
49
  self.reply_endpoint_number = self.config.get("reply_endpoint_number")
50
+ self.library = self.config.get("library")
46
51
  self.device = None
47
52
 
48
53
  self.status = 0
@@ -55,15 +60,25 @@ class Usb(BaseTransport):
55
60
  self._packets = deque()
56
61
 
57
62
  def connect(self):
63
+ if self.library:
64
+ for backend_provider in (libusb1, libusb0, openusb):
65
+ backend = backend_provider.get_backend(find_library=lambda x: self.library)
66
+ if backend:
67
+ break
68
+ else:
69
+ backend = None
70
+
58
71
  if self.vendor_id and self.product_id:
59
72
  kwargs = {
60
73
  "find_all": True,
61
74
  "idVendor": self.vendor_id,
62
75
  "idProduct": self.product_id,
76
+ "backend": backend,
63
77
  }
64
78
  else:
65
79
  kwargs = {
66
80
  "find_all": True,
81
+ "backend": backend,
67
82
  }
68
83
 
69
84
  for device in usb.core.find(**kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyxcp
3
- Version: 0.21.6
3
+ Version: 0.21.9
4
4
  Summary: Universal Calibration Protocol for Python
5
5
  Keywords: automotive,ecu,xcp,asam,autosar
6
6
  Author: Christoph Schueler
@@ -1,4 +1,9 @@
1
1
  rekorder.cpython-39-darwin.so,sha256=uW3Z92dDRzAN0SleWgd9UPBYMD2iE_1hcr7O842YL_o,319360
2
+ pyxcp-0.21.9.dist-info/RECORD,,
3
+ pyxcp-0.21.9.dist-info/WHEEL,sha256=n3FnKqnoEoBrDnlgv6JYwhAIfxqO8pwutUo8W22lbFc,104
4
+ pyxcp-0.21.9.dist-info/entry_points.txt,sha256=wL4Cgx0wIAbuEr93nPewLCL-6DCSunxxTkui-bibme8,219
5
+ pyxcp-0.21.9.dist-info/METADATA,sha256=9SEGwDGqBqsFd_2HpxNHjbV6C4I4iwgJx1XhjQmFtGE,3861
6
+ pyxcp-0.21.9.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
2
7
  pyxcp/dllif.py,sha256=o7t_M_n6XwE63ng97DV8t8BJkGmFHtj7Esdhi7qH4DQ,3023
3
8
  pyxcp/checksum.py,sha256=nsEosSKtU1b8L14sm9HyxvUNUMc07hnCR6oK_bH6-Ew,10837
4
9
  pyxcp/asamkeydll.sh,sha256=iema12sub6qNE0xAuzwGtx0FmkdaaOKoXalhrtWVaa8,57
@@ -6,7 +11,7 @@ pyxcp/config.py,sha256=dJ5WfX4Stlz2bvUA-mO-ez6jruFi27C9r7TDj1Vkc4g,1423
6
11
  pyxcp/asamkeydll.c,sha256=PnfD6UbMWz3cszGpJDHBrSPizjlg8RrV_nrCqC9xPOw,2862
7
12
  pyxcp/constants.py,sha256=Ifs1cxpRoctEU0BKAo5yDXqBtTWpTNIKzcV8YbrgNCA,1258
8
13
  pyxcp/cmdline.py,sha256=IvI946DR7CoCDutAaIrFTdTlCBSQ-ib_qlxBLWIK4dc,2117
9
- pyxcp/__init__.py,sha256=wOQPWhc0HtuEoBi-OorkwLqVIJnMnZhKlKE5AiDX3U0,699
14
+ pyxcp/__init__.py,sha256=G1c0D5IBEmXIA1uot58ENy_8_SkGkWQFBrfXLJjKwNs,718
10
15
  pyxcp/types.py,sha256=fwAH5XAOPAiHo4EW2JgR9P1GdNTTPGzDrPLGeNeWhjI,24006
11
16
  pyxcp/logger.py,sha256=Zl9TolTcbvUjpRs8Chx8rK8TGHiHAq9-TC3fWQRnxgY,1924
12
17
  pyxcp/timing.py,sha256=dK89nGWV1sUVCd5FVkNCTDjoyuP8qK4Ggo9GgFGe_s0,1670
@@ -17,8 +22,8 @@ pyxcp/asam/types.py,sha256=VHPeIfOAXMXV67kZsDXUtMaTLZEjXrdt1V7WrznsUpQ,2361
17
22
  pyxcp/transport/eth.py,sha256=tUYC46wPPX6eYjWfNXrcmA38Uf3V7BBQMyI0QU9dX28,7702
18
23
  pyxcp/transport/sxi.py,sha256=frPYgKBdS6xUF8ZKIc0InxucDl12W0PkQxs--LteyTE,2496
19
24
  pyxcp/transport/__init__.py,sha256=Ip3jrH0gqXyA0JvK_r4kFV12raRZvummCczKAO7Xlb8,297
20
- pyxcp/transport/usb_transport.py,sha256=qO_tIb2BQ_ZDblqe_BKvCF4f6K-gARIYz4ReVMkaR1w,7068
21
- pyxcp/transport/can.py,sha256=yTAwKSp2yG6Zsh2TzXsqqpFL60bBfr3dSJ-puUNITWM,12226
25
+ pyxcp/transport/usb_transport.py,sha256=aPXovvFJwMofIzFZTKhc0RHDwRPk6m0D4qDRbmDeYSA,7657
26
+ pyxcp/transport/can.py,sha256=snTFVHUz8wQsQUpYC2gFBMxZDyC8Dt-mbfB-w8Eokkw,12237
22
27
  pyxcp/transport/base.py,sha256=L20LZ9-n8P-GwbKYScIyFAvQeyxX14fADIjJuqVpAg4,14368
23
28
  pyxcp/transport/candriver/pc_serial.py,sha256=O10fcNFJw8v6NHH2Hm9zwSwwKQdAB7cRSOpKZ1ASgrI,689
24
29
  pyxcp/transport/candriver/pc_iscan.py,sha256=iX3sI0-2ydBSj-fjhqh86OxeHUEGIy_WPidnW1Qqkic,571
@@ -95,7 +100,7 @@ pyxcp/aml/XCPonUSB.aml,sha256=1xNuM0fsDQi712hkzhBPveJcx1m318tC28bZEfnKpXU,4846
95
100
  pyxcp/aml/ifdata_SxI.a2l,sha256=ElFw9n43E4wSNVVvOiuq9TDv_zsAwSVSh4SnW8P7pCo,304
96
101
  pyxcp/aml/XCPonFlx.aml,sha256=z58FMu6ZF4hVun8WBCuxvDrq6FZ_gj3tZM15G7E8Uvw,4647
97
102
  pyxcp/master/__init__.py,sha256=14ZrFHp9wc_lizE47yl0Yr-NZ3PT2PEFPWWAaXvna34,319
98
- pyxcp/master/master.py,sha256=XI44Iyzm0h4FTwqavqf9RefF5ZnCDl8Sc-fQO8swEb4,69923
103
+ pyxcp/master/master.py,sha256=W45K7qTf5mBfEA1x1CBPJ6CzU2-Scqds1oOowKWDrN0,70728
99
104
  pyxcp/master/errorhandler.py,sha256=rVtCpvkxWLZtAYpjvs3SygQuLGp4lyIIxzFcYjAhsCo,13219
100
105
  pyxcp/examples/xcp_read_benchmark.py,sha256=8nlFK7ZssAuwp2nyPdI8s5MDVObP4PKRZJ--hRouNDU,839
101
106
  pyxcp/examples/conf_eth.toml,sha256=zONw4kMsNH-uQYd8V3AlNH21sAlJ9wY7RY0DuSGJiiA,109
@@ -140,8 +145,3 @@ pyxcp/recorder/lz4.c,sha256=zpWRavGVvyz-7RsD9NugePXene2bQgDvu1f26SbdkSg,114204
140
145
  pyxcp/recorder/build_gcc.sh,sha256=uvMhL4faEJmhG_8rzSOxEBRRqrACC0kmZgaERN8GkUs,209
141
146
  pyxcp/vector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
147
  pyxcp/vector/map.py,sha256=7CsFSHBjorSw86jHk8bA-Lp1zaQTVeAVxx3JVt7tK1s,2285
143
- pyxcp-0.21.6.dist-info/RECORD,,
144
- pyxcp-0.21.6.dist-info/WHEEL,sha256=n3FnKqnoEoBrDnlgv6JYwhAIfxqO8pwutUo8W22lbFc,104
145
- pyxcp-0.21.6.dist-info/entry_points.txt,sha256=wL4Cgx0wIAbuEr93nPewLCL-6DCSunxxTkui-bibme8,219
146
- pyxcp-0.21.6.dist-info/METADATA,sha256=wnrJ_7sGy-beWOXX_2budDF1d_jvN1OBvhCPN1trNzA,3861
147
- pyxcp-0.21.6.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
File without changes