public async Task DeployApp(int debugPort, CancellationToken cancellationToken)
        {
            DeploymentTargetsManager.StopPollingForDevices();

            cleanedup = false;
            meadow?.Dispose();

            var target = this.Target as MeadowDeviceExecutionTarget;
            var device = await MeadowDeviceManager.GetMeadowForSerialPort(target.Port, logger : logger);

            meadow = new MeadowDeviceHelper(device, device.Logger);

            var fileNameExe = System.IO.Path.Combine(OutputDirectory, "App.dll");

            var debug = debugPort > 1000;

            await meadow.DeployAppAsync(fileNameExe, debug, cancellationToken);

            if (debug)
            {
                meadowDebugServer = await meadow.StartDebuggingSessionAsync(debugPort, cancellationToken);
            }
            else
            {
                // sleep until cancel since this is a normal deploy without debug
                while (!cancellationToken.IsCancellationRequested)
                {
                    await Task.Delay(1000);
                }

                Cleanup();
            }
        }
예제 #2
0
        // Enter VSDebug mode.
        public static void VSDebug(int vsDebugPort)
        {
            // Create an instance of the TCP socket send/receiver class and
            // starts it receiving.
            if (vsDebugPort == 0)
            {
                Console.WriteLine($"With '--VSDebugPort' not found. Assuming Visual Studio 2019 with port {DefaultVS2019DebugPort}");
                vsDebugPort = DefaultVS2019DebugPort;
            }

            debuggingServer = new DebuggingServer(vsDebugPort);
            debuggingServer.StartListening();
        }
        public void Cleanup()
        {
            if (cleanedup)
            {
                return;
            }

            meadowDebugServer?.StopListeningAsync();
            meadowDebugServer?.Dispose();
            meadowDebugServer = null;

            meadow?.Dispose();

            if (!cleanedup)
            {
                _ = DeploymentTargetsManager.StartPollingForDevices();
            }

            cleanedup = true;
        }
예제 #4
0
        // Enter StartDebugging mode.
        public static async Task StartDebugging(MeadowSerialDevice meadow, int vsDebugPort)
        {
            // Tell meadow to start it's debugging server, after restarting.
            _meadowRequestType = HcomMeadowRequestType.HCOM_MDOW_REQUEST_MONO_START_DBG_SESSION;
            await new SendTargetData(meadow).SendSimpleCommand(_meadowRequestType);

            // The previous command caused Meadow to restart. Therefore, we must reestablish
            // Meadow communication.
            meadow.AttemptToReconnectToMeadow();

            // Create an instance of the TCP socket send/receiver class and
            // start it receiving.
            if (vsDebugPort == 0)
            {
                Console.WriteLine($"Without '--VSDebugPort' being specified, will assume Visual Studio 2019 using default port {DefaultVS2019DebugPort}");
                vsDebugPort = DefaultVS2019DebugPort;
            }

            // Start the local Meadow.CLI debugging server
            debuggingServer = new DebuggingServer(vsDebugPort);
            debuggingServer.StartListening(meadow);
        }
예제 #5
0
        /// <summary>
        /// Start a session to debug an application on the Meadow
        /// </summary>
        /// <param name="port">The port to use for the debugging proxy</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for cancelling the operation</param>
        /// <returns>A running <see cref="DebuggingServer"/> that is available for connections</returns>
        public async Task <DebuggingServer> StartDebuggingSessionAsync(int port, CancellationToken cancellationToken)
        {
            await MonoEnableAsync(cancellationToken : cancellationToken);

            await _meadowDevice.StartDebuggingAsync(port, cancellationToken)
            .ConfigureAwait(false);

            await Task.Delay(1000, cancellationToken)
            .ConfigureAwait(false);

            await ReInitializeMeadowAsync(cancellationToken).ConfigureAwait(false);

            if (_meadowDevice == null)
            {
                throw new DeviceNotFoundException();
            }

            var endpoint        = new IPEndPoint(IPAddress.Loopback, port);
            var debuggingServer = new DebuggingServer(_meadowDevice, endpoint, Logger);
            await debuggingServer.StartListeningAsync(cancellationToken).ConfigureAwait(false);

            return(debuggingServer);
        }