Ejemplo n.º 1
0
        public PortDefinition[] GetPersistablePortDefinitions()
        {
            PortDefinition[] ports = null;

            switch (m_portFilter)
            {
            case PortFilter.Emulator:
                Debug.Assert(false);
                break;

            case PortFilter.Serial:
                ports = AsyncSerialStream.EnumeratePorts();
                break;

            case PortFilter.Usb:
            {
                if (MonoDevelop.Core.Platform.IsWindows)
                {
                    PortDefinition[] portUSB;
                    PortDefinition[] portWinUSB;

                    portUSB    = AsyncUsbStream.EnumeratePorts();
                    portWinUSB = WinUsb_AsyncUsbStream.EnumeratePorts();

                    int lenUSB    = portUSB != null ? portUSB.Length : 0;
                    int lenWinUSB = portWinUSB != null ? portWinUSB.Length : 0;

                    ports = new PortDefinition[lenUSB + lenWinUSB];

                    if (lenUSB > 0)
                    {
                        Array.Copy(portUSB, ports, lenUSB);
                    }
                    if (lenWinUSB > 0)
                    {
                        Array.Copy(portWinUSB, 0, ports, lenUSB, lenWinUSB);
                    }
                }
                else
                {
                    ports = LibUsb_AsyncUsbStream.EnumeratePorts();
                }
            }
            break;

            case PortFilter.TcpIp:
                ports = PortDefinition_Tcp.EnumeratePorts(false);
                break;

            default:
                Debug.Assert(false);
                throw new ApplicationException();
            }

            return(ports);
        }
Ejemplo n.º 2
0
        static public ArrayList Enumerate(params PortFilter[] args)
        {
            ArrayList lst = new ArrayList();

            foreach (PortFilter pf in args)
            {
                PortDefinition[] res;

                switch (pf)
                {
                case PortFilter.Emulator:
                    res = Emulator.EnumeratePipes();
                    break;

                case PortFilter.Serial:
                    res = AsyncSerialStream.EnumeratePorts();
                    break;

                case PortFilter.LegacyPermiscuousWinUsb:
                case PortFilter.Usb:
                {
                    res = WinUsb_AsyncUsbStream.EnumeratePorts(pf == PortFilter.LegacyPermiscuousWinUsb);

                    lst.AddRange(res);

                    res = AsyncUsbStream.EnumeratePorts();
                    // res will be added to list below...
                }
                break;

                case PortFilter.TcpIp:
                    res = PortDefinition_Tcp.EnumeratePorts();
                    break;

                default: res = null; break;
                }

                if (res != null)
                {
                    lst.AddRange(res);
                }
            }

            return(lst);
        }
Ejemplo n.º 3
0
        private bool Connect()
        {
            Disconnect();

            try
            {
                _DBG.PortDefinition pd = (_DBG.PortDefinition)comboBoxPort.SelectedItem;

                string port     =                      pd.Port;
                uint   baudrate = uint.Parse( ((string)comboBoxBaud.SelectedItem) );

                using(_DBG.AsyncSerialStream stream = new _DBG.AsyncSerialStream( port, baudrate ))
                {
                    stream.Close();
                }

                m_eng = new _DBG.Engine( new Microsoft.SPOT.Debugger.PortDefinition_Serial( port, port, baudrate ) );

                m_eng.Silent = true;

                m_eng.Start();

                if(m_eng.TryToConnect( 4, 250 ))
                {
                    m_deviceRunning = true;

                    m_eng.PauseExecution();

                    m_ranges = m_eng.MemoryMap();
                    if(m_ranges == null)
                    {
                        //
                        // Fallback to some defaults.
                        //
                        m_ranges = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range[2];

                        m_ranges[0] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[0].m_address = 0x00000000;
                        m_ranges[0].m_length  = 0x00060000;
                        m_ranges[0].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_RAM;

                        m_ranges[1] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[1].m_address = 0x10000000;
                        m_ranges[1].m_length  = 1024*1024;
                        m_ranges[1].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_FLASH;
                    }
                }
                else
                {
                    m_deviceRunning = false;
                }


                m_ah = new _DBG.AbortHandler( m_eng, m_deviceRunning );

                m_ah.Start();

                
                bool connected = false;

                for(int tries=0; tries < 5; tries++)
                {
                    if(m_ah.ReadRegisters( m_snapshot.m_registers, out m_snapshot.m_cpsr, out m_snapshot.m_BWA, out m_snapshot.m_BWC ))
                    {
                        connected = true; break;
                    }

                    Thread.Sleep( 1000 );
                }

                if(connected)
                {
                    for(int tries=0; tries < 5; tries++)
                    {
                        if(m_ah.ReadLayout( out m_snapshot.m_flashBase, out m_snapshot.m_flashSize, out m_snapshot.m_ramBase, out m_snapshot.m_ramSize ))
                        {
                            break;
                        }

                        Thread.Sleep( 1000 );
                    }

                    return true;
                }

                if(!connected)
                {
                    MessageBox.Show( "Cannot connect to device" );
                }

                return connected;
            }
            catch(Exception ex)
            {
                MessageBox.Show( ex.Message );

                return false;
            }
        }
Ejemplo n.º 4
0
        private bool Connect()
        {
            Disconnect();

            try
            {
                _DBG.PortDefinition pd = (_DBG.PortDefinition)comboBoxPort.SelectedItem;

                string port     = pd.Port;
                uint   baudrate = uint.Parse(((string)comboBoxBaud.SelectedItem));

                using (_DBG.AsyncSerialStream stream = new _DBG.AsyncSerialStream(port, baudrate))
                {
                    stream.Close();
                }

                m_eng = new _DBG.Engine(new Microsoft.SPOT.Debugger.PortDefinition_Serial(port, port, baudrate));

                m_eng.Silent = true;

                m_eng.Start();

                if (m_eng.TryToConnect(4, 250))
                {
                    m_deviceRunning = true;

                    m_eng.PauseExecution();

                    m_ranges = m_eng.MemoryMap();
                    if (m_ranges == null)
                    {
                        //
                        // Fallback to some defaults.
                        //
                        m_ranges = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range[2];

                        m_ranges[0]           = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[0].m_address = 0x00000000;
                        m_ranges[0].m_length  = 0x00060000;
                        m_ranges[0].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_RAM;

                        m_ranges[1]           = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[1].m_address = 0x10000000;
                        m_ranges[1].m_length  = 1024 * 1024;
                        m_ranges[1].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_FLASH;
                    }
                }
                else
                {
                    m_deviceRunning = false;
                }


                m_ah = new _DBG.AbortHandler(m_eng, m_deviceRunning);

                m_ah.Start();


                bool connected = false;

                for (int tries = 0; tries < 5; tries++)
                {
                    if (m_ah.ReadRegisters(m_snapshot.m_registers, out m_snapshot.m_cpsr, out m_snapshot.m_BWA, out m_snapshot.m_BWC))
                    {
                        connected = true; break;
                    }

                    Thread.Sleep(1000);
                }

                if (connected)
                {
                    for (int tries = 0; tries < 5; tries++)
                    {
                        if (m_ah.ReadLayout(out m_snapshot.m_flashBase, out m_snapshot.m_flashSize, out m_snapshot.m_ramBase, out m_snapshot.m_ramSize))
                        {
                            break;
                        }

                        Thread.Sleep(1000);
                    }

                    return(true);
                }

                if (!connected)
                {
                    MessageBox.Show("Cannot connect to device");
                }

                return(connected);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                return(false);
            }
        }