USB (Universal Serial Bus ) Standard |
Version 7 |
USB based devices are divided to RAW and USBTMC (Test and Measurement Class) devices. USBTMC is a standard created by the USB organization (http://www.usb.org) and is designed to mimic the message-based IEEE 488 style of programming with which instrumentation users have become accustomed using a USB 2.0 ports. USBTMC designed to RAW access is required for low level device access for any USB class.
ATEasy includes the following features to support controlling USV devices:
Support for RAW and USBTMC devices
USB device driver to work as a device driver or a filter driver (co-exist with exiting device driver)
Communication with USB devices using I/O Tables or internal functions
Internal library functions including UsbOpen, UsbClose, UsbSend, UsbReceive, UsbSetup, UsbStandardControlRequest, UsbControlRequest, UsbGetHandle
USB SRQ and error events (using SetInterfaceEvent)
USB driver interface configuration and browser using driver and driver shortcut property pages
ADriver.InterfaceInfo property support USB
Monitor window shows USB commands/data sent or receive using ATEasy.
Each USB device has address specified by vendor id, product id and S/N. Users call UsbOpen to open a device, once opened a handle to a device is returned. When communication is no longer need you can call USB to release the handle created. ATEasy automatically closes all handle when the application is closed.
Each device has one or more configurations (usually 1). Each configuration contains one or more interfaces, each interface constrains one or more endpoints (max 32 endpoints for a configuration for USB 2.0 device and 16 for USB 1.0). Pipes is the channels connected to an endpoint and used to transfer data or command.
After the handle is created UsbSetup can be called to set the default interface number within the configuration index specified and if the device interface is a USBTMC class. For USBTMC devices (argument set to TRUE) the interface and configuration is automatically selected and the interface number/configuration index are ignored. Once the interface is selected all send and receive commands will use that interface.
To send or receive data use the UsbSend and UsbReceive functions. The functions communicate through a pipe to a device specified by the enPipeType (enumAUsbPipeTypes) or the lEndpointAddress. For USBTMC devices aUsbPipeTypeBulkOut for UsbSend or aUsbPipeTypeBulkIn for UsbReceive are used by default. lEndpointAddress address is used for specifying the absolute address within the configuration. enPipe Type is the address that is relative within the current selected interface.
Additional low level functions are provided mainly for RAW devices:
UsbControlRequest used to send and receive any command (packet used to control the device). See the USB 2.0 specification section 9.3 - USB Device Requests for detailed information regarding the parameters of these functions.
UsbStandardControlRequest is similar but used for pre-defined commands defined in the USB or USBTMC specification (see 9.4 Standard Device Requests in the USB 2.0 specification and 4.3 - USB488 subclass specific requests in the USBTMC-USB488 v1.0 specifications).
UsbGetHandle used to return the Windows handle for endpoint specified using a pipe or an endpoint address. This handle may be used by Windows API such as ReadFile/WriteFile to communicate with the device. You can used the provided UsbSend/UsbReceive as well.