override public void Read(ReadCallback callback, int timeout) { if (!IsConnected) { return; } if (IsReadInProgress) { //UnityEngine.Debug.Log("Clone paket"); __lastHIDReport.Status = HIDReport.ReadStatus.Buffered; callback.BeginInvoke(__lastHIDReport, EndReadCallback, callback); // callback.Invoke(__lastHIDReport); return; } IsReadInProgress = true; //TODO make this fields or use pool var readDelegate = new ReadDelegate(Read); var asyncState = new HidAsyncState(readDelegate, callback); readDelegate.BeginInvoke(timeout, EndRead, asyncState); }
public override void Write(object data, HIDDevice.WriteCallback callback, int timeout) { if (!IsConnected) { return; } if (IsOpen == false) { OpenDevice(); } var writeDelegate = new WriteDelegate(Write); var asyncState = new HidAsyncState(writeDelegate, callback); writeDelegate.BeginInvoke((byte[])data, timeout, EndWrite, asyncState); }
public override void Write(object data, HIDDevice.WriteCallback callback,int timeout) { if (!IsConnected) return; if (IsOpen == false) OpenDevice(); var writeDelegate = new WriteDelegate(Write); var asyncState = new HidAsyncState(writeDelegate, callback); writeDelegate.BeginInvoke((byte[])data,timeout, EndWrite, asyncState); }
override public void Read(ReadCallback callback,int timeout) { if (!IsConnected) return; if (IsReadInProgress) { //UnityEngine.Debug.Log("Clone paket"); __lastHIDReport.Status = HIDReport.ReadStatus.Buffered; callback.BeginInvoke(__lastHIDReport, EndReadCallback, callback); // callback.Invoke(__lastHIDReport); return; } IsReadInProgress = true; //TODO make this fields or use pool var readDelegate = new ReadDelegate(Read); var asyncState = new HidAsyncState(readDelegate, callback); readDelegate.BeginInvoke(timeout,EndRead, asyncState); }