Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

get usb device descriptor through ioctl?

Opening each endpoint (/dev/ugen0.xy) give me the same error... I read
in the man that ugen is linked to device which don't have a driver but
the dfu device I try to access (an OpenMoko Neo Freerunner) is linked
against umodem0 and the other usb device connected to my computer are
linked against umass0 and uvideo0, but trying to create this device on
/dev with MAKEDEV give the error "unknown device". During my research
on the web before writing to this ML, I've learned that
umodem0/umass0/uvideo0 are device created by the kernel so it's normal
to not have access to them from /dev but I don't know the alternative
to access this device...

2010/2/10 thomas nivelet <>:
> thank you for your answer:
> opening /dev/ugen0.00 give me the error "Device Not Configured"
> 2010/2/10 Jonathan A. Kollasch <>:
>> On Wed, Feb 10, 2010 at 12:57:09PM +0100, thomas nivelet wrote:
>>> hi,
>>> I don't know if I'm on the right ML, if not please tell me.
>> netbsd-users might have worked better, but this will work.
>>> My problem: I'm on the NetBSD-daily of 2 feb (I upgrade every month)
>>> and I'm trying to make a fork of dfu-util because this application
>>> can't find dfu device on -current (and maybe on earlier version) but I
>>> have a little problem:
>>> I try to get the device descriptor wih ioctl just like in the man
>>> ugen(4) but I only get an "Invalid Argument" error. the only think
>>> which work is the USB_DEVICEINFO from man usb(4) but I don't know how
>>> to get device descriptor from it (trying to open udi_devnames[0] lead
>>> to another error: "File not found") and doing an sh MAKEDEV with the
>>> value of udi_devnames[0] throw the error "unknow device"
>>> So this is my question: how to access udi_devnames[0] with open() to
>>> get the file descriptor to give to ioctl?
>>> this is the faulty code:
>>> devicefd = open(file.c_str(), O_RDWR);
>>> if (devicefd != -1)
>>> {
>>>   device_info.udi_addr = 2;
>>>   if (ioctl(devicefd, USB_DEVICEINFO, &device_info) != -1)
>>>     usb_info.push_back(device_info);
>>>   if (ioctl(devicefd, USB_GET_DEVICE_DESC, &device_desc) != -1)
>>>     dev.push_back(device_desc);
>>> }
>> What file are you opening?  USB_GET_DEVICE_DESC works on /dev/ugenX.00,
>> USB_DEVICEINFO works on /dev/usbX.
>> Anyway, something like this should work:
>> usb_device_descriptor_t udd;
>> controlfd = open("/dev/ugen0.00", O_RDWR, 0);
>> ret = ioctl(controlfd, USB_GET_DEVICE_DESC, &udd);
>> Hope that helps.
>>        Jonathan Kollasch

Home | Main Index | Thread Index | Old Index