c - USB packet streaming input+output performance poor, advice needed please -


i'm looking advice on methods used optimize usb streaming performance. bare-metal embedded software application built on top of bare-metal usb engine.

thanks in advance.

i have data stream of continuous usb packets coming in. need process data , send return packets on usb fast can.

i have following code below. works, performance quite horrible.

  1. i'm feeding input circular buffer receive handler.
  2. main in endless while loop processing incoming packets , filling output buffer.
  3. in same endless while loop in main, if output buffer contains anything, send out right away.

(pseudo)-code:

global: (circular buffer) input buffer, (int *) output buffer, (int) count main {     ...     /* endless loop takes care of processing , sending packets. */     while (1) {         /* input buffer contains (from rxhandler), process it. */         while (input buffer not empty) {             tempvar = readfromcircularbuffer(input buffer);             fooinputprocessing(tempvar);         }         /* output buffer not empty.*/         if (count != 0) {             sendpacketoverusb(output buffer pointer, count);             count = 0;         }     }     ... }  fooinputprocessing(tempvar) {     ...     writetocircularbuffer(&outputbuffer, processedvar);     count++;     ... }  rxhandler (..., rxbuffer, ...) {     /* handles receive events. */     ...     /* write input buffer. */     (i=0; i<(buffer length); i++) {         writetocircularbuffer(input buffer, rxbuffer[i]);     }     ... }  txhandler (..., txbuffer, ...) {     /* handles transmit revents. */     /* not doing here since packets have been sent , don't need after (deallocating, or post-processing). */ } 


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -