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


Groups > comp.lang.python > #34547

Re: problem with usbtmc-communication

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <wrw@mac.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'modify': 0.05; 'sys': 0.05; 'filename': 0.07; 'line:': 0.07; 'subject:skip:c 10': 0.07; 'python': 0.09; '"\\n")': 0.09; '%s\\n"': 0.09; 'skip:k 40': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; '"enter': 0.16; '%d:': 0.16; '(11': 0.16; '1):': 0.16; 'did.': 0.16; 'file:"': 0.16; 'pair,': 0.16; 'received:mac.com': 0.16; 'workaround:': 0.16; 'wrote:': 0.17; 'received:10.0.1': 0.17; 'skip:i 40': 0.17; 'skip:u 30': 0.17; 'thanks,': 0.18; 'skip:= 10': 0.20; 'import': 0.21; 'subject:problem': 0.22; 'example': 0.23; "i've": 0.23; 'seems': 0.23; 'cc:2**1': 0.24; 'command': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'am,': 0.27; 'implemented': 0.27; 'skip:# 10': 0.27; 'question': 0.27; 'interface': 0.27; 'trouble': 0.28; 'argue': 0.29; 'jean': 0.29; 'measure': 0.29; 'readline': 0.29; 'url:mailman': 0.29; "skip:' 10": 0.30; 'that.': 0.30; 'e.g.': 0.30; 'code': 0.31; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'rid': 0.33; 'received:10.0': 0.33; 'problem': 0.33; 'code:': 0.33; 'received:17': 0.35; 'there': 0.35; 'add': 0.36; 'explain': 0.36; 'skip:u 20': 0.36; 'url:org': 0.36; 'cc:no real name:2**1': 0.36; 'skip:m 40': 0.36; "i'll": 0.36; 'subject:with': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'received:10': 0.38; 'where': 0.40; 'subject:-': 0.40; 'url:mail': 0.40; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.60; 'real': 0.61; 'first': 0.61; 'more': 0.63; 'here': 0.65; 'serial': 0.66; 'staircase': 0.84; 'voltage': 0.84; 'device.': 0.93; 'faith': 0.93; 'instrument': 0.95
MIME-version 1.0
Content-transfer-encoding 7BIT
Content-type text/plain; CHARSET=US-ASCII
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:5.9.8327,1.0.431,0.0.0000 definitions=2012-12-10_05:2012-12-10, 2012-12-10, 1970-01-01 signatures=0
X-Proofpoint-Spam-Details rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1203120001 definitions=main-1212100127
Subject Re: problem with usbtmc-communication
From wrw@mac.com
In-reply-to <99b04e06-734c-4702-bf74-855e28d8f633@x20g2000vbf.googlegroups.com>
Date Mon, 10 Dec 2012 10:34:32 -0500
References <05927d41-f73f-4fef-9a6d-4133e5c7d86a@n8g2000vbb.googlegroups.com> <mailman.462.1354631633.29569.python-list@python.org> <0910382a-08df-4325-806f-a4c3cdf6bd7b@f17g2000vbz.googlegroups.com> <mailman.492.1354721221.29569.python-list@python.org> <fc36067e-9b74-4eed-b1db-92ee5760af30@c16g2000yqi.googlegroups.com> <mailman.533.1354746072.29569.python-list@python.org> <d8253611-dab9-461a-8b82-9c52287718a9@w8g2000yqm.googlegroups.com> <mailman.564.1354805416.29569.python-list@python.org> <123edfab-b46a-4a47-8b73-3f47e807e074@c16g2000yqi.googlegroups.com> <mailman.586.1354824932.29569.python-list@python.org> <01cdbc70-7e46-4225-9baa-b555619d1aa8@10g2000yqo.googlegroups.com> <99b04e06-734c-4702-bf74-855e28d8f633@x20g2000vbf.googlegroups.com>
To Jean Dubois <jeandubois314@gmail.com>
X-Mailer Apple Mail (2.1499)
Cc python-list@python.org, wrw@mac.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.675.1355153683.29569.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355153683 news.xs4all.nl 6943 [2001:888:2000:d::a6]:58450
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34547

Show key headers only | View raw


On Dec 10, 2012, at 8:31 AM, Jean Dubois <jeandubois314@gmail.com> wrote:

[byte]

> As you can see this approach suffers from the same "buffer problem" as
> the approach with readline did. One now good argue as a workaround:
> get rid of the first data pair and add an extra measure command for
> the missing data pair, however this still does not explain why this
> problem is there in Python and not in Octave and I also fear I'll get
> more trouble when sending combined commands e.g. such as that to
> create a staircase current
> So my question is, how to modify the Python-code such that the first
> data pair is indeed the first data pair
> 
> thanks,
> jean
> 
> Here follows the new code:
> #!/usr/bin/python
> import time
> import os
> import sys
> measurementcurr=''
> measurementvolt=''
> timesleepdefault=5
> print "Enter a numofchar (11 =<numchar =<4095):",
> numofchar = int(raw_input())
> filename ='mydata.txt'
> usbkeith = open('/dev/usbtmc1','r+')
> usbkeith.flush()
> usbkeith.write("*IDN?\n")

It seems like a real leap of faith to be opening /dev/usbtmc1 as though it were a file-oriented device.  I've never heard of ANY instrument interface implemented this way.
Where did you see example code that did that.  Have you tried to access /dev/usbtmc1 as though it were a serial device?

> #strip blank line:
> identification=usbkeith.readline().strip()
> print 'Found device: ',identification
> usbkeith.write("SYST:REM" + "\n")
> usbkeith.write(":SENS:VOLT:PROT 1.5\n")
> keithdata = open(filename,'w')
> usbkeith.write(":OUTP:STAT ON\n")
> for number, current_in in enumerate(('0.025', '0.050', '0.075',
> '0.100'), 1):
>   usbkeith.write(":SOUR:CURR %s\n" % current_in)
>   time.sleep(timesleepdefault)
>   usbkeith.write(":MEAS:CURR?\n")
>   measurementcurr=usbkeith.read(numofchar)
>   print 'Measured current %d: ' % number, measurementcurr
>   usbkeith.write(":MEAS:VOLT?\n")
>   measurementvolt=usbkeith.read(numofchar)
>   print 'Measured voltage %d: ' % number, measurementvolt
>   keithdata.write(measurementcurr.strip()+' '+measurementvolt)
> usbkeith.write(":OUTP:STAT OFF\n")
> print "Goodbye, data logged in file:"
> print filename
> usbkeith.close()
> keithdata.close()
> -- 
> http://mail.python.org/mailman/listinfo/python-list

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


Thread

[newbie] problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-04 04:14 -0800
  Re: [newbie] problem with usbtmc-communication wrw@mac.com - 2012-12-04 09:33 -0500
    Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-04 08:12 -0800
      Re: problem with usbtmc-communication wrw@mac.com - 2012-12-05 10:26 -0500
        Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-05 12:38 -0800
          Re: problem with usbtmc-communication wrw@mac.com - 2012-12-05 17:21 -0500
            Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-06 05:50 -0800
              Re: problem with usbtmc-communication wrw@mac.com - 2012-12-06 09:50 -0500
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-06 11:41 -0800
                Re: problem with usbtmc-communication Dave Angel <d@davea.name> - 2012-12-06 15:10 -0500
                Re: problem with usbtmc-communication wrw@mac.com - 2012-12-06 15:15 -0500
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-07 05:46 -0800
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-10 05:31 -0800
                Re: problem with usbtmc-communication wrw@mac.com - 2012-12-10 10:34 -0500
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-10 22:58 -0800
                Re: problem with usbtmc-communication wrw@mac.com - 2012-12-11 09:34 -0500
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-11 12:48 -0800
                Re: problem with usbtmc-communication wrw@mac.com - 2012-12-11 21:21 -0500
                Re: problem with usbtmc-communication Jerry Hill <malaclypse2@gmail.com> - 2012-12-11 19:49 -0500
                Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-12 08:16 -0800
          Re: problem with usbtmc-communication Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-05 18:08 -0500
  Re: [newbie] problem with usbtmc-communication Terry Reedy <tjreedy@udel.edu> - 2012-12-04 14:55 -0500
    Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-06 06:05 -0800
    Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-06 07:44 -0800
      Re: problem with usbtmc-communication Terry Reedy <tjreedy@udel.edu> - 2012-12-06 15:28 -0500
        Re: problem with usbtmc-communication Jean Dubois <jeandubois314@gmail.com> - 2012-12-07 05:51 -0800

csiph-web