[tuxdroid-svn] r313 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-05-11 14:58:31
|
Author: neimad Date: 2007-05-11 16:58:11 +0200 (Fri, 11 May 2007) New Revision: 313 Modified: daemon/trunk/libs/USBDaemon_usb_enum.c Log: * Coding style: removed unnecessary curly braces and parentheses, added blank lines to let the code breathe. Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-05-11 14:54:04 UTC (rev 312) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-05-11 14:58:11 UTC (rev 313) @@ -56,16 +56,11 @@ usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) - { for (tux_dev = bus->devices; tux_dev; tux_dev = tux_dev->next) - { - if ((tux_dev->descriptor.idVendor == TUX_VID) - && (tux_dev->descriptor.idProduct == TUX_PID)) - { + if (tux_dev->descriptor.idVendor == TUX_VID + && tux_dev->descriptor.idProduct == TUX_PID) return tux_dev; - } - } - } + return NULL; } @@ -81,13 +76,16 @@ /* Open usb device */ tux_hdl = usb_open(tux_dev); + setgid(NEWGID); setuid(NEWUID); + if (!tux_hdl) { log_error("Can't open device: %s (%d)", strerror(errno), errno); return NULL; } + /* Claim device interface */ error = usb_claim_interface(tux_hdl, TUX_INTERFACE); if (error != 0) @@ -116,9 +114,8 @@ { tux_device = usb_find_TuxDroid(); if (tux_device == NULL) - { log_error("Tux dongle not found"); - } + sleep(1); } while (!tux_device); @@ -131,7 +128,7 @@ "the firmware to version 1.00 or better.\n" "Check http://www.tuxisalive.com/documentation/how-to/updating-the-firmware\n" "for details."); - return (0); + return 0; } /* Get Device handle */ @@ -139,9 +136,10 @@ if (tux_handle == NULL) { log_error("You must load the daemon in root mode"); - return (0); + return 0; } - return (1); + + return 1; } /************************************************************************ */ @@ -154,10 +152,13 @@ unsigned char dongle_is_present_counter; usleep(50000); + TUX_USB_STATUS = TUX_USB_CONNECTED; + /* Reinit audio channel */ send_usb_dongle_cmd(0x02, 0, 0, 0); current_audio_channel = 0; + /* Read loop */ dongle_is_present_counter = 0; while (tux_handle) @@ -172,6 +173,7 @@ send_daemon_disconnected(); exit(1); } + usb_get_status_TuxDroid(); usleep(50000); } |