X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftestclient%2Fmain.cpp;h=33ee463cb4c8b31a11a70a23f135229cb98f18dc;hb=b2da27686d4fa820f7f17d25a804450fa02f4dd2;hp=bec5c4d1655dd597ba03b39ad396df66c6f408ba;hpb=25701fa60407a0fc0bc1dfcd4049fc01ad9e4fd1;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index bec5c4d..33ee463 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -30,20 +30,22 @@ * http://www.pulse-eight.net/ */ -#include "../../include/CECExports.h" -#include "../lib/platform/threads.h" -#include "../lib/util/StdString.h" +#include + #include #include #include #include #include +#include "../lib/platform/threads.h" +#include "../lib/util/StdString.h" using namespace CEC; using namespace std; -#define CEC_TEST_CLIENT_VERSION 5 +#define CEC_TEST_CLIENT_VERSION 7 +#include inline bool HexStrToInt(const std::string& data, uint8_t& value) { @@ -105,18 +107,22 @@ void flush_log(ICECAdapter *cecParser) switch (message.level) { case CEC_LOG_ERROR: - cout << "ERROR: " << message.message << endl; + cout << "ERROR: "; break; case CEC_LOG_WARNING: - cout << "WARNING: " << message.message << endl; + cout << "WARNING: "; break; case CEC_LOG_NOTICE: - cout << "NOTICE: " << message.message << endl; + cout << "NOTICE: "; break; case CEC_LOG_DEBUG: - cout << "DEBUG: " << message.message << endl; + cout << "DEBUG: "; break; } + + CStdString strMessageTmp; + strMessageTmp.Format("[%16lld]\t%s", message.time, message.message); + cout << strMessageTmp.c_str() << endl; } } @@ -164,22 +170,35 @@ void show_console_help(void) "tx {bytes} transfer bytes over the CEC line." << endl << "[tx 40 00 FF 11 22 33] sends bytes 0x40 0x00 0xFF 0x11 0x22 0x33" << endl << endl << + "on {address} power on the device with the given logical address." << endl << + "[on 5] power on a connected audio system" << endl << + endl << + "standby {address} put the device with the given address in standby mode." << endl << + "[standby 0] powers off the TV" << endl << + endl << "la {logical_address} change the logical address of the CEC adapter." << endl << "[la 4] logical address 4" << endl << endl << "[ping] send a ping command to the CEC adapter." << endl << - "[bl] to let the adapter enter the bootloader, to upgrade the flash rom." << endl << + "[bl] to let the adapter enter the bootloader, to upgrade" << endl << + " the flash rom." << endl << + "[r] reconnect to the CEC adapter." << endl << "[h] or [help] show this help." << endl << - "[q] or [quit] to quit the CEC test client and switch off all connected CEC devices." << endl << + "[q] or [quit] to quit the CEC test client and switch off all" << endl << + " connected CEC devices." << endl << "================================================================================" << endl; } int main (int argc, char *argv[]) { - ICECAdapter *parser = LoadLibCec("CEC Tester"); - if (!parser && parser->GetMinVersion() > CEC_TEST_CLIENT_VERSION) + ICECAdapter *parser = LoadLibCec("CECTester"); + if (!parser || parser->GetMinVersion() > CEC_TEST_CLIENT_VERSION) { - cout << "Unable to create parser. Is libcec.dll present?" << endl; +#ifdef __WINDOWS__ + cout << "Cannot load libcec.dll" << endl; +#else + cout << "Cannot load libcec.so" << endl; +#endif return 1; } CStdString strLog; @@ -263,14 +282,40 @@ int main (int argc, char *argv[]) { string strvalue; uint8_t ivalue; - cec_frame bytes; + cec_command bytes; bytes.clear(); while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue)) - bytes.push_back(ivalue); + bytes.push_back(ivalue); parser->Transmit(bytes); } + else if (command == "on") + { + string strValue; + uint8_t iValue = 0; + if (GetWord(input, strValue) && HexStrToInt(strValue, iValue) && iValue <= 0xF) + { + parser->PowerOnDevices((cec_logical_address) iValue); + } + else + { + cout << "invalid destination" << endl; + } + } + else if (command == "standby") + { + string strValue; + uint8_t iValue = 0; + if (GetWord(input, strValue) && HexStrToInt(strValue, iValue) && iValue <= 0xF) + { + parser->StandbyDevices((cec_logical_address) iValue); + } + else + { + cout << "invalid destination" << endl; + } + } else if (command == "la") { string strvalue;