Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.02; 'skip:# 20': 0.03; 'python:': 0.05; 'modules.': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'port,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'subject:python': 0.10; 'output': 0.10; 'python?': 0.15; '"couldn\'t': 0.16; 'reedy': 0.16; 'stdout': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'defined': 0.24; 'command': 0.24; 'parameters': 0.25; 'guess': 0.26; 'code.': 0.26; 'module': 0.26; 'script': 0.28; 'second': 0.28; 'print': 0.29; 'connected': 0.29; 'pm,': 0.29; 'jean': 0.30; 'url:projects': 0.30; 'pretty': 0.31; 'actually': 0.31; 'there': 0.33; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'character': 0.34; 'skip:# 10': 0.34; 'setting': 0.34; 'anything': 0.34; 'someone': 0.34; 'to:addr:python-list': 0.35; 'properties': 0.36; 'subject:]': 0.36; 'received:org': 0.36; 'but': 0.37; 'connects': 0.38; 'could': 0.38; 'should': 0.38; 'open': 0.38; 'correctly': 0.39; 'unless': 0.39; "i'd": 0.39; 'url:source': 0.39; 'to:addr:python.org': 0.40; 'supply': 0.61; 'below': 0.62; 'skip:$ 10': 0.66; 'serial': 0.71; 'usb': 0.73; 'usb.': 0.84; 'ports.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: convert perl-script for voltcraft voltmeter to python [newbie] Date: Mon, 06 Feb 2012 23:21:24 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328588509 news.xs4all.nl 6913 [2001:888:2000:d::a6]:40093 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19924 On 2/2/2012 3:57 PM, Jean Dupont wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: The script below is for an old-fashioned, slow, multiple-pin serial port, not usb. I don't know anything about interfacing through usb. Recheck what the voltmeter actually connects to. > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly in Python? Last I know, pyserial is also for old serial ports. Setting the properties should be pretty obvious from the manual or code. There are also python usb modules. http://sourceforge.net/projects/mysql-python/?source=directory > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); # wait 5ms per character > $port->read_const_time(200); # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > my ($nin, $in) = $port->read(255); > print $in; > } > > $port->close; -- Terry Jan Reedy