Example #1
0
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')
Example #2
0
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')
Example #3
0
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')
Example #4
0
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')
Example #5
0
def tcflow_llimpl(fd, action):
    error = c_tcflow(fd, action)
    if error == -1:
        raise termios.error(error, 'tcflow failed')
Example #6
0
def tcflush_llimpl(fd, queue_selector):
    error = c_tcflush(fd, queue_selector)
    if error == -1:
        raise termios.error(error, 'tcflush failed')
Example #7
0
def tcdrain_llimpl(fd):
    error = c_tcdrain(fd)
    if error == -1:
        raise termios.error(error, 'tcdrain failed')
Example #8
0
def tcsendbreak_llimpl(fd, duration):
    error = c_tcsendbreak(fd, duration)
    if error == -1:
        raise termios.error(error, 'tcsendbreak failed')
Example #9
0
def tcflow_llimpl(fd, action):
    error = c_tcflow(fd, action)
    if error == -1:
        raise termios.error(error, 'tcflow failed')
Example #10
0
def tcflush_llimpl(fd, queue_selector):
    error = c_tcflush(fd, queue_selector)
    if error == -1:
        raise termios.error(error, 'tcflush failed')
Example #11
0
def tcdrain_llimpl(fd):
    error = c_tcdrain(fd)
    if error == -1:
        raise termios.error(error, 'tcdrain failed')
Example #12
0
def tcsendbreak_llimpl(fd, duration):
    error = c_tcsendbreak(fd, duration)
    if error == -1:
        raise termios.error(error, 'tcsendbreak failed')