IoKitRead Errors found

This is the English forum for all topics related to IO-Warrior. Please post in English only

Moderator: Guido Körber

Post Reply
Jeroen
Posts: 2
Joined: Mon May 09, 2011 11:25 am

IoKitRead Errors found

Post by Jeroen »

Hi All,

There are 2 old forum items:
"IO warrior spurious behavior" and 'IOW56 SPI transmission: not all bytes are read'
in which the recommendation to sleep a few ms after read an write are mentioned.
We included the sleeps but still have problems.

If we do subsequent IowKitRead calls, it sometimes fails but its return value is OK.
more specifically, our code looks like this:

///////////////////////////////////////////////////////////

memset(&m_repSp, 0, IOWKIT56_SPECIAL_REPORT_SIZE);
m_repSp.ReportID = 0x09; // out/in

KitWrite (m_hIO, IOW_PIPE_SPECIAL_MODE, (char *) &m_repSp, IOWKIT56_SPECIAL_REPORT_SIZE);

_ASSERT(m_repSp.ReportID == 0x09);

KitRead (m_hIO, IOW_PIPE_SPECIAL_MODE, (char *) &m_repSp, IOWKIT56_SPECIAL_REPORT_SIZE);

_ASSERT(m_repSp.ReportID == 0x09);

///////////////////////////////////////////////////////////

the KitRead is a small wrapper around the IoKitRead API function including the sleep calls.
If you like I can give you the code.

The second assert fails sometimes, which shoul never occur.

I have 2 questions:

1) Is the recommendation to include sleeps still valid ? Or has it been solved and is it not needed amymore ?
2) If not solved, is there a reliable work around ?

Thanks in advance,

Jeroen van der Heijden

User avatar
Christoph Jung
Posts: 628
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IoKitRead Errors found

Post by Christoph Jung »

What does the application do?
In your posted code you dont tell the IO-Warrior how many bytes you will read.
Could you post the KitRead function please. I will take a look into to understand what you are doing in this function.
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter

Jeroen
Posts: 2
Joined: Mon May 09, 2011 11:25 am

Re: IoKitRead Errors found

Post by Jeroen »

our KitRead fct is implemented as below.
It calls KitReadTimeout (shown further below) with a starting index for a time out array (0)
which specifies a timeout value (array contains 4 elements: 1000 1000 10000 10000 ( in milisecs ))

///////////////////////////////////////
bool NCHiIobWarrior::KitRead(IOWKIT_HANDLE devHandle, ULONG numPipe, PCHAR buffer, ULONG length)
{
int iTimeoutIndex = 0;
return KitReadTimeout(devHandle, numPipe, buffer, length, iTimeoutIndex);
}
////////////////////////////////////////

the KitReadTimeout fct does what is shown below.

basically, it calls IowKitRead as long as res != IOWKIT56_SPECIAL_REPORT_SIZE


/////////////////////////////////////////////////////////
bool NCHiIobWarrior::KitReadTimeout(IOWKIT_HANDLE devHandle, ULONG numPipe, PCHAR buffer, ULONG length, int iTimeoutIndex)
{

IowKitSetTimeout(devHandle, g_vTimeoutsRead[iTimeoutIndex]); // creates read error if not read within the timeout time

ULONG res = 0;
try
{
res = IowKitRead(devHandle, numPipe, buffer, length);
}
catch (...)
{
return false;
}

Sleep(2);

if (res == length)
{
return true;
}
else
{
// restart pending read (see IowKit_V15_API.pdf)
iTimeoutIndex++;
bool retval = KitReadTimeout(devHandle, numPipe, buffer, length, iTimeoutIndex);
return retval;
}
}
////////////////////////////////

I hope you understand the code.

User avatar
Christoph Jung
Posts: 628
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IoKitRead Errors found

Post by Christoph Jung »

sorry for my late reply.

Your function looks good. I can not find any errors.
You can test a sleep of ZERO to fix it. But i have no resolution for that problem ATM.
The next 2 weeks we are busy, because we will go to a exhibition. I will take a look after that.
Please contact me here in this thread after 14th june that i don't forget it.
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter

Guido Körber
Site Admin
Posts: 2762
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IoKitRead Errors found

Post by Guido Körber »

Has this issue been solved?

Post Reply