commandline/usbdrv.h File Reference

USB-driver-parts for implementing a client. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <usb.h>
#include "usbservo.h"

Go to the source code of this file.

Defines

#define USBDEV_SHARED_VENDOR   0x16C0
 VOTI.
#define USBDEV_SHARED_PRODUCT   0x05DC
 Obdev's free shared PID.
#define USB_ERROR_NOTFOUND   1
 Error code if the device isn't found.
#define USB_ERROR_ACCESS   2
 Error code if the device isn't accessible.
#define USB_ERROR_IO   3
 Error code if errors in the communication with the device occur.

Functions

int usbGetStringAscii (usb_dev_handle *dev, int index, int langid, char *buf, int buflen)
 Reads and converts a string from USB.
int usbOpenDevice (usb_dev_handle **device, int vendor, char *vendorName, int product, char *productName)
 Connect to the USB-device.
int dev_test (usb_dev_handle *handle, int argc, char **argv)
 Test connection to the device.
int dev_set (usb_dev_handle *handle, int argc, char **argv)
 Set the angle of the Servo.
int dev_status (usb_dev_handle *handle, int argc, char **argv)
 Get the status of the device.


Detailed Description

USB-driver-parts for implementing a client.

Author:
Ronald Schaten
Version:
Id
usbdrv.h,v 1.1 2006/10/28 12:40:42 rschaten Exp
License: See documentation.

Definition in file usbdrv.h.


Define Documentation

#define USB_ERROR_ACCESS   2

Error code if the device isn't accessible.

Definition at line 22 of file usbdrv.h.

Referenced by usbOpenDevice().

#define USB_ERROR_IO   3

Error code if errors in the communication with the device occur.

Definition at line 23 of file usbdrv.h.

Referenced by usbOpenDevice().

#define USB_ERROR_NOTFOUND   1

Error code if the device isn't found.

Definition at line 21 of file usbdrv.h.

Referenced by usbOpenDevice().

#define USBDEV_SHARED_PRODUCT   0x05DC

Obdev's free shared PID.

Use obdev's generic shared VID/PID pair and follow the rules outlined in firmware/usbdrv/USBID-License.txt.

Definition at line 18 of file usbdrv.h.

Referenced by main().

#define USBDEV_SHARED_VENDOR   0x16C0

VOTI.

Definition at line 17 of file usbdrv.h.

Referenced by main().


Function Documentation

int dev_set ( usb_dev_handle *  handle,
int  argc,
char **  argv 
)

Set the angle of the Servo.

Parameters:
handle Handle to talk to the device.
argc Number of arguments.
argv Arguments.

Definition at line 162 of file usbdrv.c.

References CMD_SET.

Referenced by main().

int dev_status ( usb_dev_handle *  handle,
int  argc,
char **  argv 
)

Get the status of the device.

Status information is printed in detail (we dont't have too many details with only one servo).

Parameters:
handle Handle to talk to the device.
argc Number of arguments.
argv Arguments.

Definition at line 186 of file usbdrv.c.

References CMD_GET.

Referenced by main().

int dev_test ( usb_dev_handle *  handle,
int  argc,
char **  argv 
)

Test connection to the device.

The test consists of writing 1000 random numbers to the device and checking the echo. This should discover systematic bit errors (e.g. in bit stuffing).

Parameters:
handle Handle to talk to the device.
argc Number of arguments.
argv Arguments.

Definition at line 129 of file usbdrv.c.

References CMD_ECHO.

Referenced by main().

int usbGetStringAscii ( usb_dev_handle *  dev,
int  index,
int  langid,
char *  buf,
int  buflen 
)

Reads and converts a string from USB.

The conversion to ASCII is 'lossy' (unknown characters become '?').

Parameters:
dev Handle of the USB-Device.
index Index of the required data.
langid Index of the expected language.
buf Buffer to contain the return-string.
buflen Length of buf.
Returns:
Length of the string.

Definition at line 19 of file usbdrv.c.

Referenced by usbOpenDevice().

int usbOpenDevice ( usb_dev_handle **  device,
int  vendor,
char *  vendorName,
int  product,
char *  productName 
)

Connect to the USB-device.

Loops through all connected USB-Devices and searches our counterpart.

Parameters:
device Handle to address the device.
vendor USBDEV_SHARED_VENDOR as defined.
vendorName In our case "www.schatenseite.de".
product USBDEV_SHARED_PRODUCT as defined.
productName In our case "USB-Servo".
Returns:
Error code.

Definition at line 52 of file usbdrv.c.

References handle, USB_ERROR_ACCESS, USB_ERROR_IO, USB_ERROR_NOTFOUND, and usbGetStringAscii().

Referenced by main().


Generated on Sat Oct 28 14:48:23 2006 for USB-Servo by  doxygen 1.4.7