[tuxdroid-svn] r385 - firmware/tuxup/trunk
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-06-17 10:31:10
|
Author: neimad Date: 2007-06-17 12:31:07 +0200 (Sun, 17 Jun 2007) New Revision: 385 Modified: firmware/tuxup/trunk/usb-connection.c Log: * Fixed indentation broken by automated re-indentation. * Comply with 80 columns limit. * Removed unnecessary curly braces and parentheses. Modified: firmware/tuxup/trunk/usb-connection.c =================================================================== --- firmware/tuxup/trunk/usb-connection.c 2007-06-17 10:17:31 UTC (rev 384) +++ firmware/tuxup/trunk/usb-connection.c 2007-06-17 10:31:07 UTC (rev 385) @@ -53,16 +53,11 @@ usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) - { for (device = bus->devices; device; device = device->next) - { - if ((device->descriptor.idVendor == TUX_VENDOR_ID) - && (device->descriptor.idProduct == TUX_PRODUCT_ID)) - { + if (device->descriptor.idVendor == TUX_VENDOR_ID + && device->descriptor.idProduct == TUX_PRODUCT_ID) return device; - } - } - } + return NULL; } @@ -77,10 +72,9 @@ usb_dev_handle *dev_h; if (!(dev_h = usb_open(dev))) - { return NULL; - } - else if (verbose) + + if (verbose) printf("Device opened\n"); err = usb_claim_interface(dev_h, USB_COMMAND); @@ -95,8 +89,10 @@ return NULL; } } + if (verbose) printf("USB interface claimed successfully \n"); + return dev_h; } @@ -114,31 +110,34 @@ /** * \brief Send commands to Tux's dongle + * * \param dev_h USB device handle * \return USB communication status * - * \todo Need to define the format of the data array to send and pass it as parameter + * \todo Need to define the format of the data array to send and pass + * it as parameter * \todo Need to add some doc or links about what this status is really */ int usb_send_commands(usb_dev_handle * dev_h, uint8_t * send_data, int size) { int status; - if ((status = - usb_interrupt_write(dev_h, USB_W_ENDPOINT, (char *)send_data, size, - USB_W_TIMEOUT)) < 0) + status = usb_interrupt_write(dev_h, USB_W_ENDPOINT, (char *)send_data, size, + USB_W_TIMEOUT); + if (status < 0) + { /* error on usb_interrupt_write() */ - { fprintf(stderr, "usb_interrupt_write error: status = %d :: %s \n", status, usb_strerror()); } - else /* success */ + else { + /* success */ #if (PRINT_DATA) - printf - ("usb_interrupt_write: status =%d -> TX Buffer[%d]={%2X, %2X, %2X, %2X, %2X}\n", - status, status, send_data[0], send_data[1], send_data[2], - send_data[3], send_data[4]); + printf("usb_interrupt_write: status =%d" + " -> TX Buffer[%d]={%2X, %2X, %2X, %2X, %2X}\n", + status, status, send_data[0], send_data[1], send_data[2], + send_data[3], send_data[4]); #endif } return status; @@ -146,19 +145,21 @@ /** * \brief Get commands from Tux's dongle + * * \param dev_h USB device handle * \return USB communication status * - * \todo Need to define the format of the data array to send and pass it as parameter + * \todo Need to define the format of the data array to send and pass + * it as parameter * \todo Need to add some doc or links about what this status is really */ int usb_get_commands(usb_dev_handle * dev_h, uint8_t * receive_data, int size) { int status; - if ((status = - usb_interrupt_read(dev_h, USB_R_ENDPOINT, (char *)receive_data, size, - USB_R_TIMEOUT)) < 0) + status = usb_interrupt_read(dev_h, USB_R_ENDPOINT, (char *)receive_data, + size, USB_R_TIMEOUT); + if (status < 0) { fprintf(stderr, "usb_interrupt_read error: status = %d :: %s \n", status, usb_strerror()); @@ -167,10 +168,10 @@ { /* XXX this is only to test and display what has been received */ #if (PRINT_DATA) - printf - ("usb_interrupt_read: status = %d -> TX Buffer[%d]={%hX, %hX, %hX, %hX, %hX}\n", - status, status, receive_data[0], receive_data[1], receive_data[2], - receive_data[3], receive_data[4]); + printf("usb_interrupt_read: status = %d" + "-> TX Buffer[%d]={%hX, %hX, %hX, %hX, %hX}\n", + status, status, receive_data[0], receive_data[1], receive_data[2], + receive_data[3], receive_data[4]); #endif } return status; |