mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Windows configuration bug should be fixed.
This commit is contained in:
parent
d789b6d627
commit
0ca3a7861f
@ -36,6 +36,11 @@ the following rule in C{/etc/udev/rules.d/90-local.rules} ::
|
||||
You may have to adjust the GROUP and the location of the rules file to
|
||||
suit your distribution.
|
||||
"""
|
||||
|
||||
__version__ = "0.3.4"
|
||||
__docformat__ = "epytext"
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
||||
import sys
|
||||
iswindows = 'win32' in sys.platform.lower()
|
||||
isosx = 'darwin' in sys.platform.lower()
|
||||
|
@ -233,17 +233,10 @@ class PRS500Device(Device):
|
||||
raise DeviceError()
|
||||
try:
|
||||
self.handle = self.device.open()
|
||||
configs = self.device.configurations
|
||||
cfg = configs[0]
|
||||
for config in configs:
|
||||
if config.MaxPower > cfg.MaxPower:
|
||||
cfg = config
|
||||
try:
|
||||
self.handle.set_configuration(cfg)
|
||||
self.handle.set_configuration(1)
|
||||
except USBError:
|
||||
for config in configs:
|
||||
if config.Value != cfg.Value:
|
||||
self.handle.set_configuration(config)
|
||||
self.handle.set_configuration(2)
|
||||
self.handle.claim_interface(self.INTERFACE_ID)
|
||||
except USBError, err:
|
||||
raise DeviceBusy(str(err))
|
||||
|
@ -16,25 +16,24 @@
|
||||
This module provides a thin ctypes based wrapper around libusb.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from ctypes import cdll, POINTER, byref, pointer, Structure, \
|
||||
c_ubyte, c_ushort, c_int, c_char, c_void_p, c_byte, c_uint
|
||||
from errno import EBUSY, ENOMEM
|
||||
|
||||
_iswindows = 'win32' in sys.platform.lower()
|
||||
_isosx = 'darwin' in sys.platform.lower()
|
||||
from libprs500 import iswindows, isosx
|
||||
|
||||
_libusb_name = 'libusb.so'
|
||||
if _iswindows:
|
||||
if iswindows:
|
||||
_libusb_name = 'libusb0'
|
||||
elif _isosx:
|
||||
elif isosx:
|
||||
_libusb_name = 'libusb.dylib'
|
||||
_libusb = cdll.LoadLibrary(_libusb_name)
|
||||
|
||||
# TODO: Need to set this in a platform dependednt way (limits.h in linux)
|
||||
PATH_MAX = 4096
|
||||
if _iswindows:
|
||||
if iswindows:
|
||||
PATH_MAX = 511
|
||||
if _isosx:
|
||||
if isosx:
|
||||
PATH_MAX = 1024
|
||||
|
||||
class DeviceDescriptor(Structure):
|
||||
@ -102,7 +101,7 @@ class ConfigDescriptor(Structure):
|
||||
('Attributes', c_ubyte), \
|
||||
('MaxPower', c_ubyte), \
|
||||
('interface', POINTER(Interface)), \
|
||||
('extra', POINTER(c_char)), \
|
||||
('extra', POINTER(c_ubyte)), \
|
||||
('extralen', c_int) \
|
||||
]
|
||||
|
||||
@ -131,7 +130,6 @@ class Device(Structure):
|
||||
doc = """ List of device configurations. See L{ConfigDescriptor} """
|
||||
def fget(self):
|
||||
ans = []
|
||||
ans.append(self.config_descriptor.contents)
|
||||
for config in range(self.device_descriptor.NumConfigurations):
|
||||
ans.append(self.config_descriptor[config])
|
||||
return tuple(ans)
|
||||
@ -306,8 +304,6 @@ Device._fields_ = [ \
|
||||
('children', POINTER(POINTER(Device)))
|
||||
]
|
||||
|
||||
|
||||
|
||||
_libusb.usb_get_busses.restype = POINTER(Bus)
|
||||
_libusb.usb_open.restype = POINTER(DeviceHandle)
|
||||
_libusb.usb_open.argtypes = [POINTER(Device)]
|
||||
@ -342,7 +338,6 @@ def busses():
|
||||
|
||||
def get_device_by_id(idVendor, idProduct):
|
||||
""" Return a L{Device} by vendor and prduct ids """
|
||||
ans = []
|
||||
buslist = busses()
|
||||
for bus in buslist:
|
||||
devices = bus.device_list
|
||||
|
Loading…
x
Reference in New Issue
Block a user