Data Acquisition (DAQ) and Control from Microstar Laboratories

Knowledge Base: Applications

Q10043 Memory Fault error during DAP data transfers

Tags: Help, DAP, DAPL, DAPIO32, programming, DAPIO32, data transfer, DapBufferGet

Applies to: All applications reading DAP blocks of data

In my VB application, I am checking how many bytes are available for my data transfer, and then requesting this amount to read into my application. This almost always works. But then in rare cases, I get a memory fault. Is this because the DAP transfers too much data and stores more data than my buffer can accept?

In a sense, yes. The DapBufferGet operation will never transfer more data than the maximum that you specify when you call it. But it cannot know whether the maximum that you specify is consistent with the buffer storage area your application provides. The number of values available could depend on a number of unknown delays in your PC host, and it could be much larger than the storage area you set up. In such a case, asking to transfer the full amount of data that DapInputAvail reports could easily cause a memory fault.

DAP devices cannot force any data into your application storage. If too many samples are available, the transfer buffers on the PC host can fill up, the communications channels can fill up, and data processing on the DAP could be backlogged with data temporarily suspended, all waiting for the host activity to catch up. But in all cases, the maximum data transfer sizes you specify will be honored.

To avoid the fault, compare the available data size to the known maximum your buffer can contain. If excess data are available, specify the buffer maximum for the transfer. Perform multiple operations until you have retrieved all of the available data.

L16601