LibUsb error 4 and javax.usb error 12

3,591 views
Skip to first unread message

Pio Tofanelli

unread,
Mar 20, 2014, 4:28:37 PM3/20/14
to usb4...@googlegroups.com
Hello guys!

I'm trying to communicate to a non fiscal printer and it's not working. I followed the "quick start" of the site (http://usb4java.org/quickstart/index.html) for libusb and javax.usb and I'm getting these errors:

libusb:
Device Descriptor:
  bLength                 18
  bDescriptorType          1
  bcdUSB                1.10
  bDeviceClass             0 Per Interface
  bDeviceSubClass          0
  bDeviceProtocol          0
  bMaxPacketSize0         64
  idVendor            0x04b3
  idProduct           0x4535
  bcdDevice             4.06
  iManufacturer            1
  iProduct                 2
  iSerial                  3
  bNumConfigurations       1

Exception in thread "main" org.usb4java.LibUsbException: USB error 4: Unable to open USB device: No such device (it may have been disconnected)
at com.tgcs.usb.test.Main.main(Main.java:36)

javax.usb:
Bus 001 Device 004: ID 04b3:4535
1
Exception in thread "main" javax.usb.UsbPlatformException: USB error 12: Unable to claim interface: Operation not supported or unimplemented on this platform
at org.usb4java.javax.ExceptionUtils.createPlatformException(ExceptionUtils.java:39)
at org.usb4java.javax.AbstractDevice.claimInterface(AbstractDevice.java:430)
at org.usb4java.javax.Interface.claim(Interface.java:102)
at org.usb4java.javax.Interface.claim(Interface.java:93)
at com.tgcs.usb.main.Main.main(Main.java:48)

Could you help me?

I'm sending the snippets attached to this e-mail.

Thank you!

Pio Tofanelli
Main.java
Main.java

Klaus Reimer

unread,
Mar 20, 2014, 5:49:44 PM3/20/14
to usb4...@googlegroups.com
On 20.03.2014 21:28, Pio Tofanelli wrote:
> I'm trying to communicate to a non fiscal printer and it's not working. I
> followed the "quick start" of the site
> (http://usb4java.org/quickstart/index.html) for libusb and javax.usb and
> I'm getting these errors:

Does this happen on Linux, Windows or OSX?

--
Klaus Reimer <http://www.ailis.de/~k/>
[2FC4 CCA0 C03B 1E5F 1ACC 94D6 6461 426C E734 75A1]

signature.asc

Pio Tofanelli

unread,
Mar 20, 2014, 8:57:21 PM3/20/14
to usb4...@googlegroups.com
Sorry, my mistake, I forgot to say that.

I tested on Windows 7 x64 and VM Ware windows XP x86.

I can test on Linux (2.6.24 and 3.2.1)

Thanks for the quick response.

Pio Tofanelli

Klaus Reimer

unread,
Mar 21, 2014, 1:58:48 AM3/21/14
to usb4...@googlegroups.com
On 21.03.2014 01:57, Pio Tofanelli wrote:
> Sorry, my mistake, I forgot to say that.
> I tested on Windows 7 x64 and VM Ware windows XP x86.

Sorry, if I just rant down the usual answers for Windows users first:

Did you create a Windows driver for the device with the Zadig tool as
mentioned in the FAQ? If not then you should read the following article
in the libusb Wiki which explains how to do it:

https://github.com/libusb/libusb/wiki/Windows#How_to_use_libusb_on_Windows

usb4java internally uses libusb for the actual USB communication and on
Windows libusb only can communicate with devices for which you have
installed a libusb compatible driver. This Zadig tool mentioned in the
above article is an easy way to create such a driver with just a few
mouse clicks. Without such a driver libusb is only able to read some
descriptor information from the device but it can't actually communicate
with it. This may explain the error messages you get.


> I can test on Linux (2.6.24 and 3.2.1)

This is always a good idea. libusb works best on Linux. So it is helpful
to check if there is a problem in your code or if it is a
platform-specific problem.

But I don't know if it works on an old Distribution which still uses
kernel 2.6. The Distribution with the oldest kernel we tested usb4java
on is Debian 7 which uses kernel 3.2.0.
signature.asc

Pio Tofanelli

unread,
Mar 21, 2014, 7:40:31 AM3/21/14
to usb4...@googlegroups.com
Klaus,

Thank you for the support.

I installed the WinUSB (v6.1.7600.16385). And now the application is abble to send bytes. Console output (high-level javax.usb approach):

Bus 001 Device 004: ID 04b3:4535
1
14 bytes sent

The printer did not print anything. When using rs232 comm, just sending a text string and a 0x0a makes the printer print.

There is any USB protocol to follow before starting send bytes to the device? The commom pipe to send bytes is the "Bulk" one?

Attached to this email is the device info.

Thank you again!

Regards,

Pio Tofanelli
USB device details.html

Klaus Reimer

unread,
Mar 21, 2014, 12:07:06 PM3/21/14
to usb4...@googlegroups.com
On 03/21/2014 12:40 PM, Pio Tofanelli wrote:
> The printer did not print anything. When using rs232 comm, just sending
> a text string and a 0x0a makes the printer print.
> There is any USB protocol to follow before starting send bytes to the
> device? The commom pipe to send bytes is the "Bulk" one?

Sorry, but this is too device-specific. I don't know the protocol of
this printer (or any printer). You have to ask the vendor of the device
how you need to communicate with it.
Reply all
Reply to author
Forward
0 new messages