win32: updated visual studio project files
[deb_libcec.git] / src / testclient / main.cpp
index f2f2bf3e0a9678338fc8b347b38d6afc853b0006..813e22b4cd193501dd0f7447d26041e1f690c7e7 100644 (file)
@@ -45,11 +45,23 @@ using namespace std;
 #define CEC_TEST_CLIENT_VERSION 3
 
 
-inline bool HexStrToInt(const std::string& data, int& value)
+inline bool HexStrToInt(const std::string& data, uint8_t& value)
 {
-  return sscanf(data.c_str(), "%x", &value) == 1;
-}
+  int iTmp(0);
+  if (sscanf(data.c_str(), "%x", &iTmp) == 1)
+  {
+    if (iTmp > 256)
+      value = 255;
+         else if (iTmp < 0)
+      value = 0;
+    else
+      value = (uint8_t) iTmp;
 
+    return true;
+  }
+
+  return false;
+}
 
 //get the first word (separated by whitespace) from string data and place that in word
 //then remove that word from string data
@@ -228,7 +240,6 @@ int main (int argc, char *argv[])
   }
 
   cout << "cec device opened" << endl;
-  usleep(CEC_SETTLE_DOWN_TIME);
 
   parser->PowerOnDevices(CECDEVICE_TV);
   flush_log(parser);
@@ -254,7 +265,7 @@ int main (int argc, char *argv[])
         if (command == "tx")
         {
           string strvalue;
-          int    ivalue;
+          uint8_t ivalue;
           vector<uint8_t> bytes;
           while (GetWord(input, strvalue) && HexStrToInt(strvalue, ivalue))
           bytes.push_back(ivalue);
@@ -277,6 +288,12 @@ int main (int argc, char *argv[])
         {
           parser->StartBootloader();
         }
+        else if (command == "r")
+        {
+          parser->Close();
+          parser->Open(strPort.c_str());
+          parser->SetActiveView();
+        }
         else if (command == "h" || command == "help")
         {
           show_console_help();