Exemple #1
0
        void login(SerialCOM port)
        {
            fire_status("Wait for login...");

            //port.WaitFor("login:"******"", "login:"******"Login");
            port.WriteWait("root", "IRIS MFG Shell.*#", 10, isRegx: true);
        }
Exemple #2
0
        public void Dispose()
        {
            if (_dutport != null)
            {
                _dutport.Dispose();
                _dutport = null;
            }

            if (_bleport != null)
            {
                _bleport.Dispose();
                _bleport = null;
            }

            if (_fs_dut_data != null)
            {
                _fs_dut_data.Close();
                _fs_dut_data.Dispose();
                _fs_dut_data = null;
            }

            if (_fs_ble_data != null)
            {
                _fs_ble_data.Close();
                _fs_ble_data.Dispose();
                _fs_ble_data = null;
            }
        }
Exemple #3
0
        public void BLETest()
        {
            using (SerialCOM dutport = getDUTPort())
                using (SerialCOM bleport = getBLEPort())
                {
                    // Make sure we can talk to hubs
                    dutport.WriteWait("", "#", 3);

                    Random rand    = new Random(DateTime.Now.Second);
                    int    channel = rand.Next(0, 27);
                    bleport.WriteLine("ble_rx " + channel.ToString() + " 3000");
                    dutport.WriteLine("ble_tx " + channel.ToString());
                    bleport.WaitFor("Packets received:", 5, clear_data: false);
                    string data  = bleport.Data;
                    Match  match = Regex.Match(data, @"Packets received: (\d*)", RegexOptions.Singleline);
                    if (!match.Success || match.Groups.Count < 2)
                    {
                        string emsg = string.Format("Unable to get packets received from BLE master.\r\nData was: {0}", data);
                        throw new Exception(emsg);
                    }
                    int packets_received = Convert.ToInt32(match.Groups[1].Value);
                    // if (packets_received < 1500)
                    if (packets_received < 800)
                    {
                        string emsg = string.Format("BLE packets received < 1500.\r\nPackets received were: {0}", packets_received);
                        throw new Exception(emsg);
                    }
                    string rmsg = string.Format("BLE packets received: {0}", packets_received);
                    fire_status(rmsg);
                }
        }
Exemple #4
0
 void exitShell(SerialCOM port)
 {
     // Exit shell
     port.WriteWait("exit", "debug>", 3);
     // Exit debug
     port.WriteWait("exit", "#", 3);
 }
Exemple #5
0
        public void ShowRadios()
        {
            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                dutport.WaitForPrompt();

                dutport.WriteWait("show radios", "Zwave Stack Version", timeout_sec: 5, clear_data: false);
                string data = dutport.Data;
                Match  m    = Regex.Match(data, @"Z-Wave (\d+\.\d+)", RegexOptions.Singleline);
                if (m.Success && m.Groups.Count > 1)
                {
                    string verstr = m.Groups[1].Value;

                    fire_status("Zwave Stack Version: " + verstr);
                    bool needToUpdate = needsUpdate(verstr, _zwave_ver_major, _zwave_ver_minor);
                    if (needToUpdate)
                    {
                        throw new Exception("Unexpected Zwave version: " + verstr);
                    }
                }
                else
                {
                    throw new Exception("Unable to detect Zwave version.\r\nData was: " + data);
                }
            }
        }
Exemple #6
0
 void enterShell(SerialCOM port)
 {
     // Enter debug
     port.WriteWait("debug", "debug>", 3);
     // Enter Shelf
     port.WriteWait("sh", "#", 3);
 }
Exemple #7
0
        string setHubIpAddr(string ipaddr, string adapter = "eth0", string netmask = "255.255.0.0")
        {
            string data;

            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                dutport.WriteWait("", "#", 3);

                enterShell(dutport);

                try
                {
                    string cmd = string.Format("ifconfig {0} {1} netmask {2}", adapter, ipaddr, netmask);
                    dutport.WriteWait(cmd, Regex.Escape(cmd) + ".*" + _shell_prompt, timeout_sec: 3, isRegx: true);

                    cmd  = "ifconfig";
                    data = dutport.WriteWait(cmd, Regex.Escape(cmd) + ".*" + _shell_prompt, timeout_sec: 3, isRegx: true);
                }
                finally
                {
                    exitShell(dutport);
                }
            }

            return(data);
        }
Exemple #8
0
 SerialCOM getBLEPort()
 {
     if (_bleport == null || _bleport.IsDisposed)
     {
         _bleport = new SerialCOM(_bleport_name);
         _bleport.DataReceived += _bleport_DataReceived;
     }
     return(_bleport);
 }
Exemple #9
0
 SerialCOM getDUTPort()
 {
     if (_dutport == null || _dutport.IsDisposed)
     {
         _dutport = new SerialCOM(_dutport_name);
         _dutport.DataReceived += _dutport_DataReceived;
     }
     return(_dutport);
 }
Exemple #10
0
        /// <summary>
        /// Zeus certificate server: `172.24.32.6`
        /// </summary>
        public void Certificate()
        {
            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                dutport.WriteWait("", "#", 3);

                dutport.WriteWait("certificate " + _certificate_server + " skip_ca_check true", "Key install was successful", 5);

                fire_status("Key install was successful");
            }
        }
Exemple #11
0
        /// <summary>
        /// Based on test spec:LOWESHUB-65830935-070716-0910-4
        ///
        /// And from Edgar:
        /// "Zwave_test" is needed to verify Zwave version is equal or higher to 4.05,
        /// if it is lower (all new components have lower version),
        /// then you have to send "zwave_flash -w /data/firmware/zwave-firmware.bin\n".
        /// </summary>
        public void ZWaveUpdate()
        {
            _zwave_updated = false;
            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                dutport.WriteWait("", "#", 3);

                enterShell(dutport);

                try
                {
                    dutport.WriteWait("zwave_test -v", "Zwave Stack Version:", timeout_sec: 5, clear_data: false);
                    string data = dutport.Data;
                    Match  m    = Regex.Match(data, @"Z-Wave (\d+\.\d+)", RegexOptions.Singleline);
                    if (m.Success && m.Groups.Count > 1)
                    {
                        string verstr = m.Groups[1].Value;
                        fire_status("Zwave Stack Version: " + verstr);
                        bool needToUpdate = needsUpdate(verstr, _zwave_ver_major, _zwave_ver_minor);
                        if (needToUpdate)
                        {
                            fire_status("Zwave Updating...");
                            dutport.WriteWait(
                                "zwave_flash -w /data/firmware/zwave-firmware.bin",
                                "Flash programming complete", 60);
                            fire_status("Zwave Flash programming complete");

                            dutport.WriteWait("zwave_default", "Zwave module has been factory defaulted", 3);
                            fire_status("Zwave module has been factory defaulted");

                            _zwave_updated = true;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to extract Z-Wave version info.\r\nData was: " + data);
                    }
                }
                finally
                {
                    exitShell(dutport);
                }
            }
        }
Exemple #12
0
        public void SaveShowMfg()
        {
            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                dutport.WriteWait("", "#", 3);
                dutport.Data = "";
                string mfg_data = dutport.WriteWait("show mfg", "Batch Number:", 3);

                fire_status(mfg_data);

                string fileloc = Path.Combine(this.LogFolder, "d" + SMT_Serial.ToString() + ".txt");
                using (FileStream fs = new FileStream(fileloc, FileMode.Create, FileAccess.Write, FileShare.Read))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write(mfg_data);
                        sw.Close();
                    }
            }
        }
Exemple #13
0
        public void Serialize()
        {
            using (CLStoreEntities cx = new CLStoreEntities())
                using (SerialCOM port = getDUTPort())
                {
                    // Make sure we can talk to hub
                    port.WriteLine();
                    port.WaitFor("#", 3);

                    LowesHub loweshub_data = new LowesHub();

                    // Gather info to serialize hub
                    int production_site_id = MACAddrUtils.ProductionSiteId();
                    while (production_site_id > byte.MaxValue)
                    {
                        production_site_id = production_site_id >> 1;
                    }

                    int test_station_id = MACAddrUtils.StationSiteId();
                    loweshub_data.test_station_id = test_station_id;
                    while (test_station_id > byte.MaxValue)
                    {
                        test_station_id = test_station_id >> 1;
                    }

                    int hw_ver = HW_Ver;
                    loweshub_data.hw_ver = HW_Ver;
                    while (hw_ver > byte.MaxValue)
                    {
                        hw_ver = hw_ver >> 1;
                    }

                    int operator_id = DataUtils.OperatorId(_tester);
                    loweshub_data.operator_id = operator_id;
                    while (operator_id > short.MaxValue)
                    {
                        operator_id = operator_id >> 1;
                    }

                    _lowes_serial = LowesSerial.GetSerial(
                        model: LowesSerial.Model.IH200,
                        hw_version: (byte)hw_ver,
                        datetime: DateTime.Now,
                        factory: (byte)production_site_id,
                        test_station: (byte)test_station_id,
                        tester: (short)operator_id);

                    int customer_id = cx.LowesCustomers.Where(c => c.Name == Customer.ToString()).Single().Id;

                    // See if this board already had a mac assigned
                    long mac   = MACAddrUtils.INVALID_MAC;
                    var  hubsq = cx.LowesHubs.Where(h => h.smt_serial == SMT_Serial).OrderByDescending(h => h.date);
                    if (hubsq.Any())
                    {
                        var hubs = hubsq.ToArray();
                        foreach (LowesHub hub in hubs)
                        {
                            long hubmac = hub.MacAddress.MAC;
                            if (MACAddrUtils.Inrange(hubmac))
                            {
                                mac = hubmac;
                                break;
                            }
                        }
                    }
                    if (mac == MACAddrUtils.INVALID_MAC)
                    {
                        mac = MACAddrUtils.GetNewMac();
                    }
                    int mac_id = MACAddrUtils.GetMacId(mac);


                    string macstr = MACAddrUtils.LongToStr(mac);


                    string cmd = string.Format("serialize {0} model {1} customer {2} hw_version {3} batch_no {4}",
                                               macstr, Serialize_Model, Customer.ToString(), HW_Ver, Lowes_Serial);

                    fire_status(cmd);
                    port.WriteLine(cmd);
                    port.WaitFor("Device serialization is complete - please reboot", 5);
                    fire_status("Device serialization is complete.");

                    port.Data = "";
                    string mfg_data = port.WriteWait("show mfg", "Batch Number:", 3);
                    Regex  regx     = new Regex(@"HubID:\s+([A-Z]+-\d+)");
                    Match  m        = regx.Match(mfg_data);
                    if (!m.Success || m.Groups.Count < 2)
                    {
                        string emsg = string.Format("Unable to extract Hub id from data:{0}", mfg_data);
                        throw new Exception(emsg);
                    }
                    string hubid = m.Groups[1].Value;
                    fire_status("Hub ID: " + hubid);

                    // Insert the hub
                    loweshub_data.customer_id  = customer_id;
                    loweshub_data.mac_id       = mac_id;
                    loweshub_data.smt_serial   = SMT_Serial.ToString().ToUpper();
                    loweshub_data.lowes_serial = Lowes_Serial;
                    loweshub_data.hub_id       = hubid;

                    cx.LowesHubs.Add(loweshub_data);
                    cx.SaveChanges();
                }
        }
Exemple #14
0
        public void Diagnostics()
        {
            using (SerialCOM dutport = getDUTPort())
            {
                // Make sure we can talk to hub
                //dutport.WriteWait("", "#", 3, clear_data:false);
                dutport.WaitForPrompt();

                // Diags
                fire_status("Start diagnostics");
                dutport.WriteWait("diagnostics", "Press the reset button...", 3);

                fire_status("Press the reset button...");
                write_SingleDIO(Relays.BUTTON, true);
                dutport.WaitFor(@"Insert both USB drives and attach increased load to usb0. Press <enter> when ready...", 10);
                fire_status("USB0 Test");
                write_SingleDIO(Relays.USB1, true);
                Thread.Sleep(500);
                dutport.WriteLine();

                dutport.WaitFor(@"Remove increased load from usb0 and attach load to usb1. Press <enter> when ready...", 5);
                fire_status("USB1 Test");
                write_SingleDIO(Relays.USB1, false);
                write_SingleDIO(Relays.USB2, true);
                Thread.Sleep(500);
                dutport.WriteLine();

                fire_status("Buzzer Test");
                dutport.WaitFor("Buzzer on?", 3);
                double val    = -1.0;
                double expval = 3.0;
                for (int i = 0; i < 5; i++)
                {
                    val = read_SingelAi(Sensors.BUZZER_AUDIO);
                    fire_status(string.Format("Buzzer Voltage: {0}", val.ToString("f2")));
                    if (val > expval)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                if (val > 3.0)
                {
                    dutport.WriteLine("y");
                }
                else
                {
                    dutport.WriteLine("n");
                    string emsg = string.Format("Unable to detect buzzer. Volatgae was: {0}. Expected more than {1}",
                                                val.ToString("f2"), expval.ToString("f2"));
                    throw new Exception(emsg);
                }


                fire_status("LED Tests");
                led_test(Sensors.GREEN_LIGHT, LED_Green_Low_Value, LED_Green_High_Value, "green");
                led_test(Sensors.RED_LIGHT, LED_Red_Low_Value, LED_Red_High_Value, "red");
                led_test(Sensors.YELLOW_LIGHT, LED_Yellow_Low_Value, LED_Yellow_High_Value, "yellow");

                // Other tests
                fire_status("Other Built-in Tests...");
                dutport.WaitFor("All Tests Passed", 20);
                fire_status("All Tests Passed");
            }
        }
Exemple #15
0
        public void Run()
        {
            DateTime start_time = DateTime.Now;

            // Init the serial data log files
            string fileloc = Path.Combine(LogFolder, "log_dut_data.txt");

            _fs_dut_data = new FileStream(fileloc, FileMode.Create, FileAccess.Write, FileShare.Read);

            fileloc      = Path.Combine(LogFolder, "log_ble_data.txt");
            _fs_ble_data = new FileStream(fileloc, FileMode.Create, FileAccess.Write, FileShare.Read);

            Set_all_relays(false);
            Thread.Sleep(500);
            using (SerialCOM dutport = getDUTPort())
                using (SerialCOM bleport = getBLEPort())
                {
                    // Turn BLE board so
                    fire_status("Power up BLE master");
                    write_SingleDIO(Relays.BLE, true);
                    bleport.WaitFor("U-Boot", 3);

                    // Turn DUT on
                    fire_status("Power up DUT");
                    write_SingleDIO(Relays.DUT, true);
                    dutport.WaitFor("U-Boot", 3);
                    Thread.Sleep(3000);

                    // Login
                    fire_status("Login to DUT");
                    login(dutport);

                    // Program_Radios
                    if (Program_Radios)
                    {
                        fire_status("Program Radios");
                        dutport.Data = "";
                        DateTime t1 = DateTime.Now;
                        dutport.WriteLine("program_radios");
                        string data = dutport.WaitFor("Radio programming is complete.", Program_Radios_Timeout_Sec);
                        if (data.Contains("Error"))
                        {
                            throw new Exception("Errors detected during program radios.\r\nOutput was:\r\n" + data);
                        }
                        TimeSpan ts1 = DateTime.Now - t1;
                        fire_status("Radio programming is complete after " + ts1.TotalSeconds.ToString() + "sec");
                    }
                }

            if (_hub_ip != null && _hub_ip != "")
            {
                fire_status("Set Hub IP to " + _hub_ip);
                string data = setHubIpAddr(_hub_ip);
                fire_status(data);
            }

            fire_status("ZWave Update...");
            ZWaveUpdate();

            if (_zwave_updated)
            {
                fire_status("Show Radios...");
                ShowRadios();
            }

            fire_status("Diagnostics...");
            Diagnostics();

            if (BLETestDisable)
            {
                fire_status("BLE Test DISABLED!!!");
            }
            else
            {
                fire_status("BLE Test...");
                using (SerialCOM bleport = getBLEPort())
                {
                    fire_status("Login to BLE");
                    login(bleport);
                }
                int trycount = 0;
                while (true)
                {
                    try
                    {
                        BLETest();
                        break;
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        if (!msg.Contains("BLE packets received"))
                        {
                            throw;
                        }

                        if (trycount++ > 3)
                        {
                            throw;
                        }
                    }
                }
            }

            fire_status("Serialize...");
            Serialize();

            fire_status("Certificate...");
            Certificate();

            fire_status("Show Mfg...");
            SaveShowMfg();

            TimeSpan ts   = DateTime.Now - start_time;
            string   tmsg = string.Format("ETime: {0}s.", ts.TotalSeconds);

            fire_status(tmsg);
        }