diff options
author | David Chiu <dchiu@synaptics.com> | 2022-03-02 15:47:31 +0800 |
---|---|---|
committer | Vincent Huang <vincenthsw@gmail.com> | 2022-03-14 15:23:15 +0800 |
commit | 7f553ab32a9f7096c8d041bc8cf79533a4cb3ff2 (patch) | |
tree | 49f1e5cf1a73f6dd3770bb9d3ea49d40d85f87da | |
parent | e9115fa74a72e9a267ec6c08b8df8cd05d4f9085 (diff) | |
download | rmi4utils-7f553ab32a9f7096c8d041bc8cf79533a4cb3ff2.tar.gz |
Support debugging message in read/write
-rwxr-xr-x | rmi4update/main.cpp | 14 | ||||
-rwxr-xr-x | rmidevice/hiddevice.cpp | 18 | ||||
-rw-r--r-- | rmidevice/rmidevice.h | 4 |
3 files changed, 34 insertions, 2 deletions
diff --git a/rmi4update/main.cpp b/rmi4update/main.cpp index 38b1f77..386930f 100755 --- a/rmi4update/main.cpp +++ b/rmi4update/main.cpp @@ -36,7 +36,9 @@ #define VERSION_MINOR 3 #define VERSION_SUBMINOR 9 -#define RMI4UPDATE_GETOPTS "hfd:t:pclv" +#define RMI4UPDATE_GETOPTS "hfd:t:pclvm" + +bool needDebugMessage; void printHelp(const char *prog_name) { @@ -66,6 +68,9 @@ int GetFirmwareProps(const char * deviceFile, std::string &props, bool configid) rc = rmidevice.Open(deviceFile); if (rc) return rc; + + if (needDebugMessage) + rmidevice.m_hasDebug = true; // Clear all interrupts before parsing to avoid unexpected interrupts. rmidevice.ToggleInterruptMask(false); @@ -115,6 +120,7 @@ int main(int argc, char **argv) bool printFirmwareProps = false; bool printConfigid = false; bool performLockdown = false; + needDebugMessage = false; HIDDevice device; enum RMIDeviceType deviceType = RMI_DEVICE_TYPE_ANY; @@ -148,6 +154,9 @@ int main(int argc, char **argv) case 'v': printVersion(); return 0; + case 'm': + needDebugMessage = true; + break; default: break; @@ -195,6 +204,9 @@ int main(int argc, char **argv) return 1; } + if (needDebugMessage) { + device.m_hasDebug = true; + } RMI4Update update(device, image); rc = update.UpdateFirmware(force, performLockdown); diff --git a/rmidevice/hiddevice.cpp b/rmidevice/hiddevice.cpp index 00067e0..b727cb5 100755 --- a/rmidevice/hiddevice.cpp +++ b/rmidevice/hiddevice.cpp @@ -306,6 +306,10 @@ int HIDDevice::Read(unsigned short addr, unsigned char *buf, unsigned short len) if (!m_deviceOpen) return -1; + if (m_hasDebug) { + fprintf(stdout, "R %02x : ", addr); + } + if (m_bytesPerReadRequest) bytesPerRequest = m_bytesPerReadRequest; else @@ -386,6 +390,12 @@ Resend: } addr += bytesPerRequest; } + if (m_hasDebug) { + for (int i=0 ; i<len ; i++) { + fprintf(stdout, "%02x ", buf[i]); + } + fprintf(stdout, "\n"); + } return totalBytesRead; } @@ -406,6 +416,14 @@ int HIDDevice::Write(unsigned short addr, const unsigned char *buf, unsigned sho m_outputReport[HID_RMI4_WRITE_OUTPUT_ADDR + 1] = (addr >> 8) & 0xFF; memcpy(&m_outputReport[HID_RMI4_WRITE_OUTPUT_DATA], buf, len); + if (m_hasDebug) { + fprintf(stdout, "W %02x : ", addr); + for (int i=0 ; i<len ; i++) { + fprintf(stdout, "%02x ", buf[i]); + } + fprintf(stdout, "\n"); + } + for (;;) { m_bCancel = false; count = write(m_fd, m_outputReport, m_outputReportSize); diff --git a/rmidevice/rmidevice.h b/rmidevice/rmidevice.h index e40c653..9b8c915 100644 --- a/rmidevice/rmidevice.h +++ b/rmidevice/rmidevice.h @@ -38,7 +38,7 @@ class RMIDevice public: RMIDevice() : m_functionList(), m_sensorID(0), m_bCancel(false), m_bytesPerReadRequest(0), m_page(-1), m_deviceType(RMI_DEVICE_TYPE_ANY) - {} + { m_hasDebug = false; } virtual ~RMIDevice() {} virtual int Open(const char * filename) = 0; virtual int Read(unsigned short addr, unsigned char *data, @@ -83,6 +83,8 @@ public: virtual bool FindDevice(enum RMIDeviceType type = RMI_DEVICE_TYPE_ANY) = 0; enum RMIDeviceType GetDeviceType() { return m_deviceType; } + bool m_hasDebug; + protected: std::vector<RMIFunction> m_functionList; unsigned char m_manufacturerID; |