When issuing CSAFE commands I always get USB time out errors
Posted: February 22nd, 2015, 5:34 pm
Hi All.
I've just started work on an application which will provide a speaking interface to the PM so that blind users are better able to use the functions.
I'm developing this application on windows using C++ and MFC.
I'm using a PM5 to test with and I've had no problems getting it connected and getting my software to detected however all the CSAFE commands i have tried to send result in a USB time out error. the message reads:
Unable to initialize PM Interface Libraries. The USB read operation did not complete within the timeout period
Some calls are working fine, these are the calls to get the hw, fw versions and serial number.
Below I've copied my initialization code and commands that demonstrate the issue.
Anyone have any ideas how i fix this?
Using windows 7 64 bit and VS2008 as my IDE. I've not installed any extra drivers and haven't changed any USB settings. The PM auto detected with out problems.
Thanks.
Nick.
I've just started work on an application which will provide a speaking interface to the PM so that blind users are better able to use the functions.
I'm developing this application on windows using C++ and MFC.
I'm using a PM5 to test with and I've had no problems getting it connected and getting my software to detected however all the CSAFE commands i have tried to send result in a USB time out error. the message reads:
Unable to initialize PM Interface Libraries. The USB read operation did not complete within the timeout period
Some calls are working fine, these are the calls to get the hw, fw versions and serial number.
Below I've copied my initialization code and commands that demonstrate the issue.
Anyone have any ideas how i fix this?
Using windows 7 64 bit and VS2008 as my IDE. I've not installed any extra drivers and haven't changed any USB settings. The PM auto detected with out problems.
Thanks.
Nick.
Code: Select all
// connect code. this works fine.
{ // attempt a connection
tkcmdsetUSB_init();
tkcmdsetDDI_init();
/* Discover and get count of all discovered PM3s or PM4s. Tell DLL to start numbering at 0. */
UINT16 numUnits( 0 );
tkcmdsetDDI_discover_pm3s(TKCMDSET_PM3_PRODUCT_NAME2, 0, &numUnits);
tkcmdsetDDI_discover_pm3s(TKCMDSET_PM4_PRODUCT_NAME, 0, &numUnits);
tkcmdsetDDI_discover_pm3s("Concept2 Performance Monitor 5 (PM5)", 0, &numUnits);
if (numUnits > 0)
{/* Initialize the CSAFE protocol engine. Leave timeout at default. */
ERRCODE_T result = tkcmdsetCSAFE_init_protocol( 1000 );
if (result != 0)
{
CString error = L"Unable to inicialise PM Interface Libraries. ";
char message[200];
tkcmdsetDDI_get_error_text( result, &message[0], 200);
error.Append( CharToWChar( &message[0] ) );
m_window->MessageBox( error, L"ERG Jabber", IDOK);
}
else
{
m_isConnected = true;
m_window->PmConnected();
}
}
}
// query function. this results in the error above.
bool CPmInterfaceWrapper::QueryPM()
{
bool finalResult = true;
// return true if you get any data at all from the PM.
// false should be returned only if we think the connection has been lost.
const UINT16_T CMD_SIZE = 1;
const UINT16_T RESPONSE_SIZE = 10;
UINT32_T command[ CMD_SIZE ];
UINT32_T response[ RESPONSE_SIZE ];
UINT16_T responseSize( RESPONSE_SIZE );
command[0] = CSAFE_GETTWORK_CMD;
for (UINT16 i = 0; i < RESPONSE_SIZE; i++)
{
response[ i ] = 0xFFFFFFFF;
}
ERRCODE_T result = tkcmdsetCSAFE_command(0,
CMD_SIZE,
&command[0],
&responseSize,
&response[0] );
if (result != 0)
{
CString error = L"Unable to inicialise PM Interface Libraries. ";
char message[200];
tkcmdsetCSAFE_get_error_text( result, &message[0], 200);
error.Append( CharToWChar( &message[0] ) );
m_window->UpdateStatus( error );
}
else
{
finalResult = true;
WCHAR cText[32];
wsprintf(cText, L"%d:%02d:%02d", response[0], response[1], response[2] );
m_time = cText;
}
return finalResult;
}