public void Start() { Console.WriteLine(Environment.OSVersion.Platform); ShimmerController sc = new ShimmerController(this); sc.Connect(comPort); Console.WriteLine("Connecting..."); do // TODO : fix this, can cause hang if cannot connect to Shimmer { System.Threading.Thread.Sleep(100); } while (!sc.ShimmerDevice.IsConnected()); Console.WriteLine("Connected"); Console.WriteLine("Starting stream..."); sc.ShimmerDevice.Set3DOrientation(true); // set 3D orientation sc.ShimmerDevice.WriteBaudRate(230400); // set baud rates Console.WriteLine("Baud Rate: " + sc.ShimmerDevice.GetBaudRate()); Console.WriteLine("Sampling Rate: " + sc.ShimmerDevice.GetSamplingRate()); sc.StartStream(); Console.ReadKey(); Console.WriteLine("Stopping stream..."); sc.StopStream(); Console.ReadKey(); }
// stop the stream and disconnect from paired shimmer public void Disconnect() { sc.ShimmerDevice.Disconnect(); // disconnect from the Shimmer sc = null; // set controller to null txtOutput.text += "\nDisconnected"; isPairedBackground.color = Color.red; }
// connect to a shimmer, comPort must be set public void Connect() { Debug.Log("CONNECT AND STREAM CLICKED"); this.comPort = inputComPort.text; Debug.Log("USING COM" + this.comPort); txtOutput.text = "Connecting..."; sc = new ShimmerController(this); txtOutput.text += "\nTrying to connect on COM" + this.comPort; sc.Connect("COM" + this.comPort); }
// stop the stream and disconnect from paired shimmer public void Disconnect() { print("Stopping stream..."); txtOutput.text += "\nStopping stream"; sc.StopStream(); // stop the stream sc.ShimmerDevice.Disconnect(); // disconnect from the Shimmer sc = null; // set controller to null txtOutput.text += "\nStream Stopped"; txtOutput.text += "\nDisconnected"; }
// connect to a shimmer, comPort must be set public void Connect() { selectedItem = deviceDropdown.SelectedDevice; if (selectedItem == null) { Debug.Log("NO DEVICE SELECTED!"); return; } Debug.Log("CONNECT AND STREAM CLICKED"); this.comPort = selectedItem.ComPort.ToString(); Debug.Log("USING COM" + this.comPort); txtOutput.text = "Connecting..."; sc = new ShimmerController(this); txtOutput.text += "\nTrying to connect on COM" + this.comPort; sc.Connect("COM" + this.comPort); IsConnecting = true; }