IEnumerator OpenComThread()
    {
        if (!pcvr.bIsHardWare)
        {
            yield break;
        }

        ReadMsgTimeOutVal = 0f;
        ComThreadClass.IsReadMsgComTimeOut = false;
        ComThreadClass.IsReadComMsg        = false;
        ComThreadClass.IsStopComTX         = false;
        if (_ComThreadClass == null)
        {
            _ComThreadClass = new ComThreadClass(ComThreadClass.ComPortName);
        }
        else
        {
            ComThreadClass.CloseComPort();
        }

        if (ComThread != null)
        {
            CloseComThread();
        }
        yield return(new WaitForSeconds(2f));

        ComThreadClass.OpenComPort();
        if (ComThread == null)
        {
            ComThread = new Thread(new ThreadStart(_ComThreadClass.Run));
            ComThread.Start();
        }
    }
 void OnApplicationQuit()
 {
     Debug.Log("OnApplicationQuit...Com");
     XkGameCtrl.IsGameOnQuit = true;
     ComThreadClass.CloseComPort();
     Invoke("CloseComThread", 2f);
 }
Example #3
0
    /// <summary>
    /// 打开IO线程.
    /// </summary>
    IEnumerator OpenComThread()
    {
        if (mComThreadClass == null)
        {
            mComThreadClass = new ComThreadClass(ComThreadClass.ComPortName);
        }
        else
        {
            mComThreadClass.CloseComPort();
        }

        if (mComThreadIO != null)
        {
            CloseComThread();
        }
        yield return(new WaitForSeconds(2f));

        if (mComThreadIO == null)
        {
            mComThreadIO = new Thread(new ThreadStart(mComThreadClass.Run));
            mComThreadIO.Start();
        }
    }
 void OnApplicationQuit()
 {
     //Debug.Log("OnApplicationQuit...");
     ComThreadClass.CloseComPort();
     Invoke("CloseComThread", 2f);
 }