|
|
| TopPage > libusbを使ってみる > libusbを使ってみる[02] |
/*
usb_test.c
2008.07.21-2008.08.18
*/
#include "config.h"
#include <stdio.h>
#include <usb.h>
int main()
{
// for initialize
struct usb_bus *busses;
// get each bus data
struct usb_bus *bus;
struct usb_device *dev;
int ret_val;
int bus_count = 0;
int dev_count = 0;
printf("--USB Test Program--\n");
// initial and get all bus device
usb_init();
ret_val = usb_find_busses();
printf("usb_find_busses return value=[%d]\n",ret_val);
ret_val = usb_find_devices();
printf("usb_find_devices return value=[%d]\n\n",ret_val);
busses = usb_get_busses();
//
for ( bus = busses ; bus ; bus = bus->next )
{
bus_count++;
printf("\n----bus_count=%d----\n",bus_count);
printf("bus=[0x%x]\n",bus);
printf("bus->next=[0x%x]\n",bus->next);
for ( dev = bus->devices ; dev ; dev = dev->next )
{
dev_count++;
printf("----dev_count=%d----\n",dev_count);
printf("dev=[0x%x]\n",dev);
printf("dev->descriptor.bDeviceClass=[0x%x]\n",dev->descriptor.bDeviceClass);
}
}
return 0;
}
|
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) AC_INIT(USB Test, 1.00, xxxx@yyyy.ne.jp) AC_CONFIG_SRCDIR([usb_test.c]) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC # add AC_PROG_INSTALL # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. # add AC_CONFIG_FILES([Makefile]) # Checks for library functions. AC_OUTPUT |
DESTDIR = prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ CC = @CC@ INSTALL = @INSTALL@ CFLAGS=-W -Wall -g LFLAGS=-lusb <--これ忘れないように OBJECTS = usb_test.o TARGET = usb_test all:$(TARGET) $(TARGET):$(OBJECTS) $(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) install: mkdir -p $(DESTDIR)$(bindir) $(INSTALL) -m755 $(TARGET) $(DESTDIR)$(bindir) clean: $(RM) $(TARGET) $(OBJECTS) uninstall: $(RM) $(DESTDIR)$(bindir)/$(TARGET) |
| TopPage > libusbを使ってみる > libusbを使ってみる[02] |