Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28083
| Date | 2012-08-30 01:53 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Sending USB commands with Python |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3951.1346288000.4697.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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