void Start() { arduinoSerial = new ArduinoSerial(); arduinoSerial.ConnectToArduino(baudRate: 9600); AnnounceScene(SceneManager.GetActiveScene()); SceneManager.sceneLoaded += SceneManager_sceneLoaded; }
public void Disconnect() { Arduino?.Disconnect(); Arduino = null; _thread?.Abort(); _thread?.Join(100); _thread = null; }
private void Cleanup() { if (arduinoSerial != null) { arduinoSerial.ClosePort(); arduinoSerial = null; } }
public void Start(string portName) { _arduino = new ArduinoSerial(portName); _arduino.BytesReceived += Receive; _arduino.Start(); _thread = new Thread(Loop); _thread.IsBackground = true; _thread.Start(); }
void Start() { serial = ArduinoSerial.Instance; bool success = serial.Open(portNum, ArduinoSerial.Baudrate.B_115200); if (!success) { return; } serial.OnDataReceived += SerialCallBack; }
private void Start() { _serial = ArduinoSerial.Instance; bool success = _serial.Open(null, ArduinoSerial.Baudrate.B_115200); if (!success) { return; } _serial.OnDataReceived += OnDataReceived; }
public void Connect(string portName) { Disconnect(); Arduino = new ArduinoSerial(portName); Arduino.BytesSent += (port, bytes) => BytesSent?.Invoke(port, bytes); Arduino.BytesReceived += (port, bytes) => BytesReceived?.Invoke(port, bytes); Arduino.Connect(false); _thread = new Thread(Loop); _thread.IsBackground = true; _thread.Start(); }
public ConnectResult TryConnect(string portName, bool sayhello) { if (portName == "") { return(ConnectResult.InvalidArgument); } Disconnect(); EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.AutoReset); ConnectResult result = ConnectResult.None; Arduino = new ArduinoSerial(portName); Arduino.BytesSent += (port, bytes) => BytesSent?.Invoke(port, bytes); Arduino.BytesReceived += (port, bytes) => BytesReceived?.Invoke(port, bytes); ArduinoSerial.StatusChangedHandler statuschanged = status => { lock (ewh) { if (result != ConnectResult.None) { return; } if (status == ArduinoSerial.Status.Connected || status == ArduinoSerial.Status.ConnectedUnsafe) { result = ConnectResult.Success; ewh.Set(); } if (status == ArduinoSerial.Status.Error) { result = ConnectResult.Error; ewh.Set(); } } }; Arduino.StatusChanged += statuschanged; Arduino.Connect(sayhello); if (!ewh.WaitOne(300) && sayhello) { Arduino.Disconnect(); Arduino = null; return(ConnectResult.Timeout); } if (result != ConnectResult.Success) { Arduino.Disconnect(); Arduino = null; return(result); } Arduino.StatusChanged -= statuschanged; _thread = new Thread(Loop); _thread.IsBackground = true; _thread.Start(); return(ConnectResult.Success); }
void Start() { arduinoSerial = new ArduinoSerial(); arduinoSerial.ConnectToArduino(baudRate: 115200); }
void Start() { arduinoSerial = new ArduinoSerial(); arduinoSerial.ConnectToArduino(baudRate: 115200, pName: portName); startRot = go.transform.rotation; }
// Use this for initialization void Start() { arduinoInfo = FindObjectOfType <ArduinoSerial>(); setCom(); arduinoInfo.comienzaThread(); }
void Start() { serial = ArduinoSerial.Instance; serial.OnDataReceived += OnSerialReceived; serial.Open(null, ArduinoSerial.Baudrate.B_9600); }