public async Task <List <RemoteProgram> > ReadProgramInfo()
        {
            var remoteProgramList = new List <RemoteProgram>();

            // Decode data
            for (var i = 1; ; i++)
            {
                manipulator.SendCustom(i == 1 ? "EXE0, \"Fd<*\"" : $"EXE0, \"Fd{i}\"");

                await manipulator.Port.WaitForMessageAsync();

                var QoK = manipulator.Port.Read();
                if (QoK.Equals("QoK\r"))
                {
                    break;
                }

                var remoteProgram = RemoteProgram.Create(QoK);
                if (remoteProgram != null)
                {
                    remoteProgramList.Add(remoteProgram);
                }
            }
            return(remoteProgramList);
        }
Ejemplo n.º 2
0
        public async Task <List <RemoteProgram> > ReadProgramInfo(CancellationToken cancellationToken)
        {
            var remoteProgramList = new List <RemoteProgram>();

            // Decode data
            for (var i = 1; ; i++)
            {
                manipulator.SendCustom(i == 1 ? "EXE0, \"Fd<*\"" : $"EXE0, \"Fd{i}\"");

                await manipulator.Port.WaitForMessageAsync();

                var QoK = manipulator.Port.Read();
                if (QoK.Equals("QoK\r") || Regex.IsMatch(QoK, @"^QoK\s*$"))
                {
                    break;
                }

                try
                {
                    cancellationToken.ThrowIfCancellationRequested();
                }
                catch (OperationCanceledException)
                {
                    break;
                }

                var remoteProgram = RemoteProgram.Create(QoK);
                if (remoteProgram != null)
                {
                    remoteProgramList.Add(remoteProgram);
                }
            }
            return(remoteProgramList);
        }