Ejemplo n.º 1
0
    // 端口写入流程
    private IEnumerator PortWriteRoutine(byte[] bytes)
    {
        while (!IsPortWriting)
        {
            try {
                Port.Write(bytes, 0, bytes.Length);
                IsPortWriting = true;
            } catch (System.TimeoutException ex) {
                Debug.LogWarning(ex);
                Debug.Log("重启写入程序");
            }
        }

        yield return(new WaitForSeconds(0.1f));

        m_isConnected = false;
        yield return(new WaitUntil(() => m_isConnected));

        Debug.Log("校准完毕");
        IsPortWriting = false;

        yield return(controller.StartCoroutine(CurrentResolver.OnFinishPortWrite()));
    }