Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28084

Re: Sending USB commands with Python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'that?': 0.05; 'utf-8': 0.07; 'python': 0.09; 'input,': 0.09; 'notation': 0.09; 'observation': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unsigned': 0.09; 'aug': 0.13; 'encoding': 0.15; 'modification': 0.15; "'b'": 0.16; '2.7.2': 0.16; 'lambda': 0.16; 'module:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'spit': 0.16; 'there?': 0.16; 'wed,': 0.16; 'string': 0.17; 'byte': 0.17; 'char': 0.17; "shouldn't": 0.17; '>>>': 0.18; 'import': 0.21; 'interpret': 0.22; 'progress.': 0.22; 'work.': 0.23; 'seems': 0.23; 'signed': 0.24; 'guess': 0.27; 'skip:e 30': 0.27; 'header:X-Complaints-To:1': 0.28; 'concern': 0.29; 'subject:Sending': 0.29; 'array': 0.29; 'manual': 0.29; "i'm": 0.29; 'ends': 0.30; 'problem.': 0.32; 'curious': 0.33; 'int': 0.33; 'url:home': 0.33; 'venture': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'there': 0.35; 'received:org': 0.36; 'skip:u 20': 0.36; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'needing': 0.62; 'talking': 0.66; 'paper': 0.78; "(don't": 0.84; 'about,': 0.84; 'me!': 0.84; 'printer': 0.84; 'subject:commands': 0.84; 'dennis': 0.91; 'received:108': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Sending USB commands with Python
Date Wed, 29 Aug 2012 22:07:36 -0400
Organization > Bestiaria Support Staff <
References <eq3t38542luf3dmula4k92islpa9lh0opk@invalid.netcom.com> <20120829222932.GA18700@cskk.homeip.net> <mailman.3947.1346280975.4697.python-list@python.org> <ad907349-042b-4ddf-aef7-043d7dfb1f9a@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-178-177.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3952.1346292474.4697.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346292474 news.xs4all.nl 6899 [2001:888:2000:d::a6]:58886
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28084

Show key headers only | View raw


On Wed, 29 Aug 2012 16:45:10 -0700 (PDT), "Adam W."
<AWasilenko@gmail.com> declaimed the following in
gmane.comp.python.general:

> 
> Huzzah!  I am indeed using 3.x, and slapping on an .encode('utf-8') made my printer try to spit paper at me! Progress.
> 
> Also, astute observation about the endpoint needing to be an input, with the following modification I get:
> 
> >>> ep.write('\x1BA'.encode('utf-8'))
> 2

	I'm a tad curious if using the notation

		b'\x1bA'

without the .encode() would work.

	My concern is that you may encounter some "string" of data for
printing which the .encode() ends up /changing/ (don't UTF-8 strings use
a high-bit to signal a multi-byte encoding of what had been a single
character?). A pure byte string shouldn't have that problem.

> >>> ep = usb.util.find_descriptor(
>     intf,
>     custom_match = \
>     lambda e: \
>         usb.util.endpoint_direction(e.bEndpointAddress) == \
>         usb.util.ENDPOINT_IN
> )

	Seems tedious to keep swapping -- does USB support bidirectional
connections?

> >>> ep.read(1)
> array('B', [163])
> >>> 
> 
> Anyone want to venture a guess on how I should interpret that?  It seems the [163] is the byte data the manual is talking about, but why is there a 'B' there?  If I put paper in it and try again I get: array('B', [3])

	Per documentation (section 8.6 in Python 2.7.2 library) of "array"
module:

'b' signed char int 1 
'B' unsigned char int 1 


>>> import array
>>> array.array("B", "\x1bB")
array('B', [27, 66])
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-29 18:56 -0400
  Re: Sending USB commands with Python "Adam W." <AWasilenko@gmail.com> - 2012-08-29 16:45 -0700
  Re: Sending USB commands with Python MRAB <python@mrabarnett.plus.com> - 2012-08-30 01:53 +0100
  Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-29 22:07 -0400
    Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-30 00:55 -0400
      Re: Sending USB commands with Python "Adam W." <AWasilenko@gmail.com> - 2012-08-30 05:51 -0700
        Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-30 14:24 -0400
        Re: Sending USB commands with Python Cameron Simpson <cs@zip.com.au> - 2012-08-31 08:47 +1000

csiph-web