Exemple #1
0
func Main() {
	flags.Parse(flag.Args()[2:])

	log.Printf("Connecting to bootloader, please, restart Crazyflie...")
	dev, info, err := boot.Cold()
	if err != nil {
		log.Fatal(err)
	}
	defer dev.Close()

	conf, err := boot.ReadConfig(dev, info)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Config block: %+v", conf)

	if *channel != 0 {
		if *channel > cflie.MaxChannel {
			log.Fatal("Max channel: %d", cflie.MaxChannel)
		}
		if *channel <= 0 {
			log.Fatal("Channel must be positive")
		}
		conf.Channel = byte(*channel)
	}

	if *speed > 2 {
		log.Fatal("Max speed: 2")
	}
	if *speed >= 0 {
		conf.Speed = byte(*speed)
	}

	if err = boot.WriteConfig(dev, info, conf); err != nil {
		log.Fatal("WriteConfig: ", err)
	}
	log.Printf("Config updated, validating")

	conf2, err := boot.ReadConfig(dev, info)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Config block: %+v", conf2)

	if conf != conf2 {
		log.Fatal("Config block update failed. Want: %+v, got: %+v", conf, conf2)
	}
	log.Printf("OK")
}
Exemple #2
0
func Main() {
	log.Printf("Connecting to bootloader, please, restart Crazyflie...")
	dev, info, err := boot.Cold()
	if err != nil {
		log.Fatal(err)
	}
	defer dev.Close()

	conf, err := boot.ReadConfig(dev, info)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Config block: %+v", conf)
}