Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.01; 'subject:Python': 0.05; 'python': 0.08; 'omit': 0.09; 'string)': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received :mail-iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; '\xa0so': 0.18; 'header:In-Reply-To:1': 0.22; 'mask': 0.23; 'produces': 0.23; 'string': 0.24; 'code': 0.25; "i'm": 0.26; 'bit': 0.28; 'message- id:@mail.gmail.com': 0.28; 'work:': 0.29; 'nov': 0.29; 'correct': 0.29; '22,': 0.30; 'iterating': 0.30; 'tue,': 0.32; 'that,': 0.33; 'there': 0.33; 'done': 0.34; 'to:addr:python-list': 0.34; 'something': 0.35; 'subject:/': 0.35; 'skip:" 20': 0.35; 'device': 0.36; 'subject:with': 0.36; 'but': 0.37; 'received:google.com': 0.37; "there's": 0.37; 'using': 0.38; 'received:209.85': 0.38; 'else': 0.39; 'subject: (': 0.40; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'once': 0.60; '2011': 0.61; 'high': 0.67; 'subject:Serial': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Ee6bDvDdbbziScIrAP+CEa5u2NH1n87iLFwkdf+9MN8=; b=c2ujiyZxJPuUB0BBxzYuIVdZf2iwuIbOwFLYq258qQOru3w97qz4ITiNt7uNbDY98H uaYirUMkfgTr7likWiMQL3GDuz5jB7Nku+nRQN1Bl4t69bzouUqvrShmUruQOs3zVWX6 RxBLYwvJ2Yx+6ng4BkFxd2irhFflhfn6wcqxU= MIME-Version: 1.0 In-Reply-To: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Date: Tue, 22 Nov 2011 03:41:01 +1100 Subject: Re: Non-POSIX parity (mark/space) with Python-Serial on Linux. From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321893664 news.xs4all.nl 6919 [2001:888:2000:d::a6]:51290 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16023 On Tue, Nov 22, 2011 at 3:28 AM, Matthew Lenz wrote= : > Using 8N1 under minicom with this device resulted in garbled text when on= ce connected. =A0Connection using 7M1 resulted in the correct text. =A0So t= here must be something else that needs to be done in my python program corr= ect? Using 8N1 when it's really 7M1 means you have the high bit set on every byte. I don't know if there's an easy way to do this fast in Python, but what you need to do is mask them all off... I'm not sure if there's a better way, but this ought to work: string =3D "".join(chr(ord(x)&0x7f) for x in string) In Python 3, iterating over a 'bytes' string produces integers, so omit the ord() call. Other than that, code is not tested. ChrisA