java - Reading continuously incoming data (usb4java) -


I have spent a lot of time knowing about the best method for continuously using USB4 Java ( Libsub) K-Livel Functions.

640kbyte / s needs to be read in a full speed device, it is theoretically possible, and I should use less than half bandwidth. The problem I have is that the data I am reading are those that are coming from missing or corrupted data.

I have tried both sync and async with the same result. Here I am using the code to do this in async mode, any help is appreciated.

  public volume doInBackground () {loop = true; Handle = comm_device_async.gethandle (); Buffer = buffer utilities. Olloclibt buffer (packet size) .reader (byte order. LITTLE_ENDIN); Transfer Transfer = LYUSB Alok Transfer (); LibUsb.fillBulk Transfer (transfer, handle, IN_ENDPOINT, buffer, read_callback, null, TIMEOUT); Int result = lbube. Vittrant Transfer (Transfer); If (result! = LibUsb.SUCCESS) {new LibUsbException ("Unable to send transfer", results); } While (loop) {synchronize} {while (! Transfer complete) {try {synchObj.wait ()}} hold (interrupted predefined) {logger.galllogger (graphpany_jourcht2d.class.getname ()). Logs (level. SESEE, ANNEL, X); }}} Transfercompleted = false; MultipailShort [readcyclecount] = read_callback_data; Readcyclecount ++; If (readcyclecount == recycle) {synchronize (data list shot) {dataListShort.add (multipledatashort); DataListShort.notify (); } Readcyclecount = 0; }} Return tap; } Transfer callback read_callback = new transfer callback () {byte buffer; Long startTime = 0; @ Override Public Voice Process Transfer (Transfer Transfer) {System.out.println ("ReadCallback Loop Time" + (System. Nano Time / 1000 - Starttime)); StartTime = System.nanoTime () / 1000; Read_callback_data = New small [transfer.buffer () Ability () / 2]; For (int i = 0; i & lt; read_callback_data.length; i ++) read_callback_data [i] = transfer.buffer (). GetShort (); Synchronize {transfercompleted = true; SynchObj.notify (); } Buffer = buffer utilities. Ollotbitbuffer (packet size) .dr (byte order. LITTLE_ENDIN); LibUsb.fillBulkTransfer (transfer, collectWorker_usb4java_async_fast.handle, IN_ENDPOINT, buffer, read_callback, null, TIMEOUT); Int result = lbube. Vittrant Transfer (Transfer); If (result! = LibUsb.SUCCESS) {new LibUsbException ("Unable to send transfer", results); }}};  

I think a thread got similar to the same issue

  1. Asynchronous (and re-deposited) is asking to submit a single request to work worse than submitting a synchronous request. Hopefully it will take more time to work more busy.

  2. The goal is to keep the list of the URB on the kernel that is constantly filling, this list is empty at any given time, The request will not be filled again in time and will fill the FT2232H buffer. The way to do asynchronous mode is to make a list of correct movements, each time one of them returns, the second request is made to change the request to the list of the URB to overhead, but as long as By the time the list starts bigger, we can complete this overhead on time to complete other transfers.

So basically For large amounts of data, we The buffer buffer needs to be traded, so it is always pending if the last is pending.

I am going to work on it, but I have not found a good example of how it should be used by usb4java, then any help is appreciated.

>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -