Python termios.CLOCAL Examples
The following are 1
code examples of termios.CLOCAL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
termios
, or try the search function
.
Example #1
Source File: serial.py From rpi3-webiopi with Apache License 2.0 | 5 votes |
def __init__(self, device="/dev/ttyAMA0", baudrate=9600): if not device.startswith("/dev/"): device = "/dev/%s" % device if isinstance(baudrate, str): baudrate = int(baudrate) aname = "B%d" % baudrate if not hasattr(termios, aname): raise Exception("Unsupported baudrate") self.baudrate = baudrate Bus.__init__(self, "UART", device, os.O_RDWR | os.O_NOCTTY) fcntl.fcntl(self.fd, fcntl.F_SETFL, os.O_NDELAY) #backup = termios.tcgetattr(self.fd) options = termios.tcgetattr(self.fd) # iflag options[0] = 0 # oflag options[1] = 0 # cflag options[2] |= (termios.CLOCAL | termios.CREAD) options[2] &= ~termios.PARENB options[2] &= ~termios.CSTOPB options[2] &= ~termios.CSIZE options[2] |= termios.CS8 # lflag options[3] = 0 speed = getattr(termios, aname) # input speed options[4] = speed # output speed options[5] = speed termios.tcsetattr(self.fd, termios.TCSADRAIN, options)