Debian Codegraph @

libusb1.egg-info/PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: libusb1
3 Version: 3.3.1
4 Summary: Pure-python wrapper for libusb-1.0
5 Home-page: https://github.com/vpelletier/python-libusb1
6 Author: Vincent Pelletier
7 Author-email: [email protected]
8 License: LGPLv2.1+
9 Keywords: usb,libusb
10 Platform: any
11 Classifier: Intended Audience :: Developers
12 Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
13 Classifier: Operating System :: OS Independent
14 Classifier: Programming Language :: Python :: 3
15 Classifier: Programming Language :: Python :: Implementation :: CPython
16 Classifier: Programming Language :: Python :: Implementation :: PyPy
17 Classifier: Topic :: Software Development :: Libraries
18 Classifier: Topic :: System :: Hardware :: Hardware Drivers
19 Description-Content-Type: text/x-rst
20 License-File: COPYING
21 License-File: COPYING.LESSER
22
23 .. contents::
24
25 Supports all transfer types, both in synchronous and asynchronous mode.
26
27 Home: http://github.com/vpelletier/python-libusb1
28
29 PyPI: http://pypi.python.org/pypi/libusb1
30
31 .. role:: c_code(code)
32 :language: c
33
34 .. role:: python_code(code)
35 :language: python
36
37 Dependencies
38 ============
39
40 - CPython_ 3.6+, pypy_ 2.0+. Older versions may work, but are not
41 recommended as there is no automated regression testing set up for them.
42 - libusb-1.0_
43
44 Supported OSes
45 ==============
46
47 python-libusb1 can be expected to work on:
48
49 - GNU/Linux
50 - Windows [#]_ native dll or via Cygwin_
51 - OSX [#]_ via MacPorts_, Fink_ or Homebrew_
52 - FreeBSD (including Debian GNU/kFreeBSD)
53 - OpenBSD
54
55 .. [#] Beware of libusb-win32, which implements 0.1 API, not 1.0 .
56
57 .. [#] Beware of possible lack of select.poll if you want to use asynchronous
58 API.
59
60 Installation
61 ============
62
63 Releases from PyPI, with name *libusb1*. Installing from command line::
64
65 $ pip install libusb1
66
67 Latest version from source tree::
68
69 $ git clone https://github.com/vpelletier/python-libusb1.git
70 $ cd python-libusb1
71 $ pip install .
72
73 Windows installation notes
74 --------------------------
75
76 On Windows, installing wheels from pypi also installs the libusb dll within the
77 usb1 python module. It does not install any driver, so you still need to decide
78 which of libusbk or WinUSB to use for each device and install it appropriately
79 (possibly using Zadig_, or by providing a driver for your users to install).
80
81 Installing from source tree does not install the dll, so you need to install the
82 library where ctypes can find it - and of course the driver as well.
83
84 Checking release file signature
85 -------------------------------
86
87 pipy releases are signed. To verify the signature:
88
89 - download the release file, note its URL
90 - download its detached signature by adding `.asc` at the end of the release
91 file URL
92 - add the release key(s) to a gnupg keyring (`KEYS` file in the home
93 repository), and use gnupg to validate the signature both corresponds to the
94 distribution file and is trusted by your keyring
95 - install the already-fetched release file
96
97 Usage
98 =====
99
100 Finding a device and gaining exclusive access:
101
102 .. code:: python
103
104 import usb1
105 with usb1.USBContext() as context:
106 handle = context.openByVendorIDAndProductID(
107 VENDOR_ID,
108 PRODUCT_ID,
109 skip_on_error=True,
110 )
111 if handle is None:
112 # Device not present, or user is not allowed to access device.
113 with handle.claimInterface(INTERFACE):
114 # Do stuff with endpoints on claimed interface.
115
116 Synchronous I/O:
117
118 .. code:: python
119
120 while True:
121 data = handle.bulkRead(ENDPOINT, BUFFER_SIZE)
122 # Process data...
123
124 Asynchronous I/O, with more error handling:
125
126 .. code:: python
127
128 def processReceivedData(transfer):
129 if transfer.getStatus() != usb1.TRANSFER_COMPLETED:
130 # Transfer did not complete successfully, there is no data to read.
131 # This example does not resubmit transfers on errors. You may want
132 # to resubmit in some cases (timeout, ...).
133 return
134 data = transfer.getBuffer()[:transfer.getActualLength()]
135 # Process data...
136 # Resubmit transfer once data is processed.
137 transfer.submit()
138
139 # Build a list of transfer objects and submit them to prime the pump.
140 transfer_list = []
141 for _ in range(TRANSFER_COUNT):
142 transfer = handle.getTransfer()
143 transfer.setBulk(
144 usb1.ENDPOINT_IN | ENDPOINT,
145 BUFFER_SIZE,
146 callback=processReceivedData,
147 )
148 transfer.submit()
149 transfer_list.append(transfer)
150 # Loop as long as there is at least one submitted transfer.
151 while any(x.isSubmitted() for x in transfer_list):
152 try:
153 context.handleEvents()
154 except usb1.USBErrorInterrupted:
155 pass
156
157 For more, see the ``example`` directory.
158
159 Documentation
160 =============
161
162 python-libusb1 main documentation is accessible with python's standard
163 ``pydoc`` command.
164
165 python-libusb1 follows libusb-1.0 documentation as closely as possible, without
166 taking decisions for you. Thanks to this, python-libusb1 does not need to
167 duplicate the nice existing `libusb1.0 documentation`_.
168
169 Some description is needed though on how to jump from libusb-1.0 documentation
170 to python-libusb1, and vice-versa:
171
172 ``usb1`` module groups libusb-1.0 functions as class methods. The first
173 parameter (when it's a ``libusb_...`` pointer) defined the class the function
174 belongs to. For example:
175
176 - :c_code:`int libusb_init (libusb_context **context)` becomes USBContext class
177 constructor, :python_code:`USBContext.__init__(self)`
178
179 - :c_code:`ssize_t libusb_get_device_list (libusb_context *ctx,
180 libusb_device ***list)` becomes an USBContext method, returning a
181 list of USBDevice instances, :python_code:`USBDevice.getDeviceList(self)`
182
183 - :c_code:`uint8_t libusb_get_bus_number (libusb_device *dev)` becomes an
184 USBDevice method, :python_code:`USBDevice.getBusNumber(self)`
185
186 Error statuses are converted into :python_code:`usb1.USBError` exceptions, with
187 status as ``value`` instance property.
188
189 ``usb1`` module also defines a few more functions and classes, which are
190 otherwise not so convenient to call from Python: the event handling API needed
191 by async API.
192
193 History
194 =======
195
196 0.0.1
197 -----
198
199 Initial release
200
201 0.1.1
202 -----
203
204 Massive rework of usb1.py, making it more python-ish and fixing some
205 memory leaks.
206
207 0.1.2
208 -----
209
210 Deprecate "transfer" constructor parameter to allow instance reuse.
211
212 0.1.3
213 -----
214
215 Some work on isochronous "in" transfers. They don't raise exceptions anymore,
216 but data validity and python-induced latency impact weren't properly checked.
217
218 0.2.0
219 -----
220
221 Fix asynchronous configuration transfers.
222
223 Stand-alone polling thread for multi-threaded apps.
224
225 More libusb methods exposed on objects, including ones not yet part of
226 released libusb versions (up to their commit 4630fc2).
227
228 2to3 friendly.
229
230 Drop deprecated USBDevice.reprConfigurations method.
231
232 0.2.1
233 -----
234
235 Add FreeBSD support.
236
237 0.2.2
238 -----
239
240 Add Cygwin support.
241
242 OpenBSD support checked (no change).
243
244 0.2.3
245 -----
246
247 Add fink and homebrew support on OSX.
248
249 Drop PATH_MAX definition.
250
251 Try harder when looking for libusb.
252
253 1.0.0
254 -----
255
256 Fix FreeBSD ABI compatibility.
257
258 Easier to list connected devices.
259
260 Easier to terminate all async transfers for clean exit.
261
262 Fix few segfault causes.
263
264 pypy support.
265
266 1.1.0
267 -----
268
269 Descriptor walk API documented.
270
271 Version and capability APIs exposed.
272
273 Some portability fixes (OSes, python versions).
274
275 Isochronous transfer refuses to round transfer size.
276
277 Better exception handling in enumeration.
278
279 Add examples.
280
281 Better documentation.
282
283 1.2.0
284 -----
285
286 Wrap hotplug API.
287
288 Wrap port number API.
289
290 Wrap kernel auto-detach API.
291
292 Drop wrapper for libusb_strerror, with compatibility place-holder.
293
294 Add a few new upstream enum values.
295
296 1.3.0
297 -----
298
299 **Backward-incompatible change**: Enum class now affects caller's local scope,
300 not its global scope. This should not be of much importance, as:
301
302 - This class is probably very little used outside libusb1.py
303
304 - This class is probably mostly used at module level, where locals == globals.
305
306 It is possible to get former behaviour by providing the new ``scope_dict``
307 parameter to ``Enum`` constructor::
308
309 SOME_ENUM = libusb1.Enum({...}, scope_dict=globals())
310
311 Improve start-up time on CPython by not importing standard ``inspect`` module.
312
313 Fix some more USBTransfer memory leaks.
314
315 Add Transfer.iterISO for more efficient isochronous reception.
316
317 1.3.1
318 -----
319
320 Fixed USBContext.waitForEvent.
321
322 Fix typo in USBInterfaceSetting.getClassTuple method name. Backward
323 compatibility preserved.
324
325 Remove globals accesses from USBDeviceHandle destructor.
326
327 Assorted documentation improvements.
328
329 1.3.2
330 -----
331
332 Made USBDevice instances hashable.
333
334 Relaxed licensing by moving from GPL v2+ to LGPL v2.1+, for consistency with
335 libusb1.
336
337 1.4.0
338 -----
339
340 Reduce (remove ?) the need to import libusb1 module by exposing USBError and
341 constants in usb1 module.
342
343 Fix libusb1.LIBUSB_ENDPOINT_ENDPOINT_MASK and
344 libusb1.LIBUSB_ENDPOINT_DIR_MASK naming.
345
346 Fix pydoc appearance of several USBContext methods.
347
348 Define exception classes for each error values.
349
350 1.4.1
351 -----
352
353 Fix wheel generation (``python3 setup.py bdist_wheel``).
354
355 1.5.0
356 -----
357
358 controlWrite, bulkWrite and interruptWrite now reject (with TypeError) numeric
359 values for ``data`` parameter.
360
361 Fix libusb1.REQUEST_TYPE_* names (were TYPE_*). Preserve backward
362 compatibility.
363
364 Add USBContext.getDeviceIterator method.
365
366 Rename USBContext.exit as USBContext.close for consistency with other USB*
367 classes. Preserve backward compatibility.
368
369 Make USBDeviceHandle.claimInterface a context manager, for easier interface
370 releasing.
371
372 1.5.1
373 -----
374
375 Introduce USBPollerThread.stop .
376
377 Fix USBDeviceHandle.getSupportedLanguageList bug when running under python 3.
378 While fixing this bug it was realised that this method returned ctypes objects.
379 This was not intended, and it now returns regular integers.
380
381 1.5.2
382 -----
383
384 Make USBTransfer.cancel raise specific error instances.
385
386 1.5.3
387 -----
388
389 Fix USBTransfer.cancel exception raising introduced in 1.5.2: it was
390 accidentally becomming a bound method, preventing the raise to actually
391 happen (in at least CPython 2.x) or raising type conversion errors (in at least
392 CPython 3.5.2).
393
394 1.6
395 ---
396
397 Improve asynchronous transfer performance: (very) suboptimal code was used to
398 initialise asynchronous transfer buffer. As a consequence, usb1 now exposes
399 ``bytearrays`` where it used to expose ``bytes`` or ``str`` objects.
400
401 Deprecate libusb1 module import, which should not be needed since all (?)
402 needed constants were re-bound to usb1 module.
403
404 Move testUSB1 module inside usb1, to eventually only expose usb1 as top-level
405 module.
406
407 1.6.1
408 -----
409
410 Fix getSupportedLanguageList.
411
412 Fix and extend get{,ASCII}StringDescriptor .
413
414 Fix iterISO and getISOBufferList.
415
416 1.6.2
417 -----
418
419 Fix getASCIIStringDescriptor: unlike getStringDescriptor, this returns only the
420 payload of the string descriptor, without its header.
421
422 1.6.3
423 -----
424
425 Deprecate USBPollerThread . It is mileading users for which the simple version
426 (a thread calling ``USBContext.handleEvents``) would be enough. And for more
427 advanced uses (ie, actually needing to poll non-libusb file descriptors), this
428 class only works reliably with epoll: kqueue (which should tehcnically work)
429 has a different API on python level, and poll (which has the same API as epoll
430 on python level) lacks the critical ability to change the set of monitored file
431 descriptors while a poll is already running, causing long pauses - if not
432 deadlocks.
433
434 1.6.4
435 -----
436
437 Fix asynchronous control transfers.
438
439 1.6.5
440 -----
441
442 Document hotplug handler limitations.
443
444 Run 2to3 when running setup.py with python3, and reduce differences with
445 python3.
446
447 Properly cast libusb_set_pollfd_notifiers arguments.
448 Fix null pointer value: POINTER(None) is the type of a pointer which may be a
449 null pointer, which falls back to c_void_p. But c_void_p() is an actual null
450 pointer.
451
452 1.6.6
453 -----
454
455 Expose bare string descriptors (aka string indexes) on USBDevice.
456
457 1.6.7
458 -----
459
460 get{,ASCII}StringDescriptor now return None for descriptor 0 instead of raising
461 UnicodeDecodeError. Use getSupportedLanguageList to access it.
462
463 Moved getManufacturer, getProduct and getSerialNumber to USBDeviceHandle. Kept
464 shortcuts for these on USBDevice.
465
466 1.7
467 ---
468
469 get{,ASCII}StringDescriptor now return None for descriptor 0, use
470 getSupportedLanguageList to get its content.
471
472 getManufacturer, getProduct and getSerialNumber are now on USBDeviceHandle,
473 with backward-compatibility aliases on their original location.
474
475 Synchronous bulk and interrupt API exposes number of bytes sent and received
476 bytes even when a timeout occurs.
477
478 1.7.1
479 -----
480
481 usb1.__version__ is now present, managed by versioneer.
482
483 Fix an occasional segfault when closing a transfer from inside its callback
484 function.
485
486 1.8
487 ---
488
489 Fix getExtra and libusb1.libusb_control_transfer_get_data .
490
491 Fix getMaxPower unit on SuperSpeed devices.
492
493 1.8.1
494 -----
495
496 Release process rework:
497
498 - embed libusb1 dll for easier deployment on Windows
499 - cryptographically signed releases
500
501 Use libusb_free_pollfds whenever available (libusb1>=1.0.20).
502
503 Fix hotplug callback destruction at context teardown.
504
505 Drop remnants of python 2.6 support code.
506
507 1.9
508 ---
509
510 Drop USBPollerThread and deprecate libusb-lock-related USBContext API.
511
512 1.9.1
513 -----
514
515 Fix installation from pypi source tarball, broken in 1.8.1 .
516
517 1.9.2
518 -----
519
520 Windows wheels: Update bundled libusb to 1.0.24 .
521
522 Fix soure-only build when wheel is not available.
523
524 1.9.3
525 -----
526
527 Add support for pyinstaller.
528
529 Improve the way the windows dlls are embedded in wheels.
530
531 Fix support for python 3.10 .
532
533 Add support for homebrew on Apple M1.
534
535 1.10.1 (yanked)
536 ---------------
537
538 NOTE: Release yanked_ from pypi and re-released as 2.0.0.
539
540 2.0.0
541 -----
542
543 Drop python <3.4 support.
544
545 Do not load the C library on import. Allows applications to customise the
546 lookup logic (see `usb1.loadLibrary`).
547
548 Add LIBUSB_SPEED_SUPER_PLUS.
549
550 Better control device iterator end of life.
551
552 Fix objects escaping control from their parent.
553
554 2.0.1
555 -----
556
557 Fix a TypeError exception in USBContext.handleEvents .
558
559 Fix an AttributeError exception in USBContext.hotplugRegisterCallback .
560
561 Fix segfault in pypy3 when finalizing USBDevice objects .
562
563 Source only: convert examples to python3.
564
565 Release process: also run some examples scripts.
566
567 3.0.0
568 -----
569
570 Update versioneer to be compatible with 3.11 .
571
572 Drop python <3.6 support (consequence of versioneer update), hence the major
573 version change.
574
575 3.1.0
576 -----
577
578 Fix bug preventing use of setPollFDNotifiers.
579
580 Wrap libusb_interrupt_event_handler, available since libusb 1.0.21, to help
581 applications wake an event handling thread (ex: durring exit).
582
583 Windows wheels: Update bundled libusb dll to 1.0.26 (warning: libusb1 7z archive changed since this release, and reports mention the DLLs were of 1.0.25) .
584
585 3.2.0
586 -----
587
588 Fix callbacks on 32bits Windows.
589
590 Try loading libusb1.so.0 in addition to libusb1.so on \*nix.
591
592 Bundle libusb1 dll 1.0.27 in Windows wheels.
593
594 Expose more modern libusb1 API:
595 - libusb_init_context
596 - libusb_set_log_cb
597 - libusb_setlocale + libusb_strerror
598 - libusb_wrap_sys_device
599 - transfer flags LIBUSB_TRANSFER_SHORT_NOT_OK and LIBUSB_TRANSFER_ADD_ZERO_PACKET
600
601 As a result, python-libusb1 should now be usable on Android.
602
603 Fix tests on python 3.13 .
604
605 3.3.0
606 -----
607
608 Improve deprecation warning, by showing the correct caller location.
609
610 Fix finalizer registration errors on pypi by using a thread-safe sequential number generator instead of relying on object id unicity and timely finalizer triggering.
611
612 Check in-dll version when creating Windows wheels. Should hopefully version mixups like what happened in 3.1.0 .
613
614 3.3.1
615 -----
616
617 Fix ``AttributeError`` in ``USBContext.setPollFDNotifiers`` introduced in 3.3.0 .
618
619 .. _CPython: http://www.python.org/
620
621 .. _pypy: http://pypy.org/
622
623 .. _Cygwin: https://www.cygwin.com/
624
625 .. _MacPorts: https://www.macports.org/
626
627 .. _Fink: http://www.finkproject.org/
628
629 .. _Homebrew: http://brew.sh/
630
631 .. _libusb-1.0: https://github.com/libusb/libusb/wiki/
632
633 .. _libusb1.0 documentation: http://libusb.sourceforge.net/api-1.0/
634
635 .. _Zadig: https://zadig.akeo.ie/
636
637 .. _yanked: https://www.python.org/dev/peps/pep-0592/