TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

New Problem after a decade of successful use

Forums › TWAIN Classic › New Problem after a decade of successful use

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 3 months ago by MarkM.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 11, 2012 at 4:03 am #22789 Reply
    randyf
    Participant
    • Topics - 1
    • Replies - 0
    • Total Posts - 1

    I apologize if this question is not appropriate in this forum.

    I wrote a twain source for a camera about a decade ago (I believe I used Twain 1.71) that’s worked flawlessly in over 8000 installations.

    Just recently I received an issue from one client with multiple units that I have never seen before. It’s happened on multiple PC on this client’s network. When it happens it’s continuous but can then disappear. I’ve confirmed the issue with Twacker.

    After the source takes a capture, Twacker generated this error message:
    “Received while not in State 5”.

    If this rings a bell of what might be going on I’d appreciate any hints. My old memory banks (brain) have been wiped clean on the details of the Twain structure and protocol and thought I’d asked before relearning. I wasn’t young when I wrote the twain driver and things haven’t gotten better 🙂

    Thanks much,
    randyf

    October 24, 2012 at 3:02 pm #25715 Reply
    MarkM
    Participant
    • Topics - 1
    • Replies - 135
    • Total Posts - 136

    The looks like it may be a “sequence error”, an error return of TWRC_FAILURE / TWCC_SEQERROR.

    This typically happens when the application and the data source get out of sync with each other on what the current TWAIN state is. In this case the driver is complaining that it received a command that is only valid in state 5.

    Well, as it happens, the only command that’s typically issued in state 5 is DG_CONTROL / DAT_USERINTERFACE / MSG_DISABLEDS, which is the command to return to state 4 (negotiation mode).

    Regardless, the standard way to handle that sort of thing is to write a generic “resync” function. Something like the following…

    ResyncState(target) { // get us back to state 4…
    if (target < 7) DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER
    if (target < 6) DG_CONTROL / DAT_PENDINGXFERS / MSG_RESET
    if (target < 5) DG_CONTROL / DAT_USERINTERFACE / MSG_DISABLEDS
    }

    At this point you should be able to negotiate some value, like ICAP_XFERMECH to confirm that you’re in state 4.

    It’s also possible that the driver is in a bad situation, and it can’t work it’s way down to state 4. In that case you might try closing and reopening it with DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS and DG_CONTROL / DAT_IDENTITY / MSG_OPENDS. Even though MSG_CLOSEDS wasn’t designed to be run from any state, a lot of drivers support it.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: New Problem after a decade of successful use
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • Big Ass Photos – Free Huge Butt Porn, Big Booty Pics
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.