projects
/
svn42.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d77b186
)
termios_speed
author
Bernhard Tittelbach
<xro@realraum.at>
Thu, 21 Nov 2013 18:58:37 +0000
(18:58 +0000)
committer
Bernhard Tittelbach
<xro@realraum.at>
Thu, 21 Nov 2013 18:58:37 +0000
(18:58 +0000)
go/termios/termios.go
patch
|
blob
|
history
diff --git
a/go/termios/termios.go
b/go/termios/termios.go
index
c23edeb
..
f3f0077
100644
(file)
--- a/
go/termios/termios.go
+++ b/
go/termios/termios.go
@@
-1,7
+1,6
@@
package termios
import (
package termios
import (
- "fmt";
"os";
"syscall";
"unsafe"
"os";
"syscall";
"unsafe"
@@
-10,8
+9,8
@@
import (
// termios types
type cc_t byte
// termios types
type cc_t byte
-type speed_t uint
-type tcflag_t uint
+type speed_t uint32
+type tcflag_t uint32
// termios constants
const (
// termios constants
const (
@@
-99,7
+98,6
@@
func getTermios (dst *termios) error {
if r1 != 0 {
// return errors.New("Error")
}
if r1 != 0 {
// return errors.New("Error")
}
-
return nil
}
return nil
}
@@
-113,56
+111,28
@@
func setTermios (src *termios) error {
}
if r1 != 0 {
}
if r1 != 0 {
- return errors.New ("Error")
+ return errors.New ("Error during ioctl tcsets syscall")
}
}
-
- return nil
-}
-
-func tty_raw () error {
- raw := orig_termios;
-
- raw.c_iflag &= ^(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
- raw.c_oflag &= ^(OPOST);
- raw.c_cflag |= (CS8);
- raw.c_lflag &= ^(ECHO | ICANON | IEXTEN | ISIG);
-
- raw.c_cc[VMIN] = 1;
- raw.c_cc[VTIME] = 0;
-
- if err := setTermios (&raw); err != nil { return err }
-
return nil
}
return nil
}
-func SetRaw () {
- var (
- err error
- )
+func SetRaw () (error) {
+ if err := getTermios (&orig_termios); err != nil { return err}
- defer func () {
- if err != nil { fmt.Printf ("SetRaw Error: %v\n",err) }
- } ();
+ orig_termios.c_iflag &= ^(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+ orig_termios.c_oflag &= ^(OPOST);
+ orig_termios.c_cflag |= (CS8);
+ orig_termios.c_lflag &= ^(ECHO | ICANON | IEXTEN | ISIG);
- if err = getTermios (&orig_termios); err != nil { return }
+ orig_termios.c_cc[VMIN] = 1;
+ orig_termios.c_cc[VTIME] = 0;
-// defer func () {
-// err = setTermios (&orig_termios)
-// } ();
-
- if err = tty_raw (); err != nil { return }
- //if err = screenio (); err != nil { return }
+ return setTermios(&orig_termios)
}
}
-func SetSpeed (speed speed_t) {
- var err error
-
- defer func () {
- if err != nil { fmt.Printf ("SetSpeed Error: %v\n",err) }
- } ();
-
- if err = getTermios (&orig_termios); err != nil { return }
+func SetSpeed (speed speed_t) (error) {
+ if err := getTermios (&orig_termios); err != nil { return err }
orig_termios.c_ispeed = speed
orig_termios.c_ospeed = speed
orig_termios.c_ispeed = speed
orig_termios.c_ospeed = speed
- err = setTermios (&orig_termios)
+ return setTermios(&orig_termios)
}
}