May 20, 2008 at 2:06 pm #22344
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…
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);
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]));
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.May 20, 2008 at 3:34 pm #24515alviseParticipant
- Topics - 10
- Replies - 23
- Total Posts - 33
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.May 20, 2008 at 3:42 pm #24516
Sorry, my CallTwainProc method returns a logical, the method itself returns ‘rc == TWRC_SUCCESS’. So I know this has been successful.May 20, 2008 at 10:10 pm #24517
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.
.May 21, 2008 at 8:29 am #24518
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?May 21, 2008 at 4:27 pm #24519
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?
.May 23, 2008 at 5:44 am #24520
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.May 27, 2008 at 1:56 pm #24521
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?May 28, 2008 at 9:51 pm #24522
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?
.June 9, 2008 at 3:36 pm #24523
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.
- This topic has 9 replies, 3 voices, and was last updated 12 years, 10 months ago by .
Viewing 10 posts - 1 through 10 (of 10 total)
Viewing 10 posts - 1 through 10 (of 10 total)