public bool Connect() { Debug.WriteLine("About to open Sphero " + this.Name + "."); com = new SpheroCommunicator(); bool connected = false; for (int i = 0; i < 10; i++) { try { com.openPort(this.ComPortName); } catch (Exception) { Debug.WriteLine("Opening Sphero " + this.Name + " failed on try " + (i + 1).ToString()); continue; } connected = true; Debug.WriteLine("Sphero " + this.Name + " opened on try " + (i + 1).ToString()); break; } if (connected) { if (this.DebugMode) { var p = PacketFactory.new_SetRGBLEDPacket((byte)200, (byte)200, (byte)0, false); this.com.write(p); } } else { Debug.WriteLine("Unable to open Sphero " + this.Name + "!"); } return(connected); }
public bool Connect() { Debug.WriteLine("About to open Sphero " + this.Name + "."); com = new SpheroCommunicator(); bool connected = false; for (int i = 0; i < 10; i++) { try { com.openPort(this.ComPortName); } catch (Exception) { Debug.WriteLine("Opening Sphero " + this.Name + " failed on try " + (i + 1).ToString()); continue; } connected = true; Debug.WriteLine("Sphero " + this.Name + " opened on try " + (i + 1).ToString()); break; } if (connected) { if (this.DebugMode) { var p = PacketFactory.new_SetRGBLEDPacket((byte)200, (byte)200, (byte)0, false); this.com.write(p); } } else { Debug.WriteLine("Unable to open Sphero " + this.Name + "!"); } return connected; }
public SpheroCommander() { spheroComm = new SpheroCommunicator(); }