Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.04; 'string.': 0.04; 'subject:Python': 0.05; 'that?': 0.05; 'python': 0.09; 'input,': 0.09; 'observation': 0.09; 'modification': 0.15; "'b'": 0.16; 'adam': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'guys,': 0.16; 'lambda': 0.16; 'means:': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'spit': 0.16; 'there?': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'bytes': 0.17; 'unicode': 0.17; '3.x': 0.22; 'interpret': 0.22; 'progress.': 0.22; 'wednesday,': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'coding': 0.27; 'guess': 0.27; 'skip:e 30': 0.27; '>>>>': 0.29; 'declared': 0.29; 'received:192.168.1.3': 0.29; 'subject:Sending': 0.29; 'array': 0.29; 'manual': 0.29; 'error': 0.30; 'received:84': 0.32; 'venture': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'thanks': 0.34; 'there': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'possible': 0.37; 'why': 0.37; 'rather': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'help': 0.40; 'think': 0.40; 'your': 0.60; 'needing': 0.62; 'fun': 0.64; 'talking': 0.66; 'august': 0.66; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'paper': 0.78; 'about,': 0.84; 'me!': 0.84; 'printer': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:commands': 0.84; 'dennis': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=DKcI9XZsuF4A:10 a=3Vg6u79OFI4A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=ScLz5s_fao0A:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=3xVNnwO5gfMJCNHoNuoA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Thu, 30 Aug 2012 01:53:17 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Sending USB commands with Python References: <20120829222932.GA18700@cskk.homeip.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346288000 news.xs4all.nl 6927 [2001:888:2000:d::a6]:49064 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28083 On 30/08/2012 00:45, Adam W. wrote: > On Wednesday, August 29, 2012 6:56:16 PM UTC-4, Dennis Lee Bieber wrote: >> >> BUT you do give a possible clue. Is the OP using a 3.x Python where >> >> strings are Unicode -- in which case the above may need to be explicitly >> >> declared as a "byte string" rather than text (unicode) string. >> > > 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 >>>> ep = usb.util.find_descriptor( > intf, > custom_match = \ > lambda e: \ > usb.util.endpoint_direction(e.bEndpointAddress) == \ > usb.util.ENDPOINT_IN > ) >>>> 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]) > > Thanks for all your help guys, just about ready to stared coding the fun part! > The result is an array of bytes ('B'). I think the value means: 0b10100011 ^Ready ^Top of form ^No paper ^Printer error The error is that it's out of paper.