[Ilugc] Serial Communication - Mark/Space parity problem

  • From: ganeshpulsars@xxxxxxxxx (M.Ganesh)
  • Date: Wed Feb 10 16:32:31 2010

On 10/02/2010 12:03, steve wrote:

On 02/09/2010 04:35 AM, M.Ganesh wrote:
Hi All,

I am trying to use python&  pyserial on Ubuntu 9.10 to communicate with
a serial device. I need to be able to set the parity bit Mark/Space for
this particular device. I understand linux/posix compliant OSs don't
natively support this. I googled and found this
[http://www.lothosoft.ch/thomas/libmip/markspaceparity.php] link and
implemented that in my code. With this I am able to send only one byte
with my desired parity and the port somehow goes back to 'No parity'
after one byte.

Umm, a quick glance at that pyserial documentation tells me that the 
parity mode setting can be done using the module constants:

http://pyserial.sourceforge.net/pyserial_api.html#constants

is this how you are setting the parity bit ?

I am assuming that pyserial should do the RIGHT THING(tm) irrespective 
of the OS, which might not be true if instead you are twiddling around 
using the termios module (as suggested in the link you posted).

cheers,
- steve

PS: You can also direct your python specific questions to the 
bangpypers mailing list where a number of Indian pythoniasts hang out:
http://mail.python.org/mailman/listinfo/bangpypers


Steve,

Thanks for a quick reply.

pyserial senses the OS and acts accordingly. When I set serial.parity = 
serial.PARITY_MARK, it works in Windows, but in Ubuntu it throws an 
error 'Invalid parity "M"' (line no 380 in serialposix.py). Patched it 
with code in the above link and now Mark parity is set but for only one 
byte. It appears to be more of posix issue than python issue.

Any more suggestions please (from any other enlightened souls)

Thanks in advance
Ganesh

PS: I am not getting a copy of mails sent by me back from the list. I 
have already set the relevent option  in the mailman

Other related posts: