From 17698bfeae26298bfe9bd9a50d73fa3c46514463 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Wed, 12 Dec 2012 20:44:29 +0200 Subject: [PATCH] minor clean-ups in texts --- app/listener.py | 5 ++++- app/ui/action.py | 4 ++-- lib/logitech/unifying_receiver/base.py | 27 ++++++++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/listener.py b/app/listener.py index cee2e1b2..f7ed5576 100644 --- a/app/listener.py +++ b/app/listener.py @@ -102,7 +102,10 @@ class ReceiverListener(_listener.EventsListener): def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None): if _log.isEnabledFor(_DEBUG): - _log.debug("status_changed %s: %s (%X) %s", device, None if device is None else device.status, alert, reason or '') + _log.debug("status_changed %s: %s %s (%X) %s", device, + None if device is None else 'active' if device.status else 'inactive', + None if device is None else device.status, + alert, reason or '') if self.status_changed_callback: r = self.receiver or DUMMY if device is None or device.kind is None: diff --git a/app/ui/action.py b/app/ui/action.py index 79ae460b..d6ba15b2 100644 --- a/app/ui/action.py +++ b/app/ui/action.py @@ -53,7 +53,7 @@ def _show_about_window(action): about.set_authors(('Daniel Pavel http://github.com/pwr',)) try: - about.add_credit_section('Testing', ('Douglas Wagner',)) + about.add_credit_section('Testing', ('Douglas Wagner', 'Julien Gascard')) about.add_credit_section('Technical specifications\nprovided by', ('Julien Danjou http://julien.danjou.info/blog/2012/logitech-unifying-upower',)) except TypeError: @@ -64,7 +64,7 @@ def _show_about_window(action): pass about.set_website('http://pwr.github.com/Solaar/') - about.set_website_label('Solaar Wiki') + about.set_website_label('Solaar') about.run() about.destroy() diff --git a/lib/logitech/unifying_receiver/base.py b/lib/logitech/unifying_receiver/base.py index e8387070..90f47566 100644 --- a/lib/logitech/unifying_receiver/base.py +++ b/lib/logitech/unifying_receiver/base.py @@ -67,7 +67,7 @@ def receivers(): if d.driver == 'logitech-djreceiver': yield d - # apparently there are TWO product ids possible for the UR + # apparently there are TWO product ids possible for the UR? for d in _hid.enumerate(0x046d, 0xc532, 2): if d.driver == 'logitech-djreceiver': yield d @@ -124,8 +124,7 @@ def write(handle, devnumber, data): :param devnumber: attached device number. :param data: data to send, up to 5 bytes. - The first two (required) bytes of data must be the feature index for the - device, and a function code for that feature. + The first two (required) bytes of data must be the SubId and address. :raises NoReceiver: if the receiver is no longer available, i.e. has been physically removed from the machine, or the kernel driver has been @@ -151,8 +150,7 @@ def read(handle, timeout=DEFAULT_TIMEOUT): """Read some data from the receiver. Usually called after a write (feature call), to get the reply. - If any data was read in the given timeout, returns a tuple of - (code, devnumber, message data). + :returns: a tuple of (devnumber, message data), or `None` :raises NoReceiver: if the receiver is no longer available, i.e. has been physically removed from the machine, or the kernel driver has been @@ -164,6 +162,14 @@ def read(handle, timeout=DEFAULT_TIMEOUT): def _read(handle, timeout): + """Read an incoming packet from the receiver. + + :returns: a tuple of (report_id, devnumber, data), or `None`. + + :raises NoReceiver: if the receiver is no longer available, i.e. has + been physically removed from the machine, or the kernel driver has been + unloaded. The handle will be closed automatically. + """ try: data = _hid.read(int(handle), _MAX_READ_SIZE, timeout) except Exception as reason: @@ -185,7 +191,10 @@ def _read(handle, timeout): def _skip_incoming(handle): - """Read anything already in the input buffer.""" + """Read anything already in the input buffer. + + Used by request() and ping() before their write. + """ ihandle = int(handle) while True: @@ -249,9 +258,7 @@ def make_event(devnumber, data): def request(handle, devnumber, request_id, *params): """Makes a feature call to a device and waits for a matching reply. - This function will skip all incoming messages and events not related to the - device we're requesting for, or the feature specified in the initial - request; it will also wait for a matching reply indefinitely. + This function will wait for a matching reply indefinitely. :param handle: an open UR handle. :param devnumber: attached device number. @@ -259,7 +266,7 @@ def request(handle, devnumber, request_id, *params): :param params: parameters for the feature call, 3 to 16 bytes. :returns: the reply data, or ``None`` if some error occured. """ - assert type(request_id) == int + assert isinstance(request_id, int) if devnumber != 0xFF and request_id < 0x8000: timeout = _DEVICE_REQUEST_TIMEOUT # for HID++ 2.0 feature request, randomize the swid to make it easier to