r3295 - in trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb: . src
mickey at sita.openmoko.org
mickey at sita.openmoko.org
Mon Oct 29 04:43:22 CET 2007
Author: mickey
Date: 2007-10-29 04:43:17 +0100 (Mon, 29 Oct 2007)
New Revision: 3295
Modified:
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/ChangeLog
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/configure.ac
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/src/openmoko-panel-usb.c
Log:
openmoko-panel-usb: add USB debug code
Modified: trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/ChangeLog 2007-10-28 20:29:29 UTC (rev 3294)
+++ trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/ChangeLog 2007-10-29 03:43:17 UTC (rev 3295)
@@ -1,6 +1,13 @@
+2007-10-29 Michael Lauer <mickey at openmoko.org>
+
+ * configure.ac:
+ Depend on libusb
+ * src/openmoko-panel-usb:
+ Add usb debug code.
+
2007-09-02 Michael Lauer <mickey at openmoko.org>
- * src/openmoko-panel-gps:
+ * src/openmoko-panel-usb:
Use moko_panel_applet_set_icon to set the icon.
2007-07-30 Michael Lauer <mickey at openmoko.org>
Modified: trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/configure.ac
===================================================================
--- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/configure.ac 2007-10-28 20:29:29 UTC (rev 3294)
+++ trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/configure.ac 2007-10-29 03:43:17 UTC (rev 3295)
@@ -11,7 +11,7 @@
AC_PROG_LIBTOOL
# base deps
-PKG_CHECK_MODULES(OPENMOKO, libmokopanelui2)
+PKG_CHECK_MODULES(OPENMOKO, libmokopanelui2 libusb)
LIBS="$LIBS $OPENMOKO_LIBS"
CFLAGS="$CFLAGS $OPENMOKO_CFLAGS"
Modified: trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/src/openmoko-panel-usb.c
===================================================================
--- trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/src/openmoko-panel-usb.c 2007-10-28 20:29:29 UTC (rev 3294)
+++ trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-usb/src/openmoko-panel-usb.c 2007-10-29 03:43:17 UTC (rev 3295)
@@ -1,6 +1,6 @@
/* openmoko-panel-usb.c
*
- * Authored by
+ * Authored by Michael 'Mickey' Lauer <mlauer at vanille-media.de>
* Copyright (C) 2007 OpenMoko Inc.
*
* This program is free software; you can redistribute it and/or modify
@@ -12,14 +12,18 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
- * Current Version: $Rev$ ($Date$) [$Author: mickey $]
*/
#include <libmokopanelui2/moko-panel-applet.h>
+#include <sys/types.h>
+#include <linux/limits.h>
+#include <usb.h>
+
#include <gtk/gtkimage.h>
#include <time.h>
typedef struct {
+ MokoPanelApplet* mpa;
int dummy;
} UsbApplet;
@@ -29,6 +33,124 @@
g_slice_free (UsbApplet, applet);
}
+void print_endpoint(struct usb_endpoint_descriptor *endpoint)
+{
+ printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
+ printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
+ printf(" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize);
+ printf(" bInterval: %d\n", endpoint->bInterval);
+ printf(" bRefresh: %d\n", endpoint->bRefresh);
+ printf(" bSynchAddress: %d\n", endpoint->bSynchAddress);
+}
+
+void print_altsetting(struct usb_interface_descriptor *interface)
+{
+ int i;
+
+ printf(" bInterfaceNumber: %d\n", interface->bInterfaceNumber);
+ printf(" bAlternateSetting: %d\n", interface->bAlternateSetting);
+ printf(" bNumEndpoints: %d\n", interface->bNumEndpoints);
+ printf(" bInterfaceClass: %d\n", interface->bInterfaceClass);
+ printf(" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass);
+ printf(" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol);
+ printf(" iInterface: %d\n", interface->iInterface);
+
+ for (i = 0; i < interface->bNumEndpoints; i++)
+ print_endpoint(&interface->endpoint[i]);
+}
+
+void print_interface(struct usb_interface *interface)
+{
+ int i;
+
+ for (i = 0; i < interface->num_altsetting; i++)
+ print_altsetting(&interface->altsetting[i]);
+}
+
+void print_configuration(struct usb_config_descriptor *config)
+{
+ int i;
+
+ printf(" wTotalLength: %d\n", config->wTotalLength);
+ printf(" bNumInterfaces: %d\n", config->bNumInterfaces);
+ printf(" bConfigurationValue: %d\n", config->bConfigurationValue);
+ printf(" iConfiguration: %d\n", config->iConfiguration);
+ printf(" bmAttributes: %02xh\n", config->bmAttributes);
+ printf(" MaxPower: %d\n", config->MaxPower);
+
+ for (i = 0; i < config->bNumInterfaces; i++)
+ print_interface(&config->interface[i]);
+}
+
+static void usb_applet_dump_usb_status()
+{
+ struct usb_bus *bus;
+ struct usb_device *dev;
+ printf("bus/device idVendor/idProduct\n");
+
+ for (bus = usb_busses; bus; bus = bus->next) {
+ for (dev = bus->devices; dev; dev = dev->next) {
+ int ret, i;
+ char string[256];
+ usb_dev_handle *udev;
+
+ printf("%s/%s %04X/%04X\n", bus->dirname, dev->filename,
+ dev->descriptor.idVendor, dev->descriptor.idProduct);
+
+ udev = usb_open(dev);
+ if (udev) {
+ if (dev->descriptor.iManufacturer) {
+ ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string));
+ if (ret > 0)
+ printf("- Manufacturer : %s\n", string);
+ else
+ printf("- Unable to fetch manufacturer string\n");
+ }
+
+ if (dev->descriptor.iProduct) {
+ ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string));
+ if (ret > 0)
+ printf("- Product : %s\n", string);
+ else
+ printf("- Unable to fetch product string\n");
+ }
+
+ if (dev->descriptor.iSerialNumber) {
+ ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
+ if (ret > 0)
+ printf("- Serial Number: %s\n", string);
+ else
+ printf("- Unable to fetch serial number string\n");
+ }
+
+ usb_close (udev);
+ }
+
+ if (!dev->config) {
+ printf(" Couldn't retrieve descriptors\n");
+ continue;
+ }
+
+ for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
+ print_configuration(&dev->config[i]);
+ }
+ }
+}
+
+static void usb_applet_update_status( UsbApplet *applet )
+{
+ usb_init();
+ int new_busses = usb_find_busses();
+ g_debug( "usb_applet_update_status: %d new USBes found", new_busses );
+ int new_devices = usb_find_devices();
+ g_debug( "usb_applet_update_status: %d new USB devices found", new_devices );
+
+ usb_applet_dump_usb_status();
+
+ moko_panel_applet_set_icon( applet->mpa, PKGDATADIR "/Usb.png" );
+
+}
+
G_MODULE_EXPORT GtkWidget*
mb_panel_applet_create(const char* id, GtkOrientation orientation)
{
@@ -38,9 +160,10 @@
time_t t;
struct tm *local_time;
- applet = g_slice_new (UsbApplet);
+ applet = g_slice_new( UsbApplet );
+ applet->mpa = mokoapplet;
- moko_panel_applet_set_icon( mokoapplet, PKGDATADIR "/Usb.png" );
+ usb_applet_update_status( applet );
gtk_widget_show_all( GTK_WIDGET(mokoapplet) );
return GTK_WIDGET(mokoapplet);
More information about the commitlog
mailing list