+ fmt.Printf("Received: %v\n", line)
+ tokens:=strings.Fields(line)
+ remainStr:=strings.Join(tokens[1:]," ")
+ handleCmd(tokens,remainStr,client)
+ }
+}
+
+func handleCmd(tokens []string, remainStr string,client * bufio.ReadWriter) {
+ cmd:=tokens[0]
+ func_ptr,present := cmdHandler[cmd]
+ if present {
+ func_ptr(tokens, remainStr,client)
+ } else {
+ fmt.Printf("Error: unknown Cmd: %v\n", cmd)
+ }
+}
+
+func handleCmdTest(tokens []string, remainStr string, client * bufio.ReadWriter) {
+ //cmd:=tokens[0]
+ fmt.Printf("Test: %v\n", remainStr)
+}
+
+func handleCmdController(tokens []string, remainStr string, client * bufio.ReadWriter) {
+ cmd:=tokens[0]
+ s_r:=strings.NewReader(cmd)
+ char := make([]byte,1)
+ s_r.Read(char)
+ fmt.Println(string(char))
+}
+
+
+func openTTY(name string) *os.File {
+ file, err := os.OpenFile(name,os.O_RDWR ,0600) // For read access.
+ if err != nil {
+ fmt.Println(err.Error())
+ }
+ termios.Ttyfd(file.Fd())
+ termios.SetRaw()
+ return file
+}
+func usage() {
+ fmt.Fprintf(os.Stderr, "usage: myprog [inputfile]\n")
+ flag.PrintDefaults()
+ os.Exit(2)
+}
+
+func SerialWriter(c chan string, serial * os.File ) {
+ for {
+ serial.WriteString(<-c)
+ serial.Sync()
+ }
+}
+
+func SerialReader(c chan string , serial * bufio.Reader) {
+ for {
+ s,err := readLineSafe(serial)
+ if (s=="") {
+ continue