Home › Forums › TWAIN Classic › Twain Driver Implementation question – long scan
- This topic has 3 replies, 2 voices, and was last updated 14 years, 2 months ago by jimwatters.
- AuthorPosts
Hi Community,
I read Twain Spec several times but this aspect still not clear to me. I am trying to implement driver for very slow scanner. So when first image already was transferred second is in process. In MSG_ENDXFER I as understand have to set pData->Count to -1. This means that I have more data. what State should I put my source: 5 or 6? it seems 5 is correct, or not?but the biggest issue is with Twack_32 from SDK. it processes scanning in a loop: do{} while (twPendingXfer.Count != 0);
so it does not wait for MSG_XFERREADY. is this correct and usual? i think if this implemented this way in SDK many applications in wild world use this tactic. May be I need to implement other way. But if i set pData->Count to zero, twacker exits scan loop 🙁Any advice will be helpful
Thank you!If you have more images to transfer you should stay in state 6 and return a count of -1 or >0.
Traversing from state 6 to 5 happens if you send a count of 0 for DAT_PENDINGXFERS.
Either by transferring all images or after receiving DAT_PENDINGXFERS/MSG_RESET which stops the transfers and sets the count to 0.
The source only sends one MSG_XFERREADY at the beginning of each scan loop.
Jim Watters
Jim, thank you!
I will stay in state6. I have question regarding how to process this situation correctly:
because source sends Ready only for first image, does this mean for subsequent requests I have to block DAT_IMAGENATIVEXFER request till image will be fully scanned?and what is correct to send back to DSM if this scan during I blocked process was canceled by pressing hardware button? Now I send MSG_CLOSEDSREQ, may be i need to do this more accurate way.
Thank you!!!
If I understand correctly you are always returning -1 as XferCount to indicate that there is more images coming regardless if there is more paper in the scanner. The scanner has a stop button to finish the scan job.
Then return TWRC_CANCEL to the DAT_IMAGExxxXFER message to indicate the user canceled.
The source remains in state 7. It is up to the application to send PendingXfer MSG_RESET
If the UI was visible and you want the application to close the UI too then you should send MSG_CLOSEDSREQ.
Applications like Photoshop will keep the UI open so the user can press scan to start the next batch.
Jim Watters
- AuthorPosts