Home › Forums › TWAIN Classic › New Problem after a decade of successful use
- This topic has 1 reply, 2 voices, and was last updated 11 years, 5 months ago by MarkM.
- AuthorPosts
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,
randyfThe 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.
- AuthorPosts