Exemplo n.º 1
0
        public async Task <bool> Search(IPort p)
        {
            _port = p;

            Task <bool> run = new Task <bool>(() =>
            {
                lock (_port)
                {
                    if (!_port.InitializePort())
                    {
                        return(false);
                    }
                    _lastDiscrepancy = -1;
                    _lastSelectedBit = 0x00;
                    _done            = true;
                    do
                    {
                        this.Run(_lastSelectedBit);
                        _ds.Add(_port.BitsToBytes(_currentId));
                    } while (!_done);
                }
                return(true);
            });

            run.Start();
            return(await run);
        }
Exemplo n.º 2
0
 ///<summary>
 /// Search slaves
 ///</summary>
 ///<param name="p">Port name, example: COM1</param>
 ///<returns></returns>
 public bool Search(IPort p)
 {
     port = p;
     lock (port)
     {
         if (!port.InitializePort())
         {
             return(false);
         }
         lastDiscrepancy = -1;
         lastSelectedBit = 0x00;
         done            = true;
         do
         {
             Run(lastSelectedBit);
             IDs.Add(port.BitsToBytes(currentID));
         } while (!done);
     }
     return(true);
 }
Exemplo n.º 3
0
        public async Task<bool> Search(IPort p)
        {
            _port = p;

            Task<bool> run = new Task<bool>(() =>
            {
                lock (_port)
                {
                    if (!_port.InitializePort())
                        return false;
                    _lastDiscrepancy = -1;
                    _lastSelectedBit = 0x00;
                    _done = true;
                    do
                    {
                        this.Run(_lastSelectedBit);
                        _ds.Add(_port.BitsToBytes(_currentId));
                    } while (!_done);
                }
                return true;
            });
            run.Start();
            return await run;
        }