예제 #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
    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();
    }