2

The module pySerial provides an interface to communicate with a serial device. However, looking at the configuration of a serial device, for example /dev/ttyS1, there are MANY things to configure:

stty -F /dev/ttyS1 -a
speed 1200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
parenb -parodd cs7 -hupcl cstopb cread clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke

I am especially interested in the parameter -parodd cs7. Is there a way to configure this parameter from within python, or do I have to call an external command to do this (like stty -F /dev/ttyS1 ...)?

asked Jul 29, 2013 at 15:10

1 Answer 1

2

Yes, you can even configure after declaring it

ser = serial.Serial('/dev/ttyS1', 19200, timeout=1, parity=serial.PARITY_ODD)
ser.parity = serial.PARITY_EVEN
ser.bytesize = serial.SEVENBITS
answered Jul 29, 2013 at 15:34
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.