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

DS problem when CAP_SUPPORTEDCAPS

Forums › TWAIN Classic › DS problem when CAP_SUPPORTEDCAPS

  • This topic has 3 replies, 2 voices, and was last updated 10 years, 4 months ago by MSM.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 31, 2010 at 9:34 am #22629 Reply
    gregary
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    It can’t work under TWAIN2 Sample App. Can anyone tell me why? Thanks.


    //g_DSM_Entry is import from DAT_ENTRYPOINT


    case CAP_SUPPORTEDCAPS:
    {
    TW_ARRAY *array;
    TW_UINT16 ItemCount=2;
    pCap->ConType=TWON_ARRAY;
    if(g_DSM_Entry.DSM_MemAllocate!=0)
    {
    pCap->hContainer=g_DSM_Entry.DSM_MemAllocate(sizeof(*array)+sizeof(TW_UINT16)*(ItemCount)-sizeof(TW_UINT8));
    }
    else
    {
    pCap->hContainer=GlobalAlloc(GHND,sizeof(*array)+sizeof(TW_UINT16)*(ItemCount)-sizeof(TW_UINT8));
    }
    if(pCap->hContainer)
    {
    if(g_DSM_Entry.DSM_MemLock!=0)
    {
    array=(TW_ARRAY*)g_DSM_Entry.DSM_MemLock(pCap->hContainer);
    }
    else
    {
    array=(TW_ARRAY*)GlobalLock(pCap->hContainer);
    }
    array->ItemType=TWTY_UINT16;
    array->NumItems=ItemCount;
    array->ItemList[0]=CAP_SUPPORTEDCAPS;
    array->ItemList[1]=CAP_XFERCOUNT;
    if(g_DSM_Entry.DSM_MemUnlock!=0)
    {
    g_DSM_Entry.DSM_MemUnlock(pCap->hContainer);
    }
    else
    {
    GlobalUnlock(pCap->hContainer);
    }
    }
    else
    {
    m_IndependantCapMap.m_DSConditionCode=TWCC_LOWMEMORY;
    twrc=TWRC_FAILURE;
    }
    break;
    }
    September 2, 2010 at 12:42 pm #25326 Reply
    MSM
    Participant
    • Topics - 0
    • Replies - 29
    • Total Posts - 29

    Hi Gregary,

    see declaration of TW_ARRAY:

    typedef struct {
    TW_UINT16 ItemType;
    TW_UINT32 NumItems; /* How many items in ItemList */
    TW_UINT8 ItemList[1]; /* Array of ItemType values starts here */
    } TW_ARRAY, FAR * pTW_ARRAY;

    ItemList is a TW_UINT8, but not TWTY_UINT16.
    You have to fill array properly.

    TWTY_UINT16 *p_un16Array = (TWTY_UINT16 *)array->ItemList;
    p_un16Array[0]=CAP_SUPPORTEDCAPS;
    p_un16Array[1]=CAP_XFERCOUNT;

    September 8, 2010 at 2:55 am #25327 Reply
    gregary
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    Thanks for your response.
    I change my code like this:
    ((TW_UINT16*)array->ItemList)[0]=CAP_SUPPORTEDCAPS;
    ((TW_UINT16*)array->ItemList)[0]=CAP_XFERCOUNT;

    And i find out the carsh of TWAIN2 sample app is because it call “DG_CONTROL//DAT_CAPABILITY//MSG_GETLABEL//CAP_XFERCOUNT” after “DG_CONTROL//DAT_CAPABILITY//MSG_GET//CAP_SUPPORTEDCAPS” but i didn’t supply this command.

    September 10, 2010 at 2:01 pm #25328 Reply
    MSM
    Participant
    • Topics - 0
    • Replies - 29
    • Total Posts - 29

    I had such problem before.
    And I found two bugs – one in Sample App and one in the Driver

    In the Sample App it crashes because the Driver returns TWRC_SUCCESS, but the string was empty.

    In the Driver – it must return TWRC_FAILURE/TWCC_CAPBADOPERATION , but not TWRC_SUCCESS if it is not supporting this operation.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: DS problem when CAP_SUPPORTEDCAPS
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

  • Girls of Desire: All babes in one place, crazy, art
  • 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.