debug.c

Go to the documentation of this file.
00001 #define HID_INTERNAL
00002 
00003 #include <debug.h>
00004 #include <assert.h>
00005 
00006 HIDDebugLevel hid_debug_level = HID_DEBUG_NONE;
00007 FILE* hid_debug_stream = NULL;
00008 
00009 void hid_set_debug(HIDDebugLevel const level)
00010 {
00011   hid_debug_level = level;
00012 }
00013 
00014 void hid_set_debug_stream(FILE* const outstream)
00015 {
00016   hid_debug_stream = outstream;
00017 }
00018 
00019 void hid_set_usb_debug(int const level)
00020 {
00021   usb_set_debug(level);
00022 }
00023 
00024 struct usb_dev_handle;
00025 
00026 void trace_usb_bus(FILE* out, struct usb_bus const* usbbus)
00027 {
00028   fprintf(out, "usb_bus instance at: %10p\n", usbbus);
00029   fprintf(out, "  dirname:           %s\n", usbbus->dirname);
00030   fprintf(out, "  devices:           %10p\n", usbbus->devices);
00031   fprintf(out, "  prev:              %10p\n", usbbus->prev);
00032   fprintf(out, "  next:              %10p\n", usbbus->next);
00033 }
00034 
00035 void trace_usb_device(FILE* out, struct usb_device const* usbdev)
00036 {
00037   fprintf(out, "usb_device instance at: %10p\n", usbdev);
00038   fprintf(out, "  prev:                 %10p\n", usbdev->prev);
00039   fprintf(out, "  next:                 %10p\n", usbdev->next);
00040   fprintf(out, "  filename:             %s\n", usbdev->filename);
00041   fprintf(out, "  bus:                  %10p\n", usbdev->bus);
00042   fprintf(out, "  descriptor:           %10p\n", &usbdev->descriptor);
00043   fprintf(out, "  config:               %10p\n", usbdev->config);
00044   fprintf(out, "  dev:                  %10p\n", usbdev->dev);
00045 }
00046 
00047 void trace_usb_device_descriptor(FILE* out, struct usb_device_descriptor const* descriptor)
00048 {
00049   fprintf(out, "usb_device_descriptor instance at: %10p\n", descriptor);
00050   fprintf(out, "  bLength:                         %d\n", descriptor->bLength);
00051   fprintf(out, "  bDescriptorType:                 %d\n", descriptor->bDescriptorType); 
00052   fprintf(out, "  bcdUSB:                          0x%04x\n", descriptor->bcdUSB);
00053   fprintf(out, "  bDeviceClass:                    %d\n", descriptor->bDeviceClass);
00054   fprintf(out, "  bDeviceSubClass:                 %d\n", descriptor->bDeviceSubClass);
00055   fprintf(out, "  bDeviceProtocol:                 %d\n", descriptor->bDeviceProtocol);
00056   fprintf(out, "  bMaxPacketSize0:                 %d\n", descriptor->bMaxPacketSize0);
00057   fprintf(out, "  idVendor:                        0x%04x\n", descriptor->idVendor);
00058   fprintf(out, "  idProduct:                       0x%04x\n", descriptor->idProduct);
00059   fprintf(out, "  bcdDevice:                       0x%04x\n", descriptor->bcdDevice);
00060   fprintf(out, "  iManufacturer:                   %d\n", descriptor->iManufacturer);
00061   fprintf(out, "  iProduct:                        %d\n", descriptor->iProduct);
00062   fprintf(out, "  iSerialNumber:                   %d\n", descriptor->iSerialNumber);
00063   fprintf(out, "  bNumConfigurations:              %d\n", descriptor->bNumConfigurations);
00064 }
00065 
00066 void trace_usb_config_descriptor(FILE* out, struct usb_config_descriptor const* config)
00067 {
00068   fprintf(out, "usb_config_descriptor instance at: %10p\n", config);
00069   fprintf(out, "  bLength:                         %d\n", config->bLength);
00070   fprintf(out, "  bDescriptorType:                 %d\n", config->bDescriptorType);
00071   fprintf(out, "  wTotalLength:                    %d\n", config->wTotalLength);
00072   fprintf(out, "  bNumInterfaces:                  %d\n", config->bNumInterfaces);
00073   fprintf(out, "  bConfigurationValue:             %d\n", config->bConfigurationValue);
00074   fprintf(out, "  iConfiguration:                  %d\n", config->iConfiguration);
00075   fprintf(out, "  bmAttributes:                    %d\n", config->bmAttributes);
00076   fprintf(out, "  MaxPower:                        %d mA\n", config->MaxPower * 2);
00077 }
00078 
00079 void trace_usb_dev_handle(FILE* out, usb_dev_handle const* usbdev_h)
00080 {
00081   struct usb_device *device = usb_device((usb_dev_handle *)usbdev_h);
00082   trace_usb_device(out, device);
00083 }
00084 
00085 /* COPYRIGHT --
00086  *
00087  * This file is part of libhid, a user-space HID access library.
00088  * libhid is (c) 2003-2005
00089  *   Martin F. Krafft <libhid@pobox.madduck.net>
00090  *   Charles Lepple <clepple@ghz.cc>
00091  *   Arnaud Quette <arnaud.quette@free.fr> && <arnaud.quette@mgeups.com>
00092  * and distributed under the terms of the GNU General Public License.
00093  * See the file ./COPYING in the source distribution for more information.
00094  *
00095  * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
00096  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
00097  * OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00098  */

Generated on Sun Mar 30 15:28:24 2008 for libhid by  doxygen 1.5.1