Discussion:
[linux-uvc-devel] Help with Dino-Lite USB microscope
Mike Donlon
2017-06-29 20:38:50 UTC
Permalink
Hello,

I am trying to figure out how to control the LEDs under linux on my
Dino-LITE microscope. I can get them to work using the supplied software on
Windows, and I have read several threads on this list but its really hard
to put the scattered info together(especially since some dropbox links are
now dead). I am not sure that the LEDs are controllable via UVC but I have
a packet capture from wireshark and usbmon, and I have gotten the packet
count down to about 46 packets.

Here is the verbose output from lsusb:
https://drive.google.com/file/d/0Bxs6BsnizttkWm5xb21rZ0JhbjQ/view?usp=sharing


And here is the pcap file I have, that is heavily filtered:
https://drive.google.com/file/d/0Bxs6BsnizttkMUd4YjY0bDFQNmM/view?usp=sharing


I haven't done a ton of work programming USB devices, but if anyone can
give me some breadcrumbs or examples that would be awesome. I was looking
for a file in another similar thread: led_off_manfred.c but the link was
dead, it would help with testing I think but not sure.

Any advice would be appreciated.

Thanks,
Mike Donlon
David Tulloh
2017-06-30 00:23:12 UTC
Permalink
Hi Mike,

I'm afraid the capture is a bit too filtered for me to give you any
specifics but I can outline how to approach the problem.

1. Download the UVC spec from http://www.usb.org/developers/docs/devclass_docs/
You will need to refer to UVC 1.5 Class specification.pdf
2. Go through the device descriptors (sent during device
initialisation) and identify each of the chunks, wireshark should
decode them for you. You need a list of all the interfaces and their
numbers, in particular identify the control interface id. You also
need a list of all the control terminal/unit blocks and their ids.
3. Pull up your pcap around the time that you controlled the led. I
suggest adding as columns the bmRequestType, wIndex, wValue and
bRequest.

You read it as follows:
wIndex low byte = interface
wIndex high byte = terminal/unit
wValue high byte = control selector (within that terminal/unit)
bRequest = SET/GET request (129 = 0x81 = GET, 133 = 0x85 = GET_LEN, 1 = SET)

So for your file the interesting chunk seems to be at about 8s.
There are multiple get/set commands to control 0x02 of unit 0x04.
Then there are a series of set commands to multiple controls within unit 0x03.
And it returns to control 0x02 of unit 0x04.

With the device descriptors you should be able to figure out what type
of units they are and looking up the unit in the spec allows you to
know what control is being accessed.

I have no experience with microscopes, I expect that there will be a
custom, undocumented, unit type for the light. Once you identify its
id it should be fairly easy to filter down on it to match the commands
sent with the actions you take.


David
Post by Mike Donlon
Hello,
I am trying to figure out how to control the LEDs under linux on my
Dino-LITE microscope. I can get them to work using the supplied software on
Windows, and I have read several threads on this list but its really hard to
put the scattered info together(especially since some dropbox links are now
dead). I am not sure that the LEDs are controllable via UVC but I have a
packet capture from wireshark and usbmon, and I have gotten the packet count
down to about 46 packets.
https://drive.google.com/file/d/0Bxs6BsnizttkWm5xb21rZ0JhbjQ/view?usp=sharing
https://drive.google.com/file/d/0Bxs6BsnizttkMUd4YjY0bDFQNmM/view?usp=sharing
I haven't done a ton of work programming USB devices, but if anyone can give
me some breadcrumbs or examples that would be awesome. I was looking for a
file in another similar thread: led_off_manfred.c but the link was dead, it
would help with testing I think but not sure.
Any advice would be appreciated.
Thanks,
Mike Donlon
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-uvc-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linux-uvc-devel
Mike Donlon
2017-06-30 01:00:44 UTC
Permalink
Hi David,

Thanks for the info, and the fast response. I will look through the spec
and run through the steps again this weekend. Is there any references or
examples that you know of, to send the commands via python or C once I find
more details? Or is there some way to send the commands via uvcdynctl?

Thanks,
Mike Donlon
Post by David Tulloh
Hi Mike,
I'm afraid the capture is a bit too filtered for me to give you any
specifics but I can outline how to approach the problem.
1. Download the UVC spec from http://www.usb.org/developers/
docs/devclass_docs/
You will need to refer to UVC 1.5 Class specification.pdf
2. Go through the device descriptors (sent during device
initialisation) and identify each of the chunks, wireshark should
decode them for you. You need a list of all the interfaces and their
numbers, in particular identify the control interface id. You also
need a list of all the control terminal/unit blocks and their ids.
3. Pull up your pcap around the time that you controlled the led. I
suggest adding as columns the bmRequestType, wIndex, wValue and
bRequest.
wIndex low byte = interface
wIndex high byte = terminal/unit
wValue high byte = control selector (within that terminal/unit)
bRequest = SET/GET request (129 = 0x81 = GET, 133 = 0x85 = GET_LEN, 1 = SET)
So for your file the interesting chunk seems to be at about 8s.
There are multiple get/set commands to control 0x02 of unit 0x04.
Then there are a series of set commands to multiple controls within unit 0x03.
And it returns to control 0x02 of unit 0x04.
With the device descriptors you should be able to figure out what type
of units they are and looking up the unit in the spec allows you to
know what control is being accessed.
I have no experience with microscopes, I expect that there will be a
custom, undocumented, unit type for the light. Once you identify its
id it should be fairly easy to filter down on it to match the commands
sent with the actions you take.
David
Post by Mike Donlon
Hello,
I am trying to figure out how to control the LEDs under linux on my
Dino-LITE microscope. I can get them to work using the supplied software
on
Post by Mike Donlon
Windows, and I have read several threads on this list but its really
hard to
Post by Mike Donlon
put the scattered info together(especially since some dropbox links are
now
Post by Mike Donlon
dead). I am not sure that the LEDs are controllable via UVC but I have a
packet capture from wireshark and usbmon, and I have gotten the packet
count
Post by Mike Donlon
down to about 46 packets.
https://drive.google.com/file/d/0Bxs6BsnizttkWm5xb21rZ0JhbjQ/
view?usp=sharing
Post by Mike Donlon
https://drive.google.com/file/d/0Bxs6BsnizttkMUd4YjY0bDFQNmM/
view?usp=sharing
Post by Mike Donlon
I haven't done a ton of work programming USB devices, but if anyone can
give
Post by Mike Donlon
me some breadcrumbs or examples that would be awesome. I was looking for
a
Post by Mike Donlon
file in another similar thread: led_off_manfred.c but the link was dead,
it
Post by Mike Donlon
would help with testing I think but not sure.
Any advice would be appreciated.
Thanks,
Mike Donlon
------------------------------------------------------------
------------------
Post by Mike Donlon
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-uvc-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linux-uvc-devel
Mike Donlon
2017-06-30 02:11:07 UTC
Permalink
Awesome, I will try them out and get back to you. Thanks!

Thanks,
Mike Donlon
Post by David Tulloh
Hi Mike,
I thought I recalled some recent discussion on microscopes.
Alexandre has the correct control and commands for your Dino-Lite
documented here, including uvcdynctl examples.
It requires the kernel patch he supplies to work around the firmware
misbehaving slightly.
https://patchwork.kernel.org/patch/9764937/
You can also send direct USB commands in C, allowing you to work
around the firmware misbehaviour by ignoring the UVC spec.
memcpy(buf, "\x80\x01\xF1", );
ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE,
0x01, 0x0300, 0x0400, buf, 3, 1000);
David
Mike Donlon
2017-07-08 20:58:33 UTC
Permalink
I compiled the kernel with Alexandre's patch and used his example commands
with no luck :(

Does anybody have a more complete example of where this snippet is from:

memcpy(buf, "\x80\x01\xF1", );
ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE,
0x01, 0x0300, 0x0400, buf, 3, 1000);

I would like to rule out some stupid programming error on my side, I see
this snippet around in a lot of places but never the full code. I have
tried several variations of this with no luck, so hoping someone can give
me either this full code or a more thorough example.
Hello all,
Post by David Tulloh
Alexandre has the correct control and commands for your Dino-Lite
documented here, including uvcdynctl examples.
It requires the kernel patch he supplies to work around the firmware
misbehaving slightly.
https://patchwork.kernel.org/patch/9764937/
Indeed, thanks for giving the reference.
My patch (and control message payload) works well on the specific model I
use, which is not the same as Mike's, but it's likely that the payload will
be similar.
I did not find any data fragments of length 3 in your pcap though. At
least you now know what to look for (CLASS/INTERFACE messages with a
probably short data fragment).
Good look with your search.
--
Alexandre
Mike Donlon
2017-07-09 02:22:04 UTC
Permalink
I can confirm that the c code I have that contains that snippet, is not
showing anything during a Wireshark session, but the uvcdynctl program does
show in the Wireshark session. Hoping someone can give me a good example in
c using libusb to send usb_control_msg appropriately. I have looked up the
function reference, and populated each arg as received in Wireshark, but
don't see anything when I try to run it.

Thanks,
Mike Donlon


On Jul 8, 2017 3:58 PM, "Mike Donlon" <***@gmail.com> wrote:

I compiled the kernel with Alexandre's patch and used his example commands
with no luck :(

Does anybody have a more complete example of where this snippet is from:

memcpy(buf, "\x80\x01\xF1", );
ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE,
0x01, 0x0300, 0x0400, buf, 3, 1000);

I would like to rule out some stupid programming error on my side, I see
this snippet around in a lot of places but never the full code. I have
tried several variations of this with no luck, so hoping someone can give
me either this full code or a more thorough example.
Hello all,
Post by David Tulloh
Alexandre has the correct control and commands for your Dino-Lite
documented here, including uvcdynctl examples.
It requires the kernel patch he supplies to work around the firmware
misbehaving slightly.
https://patchwork.kernel.org/patch/9764937/
Indeed, thanks for giving the reference.
My patch (and control message payload) works well on the specific model I
use, which is not the same as Mike's, but it's likely that the payload will
be similar.
I did not find any data fragments of length 3 in your pcap though. At
least you now know what to look for (CLASS/INTERFACE messages with a
probably short data fragment).
Good look with your search.
--
Alexandre
Loading...