Asynchronous Listener Synchronization Java HID -


i tried around time, not able find answer problem. writing java program used read , update firmware of hid device. using purehid java libraries communicate device , working fine.

the problem experiencing, , not able fix, concerns synchronization of events.

i give example. when copying firmware installed on device, using following method

dev.setoutputreport((byte) 0, packet_to_send, buffer_size); 

the answer unit come in form of event received listener attached device manager, namely following listener invoked

oninputreport() /* happen */ 

my problem sometimes, because of concurrent writing/listening invocation, program freeze, without exception nor error signaled.

to fix problem, tried implement simple lock mechanism, lock being released when reply received; unfortunately may happen reply packet lost blocking me in deadlock.

one possible solution though use timer release lock automatically after x milliseconds if not released (the reply arrive within 10ms or not arrive), not know how create independent thread manage timer.

can please me fixing problem, or suggest me concurrency mechanism can use synchronize 2 blocks or re-transmit message, if reply lost?

thank helping.

lorenzo


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -