X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftestclient%2Fmain.cpp;h=cd83f10d48323566e6386a28a0346fc306956c8f;hb=56b36fa651f960f501b588b1d5fe069298d980a1;hp=52a5af462b2becc356ca4ca5541e138c4e7bb711;hpb=88f45c9b0ef4f03bf78ad3abc8996c0dcc95010b;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 52a5af4..cd83f10 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) { @@ -166,6 +168,7 @@ void show_console_help(void) "Available commands:" << endl << endl << "tx {bytes} transfer bytes over the CEC line." << endl << + "txn {bytes} transfer bytes and don't wait for an ACK reply." << 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 << @@ -177,6 +180,9 @@ void show_console_help(void) "la {logical_address} change the logical address of the CEC adapter." << endl << "[la 4] logical address 4" << endl << endl << + "pa {physical_address} change the physical address of the CEC adapter." << endl << + "[pa 10 00] physical address 1.0.0.0" << endl << + endl << "[ping] send a ping command to the CEC adapter." << endl << "[bl] to let the adapter enter the bootloader, to upgrade" << endl << " the flash rom." << endl << @@ -190,9 +196,13 @@ void show_console_help(void) int main (int argc, char *argv[]) { ICECAdapter *parser = LoadLibCec("CECTester"); - if (!parser && parser->GetMinVersion() > CEC_TEST_CLIENT_VERSION) + 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; @@ -272,17 +282,17 @@ int main (int argc, char *argv[]) string command; if (GetWord(input, command)) { - if (command == "tx") + if (command == "tx" || command == "txn") { 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); + parser->Transmit(bytes, command == "tx"); } else if (command == "on") { @@ -318,6 +328,17 @@ int main (int argc, char *argv[]) parser->SetLogicalAddress((cec_logical_address) atoi(strvalue.c_str())); } } + else if (command == "pa") + { + string strB1, strB2; + uint8_t iB1, iB2; + if (GetWord(input, strB1) && HexStrToInt(strB1, iB1) && + GetWord(input, strB2) && HexStrToInt(strB2, iB2)) + { + uint16_t iPhysicalAddress = ((uint16_t)iB1 << 8) + iB2; + parser->SetPhysicalAddress(iPhysicalAddress); + } + } else if (command == "ping") { parser->PingAdapter();