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


Groups > comp.lang.python > #28072

Re: Sending USB commands with Python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <AWasilenko@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'python': 0.09; '(although': 0.09; 'read()': 0.09; 'timeout': 0.09; 'timeout)': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'size,': 0.13; '"2"': 0.16; 'doing,': 0.16; 'for,': 0.16; 'none]': 0.16; 'otoh,': 0.16; 'status.': 0.16; 'written.': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'char': 0.17; 'obviously': 0.18; '>>>': 0.18; '(or': 0.18; 'skip:" 40': 0.20; 'suggested': 0.20; 'sort': 0.21; '"",': 0.22; 'wednesday,': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; '(most': 0.27; 'skip:" 50': 0.27; 'correct': 0.28; 'pertinent': 0.29; 'subject:Sending': 0.29; "i'm": 0.29; 'returned': 0.30; 'asking': 0.32; 'file': 0.32; 'skip:s 30': 0.33; 'avoiding': 0.33; 'traceback': 0.33; 'guys': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'feed': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'subject:with': 0.36; 'should': 0.36; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'behind': 0.38; 'some': 0.38; 'sure': 0.38; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'more': 0.63; 'issued': 0.65; 'august': 0.66; '301,': 0.84; 'endeavor': 0.84; 'printer': 0.84; 'subject:commands': 0.84; 'dennis': 0.91
Newsgroups comp.lang.python
Date Wed, 29 Aug 2012 14:21:30 -0700 (PDT)
In-Reply-To <mailman.3942.1346270988.4697.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=69.80.107.197; posting-account=hEeMqAoAAAAN2L2NtWcUUUG7LStm2lEM
References <ff6f931d-e5ad-40ee-aa4d-f2bbd1303046@googlegroups.com> <d8er38h4ns0obmhevo4v12u0qk2rhufeu8@4ax.com> <09ec368e-9079-46dc-a70a-3ae345d7996c@googlegroups.com> <mailman.3942.1346270988.4697.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 69.80.107.197
MIME-Version 1.0
Subject Re: Sending USB commands with Python
From "Adam W." <AWasilenko@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
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>
Message-ID <mailman.3943.1346275293.4697.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346275293 news.xs4all.nl 6985 [2001:888:2000:d::a6]:59192
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28072

Show key headers only | View raw


On Wednesday, August 29, 2012 4:09:49 PM UTC-4, Dennis Lee Bieber wrote:
>
> 	Don't the commands require an <esc> character? "\x1BA" (or
>    "\x1B\x41")
> 
> 	OTOH, if the <esc> is issued behind the scenes,

I'm not sure which esc char it is asking for, I don't think libusb is providing its own, and it seems like the one you suggested isn't what it wants either..

>  ... and you do not need to issue some sort of read()
> the "2" you are seeing is the "number of bytes written";
> 
> you need to issue a read request to retrieve the returned printer
> 
> status.
> 

You are correct about the 2 being the number of bytes written.  However when I issue a read command I get:

>>> ep.write('\x1BA')
4
>>> ep.read(1)
Traceback (most recent call last):
  File "<pyshell#75>", line 1, in <module>
    ep.read(1)
  File "C:\Python32\lib\site-packages\usb\core.py", line 301, in read
    return self.device.read(self.bEndpointAddress, size, self.interface, timeout)
  File "C:\Python32\lib\site-packages\usb\core.py", line 654, in read
    self.__get_timeout(timeout)
  File "C:\Python32\lib\site-packages\usb\backend\libusb01.py", line 483, in bulk_read
    timeout)
  File "C:\Python32\lib\site-packages\usb\backend\libusb01.py", line 568, in __read
    timeout
  File "C:\Python32\lib\site-packages\usb\backend\libusb01.py", line 384, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [_usb_setup_async] invalid endpoint 0x02\n'

Avoiding the read command all together I should be able to write "<esc> E" and have it feed some paper, which it is not doing, so obviously there is more to uncover.  That said I feel this endeavor has evolved and is no longer pertinent to the Python group so I will let you guys off the hook on this (although responses/suggestions are still welcome).

Thanks for all your help!

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


Thread

Sending USB commands with Python "Adam W." <AWasilenko@gmail.com> - 2012-08-28 17:04 -0700
  Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-28 22:54 -0400
    Re: Sending USB commands with Python hamilton <hamilton@nothere.com> - 2012-08-28 21:03 -0600
      Re: Sending USB commands with Python alex23 <wuwei23@gmail.com> - 2012-08-28 22:04 -0700
        Re: Sending USB commands with Python hamilton <hamilton@nothere.com> - 2012-08-28 23:18 -0600
  Re: Sending USB commands with Python Tim Roberts <timr@probo.com> - 2012-08-28 23:45 -0700
    Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-29 16:09 -0400
      Re: Sending USB commands with Python "Adam W." <AWasilenko@gmail.com> - 2012-08-29 14:21 -0700
        Re: Sending USB commands with Python Tim Roberts <timr@probo.com> - 2012-08-30 20:55 -0700
      Re: Sending USB commands with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-29 17:57 -0400

csiph-web