Exemple #1
0
        public void Init()
        {
            portNames = new List <string>();

            foreach (string name in SerialPort.GetPortNames())
            {
                portNames.Add(name);
            }

            OnNewPortNames?.Invoke(portNames);

            watchDogThread = new Thread(WatchDog);
            watchDogThread.Start();
        }
Exemple #2
0
        private void CheckPort()
        {
            try {
                if (!modulePort.IsOpen)
                {
                    modulePort.Open();
                }

                if (status == ModuleStatus.Disconnected)
                {
                    status = ModuleStatus.Connected;
                    Extensions.ExcecuteWithAppIdleDispatcher(() => OnModuleConnectionChange?.Invoke(ModuleStatus.Connected));
                }
            } catch {
                if (status == ModuleStatus.Connected)
                {
                    status = ModuleStatus.Disconnected;
                    Extensions.ExcecuteWithAppIdleDispatcher(() => OnModuleConnectionChange?.Invoke(ModuleStatus.Disconnected));
                }
            }

            Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewPortNames?.Invoke(SerialPort.GetPortNames().ToList()));
        }