Two device accessing USB driver

Hi All,
I developed a USB driver for my USB 2.0 chip. On top of that i developed a VC++ dll for driver access. In that i developed basic function like
EnumerateALL (Which enumerate the devices having my chip on it)
List device( Which list the number of devices connected to PC having my USB 2.0 Chip)

Now i developed one hardware, which is using my USB2.0 chip on that. So obviously it is going to use my driver. I developed simple C++ threading application which continuosly read the attached hardware.

Now i am connecting another (diffrent) hardware having the same chip. I worte simple windows service that detect anything is happen on USB bus. So when i connect 2nd hardware i got a call from that service and my application is checking what happen on USB bus using List device function. Usning this it figures out that if my USB device type hardware is connected than it shows now number of hardware is two and check it whether it is previous one or new one. Because my application are continuosly reading 1st hardware and suddenly it was switched in to that service.

Now as i mentioned that i am attaching diffrent hardware so obvious my application couldn’t match the descriptor of that device and try to do the same thing which it was doing. But at this point my application is going to be hang and it couldn’t able to read anything.

So i think my dll/driver may create some problem. I suspect more on DLL.
If any one has nay idea then let me know how to solve it.

Regards,
Tejas

Ohh…one more thing that my driver is able to detect (enumerate) two hardware. But the problem starts when i start application means dll comes to in picture.

Regards,
Tejas

xxxxx@slscorp.com wrote:

Ohh…one more thing that my driver is able to detect (enumerate) two hardware. But the problem starts when i start application means dll comes to in picture.

I can’t tell from your description what you’re actually doing. It was
too confusing. How does the application access the driver? Are you
creating a symbolic link, or are you using a device interface? If you
are using a symbolic link, are you generating a different name for each
instance?

How do you expect this to work?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,
Thanks for you answer.
Yes, i am creating symbolic link. Also i am generating a different name for each instance.

Please find below code of my function:
SLS_STATUS SLSUSBDev::EnumerateAllDevices()
{

HDEVINFO hDevInfo;
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
LPGUID pGuid =(LPGUID) &GUID_CLASS_SLSUSB_BULK;
SP_DEVINFO_DATA DevInfoData;
int iIndex;
SLS_STATUS status;

hDevInfo = SetupDiGetClassDevs (
pGuid,
NULL, // Define no enumerator (global)
NULL, // Define no
(DIGCF_PRESENT | // Only Devices present
DIGCF_DEVICEINTERFACE)); // Function class devices.

if(hDevInfo == INVALID_HANDLE_VALUE)
{
CString str;
str.FormatMessage(“SetupDiGetClassDevs: Invalid Handle Getlasterror %d\n”,GetLastError());
DbgMsg(str.GetBuffer(str.GetLength()));

return SLS_DEVICE_NOT_FOUND;
}

for(iIndex=0;;iIndex++)
{
DevInfoData.cbSize = sizeof (SP_DEVINFO_DATA);

if(!SetupDiEnumDeviceInfo(hDevInfo,iIndex,&DevInfoData))
{
if(GetLastError()==ERROR_NO_MORE_ITEMS)
break;
/*CString str;
str.FormatMessage(“SetupDiEnumDeviceInfo: function fail Getlasterror %d\n”,GetLastError());
DbgMsg(str.GetBuffer(str.GetLength())); */

}

DeviceInterfaceData.cbSize = sizeof (SP_DEVICE_INTERFACE_DATA);

if (!SetupDiEnumDeviceInterfaces(hDevInfo,0,pGuid,iIndex,&DeviceInterfaceData))
{
if(GetLastError()==ERROR_NO_MORE_ITEMS)
break;

}

/* Get SerialNumber */
std::string strSerialNo = GetSerialNumber(hDevInfo,&DevInfoData);
/* Get Product Decription */
std::string strProductDescription = GetProductDescription(hDevInfo,&DevInfoData);
/* Get Device Symbolic LinkName*/
std::string strDevSymbolicLink = GetSymbolicLink(hDevInfo,&DeviceInterfaceData);

DeviceDescriptor DevDescriptor;
DevDescriptor.m_strSerialNumber = strSerialNo;
DevDescriptor.m_strProductDescription = strProductDescription;
DevDescriptor.m_strSymbolicName = strDevSymbolicLink;

m_vecDeviceDesc.push_back(DevDescriptor);

status = GetDevicePipeInfo(strDevSymbolicLink.c_str(),iIndex);

if(status != SLS_OK)
{

return SLS_IO_ERROR;
}

}

/*The SetupDiDestroyDeviceInfoList : function destroys a device information set
and frees all associated memory. */
if(!SetupDiDestroyDeviceInfoList(hDevInfo))
{
CString str;
str.FormatMessage(“SetupDiDestroyDeviceInfoList: function fail Getlasterror %d\n”,GetLastError());
DbgMsg(str.GetBuffer(str.GetLength()));
}

return SLS_OK;
}

Now when i attached another different hardware (Having a same USB chip a first hardware has), how can i know what happen on USB bus? For that i ussed one windows service which gives me some message like something is happend on USB bus. So my first application will call List device and above function is part of it. Using that i can found that my existing device disconnected or another device is connected. But for doing this i can loss my control on first hardware application. I am not doing any thing like closing the handle and ect…just i check the number of devices and base on that i am fetching descriptor value.

It is some what complicated for me to explanin but i hope this post will clear some of your doubts.

Thanks & Regards,
Tejas