Ejemplo n.º 1
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.º 2
0
        static int Main(string[] args)
        {
            //Console.WriteLine("Press Enter to continue");
            //Console.Read();

            _log.Info("App started");

            var options        = new Options();
            var parser_options = new CommandLine.ParserSettings {
                MutuallyExclusive = true
            };
            var parser  = new CommandLine.Parser(parser_options);
            var isValid = parser.ParseArguments(args, options);

            if (!isValid)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                return(-1);
            }

            // Don't allow lower case serial
            options.SMT_Serial = options.SMT_Serial.ToUpper();
            Console.WriteLine("SMT Serial: " + options.SMT_Serial);
            Console.WriteLine("Host: " + options.Host);
            Console.WriteLine();


            // Check board was passed diags
            try
            {
                using (CLStoreEntities cx = new CLStoreEntities())
                {
                    LowesHub h    = cx.LowesHubs.Where(lh => lh.smt_serial == options.SMT_Serial).OrderByDescending(lh => lh.date).First();
                    string   info = string.Format("Hub {0} last diags {1}", h.MacAddress.MAC.ToString("X"), h.date.ToString());
                    _log.Info(info);
                }
            }
            catch (Exception ex)
            {
                _log.Fatal("Problem retrieving Hub diag info\r\n\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                return(-3);
            }


            if (options.CalibrateLEDs)
            {
                BatteryTest batcal = new BatteryTest(options.Host, options.SMT_Serial);

                char save_option = 'n';
                while (true)
                {
                    Console.WriteLine("Getting LEDs values...\r\n");
                    double[] values = batcal.GetLEDsValues();
                    int      i      = 0;

                    Console.WriteLine("Red On   : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Green On : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Yellow On: {0}", values[i++].ToString("G2"));

                    Console.WriteLine();

                    Console.WriteLine("Red Off   : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Green Off : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Yellow Off: {0}", values[i++].ToString("G2"));

                    i = 0;
                    Properties.Settings.Default.LED_Red_On_Val    = values[i++];
                    Properties.Settings.Default.LED_Green_On_Val  = values[i++];
                    Properties.Settings.Default.LED_Yellow_On_Val = values[i++];

                    Properties.Settings.Default.LED_Red_Off_Val    = values[i++];
                    Properties.Settings.Default.LED_Green_Off_Val  = values[i++];
                    Properties.Settings.Default.LED_Yellow_Off_Val = values[i++];

                    Console.WriteLine("Save Values? (y/n/r):");
                    save_option = Convert.ToChar(Console.Read());
                    if (save_option != 'r')
                    {
                        break;
                    }
                }
                if (save_option == 'y')
                {
                    Properties.Settings.Default.Save();
                }
            }

            try
            {
                if (!options.NoJigMode)
                {
                    BatteryTest battery_test = new BatteryTest(options.Host, options.SMT_Serial);

                    battery_test.InvalidateEnabled = !options.DisableInvalidate;
                    battery_test.Status_Event     += Battery_test_Status_Event;

                    battery_test.LogFolder = Properties.Settings.Default.Log_Folder;
                    Directory.CreateDirectory(battery_test.LogFolder);

                    battery_test.LED_Red.OnVal     = Properties.Settings.Default.LED_Red_On_Val;
                    battery_test.LED_Red.OffVal    = Properties.Settings.Default.LED_Red_Off_Val;
                    battery_test.LED_Green.OnVal   = Properties.Settings.Default.LED_Green_On_Val;
                    battery_test.LED_Green.OffVal  = Properties.Settings.Default.LED_Green_Off_Val;
                    battery_test.LED_Yellow.OnVal  = Properties.Settings.Default.LED_Yellow_On_Val;
                    battery_test.LED_Yellow.OffVal = Properties.Settings.Default.LED_Yellow_Off_Val;

                    battery_test.Run();
                }
                else
                {
                    BatteryTestNoJig batery_test = new BatteryTestNoJig(options.Host, options.SMT_Serial);
                    batery_test.InvalidateEnabled = !options.DisableInvalidate;

                    batery_test.Status_Event += Baterytest_Status_Event;

                    batery_test.LogFolder = Properties.Settings.Default.Log_Folder;
                    Directory.CreateDirectory(batery_test.LogFolder);

                    batery_test.Run();
                }
            }
            catch (Exception ex)
            {
                _log.Fatal(ex.Message + "\r\n" + ex.StackTrace);
                return(-2);
            }
            finally
            {
                if (!options.NoJigMode)
                {
                    BatteryJig.Set_all_relays(false);
                }
            }

            _log.Info("All Tests Passed");

            if (!options.PrintLabelDisabled)
            {
                _log.Info("Printing label...");
                try
                {
                    DataUtils.PrintHubLabel(
                        options.SMT_Serial,
                        Properties.Settings.Default.ZPL_Lable_File,
                        Properties.Settings.Default.Printer_Address);
                }
                catch (Exception ex)
                {
                    _log.Fatal(ex.Message + "\r\n" + ex.StackTrace);
                    return(-2);
                }
                finally
                {
                }
            }

            return(0);
        }
Ejemplo n.º 3
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();
            }
        }