private IEnumerator start1() { pupThread = new Thread( new ThreadStart(ReadPup) ); pupThread.Name = "UDP listen thread"; yield return null; stopWatch.Start (); PupilFrame addframe = new PupilFrame (); string message = null; for (int i = 0; i < pupBufferSize; i++) { byte[] output = clientPupil1.Receive (ref remoteIpEndPointPupil1); message = Encoding.ASCII.GetString (output); message = DateTime.Now.ToString("hh:mm:ss:fff")+ ";" + message; if (message != null && message.Length > 0) { addframe.Set (message); pupilframeBuffer [i] = addframe; } } on = true; pupThread.Start (); }
/// <summary> /// Read a frame and store it in the buffer /// </summary> private void ReadPup() { UnityEngine.Debug.Log ("Thread Pupil software"); while (on) { try { PupilFrame eyetrackerData = new PupilFrame(); int i; for (i = 0; i < pupBufferSize - 1; i++) { pupilframeBuffer[i] = pupilframeBuffer[i + 1]; } //UnityEngine.Debug.Log (pupThread.ThreadState); byte[] output = clientPupil1.Receive (ref remoteIpEndPointPupil1); string packet2 = Encoding.ASCII.GetString(output); packet2 = DateTime.Now.ToString("hh:mm:ss:fff")+ ";" + packet2; //UnityEngine.Debug.Log(packet2); if (packet2 != null && packet2.Length > 0) { eyetrackerData.Set(packet2); pupilframeBuffer [i]=eyetrackerData; //WriteData(pupilframeBuffer[i]); } } catch (Exception e) { UnityEngine.Debug.Log( e.ToString() ); } } }