func cTermios(goTerm *Termios) *C.struct_termios { var cTerm C.struct_termios cTerm.c_iflag = C.tcflag_t(goTerm.IFlag) cTerm.c_oflag = C.tcflag_t(goTerm.OFlag) cTerm.c_cflag = C.tcflag_t(goTerm.CFlag) cTerm.c_lflag = C.tcflag_t(goTerm.LFlag) for idx, ch := range goTerm.CC { cTerm.c_cc[idx] = C.cc_t(ch) } cTerm.c_ispeed = C.speed_t(goTerm.ISpeed) cTerm.c_ospeed = C.speed_t(goTerm.OSpeed) return &cTerm }
// SetISpeed sets the input (receiver) baudrate in Termios structure t // to speed. Argument speed must be a numerical (integer) baudrate // value in bits-per-second. Returns syscall.EINVAL if the requested // baudrate is not supported. See also cfsetispeed(3). func (t *Termios) SetISpeed(speed int) error { code, ok := stdSpeeds.Code(speed) if !ok { return syscall.EINVAL } C.cfsetispeed(&t.t, C.speed_t(code)) return nil }
func (bp *baseport) SetBaudRate(br int) error { var speed C.speed_t = C.speed_t(br) //fmt.Printf("C.IOSSIOSPEED %x\n", uint64(C.IOSSIOSPEED)) //fmt.Printf("for file %v, fd %d\n", bp.f, bp.f.Fd()) ret, err := C.ioctl1(C.int(bp.f.Fd()), C.uint(IOSSIOSPEED), unsafe.Pointer(&speed)) if ret == -1 || err != nil { return &Error{"setting baud rate: ioctl", err} } return nil }
BSDLY = C.tcflag_t(C.BSDLY) /* Select backspace delays: */ BS0 = C.tcflag_t(C.BS0) /* Backspace-delay type 0 */ BS1 = C.tcflag_t(C.BS1) /* Backspace-delay type 0 */ VTDLY = C.tcflag_t(C.VTDLY) /* Select vertical-tab delays: */ VT0 = C.tcflag_t(C.VT0) /* Vertical-tab delay type 0 */ VT1 = C.tcflag_t(C.VT1) /* Vertical-tab delay type 1 */ FFDLY = C.tcflag_t(C.FFDLY) /* Select form-feed delays: */ FF0 = C.tcflag_t(C.FF0) /* Form-feed delay type 0 */ FF1 = C.tcflag_t(C.FF1) /* Form-feed delay type 1 */ ) // Standard speeds const ( B0 = C.speed_t(C.B0) /* Hang up */ B50 = C.speed_t(C.B50) B75 = C.speed_t(C.B75) B110 = C.speed_t(C.B110) B134 = C.speed_t(C.B134) B150 = C.speed_t(C.B150) B200 = C.speed_t(C.B200) B300 = C.speed_t(C.B300) B600 = C.speed_t(C.B600) B1200 = C.speed_t(C.B1200) B1800 = C.speed_t(C.B1800) B2400 = C.speed_t(C.B2400) B4800 = C.speed_t(C.B4800) B9600 = C.speed_t(C.B9600) B19200 = C.speed_t(C.B19200) B38400 = C.speed_t(C.B38400)
// Cfsetospeed sets the output baud rate stored in the termios structure. func Cfsetospeed(attr *syscall.Termios, speed uintptr) error { solTermios := (*unix.Termios)(attr) _, err := C.cfsetospeed((*C.termios_t)(unsafe.Pointer(solTermios)), C.speed_t(speed)) return err }