Author Topic: Read USB data from non-HID  (Read 23677 times)

titus

  • Member
  • ***
  • Posts: 8
Read USB data from non-HID
« on: March 03, 2013, 08:28:23 am »
Hi,

I am trying to read USB data from a device which it is not a HID,
Could I do that with GenericHid ?

I downloaded Generic Hid Tester to test my device connection, after input the VID and PID, it said "Device not found",
I am sure the VID and PID are correct and its driver installed correctly.

Could anyone help me, thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #1 on: March 03, 2013, 10:49:25 am »
How a host computer communicates with a USB device depends on finding a match between the information in the device's descriptors and (assuming Windows) the information in the system's INF files.

My Generic HID examples are for use with generic (not mouse or keyboard) HID-class devices.

For mass-storage devices, use the file system.

For USB virtual serial port devices, use serial port functions.

And so on.

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #2 on: March 05, 2013, 10:46:45 am »
Thanks Jan,

Actually, my device is a USB Bluetooth adapter, it cannot recognize by Windows,
So I setup the driver with Inf-Wizard from LibUsbDotNet and it is successful with VID 1131 PID 1001,
My question is why it always return "Device not found" from Generic HID Tester.
I am appreciate your USB tool and hope could use your USB script for my program design.
Detail of problem may refer to the attached graph.


[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #3 on: March 05, 2013, 10:53:58 am »
Generic HID returns not found because it's not a HID-class device.

If Windows isn't recognizing the device, examine the setupapi log file after attachment.

Here is one tutorial:

http://sourcedaddy.com/windows-7/using-setupapi-log-file.html

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #4 on: March 05, 2013, 11:28:47 am »
I open setupapi.app.log, but it does not say any message about my Bluetooth device driver.

I attached the file into attachment.

[attachment deleted by admin]

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #5 on: March 05, 2013, 12:05:02 pm »
Hi Jan,

I use your other tool WinUsb vb version, it can detect my device with my changed GUID,
but after click Send button for Control Read Transfer, it return failed at function part:

            success = WinUsb_ControlTransfer _
             (myDevInfo.winUsbHandle, _
             setupPacket, _
             dataStage, _
             Convert.ToUInt16(dataStage.Length), _
             bytesReturned, _
             IntPtr.Zero)

How could I read and send data to my USB?
Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #6 on: March 05, 2013, 01:40:39 pm »
You need to know what kinds of transfers the device function supports.

All devices support control transfers for enumeration, but not every device function supports control transfers, and if they do, they will support a specific number of control-transfer request numbers.

The device's descriptors will tell you if the device supports bulk, interrupt, or isochronous transfers, and if so, which direction.

Even there, a knowledge of the device function's protocols is helpful. For example, a device might NAK every bulk transfer until it receives a specific request in a control transfer.

If the device is a Bluetooth adapter, you should be using Bluetooth drivers, not WinUSB. What class and subclass does the device declare in its descriptors? What does the setupapilog file show?

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #7 on: March 06, 2013, 11:09:00 am »
I only found the class GUID but could not find subclass. The SetupApilog file could be found from my post reply on March 05, 2013, 11:28:47 am.
I have found many method to read USB data with vb script, but none of them are success, and I found your script is quite straight forward and easy to understand for writing program, so I would like to use your script for my program.

Here is the USB information getting from USB cfg  Interrorgator tool:

SerialNumber:7&25c389c1&0&2
Class Guid:a5dcbf10-6530-11d2-901f-00c04fb951ed
DeviceDesc:ISSCEDRBTA
HardwareId:
           USB\VID_1131&PID_1001&REV_0373
           USB\VID_1131&PID_1001
CompatibleIds:
              USB\Class_E0&SubClass_01&Prot_01
              USB\Class_E0&SubClass_01
              USB\Class_E0
Class:libusb-win32 devices
ClassGuid:{eb781aaf-9c70-4523-a5df-642a87eca567}
Driver:{eb781aaf-9c70-4523-a5df-642a87eca567}\0001
Mfg:Integrated System Solution Corp.
FriendlyName:
LocationInformation:Port_#0002.Hub_#0003
PhysicalDeviceObjectName:\Device\USBPDO-5
BusTypeGuid:9d7debbc-c85d-11d1-9eb4-006008c3a19a
LegacyBusType:15
BusNumber:0
EnumeratorName:USB
Address:2
UiNumber:
InstallState:0
RemovalPolicy:3
SymbolicName:\??\USB#VID_1131&PID_1001#7&25c389c1&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
« Last Edit: March 06, 2013, 11:15:38 am by titus »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #8 on: March 06, 2013, 11:25:10 am »
WinUSB is intended for devices with vendor-defined functions that don't fit a standard USB class.

Bluetooth bridges can use the USB wireless controller class, subclass RF controller (01h), protocol Bluetooth Programming Interface (01h).

If you delete, move, or rename the extension on the WinUSB inf file, Windows will try to find an appropriate driver and the setupapilog file may offer a clue about what is missing.

A protocol analyzer can show the descriptors the device returns during enumeration.

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #9 on: March 07, 2013, 11:21:23 am »
I want to use GenericHid to read my USB, I have download a protocol analyzer, but I don't know where is the descriptor and how to configure with it in GenericHid library..

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #10 on: March 07, 2013, 11:34:00 am »
If you want to use GenericHID, you will need to edit the descriptors in the device so it appears as a generic (not system mouse or keyboard) HID-class device. You will also need to add a report descriptor and edit the device firmware so it sends and receives data in defined reports.

If you are using an off-the-shelf Bluetooth adapter, you can't use GenericHID.

What are you trying to accomplish with the device? If you want to use the adapter for its intended purpose, you need to concentrate on finding a compatible driver on the PC.

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #11 on: March 07, 2013, 11:46:09 am »
I am trying to read the data which send from a pressure machine, the connection between the pressure machine is a USB line, and before that I hope my program could read USB data from other USB device for the testing, but I am a new in USB programming and hope could use your library.
Could you explain or show me a Hello program could read/send data between USB and my laptop.

Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #12 on: March 07, 2013, 11:54:53 am »
Does the pressure machine have any documentation on how to use the machine's USB port?

If not, connect the pressure machine to a PC, then look for it in Windows Device Manager.

Right-click the device's entry. What does it say in:

Properties > Driver > Driver Details

titus

  • Member
  • ***
  • Posts: 8
Re: Read USB data from non-HID
« Reply #13 on: March 07, 2013, 12:01:51 pm »
I have setup the driver for pressure machine in my laptop successfully, it also provide some library coding which written with OMRON CJ2 Compolet, but I tried many times to connect the device with OMRON CJ2 Compolet coding, it always says "Not connected to device." But I could read the data from this pressure machine with its own software. I want to write a custom program to read the data between the USB and the pressure machine and store it into database such as MS Access.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Read USB data from non-HID
« Reply #14 on: March 07, 2013, 12:41:18 pm »
So you have software that works, but you've been unable to write your own code to access the device.

If you don't have documentation that tells you how to access the device, you could use a protocol analyzer to monitor and document the traffic when using the software that works.

Then, using WinUSB, duplicate that traffic in your code.
« Last Edit: March 07, 2013, 12:47:51 pm by Jan Axelson »