#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <usb.h>
#include "usbledfader.h"
#include "channels.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 | |
void | usage (char *name) |
Displays usage-informations. | |
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. | |
void | dev_test (usb_dev_handle *handle, int argc, char **argv) |
Test connection to the device. | |
void | dev_set (usb_dev_handle *handle, int argc, char **argv) |
Set waves. | |
void | dev_clear (usb_dev_handle *handle, int argc, char **argv) |
Clear all waves on one LED. | |
void | dev_status (usb_dev_handle *handle, int argc, char **argv) |
Get the status of the device. | |
void | dev_reset (usb_dev_handle *handle, int argc, char **argv) |
Reset the device. | |
void | dev_show (usb_dev_handle *handle, int argc, char **argv) |
Show a waveform. | |
int | main (int argc, char **argv) |
Main function. |
Definition in file usb-led-fader.c.
#define USB_ERROR_ACCESS 2 |
Error code if the device isn't accessible.
Definition at line 23 of file usb-led-fader.c.
Referenced by usbOpenDevice().
#define USB_ERROR_IO 3 |
Error code if errors in the communication with the device occur.
Definition at line 24 of file usb-led-fader.c.
Referenced by usbOpenDevice().
#define USB_ERROR_NOTFOUND 1 |
Error code if the device isn't found.
Definition at line 22 of file usb-led-fader.c.
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 19 of file usb-led-fader.c.
Referenced by main().
#define USBDEV_SHARED_VENDOR 0x16C0 |
void dev_clear | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
void dev_reset | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
Reset the device.
handle | Handle to talk to the device. | |
argc | Number of arguments. | |
argv | Arguments. |
Definition at line 330 of file usb-led-fader.c.
References CMD_RESET, and usage().
Referenced by main().
void dev_set | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
void dev_show | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
Show a waveform.
This will not send a command to the device, the waveform is only printed on the screen.
handle | Handle to talk to the device (not needed). | |
argc | Number of arguments. | |
argv | Arguments. |
Definition at line 351 of file usb-led-fader.c.
References fade_calculateWaveform(), and usage().
Referenced by main().
void dev_status | ( | usb_dev_handle * | handle, | |
int | argc, | |||
char ** | argv | |||
) |
void 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 171 of file usb-led-fader.c.
References CMD_ECHO, and usage().
Referenced by main().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Main function.
Initializes the USB-device, parses commandline-parameters and calls the functions that communicate with the device.
argc | Number of arguments. | |
argv | Arguments. |
Definition at line 390 of file usb-led-fader.c.
References dev_clear(), dev_reset(), dev_set(), dev_show(), dev_status(), dev_test(), usage(), USBDEV_SHARED_PRODUCT, USBDEV_SHARED_VENDOR, and usbOpenDevice().
void usage | ( | char * | name | ) |
Displays usage-informations.
This function is called if the parameters cannot be parsed.
name | The name of this application. |
Definition at line 31 of file usb-led-fader.c.
References CHANNELS.
Referenced by dev_clear(), dev_reset(), dev_set(), dev_show(), dev_status(), dev_test(), and 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 59 of file usb-led-fader.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-LED-Fader". |
Definition at line 99 of file usb-led-fader.c.
References USB_ERROR_ACCESS, USB_ERROR_IO, USB_ERROR_NOTFOUND, and usbGetStringAscii().
Referenced by main().