Home › Forums › TWAIN Classic › Try to Open data source when it is powered off….
- This topic has 5 replies, 3 voices, and was last updated 17 years ago by gabe.
- AuthorPosts
Hello,
I am trying to check if the device is available when the application tries to open the data source.
Right now with WindowsXP+HP Photosmart 3210, connected with ethernet,when I issue DG_CONTROL/DAT_IDENTITY/MSG_OPENDS,the program hangs for about 1 minute and usually crashes if the device is powered off.Message (Dialog) is as follows….
Runtime Error! This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information(Dialog box from Microsoft Visual C++ Runtime Library).So does anyone know how to check if the device is online|powered on|ready before issueing OPENDS message?
Or is there any work around for this situation — except for ‘power on the device’ !Thank you in advance.
Best Regards,
Fuyuki Kameda— environment —
OS:Windows XP professional
twain.dll : v1.7.0.0
twain_32.dll : v1.7.1.0
Twunk_16.dll : v4.5.0.730
Twunk_32.dll : v4.5.0.730
Visual Studio / VC++I’d look into
DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT (looking for a return > 1)
then
DG_CONTROL / DAT_CAPABILITY / MSG_GET (looking for a return that represents TRUE)
passing in CAP_DEVICEONLINE both times.I’ve seem rumors that CAP_DEVICEONLINE isn’t reliable, but it seems pretty reliable to me.
gabe
Hi, gabe.
Thank you for reply.
But unfortunately, DG_CONTROL/DAT_CAPABILITY is valid only after the data source is opened, right? (Valid states between 4 to 7).
So, as I cannot open the DS when the device is turned off (that means I am still in state 3), how can I proceed to there?BTW, when the device is powered on, my program runs just fine.
And one work around is ping the device –yes! it is connected on LAN–, but that is not very TWAIN way and I don’t like that.Best regards,
FuyukiHi
Have you been able to figure out the solution to this. This is exactly what I am also looking for.
thanks
AnamikaFunny I just reread this post again over the weekend (don’t remember why) and I then I reread the cap description. From the twain spec under Application for CAP_DEVICEONLINE:
“This capability can be issued at any time to determine the availability of the image source hardware .”
You *should* be able to use this to determine if the hardware is online. The spec makes no mention of having to be between states 4 and 7 – and while the spec is not always 100% accurate (severe understatement) I believe in this case it is correct. I’ll double check this with a couple of drivers that I have installed and update this thread within a day but until then I’m going to stick to my original answer; use CAP_DEVICEONLINE.
.
ok, double checked. Seems that even with drivers that I normally consider
well behaved I’m not able to check cap_deviceonline until I open the source ~ which is too late to care what the response is in many cases.Back to the part of your question where you asked if I have a solution. Yes.. no.. a bit. I have a workaround. It isn’t a twain workaround, just a general windows programming workaround. I use a cbthook and a bit of polling to determine whether any new dialogs have been launched in 3 different places in my code. Whenever I am about to call OpenDs, EnableDs or EnableDsUiOnly – I record all of the open dialogs and set the cbtHook. I keep polling until the call is finished at which point I stop polling and remove the cbtHook. If any new dialogs are detected my code checks the details of the dialog and if they match the details for any dialog in my “known dialog” list, my code sends the “known response” to the dialog. The users have instructions to ‘train’ my app where they do various things that cause dialogs to come up – unplug the device and try to scan, cause ampaper jam and try to scan etc… After the training is complete they create rules of the unwanted dialogs and when a dialog would have come up and interupted their scanning at most they get a brief flash on screen and hear the error. Usually the cbthook closes the dialog before it even comes onscreen.
I wrapped all the dialog managment into my twain library, as I feel strongly that (unfortunately) dialog management is a part of twain’s problem domain. The .net code is open source and available over at http://www.codeplex.com/opentwain
.
- AuthorPosts