| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #ifndef It3256_CONTROL_H
- #define It3256_CONTROL_H
- #include "it3256_stub.h"
- #include "advio.h"
- #include "it3256_log.h"
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <memory>
- 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<FILE, decltype(&pclose)> 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
|