Tattakashi123 / t

Automatically exported from code.google.com/p/twaindotnet
0 stars 0 forks source link

Failed to set capability #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Launch the winform interface (it's same with WPF)
2. Select the scanner source.
3. Click on "Scan".
4. An error is throwed about the impossibility to set the capability object
to the scanner.

What is the expected output? What do you see instead?
A message error with "Failed to set capability".

What version of the product are you using? On what operating system?
Using the last version of source code of twain dotnet. 
Computer with Windows XP SP3.
Scanner ref : Plustek OpticSlim M12

Please provide any additional information below.

Original issue reported on code.google.com by heinzer....@gmail.com on 30 Jun 2009 at 8:55

GoogleCodeExporter commented 8 years ago
More information :

This bug is really strange because the original project
(http://www.codeproject.com/KB/dotnet/twaindotnet.aspx) is well running with my 
scanner.
I tried to compare these two projects but I don't understand which differences
prevent me to set capabilities.

Original comment by heinzer....@gmail.com on 30 Jun 2009 at 3:49

GoogleCodeExporter commented 8 years ago
Hi David,

I've added some debugging to the capabilities class to help track this down. It 
should output something like this to the debug output window in Visual Studio:

1666 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set 
capabilities:XferCount, value:1, type:1
1696 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
1696 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set 
capabilities:IPixelType, value:2, type:2
1697 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully

Can you please try the latest code and send back the output. I'm guessing that 
your 
scanner doesn't support setting XferCount or one of the other capabilities.

Thanks,

Luke

Original comment by luke.qui...@gmail.com on 11 Jul 2009 at 1:16

GoogleCodeExporter commented 8 years ago
Hi Luke,

Thanks for your help.
I get back the last version of you code and try it with my scanner.
The problem is not resolved, I send you the output traces of the error :

4873 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:IPixelType, value:2, type:2
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
4920 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:IPixelType, value:2, type:2, result:Int16
4920 [10] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:IPixelType reason: SequenceError

I tried to comment the capability setting of IPixelType and this error occured 
with
next capability setting. I really don't understand the source of this error.

Thanks in advance for your help

David

Original comment by heinzer....@gmail.com on 15 Jul 2009 at 1:36

GoogleCodeExporter commented 8 years ago
I solve this issue alterning two operation inside the Acquire method of the 
Twain
class. Taking a look at the TWAIN standard, the only valid state where the 
capability
negotiation should take place is in state 4, that is, immediately after doing a
OPENDS and before doing a ENABLEDS.

Try moving the following code block (found inside Acquire method):

<code>
            UserInterface ui = new UserInterface();
            ui.ShowUI = (short)(settings.ShowTwainUI ? 1 : 0);
            ui.ModalUI = 1;
            ui.ParentHand = _messageHook.WindowHandle;;
            result = Twain32Native.DsUserInterface(
                _applicationId,
                _defaultSourceId,
                DataGroup.Control,
                DataArgumentType.UserInterface,
                Message.EnableDS,
                ui);

            if (result != TwainResult.Success)
            {
                CloseSource();
                return;
            }
</code>

after all capabilities setting.

Original comment by diegoz...@gmail.com on 21 Jul 2009 at 1:09

GoogleCodeExporter commented 8 years ago
Hi Luke,

I have just tested you solution.
It's better because now, I have the first SetCapability(Capabilities.XferCount) 
which
is working correctly.
But next SetCapabilities provoke exceptions.

I send you my output trace :

2843 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:XferCount, value:1, type:1
2874 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
3499 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:IPixelType, value:2, type:2
3499 [10] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:IPixelType, value:2, type:2, result:Int16
3499 [10] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:IPixelType reason: SequenceError
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll

As you can see, the exception looks to be linked to a sequence error. I tried to
change some SetCapability calls order without success.
I 'm looking for another correction solution.

Thanks for your help Luke!
David

Original comment by heinzer....@gmail.com on 21 Jul 2009 at 1:40

GoogleCodeExporter commented 8 years ago
I made some more tests, where I tried to call SetCapabilities for each possible
capability :

* My test code :

                #region tests
                try
                {
                    Capability.SetCapability(Capabilities.AutoFeed, true,
_applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.BitDepth,
settings.Resolution.GetBitDepth(), _applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.DuplexEnabled, true,
_applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.FeederEnabled, true,
_applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.FeederLoaded, true,
_applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.FeedPage, true,
_applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.XResolution,
settings.Resolution.Dpi.Value, _applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }

                try
                {
                    Capability.SetCapability(Capabilities.YResolution,
settings.Resolution.Dpi.Value, _applicationId, _defaultSourceId);
                }
                catch (Exception)
                {
                }
                #endregion

* Results in the output :

4937 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:XferCount, value:1, type:1
5031 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
5031 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:AutoFeed, value:1, type:1
5046 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
5046 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:BitDepth, value:16, type:16
5046 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
5046 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:DuplexEnabled, value:1, type:1
5046 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:DuplexEnabled, value:1, type:1, result:Bool
5062 [11] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:DuplexEnabled reason: BadCapability
5062 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:FeederEnabled, value:1, type:1
5062 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:FeederEnabled, value:1, type:1, result:Bool
5078 [11] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:FA first chance exception of type 'TwainDotNet.TwainException' 
occurred
in TwainDotNet.dll
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
A first chance exception of type 'TwainDotNet.TwainException' occurred in 
TwainDotNet.dll
eederEnabled reason: BadCapability
5249 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:FeederLoaded, value:1, type:1
5249 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:FeederLoaded, value:1, type:1, result:Bool
5249 [11] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:FeederLoaded reason: BadValue
5265 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:FeedPage, value:1, type:1
5265 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilities:FeedPage, value:1, type:1, result:Bool
5265 [11] ERROR TwainDotNet.TwainNative.Capability (null) - Failed to set
capabilites:FeedPage reason: BadCapability
5281 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:XResolution, value:300, type:300
5281 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully
5281 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Attempting to set
capabilities:YResolution, value:300, type:300
5453 [11] DEBUG TwainDotNet.TwainNative.Capability (null) - Set capabilities 
successfully

I hope it could help you to understand the problem.
Maybe my scanner doesn't support some of these capabilities?

Original comment by heinzer....@gmail.com on 21 Jul 2009 at 3:46

GoogleCodeExporter commented 8 years ago
Hi David,

I followed Diego's advice about opening the data source after setting all 
capabilities. Hopefully if you try the code again this will fix your issue.

I'm not surprised that your scanner doesn't support all of those capabilities. 
Hopefully I can get some better code in place for negotiating with the scanner 
about 
what it will support.

Thanks,

Luke

Original comment by luke.qui...@gmail.com on 29 Jul 2009 at 12:15

GoogleCodeExporter commented 8 years ago
Hi Luke,

Good news, it's working now!
Thanks for your help.
Now I will use your API and come back here if I find some possible improvements.

David

Original comment by heinzer....@gmail.com on 30 Jul 2009 at 2:10

GoogleCodeExporter commented 8 years ago

Original comment by luke.qui...@gmail.com on 3 Aug 2009 at 11:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The issue returns in latest version, failed to set capability : 'FeederEnabled'.
I test WpfTest on Benq 5560

And other different fail with capability on:
CANON DR-9080C
Panasonic KV-S2065C
Panasonic KV-S2048C

Original comment by zgg...@gmail.com on 8 Dec 2011 at 10:12