LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2130|回复: 1

solaris 10下libusb的支持

[复制链接]
发表于 2010-5-17 14:29:32 | 显示全部楼层 |阅读模式
查看了一些文档,提到solaris10系统支持libusb,我写了一个简单的枚举设备ID的程序,用的是libusb进行通讯,但是执行时确什么都没有输出,希望各位指点一下

我的usb设备使用prtconfig -v 没有打印出来设备的vid 和pid,在网上找了一些资料,发现在/kernel/drv/scsa2usb.conf文件中添加便课找到产品的pid与vid
attribute-override-list = "vid=id reduced-cmd-support=true";
#protconf -v |grep 96
value='usb96e,6.109' + 'usb96e,6' + 'usbif96e,class3.0.0' + 'usbif96e,class3.0' + 'usbif96e,class3' + 'usbif,class3.0.0' + 'usbif,class3.0' + 'usbif,class3' + 'usb,device'


[root@solaris10:/usr/hongbin/source]#uname -a
SunOS solaris10 5.11 snv_79a i86pc i386 i86pc Solaris
[root@solaris10:/usr/hongbin/source]#cat Makefile
CC=gcc
CFLAGS=-I/usr/sfw/include
LDFLAGS=-L/usr/sfw/lib -R/usr/sfw/lib -lusb

SearchDevice:SearchDevice.o
        $(CC) -o SearchDevice SearchDevice.o $(LDFLAGS)
SearchDevice.o:SearchDevice.c
        $(CC) $(CFLAGS) -c SearchDevice.c
clean:
        rm -fr *.o SearchDevice a.out core
[root@solaris10:/usr/hongbin/source]#cat SearchDevice.c
#include <stdio.h>
#include </usr/sfw/include/usb.h>

int main()
{
    struct usb_bus *busses ;
    struct usb_bus *bus ;

    usb_init();
    usb_find_busses();
    usb_find_devices();

    busses=usb_get_busses();

    for (bus = busses; bus; bus = bus->next) {
        struct usb_device *dev;
        printf("111111\n");

        for (dev = bus->devices; dev; dev = dev->next) {
            struct usb_device_descriptor *desc;
                printf("2222\n");

            desc = &(dev->descriptor);
            printf("Vendor/Product ID: %04x:%04x\n", desc->idVendor,
                   desc->idProduct);
        }
    }

    return 0;
}
[root@solaris10:/usr/hongbin/source]#
执行上边的程序 只进入了 1循环体 ,没有执行第二个循环,还请高手帮忙看下(这段代码在linux下编译可以找到产品的信息)
 楼主| 发表于 2010-5-17 14:59:34 | 显示全部楼层
(gdb) b 17
Breakpoint 1 at 0x8050b78: file SearchDevice.c, line 17.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/hongbin/source/a.out
[New LWP    1        ]

Breakpoint 1, main () at SearchDevice.c:17
17              printf("111111\n");
(gdb) info locals
dev = (struct usb_device *) 0xfeffa7d8
busses = (struct usb_bus *) 0x8062680
bus = (struct usb_bus *) 0x8062680
(gdb) s
111111
19              for (dev = bus->devices; ; /*dev; dev = dev->next*/) {
(gdb) info locals
dev = (struct usb_device *) 0xfeffa7d8
busses = (struct usb_bus *) 0x8062680
bus = (struct usb_bus *) 0x8062680
(gdb) l
14
15          for (bus = busses; bus; bus = bus->next) {
16              struct usb_device *dev;
17              printf("111111\n");
18
19              for (dev = bus->devices; ; /*dev; dev = dev->next*/) {
20                  struct usb_device_descriptor *desc;
21                      printf("2222\n");
22
23                  desc = &(dev->descriptor);
(gdb) p /x bus
$1 = 0x8062680
(gdb) s
21                      printf("2222\n");
(gdb) info locals
desc = (struct usb_device_descriptor *) 0x8047d80
dev = (struct usb_device *) 0x0
busses = (struct usb_bus *) 0x8062680
bus = (struct usb_bus *) 0x8062680
(gdb)


附上我调试的信息
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表