472,951 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

UART parity setting as "mark" or "space" (using Pyserial???)


I am trying to set-up communication to the coin change-giver from my
Linux box using the Python code. The change giver uses MDB (Multi Drop
Bus) serial protocol to communicate with the master. MDB protocol is
the 9bit serial protocol:
(TX, RX lines only) 9600bps, 9bits, No Parity, 1 Start, 1 Stop.

I would like to control the UART "parity bit" to try to simulate 9bit

Using Pyserial it is possible to set the parity bit as ODD, EVEN or

I have found in the following link (paragraph 21.3)
that UART hardware supports two "rarely used" parity settings as well:
mark parity and space parity (these setings are also known as "sticky

A "mark" is a 1-bit (or logic 1) and a "space" is a 0-bit (or logic 0).
For mark parity, the parity bit is always a one-bit. For space parity
it's always a zero-bit.

Does anybody here knows some "tricks" how to set up the mark and space
parity on the UART (using pyserial???), so I can simulate 9bit
communication? (I know it sounds silly, but I would like to try to
re-configure the UART parity before each byte transmission).

Any comment will be appreciated.

Petr Jakes

Nov 3 '05 #1
2 11822
On 2005-11-03, Petr Jakes <pe**@tpc.cz> wrote:
Using Pyserial it is possible to set the parity bit as ODD, EVEN or
Correct. Those are the parity settings supported by pretty
much all platforms.

Does anybody here knows some "tricks" how to set up the mark
and space parity on the UART (using pyserial???),
What OS? Mark and space parity are not supported by the Unix
termios API that is used to do serial port stuff.
so I can simulate 9bit communication? (I know it sounds silly,
but I would like to try to re-configure the UART parity before
each byte transmission).

I suspect you're going to have to talk to the UART yourself to
do this.

In addition to the problem with mark/space being unsupported,
you have to wait until each byte is completely sent (including
the parity bit) before changing the parity and loading the next
byte into the data register. Many OSes "drain" functions are
notoriously inaccurate.

Grant Edwards grante Yow! Did I say I was a
at sardine? Or a bus???
Nov 4 '05 #2
To provide feedback:

I have found the way how to control serial port parity bit on the Linux
(how to set the parity bit to the "mark" or "space" parity) within
Python using termios module.

With the help of:
import serial
import termios
import TERMIOS

ser=serial.Serial('/dev/ttyS0', 9600, 8, "N", timeout=1)

iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(ser)

cflag |= PARENB | CMSPAR # To select SPACE parity
cflag &= ~PARODD

cflag |= PARENB | CMSPAR | PARODD # to select MARK parity

termios.tcsetattr(ser, termios.TCSANOW, [iflag, oflag, cflag, lflag,
ispeed, ospeed, cc])
Using above mentioned it is possible to establish 9bit serial
communication according to the given protocol specifics. It is
necessary to control parity bit setting before sending each
communication byte.


Petr Jakes

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Martin Goldman | last post by:
Hello all, I've been struggling for a few days with the question of how to convert "smart" (curly) quotes into straight quotes. I tried playing with the htmlentities() function, but all that is...
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's...
by: Sandman | last post by:
I'm having some problem here... I have a javascript I've downloaded that goes through all PNG files and enables the transparency channel in them for IE5.5+ by converting them to SPAN layers with...
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the...
by: mairhtin o'feannag | last post by:
Hello, I have a tablespace striped across three drives, call them 1,2,3, just to be clever. :) I allocated a lot more space (DMS) than I should have, since I didn't know a way to estimate the...
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
by: taoberly | last post by:
A few months ago I posted a question about using a file on my hard drive to perform cross-frame scripting and pull data from a server on my company's intranet. I eventually got this working using...
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.