From 5a8be5883b56931d6715315a8b4fa3c5f0da5fd8 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 27 Apr 2025 16:21:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4gpio=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/GPIOControl.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 2906e04e..e1dfbd5d 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -26,7 +26,9 @@ std::mutex GpioControl::m_locker; std::vector GpioControl::m_items; bool GpioControl::m_cameraPowerStatus = false; -#if 0 +#define ENABLE_GPIO_TRACING + +#ifdef ENABLE_GPIO_TRACING class GpioDebugLogger { public: @@ -38,6 +40,14 @@ public: CreateEmptyFile(m_path + ".enter"); } + GpioDebugLogger(int cmd) + { + m_startTime = GetMicroTimeStamp(); + m_path = std::string("/sdcard/com.xypower.mpapp/tmp/") + std::to_string(cmd) + std::string("_") + std::to_string(m_startTime) + "_get"; + + CreateEmptyFile(m_path + ".enter"); + } + ~GpioDebugLogger() { uint64_t ts = (GetMicroTimeStamp() - m_startTime); @@ -85,7 +95,7 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param) if (oldRef == 0/* || param.cmd != CMD_SET_3V3_PWR_EN*/) { -#if 0 +#ifdef ENABLE_GPIO_TRACING GpioDebugLogger logger(param.cmd, param.value); #endif fd = open(GPIO_NODE_MP, O_RDONLY); @@ -114,7 +124,7 @@ void GpioControl::setInt(int cmd, int value) // param.cmd = cmd; // param.value = value; -#if 0 +#ifdef ENABLE_GPIO_TRACING GpioDebugLogger logger(cmd, value); #endif int fd = open(GPIO_NODE_MP, O_RDONLY); @@ -132,6 +142,9 @@ void GpioControl::setInt(int cmd, int value) int GpioControl::getInt(int cmd) { +#ifdef ENABLE_GPIO_TRACING + GpioDebugLogger logger(cmd); +#endif int fd = open(GPIO_NODE_MP, O_RDONLY); // LOGE("get_int fd=%d,cmd=%d\r\n",fd, cmd); if( fd > 0 )