diff options
author | Andrew Duggan <aduggan@synaptics.com> | 2014-04-29 13:34:42 -0700 |
---|---|---|
committer | Andrew Duggan <aduggan@synaptics.com> | 2014-04-29 13:34:42 -0700 |
commit | e9a5cd0172ce96168a9431531d259b677f331aa6 (patch) | |
tree | b210ba77d0deacecd5288d661de20e6c7efe51af /rmidevice | |
parent | d02a0b030911951257e354fa82ce967bc4e51f9f (diff) | |
download | rmi4utils-e9a5cd0172ce96168a9431531d259b677f331aa6.tar.gz |
Add additional commands to rmihidtool and allow them to be set from the command line.
Diffstat (limited to 'rmidevice')
-rw-r--r-- | rmidevice/hiddevice.cpp | 4 | ||||
-rw-r--r-- | rmidevice/hiddevice.h | 3 | ||||
-rw-r--r-- | rmidevice/rmidevice.cpp | 22 | ||||
-rw-r--r-- | rmidevice/rmidevice.h | 6 |
4 files changed, 30 insertions, 5 deletions
diff --git a/rmidevice/hiddevice.cpp b/rmidevice/hiddevice.cpp index 800dbe0..8b99d75 100644 --- a/rmidevice/hiddevice.cpp +++ b/rmidevice/hiddevice.cpp @@ -250,14 +250,14 @@ int HIDDevice::WaitForAttention(struct timeval * timeout, int *sources) return GetAttentionReport(timeout, sources, NULL, NULL); } -int HIDDevice::GetAttentionReport(struct timeval * timeout, int *sources, unsigned char *buf, int *len) +int HIDDevice::GetAttentionReport(struct timeval * timeout, int *sources, unsigned char *buf, unsigned int *len) { int rc; int interrupt_sources; const unsigned char * queue_report; int bytes = m_inputReportSize; - if (len && (int)m_inputReportSize < *len) { + if (len && m_inputReportSize < *len) { bytes = *len; *len = m_inputReportSize; } diff --git a/rmidevice/hiddevice.h b/rmidevice/hiddevice.h index 37749c7..fb3c848 100644 --- a/rmidevice/hiddevice.h +++ b/rmidevice/hiddevice.h @@ -34,7 +34,8 @@ public: unsigned short len); virtual int SetMode(int mode); virtual int WaitForAttention(struct timeval * timeout = NULL, int *sources = NULL); - virtual int GetAttentionReport(struct timeval * timeout, int *sources, unsigned char *buf, int *len); + virtual int GetAttentionReport(struct timeval * timeout, int *sources, unsigned char *buf, + unsigned int *len); virtual void Close(); ~HIDDevice() { Close(); } diff --git a/rmidevice/rmidevice.cpp b/rmidevice/rmidevice.cpp index bdb9fc3..0d4fc19 100644 --- a/rmidevice/rmidevice.cpp +++ b/rmidevice/rmidevice.cpp @@ -237,6 +237,18 @@ bool RMIDevice::GetFunction(RMIFunction &func, int functionNumber) return false; } +void RMIDevice::PrintFunctions() +{ + std::vector<RMIFunction>::iterator funcIter; + + for (funcIter = m_functionList.begin(); funcIter != m_functionList.end(); ++funcIter) + fprintf(stdout, "0x%02x (%d) (%d): 0x%02x 0x%02x 0x%02x 0x%02x\n", + funcIter->GetFunctionNumber(), funcIter->GetFunctionVersion(), + funcIter->GetInterruptSourceCount(), funcIter->GetDataBase(), + funcIter->GetControlBase(), funcIter->GetCommandBase(), + funcIter->GetQueryBase()); +} + int RMIDevice::ScanPDT() { int rc; @@ -303,4 +315,14 @@ int Sleep(int ms) } } return 0; +} + +void print_buffer(const unsigned char *buf, unsigned int len) +{ + for (unsigned int i = 0; i < len; ++i) { + fprintf(stdout, "0x%02X ", buf[i]); + if (i % 8 == 7) + fprintf(stdout, "\n"); + } + fprintf(stdout, "\n"); }
\ No newline at end of file diff --git a/rmidevice/rmidevice.h b/rmidevice/rmidevice.h index 5191790..e347f80 100644 --- a/rmidevice/rmidevice.h +++ b/rmidevice/rmidevice.h @@ -39,7 +39,7 @@ public: virtual int SetMode(int mode) { return -1; /* Unsupported */ } virtual int WaitForAttention(struct timeval * timeout = NULL, int *sources = NULL) = 0; virtual int GetAttentionReport(struct timeval * timeout, int *sources, unsigned char *buf, - int *len) + unsigned int *len) { return -1; /* Unsupported */ } virtual void Close() = 0; virtual void Cancel() { m_bCancel = true; } @@ -54,6 +54,7 @@ public: int Reset(); bool GetFunction(RMIFunction &func, int functionNumber); + void PrintFunctions(); void SetBytesPerReadRequest(int bytes) { m_bytesPerReadRequest = bytes; } @@ -87,7 +88,8 @@ protected: int m_page; }; +/* Utility Functions */ long long diff_time(struct timespec *start, struct timespec *end); int Sleep(int ms); - +void print_buffer(const unsigned char *buf, unsigned int len); #endif /* _RMIDEVICE_H_ */
\ No newline at end of file |