TwainMBS Enumeration

I’m am pulling what little hair I have out over a TwainMBS issue. I’m trying to query a scanner about one of its capabilities (actually if the Feeder is loaded) and when I call GetEnumerationCapability I never get anything back. So doing something a bit more obvious I’m calling an example from the MBS documentation:

[code] t.openDS
'#define ICAP_SUPPORTEDSIZES 0x1122 //From twain.h
const ICAP_SUPPORTEDSIZES = &h1122

dim type5 as integer
dim EnumCount as integer = 0
dim EnumItemType as integer = 0
dim EnumCurrentIndex as integer = 0
dim EnumDefaultIndex as integer = 0
dim EnumValues() as integer = t.GetEnumerationCapability(ICAP_SUPPORTEDSIZES, EnumItemType, EnumCount, EnumCurrentIndex, EnumDefaultIndex)
dim iLastError as integer = t.Lasterror
dim iConditionCode as integer = t.ConditionCode

t.closeDS[/code]

This always brings back nothing and iLastError = 1 (FAILURE) and iConditionCode = 6 (TWCC_BADCAP)

If I do NOT call OpenDS I get iLastError = 1 (FAILURE) and iConditionCode = 11 (TWCC_SEQERROR)

So, looking for some insight on what I might doing wrong.

The errors sound correct. Not calling OpenDS (open data source) first will certainly get you a sequence error.

The other error is Bad Capability. So the GetEnumerationCqpability is for returning a property that has more than one value, whereas what you are trying to get/set is a single value. I’d guess that you should be calling GetIntegerCapability for this feature.

By the way, what capability code are you using for Duplex?

Well, normally I would agree, but I found a utility app that scans the scanner (say that 3 times fast) and enumerates its capabilities. It specifically returns enumerated values back for ICAP_SUPPORTEDSIZES. So all I can say is that another utility says its possible and I’m not getting anything returned back from the MBS plugin. I’ve tried several different ICAP constants and they all bring back nothing.

I’m about ready to pitch the MBS plugin out the window and go buy EZTWain Pro.

let me try it here.

your code works for me.
I see values (EnumCount is 8).

Do you still have a debug copy of the plugin?
That one writes details on the DebugView on Windows. This way maybe you see more details like an unsupported enum type.

and I sent you a debug plugin to try.

Update on this since I promised Christian I would. The TWAIN plugin receives events from the scanner. As such there can only be one active Twain object going at any given time. I was trying to encapsulate it into a single class and while it would scan it wouldn’t get/set values properly.

So I compromised and put everything I needed into a container control. In my app I can make it so there’s only one instance of it open - ever - so the container is a nice compromise so that all of the scanner logic is encapsulated into an object and is easily droppable on a window. It’s not my ideal solution but I don’t see much of a way around it. Maybe someday I’ll revisit but as long as it works…

There was one other issue that I needed to make sure I got straight. Before doing anything with the scanner you have to make sure you Open the DataSource. Without that one call nothing will work anyway.

So, thank you Christian, for helping me out. He did send me a couple of versions of debug TWAIN plugins in helping narrow down an an issue and it looks like, for whatever reason, my scanner didn’t like the Set Integer Value method. Not the first time with this Fujitsu scanner that it acts a little wonky with the MBS plugin where it works fine with others.

Since you can only have one instance at a time, have you considered using a singleton?

In particular I’ve found that you can only have one instance of TwainMBS in your applation. Getting that to live in any sort of encapsulated class seems pretty much impossible.

I could of course try to get rid of all globals in that plugin and move them to class variables.
But I use standard glue code and it may be difficult to pass all stuff by reference.
Not urgent right now.