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!newsfeed5.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'debug': 0.03; 'specifying': 0.07; 'filename': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'enabling': 0.13; '...,': 0.16; 'bieber': 0.16; 'creation.': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'message-id:@4ax.com': 0.16; 'received:wlfraed': 0.16; 'timeout.': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'wrote:': 0.18; 'perl': 0.18; 'received:166': 0.18; 'previously': 0.19; 'url:home': 0.21; 'feb': 0.22; 'string': 0.24; 'preferred': 0.25; 'subject:data': 0.25; 'skip:= 10': 0.28; 'second': 0.28; 'example': 0.29; 'print': 0.29; 'jean': 0.30; 'tue,': 0.32; 'header:X-Complaints-To:1': 0.34; 'lee': 0.34; 'setting': 0.34; 'to:addr:python-list': 0.35; '...': 0.35; 'subject:]': 0.36; 'received:org': 0.36; 'but': 0.37; 'charset:us-ascii': 0.37; 'could': 0.38; 'should': 0.38; 'subject:how': 0.39; 'to:addr:python.org': 0.40; 'here': 0.64; 'opened': 0.64; 'high': 0.66; 'note:': 0.69; 'serial': 0.71; 'dennis': 0.73; '(your': 0.84; '-0800': 0.84; 'subject:read': 0.84; 'subject:stream': 0.84; 'usage;': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: how to read serial stream of data [newbie] Date: Tue, 07 Feb 2012 12:44:36 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: mobile-166-147-101-215.mycingular.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328636706 news.xs4all.nl 6980 [2001:888:2000:d::a6]:60124 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19968 On Tue, 7 Feb 2012 04:13:39 -0800 (PST), Jean Dupont wrote: >filename = raw_input() Note: this may include the terminating new-line character; you should strip leading/ending white-space characters. filename = raw_input().strip() >ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >rtscts=0, dsrdtr=0, timeout=15) Note: this specifying NO FLOW CONTROL (your PERL example is activating DTR, which could be both enabling DSRDTR control, AND setting the DTR line high). Finally, you are specifying a 15 SECOND timeout. >ser2.setDTR(level=True) Note: here you are setting the DTR level high -- but you previously opened the port without enabling the use of DSRDTR. Use ..., dsrdtr=True, ... in the serial port creation. >print "Opening " + ser2.portstr ser2.name is the preferred usage; and you opened it with the serial.Serial() call. And for such debug output, no need for a string concatenation print "Reading", ser2.name >s =ser2.read(11) #read up to 11bytes print len(s), repr(s) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/