Home > Software engineering >  Consulting a VC operation efficiency
Consulting a VC operation efficiency

Time:09-17

VC program description:
MFC has a start button perform void CP: : OnBnClickedBtnStart (), in this function
1, open and initialize the USB device
2, the establishment of receiving threads m_pXferThread=AfxBeginThread (BulkXferRead, & amp; M_oXferParam);
Loop to receive data in the BulkXferRead function:

Problem description:
(every 200 us to send a package, each package size is 512 bytes, PCLK is 100 MHZ, GPIF bus width for 32-bit)
1, send the package as follows (note that the first byte increments) :
0 0 1 2 3 4 5 6 7,,,,,,,, 254
1 0 1 2 3 4 5 6 7,,,,,,,, 254
2 0 1 2 3 4 5 6 7,,,,,,,, 254
3 0 1 2 3 4 5 6 7,,,,,,,, 254
,,

255 0 1 2 3 4 5 6 7,,,,,,,, 254
Original key program is as follows, namely each received a package will be the whole package written to the file:
PContext=pBulkEpIn - & gt; BeginDataXfer (pBulkBuf nBulkLen, & amp; OWrOvLap);
If (pBulkEpIn - & gt; FinishDataXfer (pBulkBuf nBulkLen, & amp; OWrOvLap pContext))//successful reading data
{
Fout. Open
for(i=0; i{
F.F ormat (gs, pBulkBuf [I]);
Fout. Write (f, f.G etLength ());
}
Fout. Close ();
}
2, open the file, found that the received data is as follows:
0 0 1 2 3 4 5 6 7,,,,,,,, 254
80 0 1 2 3 4 5 6 7,,,,,,,, 254
200 0 1 2 3 4 5 6 7,,,,,,,, 254
60 0 1 2 3 4 5 6 7,,,,,,,, 254
,,

20 0 1 2 3 4 5 6 7,,,,,,,, 254
You can see lost a lot of bag!

Now I will change the program, where each receives a packet, the first byte write cache, when receiving the 512 package, only will each packet the first byte in the file:
PContext=pBulkEpIn - & gt; BeginDataXfer (pBulkBuf nBulkLen, & amp; OWrOvLap);
If (pBulkEpIn - & gt; FinishDataXfer (pBulkBuf nBulkLen, & amp; OWrOvLap pContext))//successful reading data
{
TpBulkBuf [Tpsize]=pBulkBuf [0];
Tpsize++;
If (Tpsize>
=512){
Fout. Open
for(i=0; i{
F.F ormat (gs, TpBulkBuf [I]);
Fout. Write (f, f.G etLength ());
}
Fout. Close ();
}
}
Now open the file, found that the data is as follows:
1 2 3 4 5 6 8 9 10 11 12,,,, 200, 202,
Data I have lost, but the basic right
I want to ask is VC implementation efficiency, middle and no delay unit, what also have no other handlers,
In the original program or lost so many package, is in the process of written to the file before receiving a new package,
My 200 us to send a package, in this 200 us to finish the work of receiving and written to the file???????
I what to do???

CodePudding user response:

200 us? This request is a little bit high! WINDOWS is not real-time system, it is difficult to guarantee the real time,
If there is a delay, just write file a dongdong, called the memory mapping, may I have an idea,

CodePudding user response:

Non obstructive BeginDataXfer WaitForXfer FinishDataXfer

CodePudding user response:

Is this ah, WaitForXfer I didn't write it out

CodePudding user response:

I looked at the general, memory mapping is usually deal with big file, the suitable for you, I this file is not very big, mainly speed,
200 us a package, a package of 512 bytes, do I just use this package processing, processed all don't need to save, so the file will not be too big

CodePudding user response:

Frequent close open the file, if the system response too slow, next time the new data is written to overwrite the last did not save the data, can put the write data function independently, to save the data first, after a certain number of one-time write data

CodePudding user response:

Continue reading in VC, the FPGA testing began after once again to send, after reading the FPGA waveform caught waveform is as follows:
, as shown in the figure above each pulse interval is 200 us, about 20 pulse, VC can read data in the last time send,
So the FPGA every 20 * 200 us time to once again send a new package, this can't meet the requirements of me,
I want VC in the 200 us to put a package of data reception, it does not affect the next packet to send, what should I do???????

CodePudding user response:

The waveform on behalf of the VC to receive the data below!

CodePudding user response:

200 us, WINDOWS system, the clock frequency, to reach this level, in this case, we usually through hardware, complete the high-speed data acquisition, and then read the data, hardware clock frequency, according to the actual situation, data acquisition requirements, environment, etc.), we meet with high-speed data acquisition, periodic times collection, data analysis, continuous high-speed data acquisition, there is no met, there is no good advice,
  • Related