Ejemplo n.º 1
0
        static public SSHUtil Connect(string host)
        {
            SSHUtil  ssh   = new SSHUtil(host);
            DateTime start = DateTime.Now;

            while (true)
            {
                try
                {
                    ssh.Connect();
                    break;
                }
                catch (System.Net.Sockets.SocketException ex)
                {
                    string msg = ex.Message;
                }

                TimeSpan ts = DateTime.Now - start;
                if (ts.TotalSeconds > 30)
                {
                    ssh.Dispose();
                    throw new Exception("Unable to connect to host: " + host);
                }
            }

            return(ssh);
        }
Ejemplo n.º 2
0
 static void exitShell(SSHUtil ssh, bool clear_data = true)
 {
     // Exit shell
     ssh.WriteWait("exit", "debug>", 3, clear_data: clear_data);
     // Exit debug
     ssh.WriteWait("exit", "#", 3, clear_data: clear_data);
 }
Ejemplo n.º 3
0
 static void enterShell(SSHUtil ssh, bool clear_data = true)
 {
     // Enter debug
     ssh.WriteWait("debug", "debug>", 3, clear_data: clear_data);
     // Enter shell
     ssh.WriteWait("sh", "#", 3, clear_data: clear_data);
 }
Ejemplo n.º 4
0
        string cleanup(SSHUtil ssh)
        {
            ssh.Data = "";

            enterShell(ssh, clear_data: false);

            string cmds = @"find /data/agent/ -type f -exec md5sum {} \; | sort -k 34 | md5sum";

            ssh.WriteWait(cmds, Regex.Escape(cmds) + ".*" + _ssh_prompt, 10, clear_data: false, isRegx: true);

            string[] cmd_list = new string[]
            {
                "cd /data/agent",
                "chmod 0777 /data/agent",
                "chown -R agent .",
                "chgrp -R agent .",
                "touch factory_reset",
                "rm -f /data/log/messages*",
                "rm -f /data/log/dmesg*",
                "rm -f /data/zwave_*",
                "cat /data/mfg_test_report.json",
                "rm -f /data/mfg_test_report.json",
                "sync"
            };
            foreach (string cmd in cmd_list)
            {
                ssh.WriteWait(cmd, Regex.Escape(cmd) + ".*" + _ssh_prompt, 5, clear_data: false, isRegx: true);
            }

            exitShell(ssh, clear_data: false);

            return(ssh.Data);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Truns all LEDs on and then off capturing
        /// voltage values
        /// </summary>
        /// <returns>RGY on and off values</returns>
        public double[] GetLEDsValues()
        {
            double[] values = new double[6];

            // Trun power on
            BatteryJig.Set_all_relays(false);
            BatteryJig.Write_SingleDIO(BatteryJig.Relays.DUT, true);

            SSHUtil ssh = Connect(_host);

            try
            {
                bootWait(ssh);
                enterShell(ssh);

                bool state = true;
                _red_led.Turn(state, ssh);
                _yellow_led.Turn(state, ssh);
                _green_led.Turn(state, ssh);

                Thread.Sleep(500);

                double vred_on    = _red_led.Value;
                double vgreen_on  = _green_led.Value;
                double vyellow_on = _yellow_led.Value;

                state = false;
                _red_led.Turn(state, ssh);
                _yellow_led.Turn(state, ssh);
                _green_led.Turn(state, ssh);

                Thread.Sleep(500);

                double vred_off    = _red_led.Value;
                double vgreen_off  = _green_led.Value;
                double vyellow_off = _yellow_led.Value;

                int i = 0;
                values[i++] = vred_on;
                values[i++] = vgreen_on;
                values[i++] = vyellow_on;
                values[i++] = vred_off;
                values[i++] = vgreen_off;
                values[i++] = vyellow_off;

                exitShell(ssh);
            }
            finally
            {
                ssh.Dispose();
            }

            return(values);
        }
Ejemplo n.º 6
0
        public void Turn(bool value, SSHUtil ssh)
        {
            if (ColorName == null)
            {
                throw new Exception("Color name not set");
            }
            string path = string.Format(_fs_control_path_fmt, ColorName);

            string cmd;

            if (value)
            {
                cmd = "echo 1 > " + path;
            }
            else
            {
                cmd = "echo 0 > " + path;
            }

            ssh.WriteLine(cmd);
        }
Ejemplo n.º 7
0
        public void SaveShowMfg(SSHUtil ssh)
        {
            // Make sure we can talk to hub
            ssh.WriteWait("", "#", 3);
            ssh.Data = "";
            string mfg_data = ssh.WriteWait("show mfg", "Batch Number:", 3);

            fire_status("SMT_Number: " + _smt_serial);
            fire_status(mfg_data);

            string fileloc = Path.Combine(this.LogFolder, "b" + _smt_serial.ToString() + ".txt");

            using (FileStream fs = new FileStream(fileloc, FileMode.Create, FileAccess.Write, FileShare.Read))
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.WriteLine("SMT_Number: " + _smt_serial);

                    sw.Write(mfg_data);
                    sw.Close();
                }
        }
Ejemplo n.º 8
0
        //# show battery

        //Battery Information:
        //Voltage:         1.10
        //Maximum Voltage: 1.10
        //Level:           -1.00

        public void Run()
        {
            // There seems to be a problem with the jigs I have not been able to discovered yet.
            // The test should be to apply battery power fisrt, then main power and the board should boot.
            // Does not happen in the jig.
            // I'm able to sypply battery power using jig and manually connect main power to a transformer and
            // it works. So it seems to be a problem with the jig and not the units.

            fire_status("Cycle Power");
            BatteryJig.Set_all_relays(false);
            Thread.Sleep(500);
            fire_status("Power on DUT");
            BatteryJig.Write_SingleDIO(BatteryJig.Relays.DUT, true);
            Thread.Sleep(1000);


            fire_status("LED Boot Test...");
            DateTime start = DateTime.Now;

            LEDBootPatternTest();
            TimeSpan ts_total  = DateTime.Now - start;
            int      ts_towait = 4000 - (int)ts_total.TotalSeconds * 1000;

            if (ts_towait > 0)
            {
                Thread.Sleep((int)ts_towait);
            }

            fire_status("Power on BATTERY");
            BatteryJig.Write_SingleDIO(BatteryJig.Relays.BATT, true);
            Thread.Sleep(1000);

            // Try to connect
            fire_status("Connecting...");
            SSHUtil ssh = Connect(_host);

            try
            {
                bootWait(ssh);

                fire_status("Battery Test");
                string data  = ssh.WriteWait("show battery", "Level:", 3);
                double volts = parseVolatge(data);
                string msg   = string.Format("Battery voltage before DUT power removed detected at {0}", volts);
                fire_status(msg);
                if (volts < 5.0)
                {
                    msg = string.Format("Battery power before DUT power removed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }


                fire_status("DUT power off");
                BatteryJig.Write_SingleDIO(BatteryJig.Relays.DUT, false);
                Thread.Sleep(3000);

                data  = ssh.WriteWait("show battery", "Level:", 3);
                volts = parseVolatge(data);
                msg   = string.Format("Battery voltage after DUT power removed detected at {0}", volts);
                fire_status(msg);
                if (volts < 4.0)
                {
                    msg = string.Format("Battery power after DUT power removed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }

                fire_status("DUT power back on");
                BatteryJig.Write_SingleDIO(BatteryJig.Relays.DUT, true);
                Thread.Sleep(1000);

                data  = ssh.WriteWait("show battery", "Level:", 3);
                volts = parseVolatge(data);
                msg   = string.Format("Battery voltage after DUT power re-applied at {0}", volts);
                fire_status(msg);
                if (volts < 5.0)
                {
                    msg = string.Format("Battery power after DUT power ed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }

                SaveShowMfg(ssh);

                if (InvalidateEnabled)
                {
                    fire_status("Clean up...");
                    data = cleanup(ssh);
                    fire_status(data, Status_Level.Debug);

                    fire_status("Invalidate...");
                    //# boot invalidate
                    //Current partition has been invalidated!
                    ssh.WriteWait("boot invalidate", "Current partition has been invalidated!", 5);

                    fire_status("Reboot");
                    ssh.WriteWait("reboot", "The system is going down for reboot NOW");
                    BatteryJig.Write_SingleDIO(BatteryJig.Relays.BATT, false); // If batt is not off, we can't reboot (weird!)
                    Thread.Sleep(5000);

                    // Check for the boot LED pattern until it fails
                    fire_status("Wait for LED Boot pattern...");
                    LEDBootPatternTest();
                    fire_status("Wait for LED Boot pattern to change...");
                    start = DateTime.Now;
                    TimeSpan ts;
                    while (true)
                    {
                        try
                        {
                            LEDBootPatternTest();
                            Thread.Sleep(3000);
                        }
                        catch
                        {
                            break;
                        }

                        ts = DateTime.Now - start;
                        if (ts.TotalSeconds > 30)
                        {
                            throw new Exception("LED pattern did not changed");
                        }
                    }
                    ts = DateTime.Now - start;
                    // The LED patter should have changed
                    fire_status("LED pattern change detected after " + ts.Seconds + " seconds.");

                    fire_status("Wait for LED Inavlidated pattern...");
                    LEDInvalidatedPatternTest();

                    // Check our connection is not good anymore
                    fire_status("Test for not connected");
                    if (ssh.IsConnected)
                    {
                        throw new Exception("Our ssh is still connected. Are you sure the hub rebootted?");
                    }

                    // Now try to connect
                    // It should not let os
                    fire_status("Test connecting is not possible");
                    try
                    {
                        ssh.Connect();
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }

                    // To revert using chipserver
                    //jumpered lowes hub
                    //power up
                    //root/a1
                    //mount /dev/mmcblk0p5 /mnt
                    //vi /mnt/bootindex
                    //# Change to 5
                    //sync
                    //umount /mnt
                    //# Remove jumper
                    //reboot
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                ssh.Dispose();
            }
        }
Ejemplo n.º 9
0
 static void bootWait(SSHUtil ssh)
 {
     ssh.WaitFor("IRIS MFG Shell.*#", 5, isRegx: true);
 }
Ejemplo n.º 10
0
        public void Run()
        {
            fire_status("Insert BATTERIES and press enter to continue.");
            Console.ReadLine();

            fire_status("Connect POWER adaptor and check all LEDs blink.  Press Y if they do, N if not");
            while (true)
            {
                char c = Console.ReadKey().KeyChar;
                if (c == 'y' || c == 'Y')
                {
                    break;
                }
                else if (c == 'n' || c == 'N')
                {
                    throw new Exception("No all LEDs blinked at first power up.");
                }
            }


            fire_status("Connecting...");
            SSHUtil ssh = Connect(_host);

            try
            {
                bootWait(ssh);

                fire_status("Battery Test");

                string data;
                double volts;
                string msg = "";

                string cmd         = "show battery";
                string outputcheck = "Level:";
                fire_status("Outputcheck: " + outputcheck);
                data  = ssh.WriteWait(cmd, outputcheck, 3);
                volts = parseVolatge(data);
                msg   = string.Format("Battery voltage before DUT power removed detected at {0}", volts);
                fire_status(msg);
                if (volts < 5.0)
                {
                    msg = string.Format("Battery power before DUT power removed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }

                fire_status("Remove the POWER adapter and press enter to continue.");
                Console.ReadLine();
                Thread.Sleep(3000);
                data  = ssh.WriteWait(cmd, outputcheck, 3);
                volts = parseVolatge(data);
                msg   = string.Format("Battery voltage after DUT power removed detected at {0}", volts);
                fire_status(msg);
                if (volts < 4.0)
                {
                    msg = string.Format("Battery power after DUT power removed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }

                fire_status("Reconnect the POWER adapter and press enter to continue");
                Console.ReadLine();

                data  = ssh.WriteWait(cmd, outputcheck, 3);
                volts = parseVolatge(data);
                msg   = string.Format("Battery voltage after DUT power re-applied at {0}", volts);
                fire_status(msg);
                if (volts < 5.0)
                {
                    msg = string.Format("Battery power after DUT power ed too low.  Detected at {0}", volts);
                    throw new Exception(msg);
                }

                SaveShowMfg(ssh);

                if (InvalidateEnabled)
                {
                    fire_status("Clean up...");
                    data = cleanup(ssh);
                    fire_status(data, Status_Level.Debug);

                    fire_status("Invalidate...");
                    ssh.WriteWait("boot invalidate", "Current partition has been invalidated!", 5);

                    fire_status("Rebooting");
                    ssh.WriteWait("reboot", "The system is going down for reboot NOW");
                    Thread.Sleep(5000);

                    // Check for the boot LED pattern until it fails
                    // The LED patter should have changed
                    fire_status("LED blinking pattern should change.  Only GREEN and YELLOW bliking. Y/N?");
                    while (true)
                    {
                        char c = Console.ReadKey().KeyChar;
                        if (c == 'y' || c == 'Y')
                        {
                            break;
                        }
                        else if (c == 'n' || c == 'N')
                        {
                            throw new Exception("LEDs blinking pattern did not change.");
                        }
                    }

                    // Check our connection is not good anymore
                    fire_status("Test for not connected");
                    if (ssh.IsConnected)
                    {
                        throw new Exception("Our ssh is still connected. Are you sure the hub rebootted?");
                    }

                    // Now try to connect
                    // It should not let os
                    fire_status("Test connecting is not possible");
                    try
                    {
                        ssh.Connect();
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }

                    // To revert using chipserver
                    //jumpered lowes hub
                    //power up
                    //root/a1
                    //mount /dev/mmcblk0p5 /mnt
                    //vi /mnt/bootindex
                    //# Change to 5
                    //sync
                    //umount /mnt
                    //# Remove jumper
                    //reboot
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                ssh.Dispose();
            }
        }