Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'modify': 0.05; 'sys': 0.05; 'filename': 0.07; 'subject:skip:c 10': 0.07; 'python': 0.09; 'cc:addr:python-list': 0.10; '(the': 0.15; 'dec': 0.15; '"enter': 0.16; '(11': 0.16; 'c):': 0.16; 'character).': 0.16; 'did.': 0.16; 'pair,': 0.16; 'received:mac.com': 0.16; 'url:all': 0.16; 'workaround:': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'driver': 0.17; 'received:10.0.1': 0.17; 'thanks,': 0.18; 'examples': 0.18; '>>>': 0.18; 'skip:= 10': 0.20; 'written': 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; 'cc:addr:python.org': 0.25; 'skip:m 30': 0.26; '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; 'pointer.': 0.29; 'readline': 0.29; "i'm": 0.29; 'that.': 0.30; 'e.g.': 0.30; 'writes': 0.30; 'code': 0.31; 'print': 0.32; '11,': 0.33; 'int': 0.33; 'rid': 0.33; 'url:home': 0.33; 'received:10.0': 0.33; 'problem': 0.33; 'code:': 0.33; 'another': 0.33; 'received:17': 0.35; 'there': 0.35; 'add': 0.36; 'explain': 0.36; 'skip:u 20': 0.36; 'but': 0.36; 'cc:no real name:2**1': 0.36; 'characters': 0.36; "i'll": 0.36; 'subject:with': 0.36; 'does': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'received:10': 0.38; 'notice': 0.39; 'where': 0.40; 'subject:-': 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; 'charset:windows-1252': 0.65; 'url:be': 0.65; 'url:htm': 0.71; 'counts': 0.81; '=>>': 0.84; 'staircase': 0.84; 'url:lc': 0.84; 'suspicious': 0.91; 'url:upload': 0.91; 'device.': 0.93; 'faith': 0.93; 'instrument': 0.95; 'url:cc': 0.98 MIME-version: 1.0 Content-type: text/plain; charset=windows-1252 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.9.8327,1.0.431,0.0.0000 definitions=2012-12-11_06:2012-12-11, 2012-12-11, 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-1212110116 Subject: Re: problem with usbtmc-communication From: wrw@mac.com In-reply-to: <50b9eb4f-f319-491d-894c-2a9386b6941a@x20g2000vbf.googlegroups.com> Date: Tue, 11 Dec 2012 09:34:26 -0500 Content-transfer-encoding: quoted-printable 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> To: Jean Dubois 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 68 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355236484 news.xs4all.nl 6954 [2001:888:2000:d::a6]:37382 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34620 On Dec 11, 2012, at 1:58 AM, Jean Dubois = wrote: > On 10 dec, 16:34, w...@mac.com wrote: >> On Dec 10, 2012, at 8:31 AM, Jean Dubois = wrote: >>=20 >> [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 >>=20 >>> thanks, >>> jean >>=20 >>> Here follows the new code: >>> #!/usr/bin/python >>> import time >>> import os >>> import sys >>> measurementcurr=3D'' >>> measurementvolt=3D'' >>> timesleepdefault=3D5 >>> print "Enter a numofchar (11 =3D>> numofchar =3D int(raw_input()) >>> filename =3D'mydata.txt' >>> usbkeith =3D open('/dev/usbtmc1','r+') >>> usbkeith.flush() >>> usbkeith.write("*IDN?\n") >>=20 >> 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. > 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=3D= dut >=20 OK - I see where the examples came from, and I notice - int my_inst; my_inst=3Dopen(=93/dev/usbtmc1=94,O_RDWR); write(my_inst,=94*RST\n=94,5); close(my_inst); and similarly in another place - retval=3Dwrite(myfile,"*IDN?\n",6); Note that both write commands contain a byte count of the number of = characters to be written (\n counts as one character). Again, the read commands contain byte counts. I'm very suspicious that = a write command with no byte count writes nothing, but does move a = buffer pointer. -Bill=