Exemplo n.º 1
0
        public bool Equals(CommDevice device)
        {
            if (device == null)
            {
                return(false);
            }

            if (!name.Equals(device.name))
            {
                return(false);
            }

            if (!address.Equals(device.address))
            {
                return(false);
            }

            if (args.Count != device.args.Count)
            {
                return(false);
            }

            for (int i = 0; i < args.Count; i++)
            {
                if (!args[i].Equals(device.args[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
 public CommDevice(CommDevice device)
 {
     name    = device.name;
     address = device.address;
     for (int i = 0; i < device.args.Count; i++)
     {
         args.Add(device.args[i]);
     }
 }
Exemplo n.º 3
0
 public void CopyFrom(CommDevice device)
 {
     name    = device.name;
     address = device.address;
     args.Clear();
     for (int i = 0; i < device.args.Count; i++)
     {
         args.Add(device.args[i]);
     }
 }
Exemplo n.º 4
0
        public override void StartSearch()
        {
            foundDevices.Clear();
            OnStartSearch.Invoke();

                        #if NET_2_0
                        #if UNITY_EDITOR
                        #if UNITY_EDITOR_WIN
            // Windows port search
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                CommDevice foundDevice = new CommDevice();
                foundDevice.name    = port;
                foundDevice.address = "//./" + port;
                foundDevices.Add(foundDevice);
                OnFoundDevice.Invoke(foundDevice);
            }
                        #elif UNITY_EDITOR_OSX
            // macOS port search
            string   prefix = "/dev/";
            string[] ports  = Directory.GetFiles(prefix, "*.*");
            foreach (string port in ports)
            {
                if (port.StartsWith("/dev/cu."))
                {
                    CommDevice foundDevice = new CommDevice();
                    foundDevice.name    = port.Substring(prefix.Length);
                    foundDevice.address = port;
                    foundDevices.Add(foundDevice);
                    OnFoundDevice.Invoke(foundDevice);
                }
            }
                        #endif
                        #elif UNITY_STANDALONE
                        #if UNITY_STANDALONE_WIN
            // Windows port search
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                CommDevice foundDevice = new CommDevice();
                foundDevice.name    = port;
                foundDevice.address = "//./" + port;
                foundDevices.Add(foundDevice);
                OnFoundDevice.Invoke(foundDevice);
            }
                        #elif UNITY_STANDALONE_OSX
            // macOS port search
            string   prefix = "/dev/";
            string[] ports  = Directory.GetFiles(prefix, "*.*");
            foreach (string port in ports)
            {
                if (port.StartsWith("/dev/cu."))
                {
                    CommDevice foundDevice = new CommDevice();
                    foundDevice.name    = port.Substring(prefix.Length);
                    foundDevice.address = port;
                    foundDevices.Add(foundDevice);
                    OnFoundDevice.Invoke(foundDevice);
                }
            }
                        #endif
                        #endif
                        #endif

            OnStopSearch.Invoke();
        }