예제 #1
0
 public MfTargetDevice(MFPortDefinition port, MFDevice device)
 {
     _port = port;
     _device = device;
     _tc = App.Kernel.Get<TelemetryClient>();
     Task.Run(() => InitializeAsync());
 }
예제 #2
0
		/// <summary>
		/// Connects to the device at the specified port
		/// </summary>
		/// <param name="port"></param>
		public void Connect(MFPortDefinition port)
		{
			this._device = new MFDeploy().Connect(port);
			this._device.OnDebugText += new EventHandler<DebugOutputEventArgs>(Device_OnDebugText);

			this.Connected(this, EventArgs.Empty);
		}
예제 #3
0
        private MFDevice InitializePorts(MFPortDefinition portDefinitionMain, MFPortDefinition portDefinitionTinyBooter)
        {
            MFDevice device = null;

            MFPortDefinition[] portDefs = new MFPortDefinition[2] {
                portDefinitionMain, portDefinitionTinyBooter
            };
            _DBG.PortDefinition[] pds = new Microsoft.SPOT.Debugger.PortDefinition[2];

            for (int i = 0; i < portDefs.Length; i++)
            {
                MFPortDefinition portDefinition = portDefs[i];
                if (portDefinition == null)
                {
                    continue;
                }

                if (portDefinition.Transport == TransportType.TCPIP)
                {
                    System.Net.IPAddress[] addr = System.Net.Dns.GetHostAddresses(portDefinition.Port);

                    pds[i] = new Microsoft.SPOT.Debugger.PortDefinition_Tcp(addr[0]);
                }
                else
                {
                    ArrayList list = _DBG.PortDefinition.Enumerate(_DBG.PortFilter.Usb, _DBG.PortFilter.Serial);
                    foreach (_DBG.PortDefinition pd in list)
                    {
                        if (portDefinition.Port.Length > 0)
                        {
                            if (string.Equals(portDefinition.Port, pd.UniqueId.ToString()))
                            {
                                pds[i] = pd;
                                break;
                            }
                        }
                        if (string.Equals(portDefinition.Name, pd.DisplayName))
                        {
                            pds[i] = pd;
                            break;
                        }
                    }
                }
            }

            if (pds[0] == null && pds[1] != null)
            {
                pds[0] = pds[1];
                pds[1] = null;
            }

            if (pds[0] != null || pds[1] != null)
            {
                device = new MFDevice(pds[0], pds[1]);

                if (!device.Connect(2000, m_tryConnect))
                {
                    throw new MFDeviceNoResponseException();
                }
            }
            else
            {
                throw new MFDeviceUnknownDeviceException();
            }

            return(device);
        }
예제 #4
0
 /// <summary>
 /// This method attempts to connect to a device on the given port. The Connect method throws a
 /// MFDeviceNoResponseException exception in the case that the connection could not be made.
 /// </summary>
 /// <param name="portDefinition">A port definition for which to attempt the connection to an .Net Micro Framework device</param>
 /// <returns>A connected .Net Micro Framework device</returns>
 public MFDevice Connect(MFPortDefinition portDefinition)
 {
     return(InitializePorts(portDefinition, null));
 }
예제 #5
0
 /// <summary>
 /// This method attempts to connect to a device on the given port.  Connect throws a MFDeviceNoResponseException
 /// exception in the case that the connection could not be made.
 /// </summary>
 /// <param name="portDefinition">A Port definition for which to attempt the connection to an .Net Micro Framework device.</param>
 /// <param name="tinyBooterPortDef">Devices can use a second port for the bootloader (TinyBooter).
 /// This parameter identifies the tinyBooter port.
 /// </param>
 /// <returns>A connected .Net Micro Framework device</returns>
 public MFDevice Connect(MFPortDefinition portDefinition, MFPortDefinition tinyBooterPortDef)
 {
     return(InitializePorts(portDefinition, tinyBooterPortDef));
 }
예제 #6
0
파일: MFDeploy.cs 프로젝트: prabby/miniclr
        private MFDevice InitializePorts(MFPortDefinition portDefinitionMain, MFPortDefinition portDefinitionTinyBooter)
        {
            MFDevice device = null;
            MFPortDefinition[] portDefs = new MFPortDefinition[2] { portDefinitionMain, portDefinitionTinyBooter };
            _DBG.PortDefinition[] pds = new Microsoft.SPOT.Debugger.PortDefinition[2];

            for (int i = 0;i < portDefs.Length;i++)
            {
                MFPortDefinition portDefinition = portDefs[i];
                if (portDefinition == null) continue;

                if (portDefinition.Transport == TransportType.TCPIP)
                {
                    System.Net.IPAddress[] addr = System.Net.Dns.GetHostAddresses(portDefinition.Port);

                    pds[i] = new Microsoft.SPOT.Debugger.PortDefinition_Tcp(addr[0]);
                }
                else
                {
                    ArrayList list = _DBG.PortDefinition.Enumerate(_DBG.PortFilter.Usb, _DBG.PortFilter.Serial);
                    foreach (_DBG.PortDefinition pd in list)
                    {
                        if (portDefinition.Port.Length > 0)
                        {
                            if (string.Equals(portDefinition.Port, pd.UniqueId.ToString()))
                            {
                                pds[i] = pd;
                                break;
                            }
                        }
                        if (string.Equals(portDefinition.Name, pd.DisplayName))
                        {
                            pds[i] = pd;
                            break;
                        }
                    }
                }
            }

            if (pds[0] == null && pds[1] != null)
            {
                pds[0] = pds[1];
                pds[1] = null;
            }

            if (pds[0] != null || pds[1] != null)
            {
                device = new MFDevice(pds[0], pds[1]);

                if (!device.Connect(2000, m_tryConnect))
                {
                    throw new MFDeviceNoResponseException();
                }
            }
            else
            {
                throw new MFDeviceUnknownDeviceException();
            }

            return device;
        }
예제 #7
0
파일: MFDeploy.cs 프로젝트: prabby/miniclr
 /// <summary>
 /// This method attempts to connect to a device on the given port. The Connect method throws a 
 /// MFDeviceNoResponseException exception in the case that the connection could not be made.
 /// </summary>
 /// <param name="portDefinition">A port definition for which to attempt the connection to an .Net Micro Framework device</param>
 /// <returns>A connected .Net Micro Framework device</returns>
 public MFDevice Connect(MFPortDefinition portDefinition)
 {
     return InitializePorts(portDefinition, null);
 }
예제 #8
0
파일: MFDeploy.cs 프로젝트: prabby/miniclr
 /// <summary>
 /// This method attempts to connect to a device on the given port.  Connect throws a MFDeviceNoResponseException 
 /// exception in the case that the connection could not be made.
 /// </summary>
 /// <param name="portDefinition">A Port definition for which to attempt the connection to an .Net Micro Framework device.</param>
 /// <param name="tinyBooterPortDef">Devices can use a second port for the bootloader (TinyBooter).  
 /// This parameter identifies the tinyBooter port.
 /// </param>
 /// <returns>A connected .Net Micro Framework device</returns>
 public MFDevice Connect(MFPortDefinition portDefinition, MFPortDefinition tinyBooterPortDef)
 {
     return InitializePorts(portDefinition, tinyBooterPortDef);
 }
예제 #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBoxTransport.SelectedIndex = 0;

            if (m_transport != null)
            {
                comboBoxDevice.Text = m_transport.Name;
            }

            richTextBoxOutput.ScrollToCaret();

            foreach (MFSerialPort pd in m_deploy.EnumPorts(TransportType.Serial))
            {
                ToolStripMenuItem ti = new ToolStripMenuItem(pd.Name);
                ti.Tag = pd;
                ti.Click += new EventHandler(OnDefaultSerialPortChange);

                defaultSerialPortToolStripMenuItem.DropDownItems.Add(ti);

                if (Properties.Settings.Default.DefaultSerialPort == pd.Name)
                {
                    m_defaultSerialPort = ti;
                    ti.Checked = true;

                    m_transportTinyBooter = pd;
                }
            }


            AddPlugIns(typeof(Debug.DebugPlugins).GetNestedTypes(), "Debug");

            foreach (string file in Properties.Settings.Default.MRUFiles)
            {
                bool fAddFiles = true;
                // validate the file set
                foreach (string f in file.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    string f1 = f.Trim();
                    if (f1.Length > 0 && !File.Exists(f1))
                    {
                        fAddFiles = false;
                    }
                }
                if (fAddFiles) comboBoxImageFile.Items.Add(file);
            }

            try   { m_deploy.DiscoveryMulticastAddress     = System.Net.IPAddress.Parse(Properties.Settings.Default.DiscoveryMulticastAddress); }
            catch { richTextBoxOutput.AppendText(string.Format(Properties.Resources.ErrorAppSettings, "DiscoveryMulticastAddress")); }
            
            m_deploy.DiscoveryMulticastPort  = Properties.Settings.Default.DiscoveryMulticastPort;
            m_deploy.DiscoveryMulticastToken = Properties.Settings.Default.DiscoveryMulticastToken;

            try   { m_deploy.DiscoveryMulticastAddressRecv = System.Net.IPAddress.Parse(Properties.Settings.Default.DiscoveryMulticastAddressRecv); }
            catch { richTextBoxOutput.AppendText(string.Format(Properties.Resources.ErrorAppSettings, "DiscoveryMulticastAddressRecv")); }
            
            m_deploy.DiscoveryMulticastTimeout = Properties.Settings.Default.DiscoveryMulticastTimeout;
            m_deploy.DiscoveryTTL              = Properties.Settings.Default.DiscoveryTTL;

            try
            {
                string dir = Properties.Settings.Default.PlugIns;
                if (dir != null && dir.Length > 0)
                {
                    string plugin_dir = AppDomain.CurrentDomain.BaseDirectory + dir;

                    if (Directory.Exists(plugin_dir))
                    {
                        foreach (string file in Directory.GetFiles(plugin_dir, "*.dll"))
                        {
                            FileInfo fi = new FileInfo(file);

                            try
                            {
                                Assembly asm = Assembly.LoadFrom(file);

                                AddPlugIns(asm.GetTypes(), fi.Name.Substring(0, fi.Name.Length - 4));
                            }
                            catch
                            {
                                DumpToOutput(string.Format(Properties.Resources.ErrorUnableToInstallPlugIn, fi.Name));
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
예제 #10
0
 private void OnDefaultSerialPortChange(object sender, EventArgs ea)
 {
     ToolStripMenuItem tsi = sender as ToolStripMenuItem;
     if (tsi != null)
     {
         MFSerialPort port = tsi.Tag as MFSerialPort;
         if (port != null)
         {
             m_defaultSerialPort.Checked = false;
             Properties.Settings.Default.DefaultSerialPort = port.Name;
             tsi.Checked = true;
             m_defaultSerialPort = tsi;
             m_transportTinyBooter = port;
         }
     }
 }
예제 #11
0
 private MFDevice ConnectToNetmfDevice(MFPortDefinition port)
 {
     MFDevice result = null;
     try
     {
         result = _deploy.Connect(port);
     }
     catch
     {
         App.ShowDeploymentLogWindow();
         App.AppendToLogWindow("Failed to connect to device. You may need to reset your board or restart this program.");
         result = null;
     }
     return result;
 }
예제 #12
0
 private void AddDeployableTarget(MFPortDefinition item)
 {
     var device = ConnectToNetmfDevice(item);
     if (device != null)
     {
         if (!_devices.Any(x => x is MfTargetDevice && ((MfTargetDevice)x).Name == item.Name && ((MfTargetDevice)x).Transport == item.Transport && ((MfTargetDevice)x).Port == item.Port))
         {
             lock (_devices)
             {
                 _devices.Add(new MfTargetDevice(item, device));
             }
         }
     }
 }