本文整理汇总了C++中TimeStamp::SetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStamp::SetTime方法的具体用法?C++ TimeStamp::SetTime怎么用?C++ TimeStamp::SetTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeStamp
的用法示例。
在下文中一共展示了TimeStamp::SetTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFeatureReport
//-----------------------------------------------------------------------------
// <HidController::Read>
// Read data from the HID port
//-----------------------------------------------------------------------------
void HidController::Read
(
)
{
uint8 buffer[FEATURE_REPORT_LENGTH];
int bytesRead = 0;
uint8 inputReport[INPUT_REPORT_LENGTH];
TimeStamp readTimer;
while( true )
{
// Rx feature report buffer should contain
// [0] - 0x05 (rx feature report ID)
// [1] - length of rx data (or 0x00 and no further bytes if no rx data waiting)
// [2]... - rx data
// We poll this waiting for data.
bytesRead = GetFeatureReport(FEATURE_REPORT_LENGTH, 0x5, buffer);
CHECK_HIDAPI_RESULT(bytesRead, HidPortError);
if( bytesRead >= 2 )
{
if( buffer[1] > 0 )
{
string tmp = "";
for (int i = 0; i < buffer[1]; i++)
{
char bstr[16];
snprintf( bstr, sizeof(bstr), "0x%.2x ", buffer[2+i] );
tmp += bstr;
}
Log::Write( LogLevel_Detail, "hid report read=%d ID=%d len=%d %s", bytesRead, buffer[0], buffer[1], tmp.c_str() );
}
if( buffer[1] > 0 )
{
Put( &buffer[2], buffer[1] );
}
}
if( readTimer.TimeRemaining() <= 0 )
{
// Hang a hid_read to acknowledge receipt. Seems the response is conveying
// transaction status.
// Wayne-Dalton input report data is structured as follows (best guess):
// [0] 0x03 - input report ID
// [1] 0x01 - ??? never changes
// [2] 0xNN - if 0x01, no feature reports waiting
// if 0x02, feature report ID 0x05 is waiting to be retrieved
// [3,4] 0xNNNN - Number of ZWave messages?
int hidApiResult = hid_read( m_hHidController, inputReport, INPUT_REPORT_LENGTH );
//if( hidApiResult != 0 )
//{
// string tmp = "";
// for( int i = 0; i < INPUT_REPORT_LENGTH; i++ )
// {
// char bstr[16];
// snprintf(bstr, sizeof(bstr), "%02x ", inputReport[i] );
// tmp += bstr;
// }
// Log::Write( LogLevel_Detail, "hid read %d %s", hidApiResult, tmp.c_str() );
//}
if( hidApiResult == -1 )
{
const wchar_t* errString = hid_error(m_hHidController);
Log::Write( LogLevel_Warning, "Error: HID port returned error reading input bytes: 0x%08hx, HIDAPI error string: %ls", hidApiResult, errString );
}
readTimer.SetTime( 100 );
}
m_thread->Sleep(10);
}
HidPortError:
Log::Write( LogLevel_Warning, "Error: HID port returned error reading rest of packet: 0x%08hx, HIDAPI error string:", bytesRead );
Log::Write( LogLevel_Warning, "%ls", hid_error(m_hHidController));
}