#ifndef It3256_CONTROL_H #define It3256_CONTROL_H #include "it3256_stub.h" #include "advio.h" #include "it3256_log.h" #include #include #include #include namespace OHOS{ namespace It3256 { class It3256IOControl : public It3256IOStub { public: It3256IOControl(); ~It3256IOControl(); bool GetAIRangeCode(unsigned char startch, unsigned char stopch, unsigned char *poutbuf) override; bool SetAIRangeCode(unsigned char startch, unsigned char stopch, unsigned char *poutbuf) override; std::string executeCommand(const std::string& command) { // 使用 popen 执行命令并捕获其输出 std::unique_ptr pipe(popen(command.c_str(), "r"), pclose); if (!pipe) { std::cerr << ": Failed to execute command: " << command << std::endl; return "-1"; } // 读取命令的输出 char buffer[128]; std::string result; while (fgets(buffer, sizeof(buffer), pipe.get()) != nullptr) { result += buffer; } return result; } private: bool initialized_ = false; }; } } // namespace It3256 #endif // It3256_CONTROL_H