X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftestclient%2Fmain.cpp;h=867501d55041f1e68ecc4e28bc9cb6d4c8ccf2cb;hb=0e31a62c1ff3854f1c4dad3fb0917683c9528e5b;hp=dcbd0c00584c3ba096b69d65e5948859e5a29f02;hpb=3d0dca16aebce0c4bd125a05acf28d340138d874;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index dcbd0c0..867501d 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -49,6 +49,7 @@ using namespace std; #include int g_cecLogLevel = CEC_LOG_ALL; +int g_iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1; ofstream g_logOutput; bool g_bShortLog = false; CStdString g_strPort; @@ -179,9 +180,11 @@ void show_help(const char* strExec) "parameters:" << endl << " -h --help Shows this help text" << endl << " -l --list-devices List all devices on this system" << endl << + " -la --logical-address {a} The logical address to use." << endl << " -f --log-file {file} Writes all libCEC log message to a file" << endl << " -sf --short-log-file {file} Writes all libCEC log message without timestamps" << endl << " and log levels to a file." << endl << + " -d --log-level {level} Sets the log level. See cectypes.h for values." << endl << " [COM PORT] The com port to connect to. If no COM" << endl << " port is given, the client tries to connect to the" << endl << " first device that is detected." << endl << @@ -268,6 +271,53 @@ int main (int argc, char *argv[]) } else { + cout << "== skipped log-file parameter: no file given ==" << endl; + ++iArgPtr; + } + } + else if (!strcmp(argv[iArgPtr], "-d") || + !strcmp(argv[iArgPtr], "--log-level")) + { + if (argc >= iArgPtr + 2) + { + int iNewLevel = atoi(argv[iArgPtr + 1]); + if (iNewLevel >= CEC_LOG_ERROR && iNewLevel <= CEC_LOG_ALL) + { + g_cecLogLevel = iNewLevel; + cout << "log level set to " << argv[iArgPtr + 1] << endl; + } + else + { + cout << "== skipped log-level parameter: invalid level '" << argv[iArgPtr + 1] << "' ==" << endl; + } + iArgPtr += 2; + } + else + { + cout << "== skipped log-level parameter: no level given ==" << endl; + ++iArgPtr; + } + } + else if (!strcmp(argv[iArgPtr], "-la") || + !strcmp(argv[iArgPtr], "--logical-address")) + { + if (argc >= iArgPtr + 2) + { + int iNewAddress = atoi(argv[iArgPtr + 1]); + if (iNewAddress >= 0 && iNewAddress <= 15) + { + g_iLogicalAddress = iNewAddress; + cout << "logical address set to " << argv[iArgPtr + 1] << endl; + } + else + { + cout << "== skipped logical-address parameter: invalid address '" << argv[iArgPtr + 1] << "' ==" << endl; + } + iArgPtr += 2; + } + else + { + cout << "== skipped logical-address parameter: no address given ==" << endl; ++iArgPtr; } } @@ -311,6 +361,8 @@ int main (int argc, char *argv[]) } } + parser->SetLogicalAddress((cec_logical_address) g_iLogicalAddress); + if (!parser->Open(g_strPort.c_str())) { cout << "unable to open the device on port " << g_strPort << endl;