Link to home
Start Free TrialLog in
Avatar of HubrisSonic
HubrisSonic

asked on

talking to WinRT-USB ActiveX Dll

I have a device that uses an old WinRT-USB driver, does anybody know the sequence to open the device, write some data to one of the pipes and read the result from another pipe? I dont want to buy a Jungo Driver toolkit.

I know the Vendor ID, etc. and the interface numbers I want to write to. and what data I want to write.

Avatar of Rimscorp
Rimscorp

WinRT uses a fundamentally different approach than
other products by using a preprocessor to convert special sections of the WinRT application
into driver commands so that an entire sequence of commands is actually executed at driver level
(Ring 0). For example, the sequence:

outpb( CMOS_ADDR, reg );
stall( 20 );outpb( CMOS_DATA, val );
stall( 20 );

is converted by the preprocessor into:
WINRT_CONTROL_ITEM _WinRTpp02[] =
{// command param1 param2
{OUTP_B, 0, 0},
{STALL, 0, 20},
{INP_B, 0, 0},
{STALL, 0, 20},
};
_WinRTpp02[ 0].port = CMOS_ADDR;
_WinRTpp02[ 0].value = reg;
_WinRTpp02[ 2].port = CMOS_DATA;
if (!WinRTProcessIoBuffer(hWinRT, _WinRTpp02,
sizeof(_WinRTpp02), &iWinRTlength))
goto localError;
*val = _WinRTpp02[ 2].value;

This approach is more efficient than the one used by the other toolkits, which requires a call into
the driver for each port access.


                       :D
Avatar of HubrisSonic

ASKER

Okay, thats interesting stuff.... however, I should clarify, i actually dont want to talk to the device, I want WinRT to do that. my intent is
1. Use ActiveX WinRT USB Dll from whatever, C, C++,VB
2. Send "GETU00000" to the device (through WinRT), pipe 0x01
3. Get data back from the device (through WinRT), pipe 0x82

my questions relate to how to talk to the WinRT device driver. and how to get it to pass data to and from the device.

OHHHHHHHHHHHHHHHHHHHH   K    

Here is a step by step whitepaper

P.s you need adobe


http://www.programmable-products.com/ppidriver.pdf

 
                                                      -James
Adobe? fer what?
oh... to view the file... never mind
Actually the ppidriver.pdf describes how to use the PPI USB dll, not the WinRT lib. again, i dont want to spent $1,000 for programmable products software.

Here is the interface exposed by the WinRT ActiveX DLL.

System.Int32 BulkTransfer ( System.Byte Endpoint , System.Int32 Length , System.Byte Buffer )
void ClearStall ( System.Byte Endpoint )
System.Int32 ControlTransfer ( WINRTUSBLib.REQUEST_TYPE RequestType , WINRTUSBLib.REQUEST_RECIPIENT RequestRecipient , System.Byte Request , System.Int16 Value , System.Int16 Index , System.Int32 HostToDevice , System.Int32 Length , System.Byte Buffer )
void GetConfigurationDescriptor ( WINRTUSBLib.ConfigurationDescriptor ConfigDescriptor )
void GetDeviceDescriptor ( WINRTUSBLib.DeviceDescriptor DeviceDescriptor )
void GetEndpointDescriptor ( System.Byte Endpoint , WINRTUSBLib.EndpointDescriptor EndpointDescriptor )
void GetInterfaceDescriptor ( WINRTUSBLib.InterfaceDescriptor InterfaceDescriptor )
void GetLanguageIds ( System.Int16 NumberOfIds , System.Int16 LanguageIds )
System.Int16 GetNumberOfLanguageIds (  )
System.String GetStringDescriptor ( System.Int16 LanguageId , System.Int32 DescriptorIndex )
System.Int32 InterruptTransfer ( System.Byte Endpoint , System.Int32 Length , System.Byte Buffer )
void IsochronousTransfer ( System.Byte Endpoint , WINRTUSBLib.IsochronousTransfer Transfer )
void SelectInterface ( System.Int32 Interface , System.Int32 AlternateSetting )
int DeviceInstance [  get,  set ]
string LinkName [  get,  set ]

Does Anybody now how to use this?

Is it not using PPI USB dll as an example ?
Thanks for all your time on this Rimscorp,

No, its not using PPI USB, i have WinRT installed as the driver.

i have made some head way and am Opening the device and also getting the DeviceIoControl to almost work. (really close), next i have to figure out how to load up a write to the device of "GETU000000" and get the result.

i am not using any of the calls i posted above, but am working with the rwbulk.c sample from the DDK.

Rimscorp, i am just guessing, but if i have the "handle" of the device from the CreateFile, how can i attach it to the instance of the WinRT driver?
do i set DeviceInstance? or LinkName? of the ActiveX, or both?


The 2 are different.

Read up


Linkname is  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_wmiref_pr_ExchangeQueueLinkName.asp

Device instance is http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m_Summer_04/directx/ref/ns/microsoft.directx.directinput/s/deviceinstance/deviceinstance.asp

                                                             
                                                                        -James
Now i am getting somewhere, I am using DeviceIoControl, and then waiting for the overlapping event to finish. I am off to test my latest code on the device.
talking to a device in user-mode is not trivial, you have really follow the correct dance steps, as follows...

Open your device

                USB = CreateFile(devName,0xC0000000,0x3,0x0,0x3,0x40000000,0x0);

Create a OVERLAPPED structure, and make sure you create an event for it, AND zero out the DWORD fields.

      OverlapStruct.hEvent = CreateEvent(NULL,TRUE,TRUE,NULL);
      OverlapStruct.Internal = OverlapStruct.InternalHigh = 0;
      OverlapStruct.Offset = OverlapStruct.OffsetHigh = 0;
      
      SetLastError(NO_ERROR);

Call your DeviceIoControl

      rtn = DeviceIoControl(USB,IOCTLVALUE,InBuffer,8,OutBuffer,64,&nBytesRead,&OverlapStruct);

now... you have to first.. check the return code on the DeviceIoControl, if its not 0 then, call GetLastError(), If its ERROR_IO_PENDING, thats okay.

               if(GetLastError() == ERROR_IO_PENDING) { //

      if(WaitForSingleObject(OverlapStruct.hEvent,INFINITE) != WAIT_OBJECT_0) { // wait for the read to finish
                        !GetOverlappedResult(USB,&OverlapStruct,&dwBytesReturned,FALSE)                      
                }

You should have your data now...

using the DeviceDriver's exported functions arent necessary, just open the driver and use the DeviceIoControl, or ReadFile/WriteFile, depending on the style of Kernel Mode Driver thats used.




Can I get these points refunded to me?
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial