c# - Fixing gaps in streamed USB data -
We have a hardware system that has some FPGA and FTDI USB controller. The hardware streams data over USB bulk transfers on PCs around 5 MB / s and software is tasked to stay in sync, check CRC and write data to file.
In the FTDI chip 'busy' PC during your waiting for the pc which gets high when completing your business. There is limited amount of buffering on FTIDI and elsewhere on the hardware.
The busy line is too much compared to the buffer (50-100 ms) from the hardware, so we are losing data to help me fix this problem to prevent hardware from redesigning. Having said!
I think my code is very fast because we run it up to 15 MB / s, so that if an IO leaves the obstacle, are we expecting a lot from PC / OS?
Here my data is the entry point. I sometimes get a dropped bit or byte if the checksum is not calculated, then I change it until it does. Byte [] data is almost always 4K.
zero ftdi_OnData (byte [] data) {list & lt; Byte & gt; Buffer = new list & lt; Byte & gt; (Data lang); Int index = 0; While ((index + Kchchefail. Header. Packet Lamb + 1) & lt; data.Length) {if (CheckSum.CRC16 (data, index, Kchchifail. Header. Packet lamps + 2)) // & lt; - packet length 16bit + 2 checksum {Bfr.adarenj (data. Sabiaarara; lt; byte & gt; (index, Kchchifail. Header. Packet Lang)); Index + raw file Header Packet Lamp + 2; // & lt; - Leave two checksums, we do not want to save them ...} and {index ++; // via Pali}} rawFile.AddData (buffer .ORA (), 0, buffer.count); }
Tip: do not write a file .... in the queue.
There are multiple processors in modern computers if you want to do some things as fast as possible, they use more than one processor.
- Check on thread deals with USD data, checks, etc. The queue (only) results in a thread secure queue
- reads the data from another thread queue and writes it in a file, probably buffer.
finished;)
100 MMS time for civilized conduct I successfully managed around the C # to use the per second (financial data) 250,000 IO data packets I am
Actually, make sure your IO threads do the same and use your internal memory as a buffer. Especially to deal with hardware at one end which should only do this, possibly if it is necessary to run in a higher priority.
Comments
Post a Comment