delMar43 / javahidapi

Automatically exported from code.google.com/p/javahidapi
Other
0 stars 0 forks source link

Write Bytes to the HID Device #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Codeminders -Team,

if you have time, can you please look at this problem:

This is my code to write two bytes to my HID Device:

public void writetoHID(){
        try {
            HIDDevice hidevice = HIDManager.openById(VENDOR_ID, PRODUCT_ID, null);
            byte[] reset = new byte[]{0,8};
            hidevice.write(reset);
        } catch (IOException ex) {
            Logger.getLogger(DeviceCtrl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

But i get this Exception and i don't know why

java.io.IOException: The supplied user buffer is not for the requested 
operation.
    at com.codeminders.hidapi.HIDDevice.write(Native Method)

Everything else works great.

Original issue reported on code.google.com by khalle...@gmail.com on 19 Aug 2011 at 6:19

GoogleCodeExporter commented 9 years ago
I have even found it. The origin user buffer size is "65".

Original comment by khalle...@gmail.com on 30 Sep 2011 at 2:17

GoogleCodeExporter commented 9 years ago
Please take a look.
Is it still a bug?

Original comment by kroko...@gmail.com on 10 Jan 2012 at 12:54

GoogleCodeExporter commented 9 years ago
There can be an error when on Windows the data shorter than the output report 
length. 
These data must be padded by zero. 
Bug was fixed in the last version HID Api library. 

Original comment by volokh@codeminders.com on 10 Jan 2012 at 11:22

GoogleCodeExporter commented 9 years ago
fixed as we have updated our source with latest HID API library.

Original comment by kroko...@gmail.com on 10 Jan 2012 at 9:51

GoogleCodeExporter commented 9 years ago
Good Morning

I still have the same problem (user buffer error), even using the last version 
or padding the buffer by zeros. 
I have not compiled the hidapi-jni.dll, I just copied it into windows 
directory, it should work?

Original comment by cesar.be...@gmail.com on 24 Jan 2012 at 11:54

GoogleCodeExporter commented 9 years ago
Yes, should be compiled the hidapi-jni.dll.
There can be wrong entrance data to write to the port.
Try to write down packages using the VLI logic Protocol
buf [0] = 0x02;           // num protocol
buf [1] = dataLength; // length of the data
buf [2] = data

Original comment by volokh@codeminders.com on 24 Jan 2012 at 1:11

GoogleCodeExporter commented 9 years ago
Don’t work too; now I got a different error message: incorrect parameter
I have tried all possible values to num protocol (buf [0]), all of then return 
the incorrect parameter error, except by 0x00 that returns user buffer error.

Original comment by cesar.be...@gmail.com on 24 Jan 2012 at 3:07

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Could you send me your project or java code to try reproduce the problem?
Thanks

Original comment by vitali...@gmail.com on 24 Jan 2012 at 4:27

GoogleCodeExporter commented 9 years ago
I’m still testing the communication with my device, so the project has just 
the class TesteUSB02.
I’m sending the eclipse project folder, and the descriptor code of my device.

Original comment by cesar.be...@gmail.com on 24 Jan 2012 at 9:51

Attachments:

GoogleCodeExporter commented 9 years ago
Has made some changes in source codes, 
in particular has brought the fixed bugs from project HIDApi for all systems.
Has changed function hid_write() (the call through hid_write_time_out() is now 
made).
The device opens asynchronously. 
An asynchronous handle is being used, but the write was occurring synchronously.
Is possible with it the error is connected.
Take last changes and check up please. 
If will find out a problem let to me know. 
Checked at itself on the keyboard, a mouse.
The error user "buffer error" wasn't reproduced.

Original comment by volokh@codeminders.com on 25 Jan 2012 at 9:04

GoogleCodeExporter commented 9 years ago
Hi,
I still not tested the last changes in the code, but I have found the solution 
to the problem, and I like to share with you.
I tried to use a C++ class to access the windows dll’s directly (I used the 
waitingforfriday code), and still have no communication.
As you can see in the descriptor file of my device, I’m using both read and 
write buffers of size 5 (in hardware implementation). 
The windows requires that the first byte of buffer to be zero, and this byte 
was not transferred, then I used a buffer of size 6 (zero + 5 bytes of data) 
and the communication works.
Its also possible to use the native windows routines to know the report lengths 
of the device.
Thanks for all help, and congratulations for Codeminders –Team.

Original comment by cesar.be...@gmail.com on 25 Jan 2012 at 11:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
hi, codeminders i have the same problem because i cant either read or write 
into my GPRS modem and really dont know how to fix it here is my java code i 
hope you will answer me soon and thnx alot 

Original comment by benrej...@gmail.com on 1 Mar 2012 at 10:44

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, I have the same problem, IOException: The parameter is incorrect.
I have the last version 1.1
Could you please advice how to fix this ex? 

Original comment by victor.s...@gmail.com on 10 May 2013 at 8:02

GoogleCodeExporter commented 9 years ago
Hi, I have the same problem, IOException: The parameter is incorrect.

volokh, where I search the new code?????????

Original comment by JULIOC00...@gmail.com on 13 May 2013 at 11:54

GoogleCodeExporter commented 9 years ago
Try keeping 0 th Index as null of byte array

Regards,
Suraj Jungade

Original comment by it1aumt...@gmail.com on 22 May 2014 at 1:18