hid icon indicating copy to clipboard operation
hid copied to clipboard

Read support

Open sanbornm opened this issue 9 years ago • 7 comments

Is it possible to read from the device via Input Report?

sanbornm avatar May 16 '16 20:05 sanbornm

Not yet. you'll need to implement it yourself. But it shouldn't be a big deal... Sorry that I've no time for this at the moment. But I would be happy if someone could send a PR

boombuler avatar May 16 '16 20:05 boombuler

I have read support working on all three platforms in my fork: https://github.com/flynn/hid

This fork is maintained to support my U2F package: https://github.com/flynn/u2f

Feel free to upstream any commits that you'd like, I had to rearrange some things to fit my needs.

titanous avatar Aug 03 '16 03:08 titanous

It would be very great to add read support on this repo (ucase: read serial for a blinkstick product)

yesnault avatar Feb 05 '17 10:02 yesnault

Hi,

I've added read support on https://github.com/boombuler/hid/tree/read which is very basic and is only implemented for OSX. If anyone could provide linux / windows code, I would be happy to merge it to master...

boombuler avatar Feb 05 '17 11:02 boombuler

Thanks a lot. Just a question on how to use it, In Python, read serial for Blinkstick is done with

 usb.util.get_string(self.device, length, index)
 usb.util.get_string(self.device, 256, 3)

How to get same information with read func ?

yesnault avatar Feb 05 '17 16:02 yesnault

There is also some read support for all platforms in https://github.com/flynn/hid

titanous avatar Feb 05 '17 16:02 titanous

Hi again. I've modified the source a little.

@titanous I've read through your osx source code and if I'm correct you would lock an OS thread for each device you are listening to. Correct? My implementation of "Listen" should not have this issue (but may have others...). I would also like a funktion to stop listening to the given device... But first of all: Thanks! Your code was very helpful

@yesnault with the newest version the following code should give some results:

stop := make(chan struct{})
reports, errors := device.Listen(stop)
go func() {
	for {
		select {
		case rep := <-reports:
			fmt.Println("Report:", rep)
		case err := <-errors:
			fmt.Println("Error:", err)
		case <-stop:
			return
		}
	}
}()
fmt.Scanln()
close(stop)

boombuler avatar Feb 05 '17 17:02 boombuler