UsbDirect.h File Reference


Detailed Description

Routines for sending and receiving with a usb - rs485 adapter accessed directly through driver. These are basically convenience routines for calling FTD2XX.dll

The device numbers of usb devices are dependant on startup / installation order. The only reliable way to open a particular usb dongle is to look at all devices to determine the one with the correct serial number (which is unique)

Normally you would use UsbDirect_DeviceCount and then UsbDirect_GetDeviceSerialNumber to give a user a list of USB devices. The serial numbers can then be passed to AAComms_Init

NOTE: Any open connections cannot be discovered using this library, so close all connections before trying to enumerate the available Usb connections

Copyright (C) 2006 RMSD Ltd

Definition in file UsbDirect.h.

Go to the source code of this file.

Defines

#define __DLL_EXPORT

Enumerations

enum  UD_STATUS { , udTIMEOUT, udFAILED, udIOERROR, udDEVICE_NOT_FOUND }
 Indicates the status of the USB connection. More...

Functions

UD_STATUS __DLL_EXPORT UsbDirect_WriteBuffer (HANDLE handle, char *lpBuf, DWORD dwToWrite)
UD_STATUS __DLL_EXPORT UsbDirect_WaitForChar (HANDLE handle, char *lpBuf, DWORD WaitMsec)
HANDLE __DLL_EXPORT UsbDirect_Open (DWORD devId, int baud)
void __DLL_EXPORT UsbDirect_Close (HANDLE handle)
DWORD __DLL_EXPORT UsbDirect_DeviceCount (void)
UD_STATUS __DLL_EXPORT UsbDirect_GetDeviceSerialNumber (DWORD Index, char *buf)
UD_STATUS __DLL_EXPORT UsbDirect_GetDeviceDescription (DWORD Index, char *buf)
UD_STATUS __DLL_EXPORT UsbDirect_SerialNumToDevNum (char *serialNum, DWORD *devNum)


Enumeration Type Documentation

enum UD_STATUS
 

Indicates the status of the USB connection.

Enumerator:
udTIMEOUT  No error.
udFAILED  Function timed out.
udIOERROR  Function failed.
udDEVICE_NOT_FOUND  The specified USB device was not found.

There was an IO error. Usually this occurs when the USB->RS485 adapter is unplugged by a user

Definition at line 22 of file UsbDirect.h.


Function Documentation

UD_STATUS __DLL_EXPORT UsbDirect_WriteBuffer HANDLE  handle,
char *  lpBuf,
DWORD  dwToWrite
 

This routine writes the provided data to a serial port

Parameters:
handle Handle to the serial port
lpBuf Pointer to data to transmit
dwToWrite Size of data to send

UD_STATUS __DLL_EXPORT UsbDirect_WaitForChar HANDLE  handle,
char *  lpBuf,
DWORD  WaitMsec
 

This routine checks to see if a character has been received on the serial port.

Parameters:
handle Handle to the serial port
lpBuf Pointer to memory to store received character (left unchanged if no data avaiable)
WaitMsec The maximum amount of time (in milli seconds) to wait for a character

HANDLE __DLL_EXPORT UsbDirect_Open DWORD  devId,
int  baud
 

This routine opens a usb - rs485 interface

Parameters:
devId This is the device number of the usb port. Use UsbDirect_SerialNumToDevNum to discover this number
baud Baud rate to open port at
Returns:
INVALID_HANDLE_VALUE on error, otherwise the handle of the usb - 485 interface port

void __DLL_EXPORT UsbDirect_Close HANDLE  handle  ) 
 

Closes a previosly opened port

Parameters:
handle The value returned by a call to UsbDirect_Open

DWORD __DLL_EXPORT UsbDirect_DeviceCount void   ) 
 

Finds the number of connected usb devices

UD_STATUS __DLL_EXPORT UsbDirect_GetDeviceSerialNumber DWORD  Index,
char *  buf
 

Description: Finds the serial number of a particular usb device

Parameters:
Index The index of the usb device. Must be less than UsbDirect_DeviceCount
buf Storage for serial number. Must be at least 10 characters long

UD_STATUS __DLL_EXPORT UsbDirect_GetDeviceDescription DWORD  Index,
char *  buf
 

Gets the description of a particular usb device

Parameters:
Index The index of the usb device. Must be less than UsbDirect_DeviceCount
buf Storage for serial number. Must be at least 10 characters long

UD_STATUS __DLL_EXPORT UsbDirect_SerialNumToDevNum char *  serialNum,
DWORD *  devNum
 

Finds a usb device that has the specified serial number

Parameters:
serialNum The serial number of the wanted usb device
devNum Place to store the device number of the usb device (if it is found)


Generated on Fri Feb 10 22:31:49 2006 for Auto anchor communications library by  doxygen 1.4.6-NO