Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > RE: Device Simulator for USB

Reply
Thread Tools Display Modes

RE: Device Simulator for USB

 
 
stefanes
Guest
Posts: n/a

 
      02-22-2007
Hi!

I'm trying to get a simulated USB device to work using a MFC application,
with no luck...

I have a simulated USB device in a COM dll, and I want to "plug it in" using
my MFC application. What a do have is a working modified VBScript from the
SoftUSBAudio sample (Test2.0HubWithAudio.wsf), but I don't want to do this
using a VBScript...

I've tried all different approaches, with no luck. The solution I would like
to use is something like this;

#import "progid:SOFTUSB.SoftUSBDevice" no_namespace, no_auto_exclude
#import "progid:SoftEHCI.SoftEHCI" no_namespace
#import "progid:MyDevice.MyDevice" no_namespace

...

ISoftEHCI *m_piEHCI;

HRESULT hr = ::CoCreateInstance(CLSID_SoftEHCI,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(ISoftEHCI),
reinterpret_cast<void**>(&m_piEHCI));

...

Best regards,
Stefan


"goldrake" wrote:

> I implemented a SoftUSBDevice as a COM client. It's
> part of an application. This "dialog box" device is self
> pluggable (plug/unplug) button. Communication is
> implemented by ISoftUSBEndpointEvents. A CSink class
> manages a single endpoint, vector<CSink*> collects all
> the endpoints' references for startup/cleanup purposes.
>
> The system is:
>
> Dev simulator <-> kmdf driver <-> Test App
>
> Up until now, the system worked correctly. I tested
> ReadFiles (... passed) and DeviceIoControls that
> provide data to the device (InBuffer). In this case
> the device receives the data carried by InBuffer.
> (... passed)
>
> On the other hand, DeviceIoControls which require the
> device to send data back (OutBuffer) have some issue.
> The DeviceIoControl doesn't fail but it always reports
> 0 bytes received. Useless to say that the buffer is not
> filled.
>
> I filter the vendor request issued by the driver in
> the EP0's OnDeviceRequest callback (Simulator). At
> this point i'm required to CoTaskMemAlloc the buffer
> that holds the data to be returned.
>
> the following should let me enqueue the data:
>
> *ppbResponseData = (BYTE *)pbData;
> *pcbResponseData = 4;
> *pbSetupStatus = USB_ACK;
> *RequestHandle = 45; // for testing OnDeviceRequestComplete
>
> OnDeviceRequestComplete is also fired and handles me back 45.
> Not much to do here just a test and let
> *pbFinalRequestStatus = USB_ACK again.
>
> *************************
> * So the transaction is complete
> * but my DeviceIoControl
> * never sees any data !!!
> *************************
>
> I also hooked the OnSetupTransfer event. It seems to give
> me the right request "C0 B0 00 00 00 00 04 00".
>
> ( This should be fired before OnDeviceRequest
> is fired. But i notice that
>
> - if i hook OnSetupTransfer
> - let *pbStatus = USB_ACK;
> - and return S_OK;
>
> the driver and the app hang until i unplug the device
> and OnDeviceRequest is not called )
>
> There are not many details about it in the doc and
> if you GoogleFor("ISoftUSBDevice") you would be feeling
> luckier than me if you could find more than three links.
>
> Any clue?
>
>
>
>

 
Reply With Quote
 
 
 
 
stefanes
Guest
Posts: n/a

 
      02-23-2007
Thanks for your answer!

So i only need to import DSF.DSF and MyDevice.MyDevice?

#import "progidSF.DSF"
#import "progid:MobileStation.MobileStationDevice"

When I try to do this and try to do anything with e.g. MyDevice.MyDevice i
get "error C2653: 'MyDevice' : is not a class or namespace name" and "error
C2065: 'IMyDevice' : undeclared identifier"

I can't even instantiate object with e.g. "MyDevice::IMyDevice* pMyDevice;"

I think I'm missing something really fundamental... do you have any example
you could share, on how to get this to work in C++? All I have is this
VBScript, and I don't know anything about VBScripts...

Best regards

"goldrake" wrote:

> I guess #import and CoCreateInstance are an "either... or".
> What #import does is creating wrapper classes around the
> objects you specify (smart pointers). CoCreateInstance, on
> the other hand, lets you access to COM interfaces directly.
> Anyway, you don't have to interface to ISoftEHCI. You
> have to create an instance of the SoftUSBDevice that's in
> you COM dll (simulator). You also need to create an instance
> of DSF (framework) It is up to the framework to hot-plug
> your "DSFDevice"
>


 
Reply With Quote
 
stefanes
Guest
Posts: n/a

 
      02-23-2007
Again, sorry for the spam!

The example code i'm using should of course read

....

#import "progidSF.DSF"
#import "progid:MyDevice.MyDevice"

....
 
Reply With Quote
 
stefanes
Guest
Posts: n/a

 
      02-23-2007
Sorry, that should read

....

#import "progidSF.DSF"
#import "progid:MobileStation.MobileStationDevice"

....
 
Reply With Quote
 
stefanes
Guest
Posts: n/a

 
      02-26-2007
Hi again!

I'm getting really frustrated...

I think I've sorted out the #import/COM stuff, but how do I use it? I'm
trying to "copy" the test scripts from the samples, that comes with the
DSF-runtime, with no luck (e.g. Test2.0HubWithAudio.wsf).

The scripts I'm using as reference has a lot of ".Object(...)",
"EnumerateDevices" and other stuff in it, but I can't get it to work...

Do you have any sample/pseudo code to get the device plugged in? I have
installed the simulated host controller, but that's about it... I'm having
a really hard time getting my head around the the other stuff!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Train Simulator & Flight Simulator 2004 Jimmy Rich Windows Vista Games 9 05-21-2008 05:55 AM
Bus Simulator? Man-wai Chang ToDie Windows Vista Games 0 12-05-2007 10:29 AM
Flight Simulator X IvorY Windows Vista Games 7 11-17-2007 10:42 PM
Flight Simulator X Heywood Windows Vista Games 3 10-19-2006 11:49 AM
Kernel-mode simulator x856256@yahoo.com Windows Vista Drivers 10 08-16-2006 06:17 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59