X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftestclient%2Fmain.cpp;h=b06ef1dffc886f9194eef2fe3047e2aa4aa35b46;hb=45de9d9fb1cdefce6ecb53f372a9947480046bba;hp=de9f90342928507ce3e64d8188dbf270a16f110e;hpb=5ad0ea13af99e9b3f4893ad1f8b4dcc44ff47133;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index de9f903..b06ef1d 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -180,6 +180,7 @@ void ShowHelpCommandLine(const char* strExec) " -h --help Shows this help text" << endl << " -l --list-devices List all devices on this system" << endl << " -t --type {p|r|t|a} The device type to use. More than one is possible." << endl << + " -p --physical {hex-address} The physical address to use for the primary logical device." << 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 << @@ -268,8 +269,9 @@ void ShowHelpConsole(void) int main (int argc, char *argv[]) { + int iPhysicalAddress = -1; cec_device_type_list typeList; - typeList.clear(); + typeList.Clear(); int iArgPtr = 1; bool bSingleCommand(false); @@ -327,25 +329,25 @@ int main (int argc, char *argv[]) { if (!bSingleCommand) cout << "== using device type 'playback device'" << endl; - typeList.add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); + typeList.Add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); } else if (!strcmp(argv[iArgPtr + 1], "r")) { if (!bSingleCommand) cout << "== using device type 'recording device'" << endl; - typeList.add(CEC_DEVICE_TYPE_RECORDING_DEVICE); + typeList.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); } else if (!strcmp(argv[iArgPtr + 1], "t")) { if (!bSingleCommand) cout << "== using device type 'tuner'" << endl; - typeList.add(CEC_DEVICE_TYPE_TUNER); + typeList.Add(CEC_DEVICE_TYPE_TUNER); } else if (!strcmp(argv[iArgPtr + 1], "a")) { if (!bSingleCommand) cout << "== using device type 'audio system'" << endl; - typeList.add(CEC_DEVICE_TYPE_AUDIO_SYSTEM); + typeList.Add(CEC_DEVICE_TYPE_AUDIO_SYSTEM); } else { @@ -378,6 +380,19 @@ int main (int argc, char *argv[]) ShowHelpCommandLine(argv[0]); return 0; } + else if (!strcmp(argv[iArgPtr], "-p") || + !strcmp(argv[iArgPtr], "--physical")) + { + if (argc >= iArgPtr + 2) + { + if (sscanf(argv[iArgPtr + 1], "%x", &iPhysicalAddress)) + cout << "using physical address '" << std::hex << iPhysicalAddress << "'" << endl; + else + cout << "== skipped physical address parameter: invalid physical address '" << argv[iArgPtr + 1] << "' ==" << endl; + ++iArgPtr; + } + ++iArgPtr; + } else { g_strPort = argv[iArgPtr++]; @@ -385,11 +400,11 @@ int main (int argc, char *argv[]) } } - if (typeList.empty()) + if (typeList.IsEmpty()) { if (!bSingleCommand) cout << "No device type given. Using 'playback device'" << endl; - typeList.add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); + typeList.Add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); } ICECAdapter *parser = LibCecInit("CECTester", typeList); @@ -454,6 +469,12 @@ int main (int argc, char *argv[]) { cout << "cec device opened" << endl; + if (-1 != iPhysicalAddress) + { + parser->SetPhysicalAddress(iPhysicalAddress); + FlushLog(parser); + } + parser->PowerOnDevices(CECDEVICE_TV); FlushLog(parser); @@ -489,10 +510,10 @@ int main (int argc, char *argv[]) string strvalue; uint8_t ivalue; cec_command bytes; - bytes.clear(); + bytes.Clear(); while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue)) - bytes.push_back(ivalue); + bytes.PushBack(ivalue); if (command == "txn") bytes.transmit_timeout = 0;