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