From: Othmar Gsenger Date: Mon, 11 Mar 2013 23:53:52 +0000 (+0000) Subject: fixed errors and run script X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=06a13a5f72f55f0b1638279304bba6fde8d11c1e;p=svn42.git fixed errors and run script --- diff --git a/door_daemon_go/run.sh b/door_daemon_go/run.sh index 42b55c5..2cbf009 100755 --- a/door_daemon_go/run.sh +++ b/door_daemon_go/run.sh @@ -1,4 +1,6 @@ #!/bin/sh clear rm /tmp/test.sock 2>/dev/null +export GOPATH=`pwd` +go install termios go build unix_socket_server.go && ./unix_socket_server /dev/ttyACM0 || sleep 5 diff --git a/door_daemon_go/src/termios/termios.go b/door_daemon_go/src/termios/termios.go index cc953cb..11325c9 100644 --- a/door_daemon_go/src/termios/termios.go +++ b/door_daemon_go/src/termios/termios.go @@ -58,12 +58,12 @@ func getTermios (dst *termios) error { uintptr (ttyfd), uintptr (TCGETS), uintptr (unsafe.Pointer (dst))); - if err := os.NewSyscallError ("SYS_IOCTL", errno); err != nil { + if err := os.NewSyscallError ("SYS_IOCTL", errno); errno!=0 && err != nil { return err } if r1 != 0 { - return errors.New("Error") + // return errors.New("Error") } return nil @@ -74,7 +74,7 @@ func setTermios (src *termios) error { uintptr (ttyfd), uintptr (TCSETS), uintptr (unsafe.Pointer (src))); - if err := os.NewSyscallError ("SYS_IOCTL", errno); err != nil { + if err := os.NewSyscallError ("SYS_IOCTL", errno); errno!=0 &&err != nil { return err } @@ -107,7 +107,7 @@ func SetRaw () { ) defer func () { - if err != nil { fmt.Println (err) } + if err != nil { fmt.Printf ("SetRaw Error: %v\n",err) } } (); if err = getTermios (&orig_termios); err != nil { return } diff --git a/door_daemon_go/unix_socket_server.go b/door_daemon_go/unix_socket_server.go index 14b9226..61893ff 100644 --- a/door_daemon_go/unix_socket_server.go +++ b/door_daemon_go/unix_socket_server.go @@ -7,6 +7,7 @@ import "os" import "io" import "termios" import "flag" +import "regexp" var cmdHandler = map[string]func([]string,string,*bufio.ReadWriter ) { "test":handleCmdTest, @@ -38,7 +39,9 @@ func readLineSafe(rw *bufio.Reader) (string, error) { //rw.Flush() return "",nil } - return line,nil + reg := regexp.MustCompile("\r") + safe := reg.ReplaceAllString(line, "") + return safe,nil } func connToReadWriter(c io.Reader,cw io.Writer) (*bufio.ReadWriter) { @@ -127,7 +130,7 @@ func SerialReader(c chan string , serial * bufio.Reader) { fmt.Printf("Error in read from serial: %v\n",err.Error()) os.Exit(1) } - fmt.Printf("Serial: Read %v\n",s); + //fmt.Printf("Serial: Read %v\n",s); c<-s } } @@ -143,7 +146,7 @@ func openSerial(filename string) (chan string,chan string) { func SerialHandler(serial_i chan string) { for { - fmt.Printf("Serial said: %v\n",<-serial_i); + fmt.Printf("Serial Read: %s\n",<-serial_i); } } func main() {