Beispiel #1
0
        private async Task SetSessionIndexAsync(string index)
        {
            // select the corresponding session file in the connected device
            await arbitrator.Request(InstanceName);

            await requestResponseDataFlow.SendRequest("{FGDD}");

            await requestResponseDataFlow.SendRequest("{FF" + index + "}");

            arbitrator.Release(InstanceName);
        }
Beispiel #2
0
        // private method ---------------------------------------------------------
        // this method starts the process of looping through each of the ports and sending commands for response
        private async Task StartProcessAsync()
        {
            if (_isDeviceConnected)
            {
                return;
            }

            try
            {
                string response = "";

                await arbitrator.Request(InstanceName);

                try
                {
                    response = await requestResponseDataFlow.SendRequest("{ZA1}");
                }
                catch (TaskCanceledException e)
                {
                    System.Diagnostics.Debug.WriteLine("3 seconds no response from device.");
                    return; // return to the next port
                }
                System.Diagnostics.Debug.WriteLine($"TryingForPortResponse: response was ({response})");
                arbitrator.Release(InstanceName);

                if (response.Equals("^"))
                {
                    if (!_isDeviceConnected)
                    {
                        _keepDetectingDevice = _isDeviceConnected = IsDeviceConnected.Data = true;
                    }

                    while (_keepDetectingDevice)
                    {
                        await SendTimedResponseAsync();
                    }
                }
                else
                {
                    _keepDetectingDevice = false;
                }
            }
            catch (TaskCanceledException tce)
            {
                System.Diagnostics.Debug.WriteLine("Arbitrator 5 second timeout.");
                return; // return to the next port
            }
        }