[Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?)
Trent Jarvi
tjarvi at qbang.org
Mon Feb 23 19:32:09 MST 2009
On Sun, 22 Feb 2009, Alexander Poddey wrote:
> Hi all,
>
> I posted this about switching heavy loads close to the usb cable:
> http://mailman.qbang.org/pipermail/rxtx/2009-January/3773588.html
>
> and meanwhile guess it corresponds to a hot un- and replug of the usb cable
> (the adapter gets irritated by the strong electro-magnetic burst emitted
> during switching the load).
>
>
> in order to be able to record measurement-data continuously, i fudged in a
> timertask, which regularly checks (all 500ms)
> in_stream.available();
> as it throws an error in this situation.
> I can then close and reconnect the port without any irritation.
>
> for my datastream, this is ok, but it's not really smart.
>
> the error thrown is:
> 'Input/output error in nativeavailable'
>
>
> THE QUESTION:
> could one connect an event-listener to anything in order to get an interrupt
> when the native becomes unavailable?
>
>
The nativeavailable() error means a very simple C call failed. The
file descriptor is in an invalid state (as you noticed). RXTX can't do
more than that in it's current implementation. To get events regarding
'hotplug,' you would need to look at the USB HID API for your platform.
JSR 80 may have some code you look at for hints.
http://jcp.org/aboutJava/communityprocess/final/jsr080/index.html
I believe some others on the list have looked into this some as well.
--
Trent Jarvi
tjarvi at qbang.org
More information about the Rxtx
mailing list