简体   繁体   中英

Maximize throughput using java-libusb

I'm presently developing a USB device (microcontroller based data logger) and would like to collect data from the device to a host computer for visualization. Libusbjava is used for USB data transfer. Presently, I'm able to connect to the device and send/receive data.

My problem is when I try to continuously receive data (5.12Mb/s) from the device in a continuous fashion. Here is what happens:

· If I try to continuously collect data in a while loop, desired USB throughput is achieved, but the graphing thread no longer works · If I try collecting data every 1ms using a timer thread (640bytes every 1ms), throughput is significantly affected but the graphing thread is functional

What would be the optimal way to structure my java code to allow for desired throughput and graphing?

Handle the USB communication in the background using SwingWorker . Trying to update the GUI every millisecond is unrealistic. Instead, publish() updates in batches and process() them on the event dispatch thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM