Author Topic: Reader USB device  (Read 25852 times)

lizhi0007

  • Member
  • ***
  • Posts: 16
Reader USB device
« on: May 16, 2011, 11:04:27 pm »
Hi sir,

I have a RFID READer Kit. It has: bInterfaceClass=0x00, bInterfaceSubClass=0x00, bInterfaceProtocol=0x00. In Manage of My Computer, it displays: Microchip Customer Usb Device. I used your example: winusb_cs_181 to try interfacing. Software could receive the kit(insert and remove). But i can't read data from kit. Can you help me to give some ideal for my project? I don't know which reading i have to use (interrupt, Bulk, or click button)? I try to use all of them(reading). But software announce: "Attempted to write or read protected memory. This is often an indication that other memory is corrupt." yellow in "throw".

Please help me.

Thank you.

Include my device driver:

[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #1 on: May 17, 2011, 10:21:49 am »
What is bDeviceClass?

Jan

lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #2 on: May 17, 2011, 11:11:24 am »
Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x08 (8)
idVendor:           0x04D8 (Microchip Technology Inc.)
idProduct:          0x000C
bcdDevice:          0x0000
iManufacturer:        0x01
0x0409: "Microchip Technology Inc."
iProduct:             0x02
0x0409: "Microchip Custom USB Device"
iSerialNumber:        0x00
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x01
Open Pipes:              2

Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0x01

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0x01

Configuration Descriptor:
wTotalLength:       0x0020
bNumInterfaces:       0x01
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0xC0 (Bus Powered Self Powered )
MaxPower:             0x32 (100 Ma)

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0x00
bInterfaceSubClass:   0x00
bInterfaceProtocol:   0x00
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0x01

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0x01


lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #3 on: May 17, 2011, 11:32:32 am »
Hi sir,

I don't know which kind of reading method i must to do? Readfile or bulk transfer or interrupt transfer or control transfer,....
Software can detect device to attach or remove.

Thank you for helping.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #4 on: May 17, 2011, 11:36:24 am »
Either bDeviceClass or bInterfaceClass should have a value > 0. If it's vendor-defined, it should be FFh.

If you want to use WinUSB to access your own vendor-defined device, you need to create an INF file for it. My application is written for my WinUSB firmware that echoes back received data. To use the application with another device, you will need to edit the application to be compatible with the communication protocols your device's firmware supports.

For more about WinUSB, see:

http://www.lvr.com/winusb.htm

Jan

lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #5 on: May 17, 2011, 12:29:33 pm »
Hi sir,

I tested my device twice times: by USB View(that i showed to you), and by Visual Basic program. bDeviceClass and bInterfaceClass are zero. I don't know what kind of class. In regedit i saw: class "customUSBdevice". I saw Enum\USB\...

;Adapted from Jan Axelson's (of Lakeview Research: www.lvr.com) winusbdemo.inf file. 
;Which in turn was adapted from the example INF in the Microsoft document:
;"How to Use WinUSB to Communicate with a USB Device"

This is my MCHPWinUSBDevice.inf

[Version]
Signature = "$Windows NT$"
Class = CustomUSBDevices
ClassGuid= {a503e2d3-a031-49dc-b684-c99085dbfe92}

Provider = %MFGNAME%
DriverVer=05/21/2008,1.0.0.0
;CatalogFile=MCHPWinUSBDevice.cat   ;CAT file used when obtaining a WHQL signature on the driver package
               ;Otherwise isn't needed.
;------------------------------------------------------------------------------
; ========== Manufacturer/Models sections ===========
;------------------------------------------------------------------------------
[Manufacturer]
%MFGNAME% = MyDevice_WinUSB,NTx86,NTamd64

;------------------------------------------------------------------------------
;  Vendor and Product ID Definitions
;------------------------------------------------------------------------------
; When developing your custom USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below lines to use your VID and PID.  Use the format as shown below.
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
; There is a maximum number of devices that can be supported per line however.
; If you append a large number of VID/PIDs to the end of the line, and get a:
; "The data area passed to a system call is too small." error when trying to install
; the INF, try removing some of the VIDs/PIDs.
;------------------------------------------------------------------------------
[MyDevice_WinUSB.NTx86]
%DESCRIPTION% =USB_Install, USB\VID_04d8&PID_0053

[MyDevice_WinUSB.NTamd64]
%DESCRIPTION% =USB_Install, USB\VID_04d8&PID_0053


;=========================================================================================
;ClassInstall32 and ClassInstall_AddReg sections used to make new device manager category.
;=========================================================================================
[ClassInstall32]
AddReg=ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%DEVICEMANAGERCATEGORY%
HKR,,Icon,,"-20"



; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

[WinUSB_ServiceInstall]
DisplayName     = %WinUSB_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%\WinUSB.sys

[USB_Install.Wdf]
KmdfService=WINUSB, WinUsb_Install
UmdfServiceOrder=WINUSB

[WinUSB_Install]
KmdfLibraryVersion=1.7

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{58D07210-27C1-11DD-BD0B-0800200C9a66}"
;When editing the GUID (the big hex number with dashes inside the squiggly
;braces), make sure to write the intended PC application to use the same GUID.
;Otherwise the application won't be able to find the USB device properly.

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WinUSBCoInstaller.dll","WUDFUpdate_01007.dll","WdfCoInstaller01007.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WinUSBCoInstaller.dll
WdfCoInstaller01007.dll
WUDFUpdate_01007.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================

[SourceDisksNames.x86]
1 = %DISK_NAME%,,,\i386

[SourceDisksNames.amd64]
2 = %DISK_NAME%,,,\amd64

[SourceDisksFiles.x86]
WinUSBCoInstaller.dll=1
WdfCoInstaller01007.dll=1
WUDFUpdate_01007.dll=1

[SourceDisksFiles.amd64]
WinUSBCoInstaller.dll=2
WdfCoInstaller01007.dll=2
WUDFUpdate_01007.dll=2

; Copy Files section
;------------------------------------------------------------------------------
[_CopyFiles_sys]
winusb.sys

;************************************************* *****************************
; Destination Directories
;------------------------------------------------------------------------------
[DestinationDirs]
DefaultDestDir = 12 ; %SystemRoot%\system32\drivers
_CopyFiles_sys = 12

; =================== Strings ===================

[Strings]
MFGNAME="Microchip Technology, Inc."
DESCRIPTION="Microchip WinUSB Device"
WinUSB_SvcDesc="WinUSB Device"
DISK_NAME="WinUSB Device Install Disk"
DEVICEMANAGERCATEGORY="Custom USB Devices"



OK, Sir. I used your WINUSB program with {a5dcbf10-6530-11d2-901f-00c04fb951ed}. It just only detect attaching and removing.

For reading(any type)
at "throw" have error : "Attempted write or read protected memory..."
Can you help me what parameter i must change for Bulk transfer with my INF file?

Thanks for helping!!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #6 on: May 18, 2011, 10:00:30 am »
Use a buffer large enough to hold the data the device sends. To find out this value, examine the device firmware or whatever other documentation you have for the device.

Jan

lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #7 on: May 18, 2011, 11:26:36 am »
Hi Jan

My device has driver as i showed you.

[Version]
Signature=$Windows NT$
Class=CustomUSBDevices
ClassGuid={a503e2d3-a031-49dc-b684-c99085dbfe92}

[DeviceList]
%DESCRIPTION%=DriverInstall, USB\VID_04D8&PID_000B, USB\VID_04D8&PID_000C, USB\VID_04D8&PID_01F0 USB\VID_04D8&PID_01F1, USB\VID_04D8&PID_01F2, USB\VID_04D8&PID_01F3, USB\VID_04D8&PID_01F4, USB\VID_04D8&PID_01F5, USB\VID_04D8&PID_01F6
 
[DeviceList.ntamd64]
%DESCRIPTION%=DriverInstall64, USB\VID_04D8&PID_000B, USB\VID_04D8&PID_000C, USB\VID_04D8&PID_01F0 USB\VID_04D8&PID_01F1, USB\VID_04D8&PID_01F2, USB\VID_04D8&PID_01F3, USB\VID_04D8&PID_01F4, USB\VID_04D8&PID_01F5, USB\VID_04D8&PID_01F6


;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------
;Modify these strings to customize your device
;------------------------------------------------------------------------------
[Strings]
DEVICEMANAGERCATEGORY="Custom USB Devices"
MFGFILENAME="mchpusb"
MFGNAME="Reader USB Device."
INSTDISK="Reader USB Device Installation Disc"
DESCRIPTION="Reader USB Device"


;------------------------------------------------------------------------------
;  Source Files
;------------------------------------------------------------------------------
;The source file name prefixes need to be the same name as the string MFGFILENAME
;above
;------------------------------------------------------------------------------
[SourceDisksFiles]
mchpusb.sys=1
mchpusb64.sys=1

 According to you, can i change my device driver to WINUSB?  I know WinUsb_Initialize = fail. So, my device isnot WINUSB.
How can i do for changing?

I am stressed with this project....

That is already kit. I cant design firmware again.
« Last Edit: May 18, 2011, 11:28:34 am by lizhi0007 »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #8 on: May 18, 2011, 12:41:15 pm »
In your first message, you said reads failed. Now you are saying WinusbInitialize fails.

Check Windows device manager to find out if the PC has assigned the winusb driver.

Jan

lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #9 on: May 19, 2011, 01:29:07 am »
Hi sir

Thanks a lots.

But i can't find out. It just display "CustomUSBDevice". Reading fails because it isn't WINUSB class, And WinusbIntialize fails.

I will stop, because i can't find reading method.
Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #10 on: May 19, 2011, 10:15:12 am »
In Device Manager, find your device, then click Driver, Driver Details.

Jan

lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #11 on: May 19, 2011, 12:57:08 pm »
I saw: mchpusb.sys

I use USB VIEW to find out parameter of my device. They are nearly your firmware in C18 HID:
 0x0020
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00

............

But when i use your software in C#. It can't find out my device.    mchpusb.sys    how do i use it?

Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #12 on: May 19, 2011, 02:33:07 pm »
Move or delete the mchpusb INF file.

With the device attached, in Device Manager, right click the device and click Uninstall.

Remove and reattach the device and assign an INF file that assigns WinUSB as the driver.

Jan


lizhi0007

  • Member
  • ***
  • Posts: 16
Re: Reader USB device
« Reply #13 on: May 19, 2011, 11:02:00 pm »
It can't. How do you think about difference between firmware(already) and driver (.sys)? I use winusb.sys and MCHPWinUSBDevice.inf instead for  mchpusb.sys and mchpusb.inf, but it can't install.

What is USB interfacing type (?.dll, function?) i must use with mchpusb.sys in C#?


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Reader USB device
« Reply #14 on: May 22, 2011, 07:05:43 pm »
The setupapi log file might have a clue as to why the driver doesn't install. Search on setupapi log file to find out how.

The Microchip forum is likely the best place for mchpusb questions.

Jan