commandline/usbdrv.c File Reference

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

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

Go to the source code of this file.

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.c,v 1.1 2006/10/28 12:40:42 rschaten Exp
License: See documentation.

Definition in file usbdrv.c.


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