From: Lars Op den Kamp Date: Fri, 28 Oct 2011 00:05:39 +0000 (+0200) Subject: cec: add -la and --logical-address to the command line params X-Git-Tag: upstream/2.2.0~1^2~200 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d6cc5f60419038914337196282a6c02f3f256574;p=deb_libcec.git cec: add -la and --logical-address to the command line params --- diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 456e664..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,6 +180,7 @@ 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 << @@ -296,6 +298,29 @@ int main (int argc, char *argv[]) ++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; + } + } else if (!strcmp(argv[iArgPtr], "--list-devices") || !strcmp(argv[iArgPtr], "-l")) { @@ -336,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;