示例#1
0
    private void autoDetect(ChronopicAuto caNormal)
    {
        LogB.Information("starting port detection");

        string [] usbSerial = ChronopicPorts.GetPorts();

        bool first = true;

        foreach (string port in usbSerial)
        {
            if (configAutoDetect == Config.AutodetectPortEnum.DISCARDFIRST && first)
            {
                first = false;
                LogB.Warning("Discarded port = ", port);
                continue;
            }

            SerialPort sp = new SerialPort(port);

            LogB.Information("searching normal Chronopic at port: ", port);
            string readed = caNormal.Read(sp);

            if (caNormal.Found == ChronopicType.NORMAL)            //We found a normal Chronopic
            {
                if (searched == ChronopicType.NORMAL)              //normal Chronopic is what we are searching
                {
                    Detected = port;
                    return;
                }
                else
                {
                    /*
                     * else:
                     * means that we are searching for an encoder chronopic and found a normal
                     * so don't try to search for an encoder on that port, because 115200 bauds will saturate it
                     */
                    LogB.Information("our goal is to search encoder but found normal Chronopic at port: ", port);
                }
            }
            else if (searched == ChronopicType.ENCODER)
            {
                /*
                 * we are searching an encoder
                 * if we arrived here, we know is not a normal chronopic
                 * then wecan search safely for an encoder here
                 */
                ChronopicAuto caEncoder = new ChronopicAutoCheckEncoder();
                caEncoder.IsEncoder = true;                    //for the bauds.

                LogB.Information("searching encoder Chronopic at port: ", port);
                readed = caEncoder.Read(sp);
                if (caEncoder.Found == ChronopicType.ENCODER)
                {
                    Detected = port;
                    return;
                }
            }
        }
        Detected = "";
    }
示例#2
0
 protected override void select()
 {
     l_types = new List <object>();
     string [] strArray = ChronopicPorts.GetPorts();
     foreach (string str in strArray)
     {
         l_types.Add(str);
     }
 }
示例#3
0
 private void setEncoderPort(string myEncoderPort)
 {
     if (Util.FoundInStringArray(ChronopicPorts.GetPorts(), myEncoderPort))
     {
         encoderPort = myEncoderPort;
     }
     else
     {
         encoderPort = Util.GetDefaultPort();
     }
 }
示例#4
0
    private List <string> getPorts(bool debug)
    {
        //TODO: move that method here
        List <string> l = new List <string>(ChronopicPorts.GetPorts());       //usb-serial ports

        if (debug)
        {
            foreach (string p in l)
            {
                LogB.Information(string.Format("port: " + p));
            }
        }

        return(l);
    }
示例#5
0
    ArrayList detectPorts()
    {
        //detect ports
        string [] ports = ChronopicPorts.GetPorts();

        //get only new ports
        ArrayList portsNew = new ArrayList(0);

        foreach (string pNew in ports)
        {
            if (!Util.FoundInArrayList(portsAlreadyDetected, pNew))
            {
                portsAlreadyDetected.Add(pNew);
                portsNew.Add(pNew);
            }
        }

        return(portsNew);
    }