def tcsetattr_llimpl(fd, when, attributes): c_struct = lltype.malloc(TERMIOSP.TO, flavor='raw') c_struct.c_c_iflag, c_struct.c_c_oflag, c_struct.c_c_cflag, \ c_struct.c_c_lflag, ispeed, ospeed, cc = attributes try: for i in range(NCCS): c_struct.c_c_cc[i] = rffi.r_uchar(ord(cc[i])) error = c_cfsetispeed(c_struct, ispeed) if error == -1: raise termios.error(error, 'tcsetattr failed') error = c_cfsetospeed(c_struct, ospeed) if error == -1: raise termios.error(error, 'tcsetattr failed') error = c_tcsetattr(fd, when, c_struct) if error == -1: raise termios.error(error, 'tcsetattr failed') finally: lltype.free(c_struct, flavor='raw')
def tcgetattr_llimpl(fd): c_struct = lltype.malloc(TERMIOSP.TO, flavor='raw') error = c_tcgetattr(fd, c_struct) try: if error == -1: raise termios.error(error, 'tcgetattr failed') cc = [chr(c_struct.c_c_cc[i]) for i in range(NCCS)] ispeed = c_cfgetispeed(c_struct) ospeed = c_cfgetospeed(c_struct) result = (intmask(c_struct.c_c_iflag), intmask(c_struct.c_c_oflag), intmask(c_struct.c_c_cflag), intmask(c_struct.c_c_lflag), intmask(ispeed), intmask(ospeed), cc) return result finally: lltype.free(c_struct, flavor='raw')
def tcflow_llimpl(fd, action): error = c_tcflow(fd, action) if error == -1: raise termios.error(error, 'tcflow failed')
def tcflush_llimpl(fd, queue_selector): error = c_tcflush(fd, queue_selector) if error == -1: raise termios.error(error, 'tcflush failed')
def tcdrain_llimpl(fd): error = c_tcdrain(fd) if error == -1: raise termios.error(error, 'tcdrain failed')
def tcsendbreak_llimpl(fd, duration): error = c_tcsendbreak(fd, duration) if error == -1: raise termios.error(error, 'tcsendbreak failed')