Exemplo n.º 1
0
 public override void Stop()
 {
     logger.Log("Stop() at {0}", ToString());
     if (connectionChecker != null && connectionChecker.IsAlive())
     {
         connectionChecker.Abort();
         connectionChecker.Join();
     }
     serialPort.Close();
     Finished();
 }
Exemplo n.º 2
0
        public override void Start()
        {
            string embedDriverArgs = moduleInfo.Args()[0];
            string comPortName     = embedDriverArgs;

            if (!String.IsNullOrEmpty(comPortName))
            {
                if (comPortName.Contains(MBED))
                {
                    comPortName = comPortName.Replace(MBED + " - ", "");
                }
                this.portName = comPortName;
            }
            connectionChecker = new SafeThread(delegate() { CheckComConnection(); }, "ComPort connection-checker", logger);
            if (InitializePort() == true)
            {
                try
                {
                    serialPort.Open();
                    connectionChecker.Start();
                    while (!connectionChecker.IsAlive())
                    {
                        ;
                    }
                }
                catch (Exception)
                {
                    List <COMPortFinder> comportList = COMPortFinder.GetCOMPortsInfo();

                    foreach (COMPortFinder comPortInfo in comportList)
                    {
                        if (comPortInfo.Description.Contains(MBED))
                        {
                            this.portName = comPortInfo.Name;
                            break;
                        }
                    }
                    InitializePort();
                    //serialPort.Open();
                }

                //testPort();
            }


            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(embedDriverArgs);

            mbedPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleMbedSoftUps.Instance
            };

            BindRoles(mbedPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(mbedPort);
        }