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

Issue with CAP_DEVICEONLINE

Forums › TWAIN Classic › Issue with CAP_DEVICEONLINE

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 8 months ago by MarkM.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • May 14, 2014 at 6:37 am #22945 Reply
    Sharad
    Participant
    • Topics - 9
    • Replies - 3
    • Total Posts - 12

    Hi,

    I want to know whether device is connected or not. I opened the DS using MSG_OPENDS and then called CAP_DEVICEONLINE. Sample code is here….

    bNewReturn = m_DSMEntry(pOrigin,NULL,DG,DAT,MSG_OPENDS,pData);
    if(bNewReturn == TWRC_SUCCESS)
    {
    TW_CAPABILITY twCap;
    twCap.Cap = CAP_DEVICEONLINE;
    pTW_ONEVALUE pVal;
    TW_UINT32 value;
    TW_BOOL twReturn = DSM_Entry(pOrigin,(pTW_IDENTITY)pData,DG_CONTROL,DAT_CAPABILITY,MSG_GETCURRENT,(TW_MEMREF)&twCap);

    pVal = (pTW_ONEVALUE )GlobalLock(twCap.hContainer);
    if(pVal)
    {
    value = pVal->Item;
    GlobalUnlock(pVal);
    GlobalFree(twCap.hContainer);
    }
    }

    the pVal->item is coming 0 for not connected device and coming 1 for connected device. but twReturn value is 0 in both the case. is this behaviour is correct?
    Putting twCap.Cap = CAP_DEVICEONLINE; other two parameter twCap.Container and type I have not filled. is that oK?
    If i use the above code I get crash while opening DSM. but If i wont use CAP_DEVICEONLINE I wont get any crash.

    Please suggest how to use CAP_DEVICEONLINE correctly. Is there any other way to know whether device is online or not?

    Best Regards,
    Sharad

    May 20, 2014 at 2:57 pm #26140 Reply
    MarkM
    Participant
    • Topics - 1
    • Replies - 135
    • Total Posts - 136

    TWAIN is ambiguous about how a driver is required to respond to MSG_OPENDS, when the device is not online.

    Some vendors return a failure and refused to open. Some may open anyways. So it’s always advisable for an application to confirm that the device is present with CAP_DEVICEONLINE, but this can only happen after a successful call to MSG_OPENDS.

    The return value for a check of CAP_DEVICEONLINE should always be TWRC_SUCCESS. It only indicates that the call was successfully processed. The contents of the capability container must be examined to check for TRUE or FALSE.

    If an application wants to know about the availability of a device *before* opening it with TWAIN, it has to perform checks using tools provided by the operating system. In the case of Windows this can be done using by registering for WIA events (http://msdn.microsoft.com/en-us/library/windows/desktop/ms629856(v=vs.85).aspx). In the case of Linux it can be done using a popen to the command line “lsusb” (among other ways). In the case of Mac OS X it can be done using a popen to the command line “system_profiler SPUSBDataType” (among other ways).

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Issue with CAP_DEVICEONLINE
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

  • 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.
  • To get the list of scanners from javascript client side (browser)
  • 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.