func main() { st, err := cflie.Start(usb.Hub) if err != nil { fail("Unable to start station: %v\n", err) } addr, err := st.Scan() if err != nil { fail("Scan: %v\n", err) } if len(addr) == 0 { fail("No Crazyflies found\n") } flieAddr := addr[0] flie, err := st.Open(flieAddr) if err != nil { fail("Unable to connect to [%s]: %v\n", flieAddr, err) } go countPackets(flie.RecvChan) flie.SendChan <- []byte{60, 0, 0, 0, 0, 0, 0, 0, 128, 250, 117, 61, 64, 48, 117} fmt.Printf("Press Ctrl+C to exit\n") for { time.Sleep(time.Second) } }
func Main() { st, err := cflie.Start(usb.Hub) if err != nil { log.Fatal(err) } addr, err := st.Scan() if err != nil { log.Fatalf("Scan failed: %v", err) } log.Printf("Found Crazyflies: %v", addr) }
func Main() { flags.Parse(flag.Args()[1:]) if *output == "" { *output = fmt.Sprintf("incoming.run.%s", time.Now().UTC().Format(time.RFC3339)) } f, err := os.OpenFile(*output, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644) if err != nil { fail("Unable to open output: %v\n", err) } defer f.Close() st, err := cflie.Start(usb.Hub) if err != nil { fail("Unable to start station: %v\n", err) } addr, err := st.Scan() if err != nil { fail("Scan: %v\n", err) } if len(addr) == 0 { fail("No Crazyflies found\n") } fmt.Fprintf(os.Stderr, "Found Crazyflies: %+v\n", addr) flieAddr := addr[0] flie, err := st.Open(flieAddr) if err != nil { fail("Unable to connect to [%s]: %v\n", flieAddr, err) } for p := range flie.RecvChan { if len(p) == 0 { continue } for i, v := range p { if i > 0 { fmt.Fprint(f, " ") } fmt.Fprintf(f, "%3d", v) } fmt.Fprintln(f) if err = f.Sync(); err != nil { fail("Unable to flush output: %v\n", err) } } }
func Main() { st, err := cflie.Start(usb.Hub) if err != nil { fail("Unable to start station: %v\n", err) } addr, err := st.Scan() if err != nil { fail("Scan: %v\n", err) } if len(addr) == 0 { fail("No Crazyflies found\n") } flieAddr := addr[0] flie, err := st.Open(flieAddr) if err != nil { fail("Unable to connect to [%s]: %v\n", flieAddr, err) } for { buf := make([]byte, 1) // Currently, this awaits for enter to be pressed // To get rid of that, pty/tty must be used. // See the following packages: // https://github.com/dotcloud/docker/tree/master/term // https://github.com/kr/pty _, err := os.Stdin.Read(buf) if err != nil { fail("Could not read from stdin: %v\n", err) } switch buf[0] { case ' ': flie.SendChan <- cmd(0, 0, 0, 37000) default: flie.SendChan <- cmd(0, 0, 0, 30000) } } }
func Main() { st, err := cflie.Start(usb.Hub) if err != nil { fail("Unable to start station: %v\n", err) } addr, err := st.Scan() if err != nil { fail("Scan: %v\n", err) } if len(addr) == 0 { fail("No Crazyflies found\n") } flieAddr := addr[0] flie, err := st.Open(flieAddr) if err != nil { fail("Unable to connect to [%s]: %v\n", flieAddr, err) } flie.SendChan <- []byte{60, 0, 0, 0, 0, 0, 0, 0, 128, 250, 117, 61, 64, 48, 117} time.Sleep(500 * time.Millisecond) }