Bayesean Blog - Desktop, Mobile and IOT Developer Blog


Two Helper Apps for Delphi LibUSB

Posted on 30th Oct 2018 in Delphi FMX, Delphi VCL


libusbhelpers59.png

Recently I created the Open-Source Delphi LibUSB x86 / x64 library with Examples.  Refer to the LibUSB Library  for more in-depth info.

For further updates, I wrote an article about the Libusb Library here: https://bayeseanblog.com/blog/delphi-libusb-library-introduction/28  and further information on the library can be found at the Wiki Page  which provides an indepth view  https://github.com/Greg-Bayes/Delphi-libusb/wiki

To further assist the Developer, I found two more tools to assist when working with the Libusb Project.

 

  •  Ever experienced difficulty to create a windows 10 driver for the device to connect to and or found that the existing device driver EP in and out are access denied by the original vendors driver or found that the driver is outdated.
  •  Have you struggled to get the full Endpoint information and full details about the USB device?

To solve these issues, two great applications are available that can help to solve these possible situations.

 

USBVIEW

This Microsoft Windows 10 application will help you with obtaining all the connection information of your device that you will be working with.

ZADIG

This application will install a signed driver for your device on Windows 10 and offers different driver choices. Libusb will connect to all the driver choices although it must be noted that certain drivers may only support Synchronous connections only and may not support plug n’ play features.

SO here’s an in-depth understanding of the two complimentary helper apps that can be used to make working with your project a little easier.

 USBVIEW10.png

USBView.exe or known as Universal Serial Bus Viewer is a Windows graphical user interface application that enables you to browse all USB controllers and connected USB devices on your computer. It can work on all windows versions.

With the use of Delphi Libusb in play, it allows your application to talk directly to your windows usb device. The information that the USBVIEW creates will provide all required information about the device to assist you in creating a connection to your device and set up transferring of data between your windows device and the usb device.

This is a recommended helper tool that you should use for your Delphi Libusb Library translated by me found in my direct Github Repository.

 Where to get USBView

If you have a Delphi Enterprise and up IDE then by default, the Windows 10 SDK Kit is installed.

First check to see if it is available on your Windows 10 operating system, if not then you can follow the steps below to install the SDK.

Download and install the Windows SDK from here

If you only require this helper tool then, select just the Debugging Tools for Windows box and clear all the other boxes during installation.

By default the USBView directory for a X64 PC will be installed to this directory.

Navigate to the kits debugger directory for the processor type you are running and click on usbview.exe to start the utility.

USBView is also available in the Windows driver samples repository on GitHub with all its source code however it is easier to download it from the Windows directory.

If it is installed and you have an empty Debugger folder then the debugger apps were not installed.

 It is easy to enable these apps without downloading the kit SDK again by doing the following:-

open Apps & features (right click on Windows sign bottom left),on the dropdown screen- select Apps and Features.

Scroll to Windows SDK and select Modify.

Check the debugging tools for Windows – to install the tools.

 

chngedit0.png

 

InstallWIndowsSDK48.png

Using USBView

USBView can enumerate USB host controllers, USB hubs, and attached USB devices. It can also query information about the devices from the registry and through USB requests to the devices.

The main USBView window contains two panes. The left pane displays a connection-oriented tree view, enabling you to select any USB device.

The right pane displays the USB data structures that pertain to the selected USB device. These structures include Device, Configuration, Interface, and Endpoint Descriptors, as well as the current device configuration.

For development this tool will provide the Busses and EP in and EP out points required in your application to read and write to your usb device.  Whilst this information can be obtained through extracting it directly using the Delphi Libusb library, USBVIEW will speed up your development time by giving you all required information instantly. You can then focus on connecting reading and writing information to the USB device.

This tool packs out the ports of your USB Enhanced Host Controller. Each connected port will show the Device name. 

It provides extensive data on all aspects of the device such as the following:-

 Device Information

Open Pipes

Endpoint Descriptors

Full Configuration Descriptors

Configuration Descriptor

IAD Descriptor

Interface Descriptor (multiple)

(this has detailed required information)

Endpoint Descriptors (multiple)

(this has detailed required information)

For Video Specific the following

Class –Specific Video Control Interfaces Header Description

Video Control POutput Terminal Descriptor

Video Control Extension Unit Descriptor

Video Control Input Terminal Descriptor

Video Control Processing Unit Descriptor

Class Specific Interrupt Endpoint Descriptor

Interface Descriptor

Video Class Specific VS Video Input Header Descriptor

Video streaming Uncompressed Format Type Descriptors

Color Matching Descriptor

Video Streaming MJPEG Format Descriptor

Interface Descriptor(multiple)

Endpoint Descriptor(multiple)

USBViewimage151.png 

Above is demonstrating how easy it is to obtain the IN- ENDPOINT info $82(0x82) of the interrupt transfer type endpoint descriptor.  The endpoint byte info can be added to your application to read that endpoint.

This tool should make it much quicker for you to code the usb to production level.

 

Zadiglogo23.png 

Zadig.exe is a Windows application that installs generic drivers, such as WinUSB, LibUSB-win32/libusb0.sys or libusbK.

 

What is its purpose?

 

  • To help access a Libusb – based application.
  • To help upgrade a generic driver.
  • To generate a generic driver for an unrecognized device.
  • To access a device using WINUSB.

 

Download the Application executable and run it. First plug in the USB-device to be set up then read the device by selecting “List All Device’s” from the options menu. Select your device from the drop down menu. Then select the type of driver that you require. Then install the driver.  Zadig will install a signed Windows 10 driver behind the scenes. Once this is done, you are good to go.

Zadigview35.png

Refer to the usage guide for more info and also reference to libwidi which allows the use of installing the driver using the inno-scripts whilst installing your own app.

Using these two apps saved me a lot of time with a device that was not recognised and then to identify the actual endpoints to use in my application without having to create my own Libusb helper application which might not give you all the information required.

I hope this helps you.

Happy Coding

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Lauro      Commented   3 months ago Reply

Congratulations on the Code! This example can be used in DBGrid to make the Tree feature. | Customers A | -Sales $ 100.00

Add a Comment

9+5

Recent News

Delphi A Professional VCL DBGrid Part Four
Delphi A Professional VCL DBGrid Part Three
Delphi A Professional VCL DBGrid Part Two
Delphi A Professional VCL DBGrid Part One
Delphi VCL Buttons in DBGrid
Two Helper Apps for Delphi LibUSB
Delphi Libusb Library Introduction
Delphi Object directly to a Json string in a REST Client

Categories

Bootstrap 4
Delphi VCL
Delphi FMX
Ajax
Bootstrap 3
CSS
XE4>Delphi > XE4
Delphi < XE4
PHP

Archives

June 2019

Delphi A Professional VCL DBGrid Part Four

May 2019

Delphi A Professional VCL DBGrid Part Three

April 2019

Delphi A Professional VCL DBGrid Part Two

March 2019

Delphi A Professional VCL DBGrid Part One

November 2018

Delphi VCL Buttons in DBGrid

October 2018

Two Helper Apps for Delphi LibUSB

September 2018

Delphi Libusb Library Introduction

August 2018

Delphi Object directly to a Json string in a REST Client
Delphi using Environment Variables in your App

July 2018

Delphi FMX Leaflet Plotter using OSM Maps

June 2018

C2PAS32 Convertor Application
C to Delphi Open Source Convertors Shootout
Delphi command-line programs with DOSCommand

May 2018

Delphi PDF Embedded viewer with PDF.js

March 2018

Delphi FMX - Changing TCharacter to TCharHelper
Make Your Delphi App POP using Javascript!

January 2018

Delphi FMX Dashboard using Chart.JS
Delphi FMX Form Docking

December 2017

PHP Slim REST Server & Delphi Auth Part 5

November 2017

Delphi FMX REST Client App Part 4

October 2017

Delphi VCL REST Pricing Client App Part 3

September 2017

Delphi REST VCL Client Basic Auth Part 2B

August 2017

Delphi REST Client Part 2A
PHP PDO REST Server Part 1

July 2017

PHP REST Server and Delphi Client Intro

June 2017

Delphi SQLite Encryptor-Decryptor Tool
Updating Applications Manifest using Delphi

May 2017

Create a Visual IP Address Geolocation with PHP

March 2017

PHP Downloader using Countdown timer
PHP File Downloader from a Inbox Selection

February 2017

Javascript Image-File Uploader with ThumbViewer

January 2017

Morris Charts and PHP-PDO

December 2016

CSS to create a functional Toggle Button