Home › Forums › TWAIN Classic › Interpreting Capability results in TWON_ARRAY
- This topic has 9 replies, 3 voices, and was last updated 15 years, 11 months ago by icarus75.
- AuthorPosts
Am I being stupid or just missing something? Either way, can you help? I’m trying to get the capabilities of the connected scanner, I’ve also tried it using the TWAIN_32 Sample Source. The returned values do not make any sense. This is the code…
TW_CAPABILITY twAllCaps;
twAllCaps.Cap = CAP_SUPPORTEDCAPS;
twAllCaps.ConType = TWON_ARRAY;
twAllCaps.hContainer = NULL;
bool nCRet = CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_GET,(TW_MEMREF)&twAllCaps);if (nCRet)
{
pTW_ARRAY pvalArray;
TW_UINT16 valueU16;
TW_UINT16 index;
pvalArray = (pTW_ARRAY)GlobalLock(twAllCaps.hContainer);
for (index = 0; index < pvalArray->NumItems; index++)
{
if (pvalArray->ItemType == TWTY_UINT16)
{
valueU16 = ((TW_UINT16)(pvalArray->ItemList[index*2]));
}
}
GlobalUnlock(twAllCaps.hContainer);
}Everything appears successful, for the TWAIN_32 Sample I get 40 items with a Canon MP730 I get 122 items. However, the values are weird, for the TWAIN_32 Sample Source the results are…..
5, 2, 3, 31, 32, 0, 17, 18, 48, 49, 2, 15, 7, 3, 0 – That’s the first 15 values, the rest continue in the same way.
These don’t seem to relate to any capability, what am I missing?
Thanks.
The return value from the twain entry point (nCRet) is zero (TWRC_SUCCESS) when the call has been successful. A return value above zero means failure: check the twain status to know what happened.
You should change “if (nCRet)” into “if (!nCRet)” for your code to be OK.
And you’ll discover that the call has gone wrong, but you think it was OK, and the parameter list that you read is not the real one.
Good luck with twain. Alvise.
Sorry, my CallTwainProc method returns a logical, the method itself returns ‘rc == TWRC_SUCCESS’. So I know this has been successful.
this isn’t directly in response to your question, but I don’t see you checking that the container is an twArray. I typically check the container type regardless of how it’s written in the spec, mostly because of the large number of drivers that return things slightly differently (wrong).
Just so we can compare from a known source that is a bit more ‘real’ – how well does your code behave when run against a Kodak i30 driver in simulation mode?
If the i30 behaves I would write off the driver.
.
Thanks Gabe. I’ve checked the container, it is a twArray.
Obviously I’m getting the same problem on the Twain sample source and the Canon I’m testing on, so I’m not sure if it would be a driver issue.
I’ve downloaded the Kodak i30 driver and tried it, the results from the supported caps are 88 items in the array, here are the first few values…
1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 7, 11, 13, 14, 15, 16, 18, 19, 20, 21, 29, 31, 34, 26, 44, 45, 3, 9…the values carry on between 0 and 158.
Any ideas?
good, someplace to start – your code is odd. while I go dig out some c++ code to compare, why Index*2 ?
and just for kicks, have you looked at Dosadi’s CTwain sample?
.The index*2 I think is a little odd, but it was in the example in the twain spec.
I have tried it just as index and the results are similar to before, with the exception that once index gets to 11 every odd number value is 16.
Nope, I’ll take a look when I get to work.
I thought I’d try on a different PC that has never had a twain device installed on it before. I installed the Kodak i30 driver and gave it a try and got the same results.
This is getting stupid now. A simple bit of code to get a list of capabilities returns success. The twArray has a list of values that don’t represent any kind of capability, although the itemcount of the twArray does seem to imply that it has found varying numbers of capabilities depending on the selected scanner.
Has anyone used CAP_SUPPORTEDCAPS successfully and has a snippet of code for me to look at?
my vb.net code uses it and is over at http://www.codeplex.com/opentwain.
I don’t use it in my c++ projects. You sure this isn’t in dosadi’s sample?
.I couldn’t find any mention of CAP_SUPPORTEDCAPS in dosadi’s ctwain.
For the time being I’ve given up, I have no more time to troubleshoot this and I think I’ve also exhausted the possible causes.
I’ll just check for a couple of capabilities that our customers have so far asked for and set as required.
For some of the image manipulation I’m using DTK’s image library and DTK’s barcode reader library for handling batch control through barcodes.
- AuthorPosts