diff options
Diffstat (limited to '')
-rw-r--r-- | heimdall/source/PrintPitAction.cpp | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/heimdall/source/PrintPitAction.cpp b/heimdall/source/PrintPitAction.cpp index c520d1c..cdf5b4e 100644 --- a/heimdall/source/PrintPitAction.cpp +++ b/heimdall/source/PrintPitAction.cpp @@ -28,11 +28,13 @@ #include "Interface.h" #include "PrintPitAction.h" +using namespace std; +using namespace libpit; using namespace Heimdall; const char *PrintPitAction::usage = "Action: print-pit\n\ Arguments: [--file <filename>] [--verbose] [--no-reboot] [--stdout-errors]\n\ - [--delay <ms>]\n\ + [--delay <ms>] [--usb-log-level <none/error/warning/debug>]\n\ Description: Prints the contents of a PIT file in a human readable format. If\n\ a filename is not provided then Heimdall retrieves the PIT file from the \n\ connected device.\n"; @@ -44,9 +46,11 @@ int PrintPitAction::Execute(int argc, char **argv) map<string, ArgumentType> argumentTypes; argumentTypes["file"] = kArgumentTypeString; argumentTypes["no-reboot"] = kArgumentTypeFlag; + argumentTypes["resume"] = kArgumentTypeFlag; argumentTypes["delay"] = kArgumentTypeUnsignedInteger; argumentTypes["verbose"] = kArgumentTypeFlag; argumentTypes["stdout-errors"] = kArgumentTypeFlag; + argumentTypes["usb-log-level"] = kArgumentTypeString; Arguments arguments(argumentTypes); @@ -60,11 +64,48 @@ int PrintPitAction::Execute(int argc, char **argv) const UnsignedIntegerArgument *communicationDelayArgument = static_cast<const UnsignedIntegerArgument *>(arguments.GetArgument("delay")); bool reboot = arguments.GetArgument("no-reboot") == nullptr; + bool resume = arguments.GetArgument("resume") != nullptr; bool verbose = arguments.GetArgument("verbose") != nullptr; if (arguments.GetArgument("stdout-errors") != nullptr) Interface::SetStdoutErrors(true); + const StringArgument *usbLogLevelArgument = static_cast<const StringArgument *>(arguments.GetArgument("usb-log-level")); + + BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::UsbLogLevel::Default; + + if (usbLogLevelArgument) + { + const string& usbLogLevelString = usbLogLevelArgument->GetValue(); + + if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0) + { + usbLogLevel = BridgeManager::UsbLogLevel::None; + } + else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0) + { + usbLogLevel = BridgeManager::UsbLogLevel::Error; + } + else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0) + { + usbLogLevel = BridgeManager::UsbLogLevel::Warning; + } + else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0) + { + usbLogLevel = BridgeManager::UsbLogLevel::Info; + } + else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0) + { + usbLogLevel = BridgeManager::UsbLogLevel::Debug; + } + else + { + Interface::Print("Unknown USB log level: %s\n\n", usbLogLevelString.c_str()); + Interface::Print(PrintPitAction::usage); + return (0); + } + } + // Open file (if specified). FILE *localPitFile = nullptr; @@ -120,8 +161,9 @@ int PrintPitAction::Execute(int argc, char **argv) communicationDelay = communicationDelayArgument->GetValue(); BridgeManager *bridgeManager = new BridgeManager(verbose, communicationDelay); + bridgeManager->SetUsbLogLevel(usbLogLevel); - if (bridgeManager->Initialise() != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession()) + if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession()) { delete bridgeManager; return (1); |