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); }
/// <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); }
//# 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(); } }
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(); } }