Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'failing': 0.05; 'interpreter.': 0.07; 'subject:skip:c 10': 0.07; 'okay': 0.09; 'python:': 0.09; 'read()': 0.09; '(the': 0.15; 'dec': 0.15; 'file,': 0.15; 'buffering': 0.16; 'buffering=0)': 0.16; 'c):': 0.16; 'disables': 0.16; 'emit': 0.16; 'jerry': 0.16; 'newlines': 0.16; 'personally,': 0.16; 'truncates': 0.16; 'url:all': 0.16; 'wrote:': 0.17; 'driver': 0.17; 'examples': 0.18; 'code,': 0.18; 'subject:problem': 0.22; 'help.': 0.22; 'example': 0.23; "python's": 0.23; "haven't": 0.23; 'to:2**1': 0.23; 'device': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'jean': 0.29; 'probably': 0.29; 'link.': 0.30; 'file': 0.32; 'could': 0.32; '11,': 0.33; 'docs': 0.33; 'explains': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'done': 0.34; 'thanks': 0.34; 'along': 0.35; 'open': 0.35; 'doing': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'received:209': 0.37; 'well.': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'skip:u 10': 0.60; "you've": 0.61; 'behavior': 0.64; 'url:be': 0.65; 'url:htm': 0.71; 'url:lc': 0.84; 'url:upload': 0.91; 'url:cc': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=L/Lzkbn4qU8eBwPv9Z8Zq3j0v3+tFAQ0nt2/b4kpihQ=; b=iWBNt+suNO42Gq2e+VDvAlJGCzkA82OtXrj8a7Cm6p9plMSgA6madtvaLntyFNnKQV aOcsWUfTq0ITPfjLFxRRBbIuTrSUzX8CYvgdziHani9d3q5ojmSsV101Y2UtGyKQQMxQ A3Y6aYO3Ef0QPxC4Yv8p19XQbAyGMWJfaQfSHDyFNcHvjY2X44w619DE/efMejcRBAT5 iesKz84sUhlAkz5jEjgjl+oBzmC8UtQOCis780iPIpz6J2G7hN7KgyNwp+la10ir6NPb OtxWaHzfJqMvkW337Y3xH9HrusEK75Aon9dKc4YFUsXrELJKpYyKX+sIl+v4uNPoQzgR IfvA== MIME-Version: 1.0 In-Reply-To: <50b9eb4f-f319-491d-894c-2a9386b6941a@x20g2000vbf.googlegroups.com> References: <05927d41-f73f-4fef-9a6d-4133e5c7d86a@n8g2000vbb.googlegroups.com> <0910382a-08df-4325-806f-a4c3cdf6bd7b@f17g2000vbz.googlegroups.com> <123edfab-b46a-4a47-8b73-3f47e807e074@c16g2000yqi.googlegroups.com> <01cdbc70-7e46-4225-9baa-b555619d1aa8@10g2000yqo.googlegroups.com> <99b04e06-734c-4702-bf74-855e28d8f633@x20g2000vbf.googlegroups.com> <50b9eb4f-f319-491d-894c-2a9386b6941a@x20g2000vbf.googlegroups.com> Date: Tue, 11 Dec 2012 19:49:26 -0500 Subject: Re: problem with usbtmc-communication From: Jerry Hill To: Jean Dubois , "python-list (General)" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355294042 news.xs4all.nl 6897 [2001:888:2000:d::a6]:50021 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34685 On Tue, Dec 11, 2012 at 1:58 AM, Jean Dubois wrot= e: > > I found examples in the usbtmc kernel driver documentation (the > examples there are given in C): > http://www.home.agilent.com/upload/cmc_upload/All/usbtmc.htm?&cc=3DBE&lc= =3Ddut Thanks for that link. I think it explains how the driver works pretty well. I haven't done any work with devices like this, but I see a few things in those docs that might help. In their example code, they open the device with: open(=E2=80=9C/dev/usbtmc= 1=E2=80=9D,O_RDWR); That's not exactly the same as what you've been doing. I would try opening the file this way in python: usb_device =3D open('/dev/usbtmc1', 'w+', buffering=3D0) That truncates the file after it opening it, and disables any buffering that might be going on. Then, I would try writing to the device with usb_device.write() and usb_device.read(). read() attempts to read to end-of-file, and based on the docs, the driver will work okay that way. Doing that, along with turning off buffering when you open the file, should eliminate any issues with the driver failing to emit newlines someplace. Personally, I would probably try playing with the device from python's interactive interpreter. I think that could shed a lot of light on the behavior you're seeing. --=20 Jerry