Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read support #9

Open
sanbornm opened this issue May 16, 2016 · 7 comments
Open

Read support #9

sanbornm opened this issue May 16, 2016 · 7 comments

Comments

@sanbornm
Copy link

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

@boombuler
Copy link
Owner

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

@titanous
Copy link

titanous commented Aug 3, 2016

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.

@yesnault
Copy link

yesnault commented Feb 5, 2017

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

@boombuler
Copy link
Owner

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...

@yesnault
Copy link

yesnault commented Feb 5, 2017

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 ?

@titanous
Copy link

titanous commented Feb 5, 2017

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

@boombuler
Copy link
Owner

boombuler commented Feb 5, 2017

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants