473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

Hi,

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
communication.

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

I have found in the following link (paragraph 21.3)
http://howtos.linux.com/howtos/Seria...1.shtml#ss21.1
that UART hardware supports two "rarely used" parity settings as well:
mark parity and space parity (these setings are also known as "sticky
parity")

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 11962
On 2005-11-03, Petr Jakes <pe**@tpc.cz> wrote:
Using Pyserial it is possible to set the parity bit as ODD, EVEN or
NONE.
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???
visi.com
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:
http://www.lothosoft.ch/thomas/libmi...paceparity.php
=======================================
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.

Regards

Petr Jakes

Nov 22 '05 #3

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

Similar topics

9
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...
0
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...
6
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...
12
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...
4
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...
289
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...
20
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...
11
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...
350
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.