diff options
author | Vincent Huang <vincenthsw@gmail.com> | 2022-03-14 16:35:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 16:35:30 +0800 |
commit | 6940581af1507a177050fdd33c1847c1f9ba945c (patch) | |
tree | b46fd02eef4c8affba46bd566d173fea79d58eac | |
parent | e4e724250700867ef142a34cb38c41bc97b597fa (diff) | |
parent | 7f553ab32a9f7096c8d041bc8cf79533a4cb3ff2 (diff) | |
download | rmi4utils-6940581af1507a177050fdd33c1847c1f9ba945c.tar.gz |
Merge branch 'master' into BLv10
-rwxr-xr-x | rmi4update/main.cpp | 14 | ||||
-rwxr-xr-x | rmidevice/hiddevice.cpp | 14 | ||||
-rw-r--r-- | rmidevice/rmidevice.h | 4 |
3 files changed, 29 insertions, 3 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 df0c6ba..5bc7c99 100755 --- a/rmidevice/hiddevice.cpp +++ b/rmidevice/hiddevice.cpp @@ -308,6 +308,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 @@ -388,6 +392,12 @@ Resend: } addr += bytesPerRequest; } + if (m_hasDebug) { + for (int i=0 ; i<len ; i++) { + fprintf(stdout, "%02x ", buf[i]); + } + fprintf(stdout, "\n"); + } for (int i=0 ; i<len ; i++) { fprintf(stdout, "%02x ", buf[i]); @@ -414,11 +424,13 @@ 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); - fprintf(stdout, "W %02x : ", addr); + 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; 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; |