#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. |
Definition in file usbdrv.h.
#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 |
#define USBDEV_SHARED_VENDOR 0x16C0 |
int dev_set | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
int dev_status | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
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).
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 '?').
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. |
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.
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". |
Definition at line 52 of file usbdrv.c.
References handle, USB_ERROR_ACCESS, USB_ERROR_IO, USB_ERROR_NOTFOUND, and usbGetStringAscii().
Referenced by main().