コード例 #1
0
    void Awake()
    {
        nu = NativeUart.Instance;

        nu.OnUartState           += SerialState;
        nu.OnUartDeviceList      += SerialDeviceList;
        nu.OnUartMessageRead     += SerialMessageReceived;
        nu.OnUartMessageReadLine += SerialMessageReceivedLine;

        nu.Init();
    }
コード例 #2
0
    void Awake()
    {
        try
        {
            nu = NativeUart.Instance;

            deviceList.ClearOptions();
            deviceList.onValueChanged.AddListener(index => {
                devicePath = deviceList.options[index].text;
            });

            baudrateInput.onValueChanged.AddListener(value => {
                baudrate = int.Parse(value);
            });

            switchPort.onClick.AddListener(SwitchPort);

            send.onClick.AddListener(SendCommand);

            clear.onClick.AddListener(() => {
                logManager.ClearMssage();
            });

            forbidden.onClick.AddListener(() => {
                isForbiddenReceive = !isForbiddenReceive;
                forbidden.GetComponentInChildren <Text>().text = isForbiddenReceive ? "打开禁止自动更新日志" : "关闭禁止自动更新日志";
            });

            send.interactable = false;

            tip.SetActive(false);

            nu.OnUartState       += SerialState;
            nu.OnUartDeviceList  += SerialDeviceList;
            nu.OnUartMessageRead += SerialMessageReceived;

            nu.Init();
        }
        catch (Exception e)
        {
            logManager.AddMessage(LogManager.MessageType.Error, "Initialize serial port error: " + e.Message);
        }
    }
コード例 #3
0
ファイル: UartTest.cs プロジェクト: masafykun/ClimbCloud
    void Awake()
    {
        nu = NativeUart.Instance;

        sendButton.interactable = false;

        connectButton.onClick.AddListener(() => {
            SerialConnection();
        });
        sendButton.onClick.AddListener(() => {
            SerialSend();
        });

        boudrateInput.onEndEdit.AddListener((string boud) => {
            boudrate = int.Parse(boud);
        });

        nu.OnUartState           += SerialState;
        nu.OnUartDeviceList      += SerialDeviceList;
        nu.OnUartMessageRead     += SerialMessageReceived;
        nu.OnUartMessageReadLine += SerialMessageReceivedLine;

        nu.Init();
    }
コード例 #4
0
 private void OnDestroy()
 {
     Close();
     instance = null;
 }