diff --git a/README.md b/README.md index 9bb8177c..37d89033 100644 --- a/README.md +++ b/README.md @@ -11,23 +11,25 @@ The Diagnostic Log and Trace Viewer is an application that can send and receive ### Command line usage; -+ Windows: `dlt-viewer.exe [OPTIONS]` -+ Linux: `dlt-viewer [OPTIONS]` -+ MacOS: `open -a $DLT_BUILD_DIR/bin/DLT\ Viewer.app --args [OPTIONS]` ++ Windows: `dlt-viewer.exe [OPTIONS] [logfile] [projectfile] [filterfile]` ++ Linux: `dlt-viewer [OPTIONS] [logfile] [projectfile] [filterfile]` ++ MacOS: `open -a $DLT_BUILD_DIR/bin/DLT\ Viewer.app --args [OPTIONS] [logfile] [projectfile] [filterfile]` Options: ++ [logfile] Loading one or more logfiles on startup (must end with .dlt) ++ [projectfile] Loading project file on startup (must end with .dlp) ++ [filterfile] Loading filterfile on startup (must end with .dlf) + `-h` Print usage -+ `-p projectfile` Loading project file on startup (must end with .dlp) -+ `-l logfile` Loading logfile on startup (must end with .dlt) -+ `-f filterfile` Loading filterfile on startup (must end with .dlf) + `-s or --silent` Enable silent mode without warning message boxes + `-v or --version` Only show version and buildtime information + `-c logfile textfile` Convert logfile file to textfile (logfile must end with .dlt) -+ `-u` Conversion will be done in UTF8 instead of ASCII"; -+ `-csv` Conversion will be done in CSV format"; -+ `-d` Conversion will NOT be done, save in dlt file format again instead" -+ `-dd` Conversion will NOT be done, save as decoded messages in dlt format" -+ `-e "name of plugin|command in plugin|param1|..|param"` Execute a plugin command with parameters ++ `-u` Conversion will be done in UTF8 instead of ASCII; ++ `-csv` Conversion will be done in CSV format; ++ `-d` Conversion will NOT be done, save in dlt file format again instead ++ `-dd` Conversion will NOT be done, save as decoded messages in dlt format ++ `-b "name of plugin|command in plugin|param1|..|param"` Execute a plugin command with parameters before loading log file ++ `-e "name of plugin|command in plugin|param1|..|param"` Execute a plugin command with parameters after loading log file ++ `-w workingdirectory` Set the working directory ## API Documentation diff --git a/qdlt/qdltoptmanager.cpp b/qdlt/qdltoptmanager.cpp index 5174fa83..3602d6b8 100644 --- a/qdlt/qdltoptmanager.cpp +++ b/qdlt/qdltoptmanager.cpp @@ -55,6 +55,16 @@ QDltOptManager::QDltOptManager(QDltOptManager const&) } +const QStringList &QDltOptManager::getPostPluginCommands() const +{ + return postPluginCommands; +} + +const QStringList &QDltOptManager::getPrePluginCommands() const +{ + return prePluginCommands; +} + void QDltOptManager::printVersion(QString appname) { qDebug() << "Start" << appname << "\nBuild time" << __DATE__ << __TIME__; @@ -65,24 +75,26 @@ void QDltOptManager::printVersion(QString appname) void QDltOptManager::printUsage() { #if (WIN32) - qDebug()<<"Usage: dlt-viewer.exe [OPTIONS]"; + qDebug()<<"Usage: dlt-viewer.exe [OPTIONS] [logfile] [projectfile] [filterfile]"; #else - qDebug()<<"Usage: dlt-viewer [OPTIONS]"; + qDebug()<<"Usage: dlt-viewer [OPTIONS] [logfile] [projectfile] [filterfile]"; #endif qDebug()<<"Options:"; - qDebug()<<" -h Print usage"; - qDebug()<<" -p projectfile \t Loading project file on startup (must end with .dlp)"; - qDebug()<<" -l logfile \t Loading logfile on startup (must end with .dlt)"; - qDebug()<<" -f filterfile \t Loading filterfile on startup (must end with .dlf)"; - qDebug()<<" -s or --silent \t Enable silent mode without warning message boxes."; - qDebug()<<" -v or --version \t Only show version and buildtime information"; - qDebug()<<" -c logfile textfile \t Convert logfile file to textfile (logfile must end with .dlt)"; - qDebug()<<" -u Conversion will be done in UTF8 instead of ASCII"; - qDebug()<<" -csv Conversion will be done in CSV format"; - qDebug()<<" -d Conversion will NOT be done, save in dlt file format again instead"; - qDebug()<<" -dd Conversion will NOT be done, save as decoded messages in dlt format"; - qDebug()<<" -e \"plugin|command|param1|..|param\" \tExecute a plugin command with parameters.\n"; + qDebug()<<" [logfile]\tLoading one or more logfiles on startup (must end with .dlt)"; + qDebug()<<" [projectfile]\tLoading project file on startup (must end with .dlp)"; + qDebug()<<" [filterfile]\tLoading filterfile on startup (must end with .dlf)"; + qDebug()<<" -h \t Print usage"; + qDebug()<<" -s or --silent\tEnable silent mode without warning message boxes."; + qDebug()<<" -v or --version\tOnly show version and buildtime information"; + qDebug()<<" -c logfile textfile\tConvert logfile file to textfile (logfile must end with .dlt)"; + qDebug()<<" -u\tConversion will be done in UTF8 instead of ASCII"; + qDebug()<<" -csv\tConversion will be done in CSV format"; + qDebug()<<" -d\tConversion will NOT be done, save in dlt file format again instead"; + qDebug()<<" -dd\tConversion will NOT be done, save as decoded messages in dlt format"; + qDebug()<<" -b \"plugin|command|param1|..|param\"\tExecute a plugin command with parameters before loading log file."; + qDebug()<<" -e \"plugin|command|param1|..|param\"\tExecute a plugin command with parameters after loading log file."; + qDebug()<<" -w workingdirectory\tSet the working directory"; qDebug()<<"Examples:"; #if (WIN32) qDebug()<<" dlt-viewer.exe -c c:\\trace\\trace.dlt .\\trace.txt"; @@ -167,91 +179,6 @@ void QDltOptManager::parse(QStringList *opt) printVersion(opt->at(0)); exit(0); } - else if(str.compare("-p")==0) - { - QString p1 = opt->value(i+1); - - if(p1!=nullptr && (p1.endsWith(".dlp") || p1.endsWith(".DLP"))) - { - projectFile = QString("%1").arg(opt->at(i+1)); - QFile Fout(projectFile); - if(!Fout.exists()) - { - qDebug()<< "\n Error: " << projectFile << " not found !\n"; - exit(-1); - } - qDebug()<< "Projectfile is " << projectFile; - project = true; - } - else - { - qDebug()<<"\nError occured during processing of command line option \"-p\""; - qDebug()<<"e.g. file extension has to be \".dlp\"\n"; - printUsage(); - exit(-1); - } - i += 1; - } - else if(str.compare("-l")==0) - { - if (convert == true) - { - qDebug() << "\nError: Can't use -l and -c at once\n"; - printUsage(); - exit(-1); - } - - QString l1 = opt->value(i+1); - - if(l1!=nullptr && (l1.endsWith(".dlt")||l1.endsWith(".DLT"))) - { - const QString logFile = QString("%1").arg(l1); - logFiles += logFile; - QFile Fout(logFile); - if(false == Fout.exists()) - { - qDebug()<< "\nGiven file " << logFile << " not found !\nCreate empty file instead ..."; - } - else - { - qDebug()<< "\nLogfile is " << logFile; - } - log = true; - } - else - { - qDebug()<<"\nError occured during processing of command line option \"-l\""; - qDebug()<<"e.g. file extension has to be \".dlt\"\n"; - printUsage(); - exit(-1); - } - i += 1; - } - else if(str.compare("-f")==0) - { - QString f1 = opt->value(i+1); - - if(f1!=nullptr && (f1.endsWith(".dlf")||f1.endsWith(".DLF"))) - { - filterFile = QString("%1").arg(f1); - QFile Fout(filterFile); - if(!Fout.exists()) - { - qDebug()<< "\nError: " << filterFile << " not found !\n"; - exit(-1); - } - filter = true; - qDebug()<< "Filterfile is " << filterFile; - } - else - { - qDebug()<<"\nError occured during processing of command line option \"-f\""; - qDebug()<<"e.g. file extension has to be \".dlf\"\n"; - printUsage(); - exit(-1); - } - i += 1; - } else if(str.compare("-c")==0) { if (log == true) @@ -308,6 +235,7 @@ void QDltOptManager::parse(QStringList *opt) else if(str.compare("-e")==0) { QString c = opt->value(i+1); + postPluginCommands += c; QStringList args = c.split("|"); commandline_mode = true; if(c != nullptr && args.size() > 1) @@ -318,7 +246,6 @@ void QDltOptManager::parse(QStringList *opt) args.removeAt(0); commandParams = args; plugin = true; - } else { @@ -328,6 +255,13 @@ void QDltOptManager::parse(QStringList *opt) } ++i; } + else if(str.compare("-b")==0) + { + QString c = opt->value(i+1); + prePluginCommands += c; + commandline_mode = true; + ++i; + } else if (str.compare("-w") == 0) { workingDirectory = opt->value(i+1); @@ -360,6 +294,19 @@ void QDltOptManager::parse(QStringList *opt) project = true; qDebug()<< "Loading projectfile " << projectFile; } + else if(opt->at(i).endsWith(".dlf") || opt->at(i).endsWith(".DLF")) + { + if (filter == true) + { + qDebug() << "\nError: Can't load multiple filter files once\n"; + printUsage(); + exit(-1); + } + + filterFile = QString("%1").arg(opt->at(i)); + filter = true; + qDebug()<< "Loading filterfile " << filterFile; + } } // end of for loop printVersion(opt->at(0)); diff --git a/qdlt/qdltoptmanager.h b/qdlt/qdltoptmanager.h index 57f6c4c9..b760e042 100644 --- a/qdlt/qdltoptmanager.h +++ b/qdlt/qdltoptmanager.h @@ -63,6 +63,8 @@ class QDLT_EXPORT QDltOptManager QString getCommandName(); QStringList getCommandParams(); QString getWorkingDirectory() const; + const QStringList &getPrePluginCommands() const; + const QStringList &getPostPluginCommands() const; private: QDltOptManager(); @@ -86,6 +88,10 @@ class QDLT_EXPORT QDltOptManager QString pluginName; QString commandName; QStringList commandParams; + + QStringList prePluginCommands; // command before loading log file + QStringList postPluginCommands; // command after loading log file + QString workingDirectory; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3981cf0b..82cf2d1f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -115,14 +115,46 @@ MainWindow::MainWindow(QWidget *parent) : initSignalConnections(); + /* Commands plugin before loading log file */ + if(QDltOptManager::getInstance()->isPlugin()) + { + QStringList commands = QDltOptManager::getInstance()->getPrePluginCommands(); + + for(int num = 0; num< commands.size();num++) + { + QStringList args = commands[num].split("|"); + if(args.size() > 1) + { + QString pluginName = args.at(0); + QString commandName = args.at(1); + args.removeAt(0); + args.removeAt(0); + QStringList commandParams = args; + commandLineExecutePlugin(pluginName,commandName,commandParams); + } + } + } + initFileHandling(); - /* Command plugin */ + /* Commands plugin after loading log file */ if(QDltOptManager::getInstance()->isPlugin()) { - commandLineExecutePlugin(QDltOptManager::getInstance()->getPluginName(), - QDltOptManager::getInstance()->getCommandName(), - QDltOptManager::getInstance()->getCommandParams()); + QStringList commands = QDltOptManager::getInstance()->getPostPluginCommands(); + + for(int num = 0; num< commands.size();num++) + { + QStringList args = commands[num].split("|"); + if(args.size() > 1) + { + QString pluginName = args.at(0); + QString commandName = args.at(1); + args.removeAt(0); + args.removeAt(0); + QStringList commandParams = args; + commandLineExecutePlugin(pluginName,commandName,commandParams); + } + } } /* auto connect */ @@ -5869,26 +5901,26 @@ void MainWindow::on_action_menuHelp_Command_Line_triggered() QMessageBox::information(0, QString("DLT Viewer - Command line usage\t\t\t\t\t"), // tabs used to expand mesage box ! #ifdef WIN32 - QString("Usage: dlt-viewer.exe [OPTIONS]\n\n")+ + QString("Usage: dlt-viewer.exe [OPTIONS] [logfile] [projectfile] [filterfile]\n\n")+ QString("Options:\n")+ #else - QString("Usage: dlt-viewer [OPTIONS]\n\n")+ + QString("Usage: dlt-viewer [OPTIONS] [logfile] [projectfile] [filterfile]\n\n")+ QString("Options:\n")+ #endif - QString(" -h \t\tPrint usage\n")+ - QString(" -v \t\tShow version and buildtime information\n")+ - QString("\n")+ - QString(" -p \tLoading project (*.dlp) file on startup\n")+ - QString(" -f \t\tLoading filterfile on startup (must end with \".dlf\")\n")+ - QString(" -l \t\tLoading (*.dlt) logfile on startup\n")+ - QString(" -c \tConvert (*.dlt) logfile to ASCII textfile\n")+ + QString(" [logfile]\t\t\tLoading one or more logfiles on startup (must end with .dlt)\n")+ + QString(" [projectfile]\t\tLoading project file on startup (must end with .dlp)\n")+ + QString(" [filterfile]\t\tLoading filterfile on startup (must end with .dlf)\n")+ + QString(" -h\t\t\tPrint usage\n")+ + QString(" -s \t\t\tEnable silent mode - no message boxes\n")+ + QString(" -v\t\t\tShow version and buildtime information\n")+ + QString(" -c \tConvert (*.dlt) logfile to ASCII textfile\n")+ QString(" -u \t\t\tExport logfile to UTF8 instead\n")+ QString(" -csv \t\t\tExport logfile to csv ( Excel ) instead\n")+ QString(" -d \t\t\tExport logfile to DLT format\n")+ QString(" -dd \t\t\tExport logfile to decoded DLT format\n")+ - QString(" -s \t\t\tEnable silent mode - no message boxes\n")+ - QString("\n")+ - QString(" -e |command|param1|..|param \n\t\t\tExecute a command plugin with parameters") + QString(" -b |command|param1|..|param \n\t\t\tExecute a command plugin with parameters before loading log file\n")+ + QString(" -e |command|param1|..|param \n\t\t\tExecute a command plugin with parameters after loading log file\n")+ + QString(" -w workingdirectory\tSet the working directory\n") ); }