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

how to add hid4java to my project? #24

Closed
mohamnexus opened this issue Jun 27, 2015 · 9 comments
Closed

how to add hid4java to my project? #24

mohamnexus opened this issue Jun 27, 2015 · 9 comments
Assignees
Milestone

Comments

@mohamnexus
Copy link

mohamnexus commented Jun 27, 2015

Hi
I'm working on a java project in netbeans and i want to use usb hid, how can i add hid4java to my project?
Can i use jar file of hid4java for library?
please teach me step by step to add your library to my project.
Thanks

@gary-rowe
Copy link
Owner

Hi @mohamnexus. Thanks for your interest in hid4java. Can you verify that you've read the README and installation instructions? There is a step-by-step guide to building it in the wiki linked there.

If your project uses Maven it will be very straightforward. If not then you can use one of the pre-built releases here: https://github.com/gary-rowe/hid4java/releases

@gary-rowe gary-rowe added this to the Support milestone Jun 28, 2015
@gary-rowe gary-rowe self-assigned this Jun 28, 2015
@mohamnexus
Copy link
Author

mohamnexus commented Jul 29, 2015

Hi again
I can use hid4java in my project and send data to usb, but i couldn't get data from hid usb.
I want to use getReport() method , please help me.
Thanks

@gary-rowe
Copy link
Owner

Can you provide a code sample indicating what you're trying to do? There is extensive documentation on the API detailing how to use it.

@mohamnexus
Copy link
Author

mohamnexus commented Aug 4, 2015

Skip my previous question.
Send data to USB with trezor.write(message, PACKET_LENGTH, (byte) 0);
and get feature report with trezor.getFeatureReport(data, (byte) 0 ); is working
but when i change report ID to 0x1 , i can send data but i can't get data from usb.
why?

@gary-rowe
Copy link
Owner

When you change the report ID in USB then it changes the function of the device. You need to consult the documentation that comes with it in order to correctly determine which reports are supported and what they do.

@mohamnexus
Copy link
Author

mohamnexus commented Aug 5, 2015

Thanks for your reply.
I have an application for usb device test (SimpleHIDWrite) that supporting getFeatureReport with 0x01 report id but i couldn't use getFeatureReport with hid4java library.

untitled-2

but in hid4java
untitled32-2

@gary-rowe
Copy link
Owner

Judging by the ArrayIndexOutOfBoundsException and the structure of the getFeatureReport method it seems that the hid_get_feature_report native method is returning the full data.length + 1 which is too large for the buffer.

You've probably found a bug.

Can you build a copy of hid4java using the develop branch code and try again? Remember to change the version to develop-SNAPSHOT in your Maven configuration.

@gary-rowe
Copy link
Owner

This bug has been fixed in release 0.4.0 so closing here

@gary-rowe gary-rowe modified the milestones: Release 0.4.0, Support Aug 23, 2015
@frankmeho
Copy link

Hi @gary-rowe ,
As far as I know, GetReport mentioned by @mohamnexus is different from getFeatureReport.
I've used the latest hid4java-develop with develop-SNAPSHOT version and it works well on most of my handled projects using the USB HID interface to send/receive commands.
However, there're some specific platforms that require sending SetReport first and then sending another GetReport to obtain its results. It seems that the current hid4java-develop does not provide this GetReport API yet.

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

3 participants