Reading out ABA data
Data Transfer using Polling
If the extra data is quite slow and the delay caused by the notify size on DMA transfers is unacceptable for your application it is possible to
use the polling mode. Please be aware that the polling mode uses CPU processing power to get the data and that there might be an overrun
if your CPU is otherwise busy. You should only use polling mode in special cases and if the amount of data to transfer is not too high.
Most of the functionality is similar to the DMA based transfer mode as explained above.
The polling data transfer mode is activated as soon as the M2CMD_EXTRA_POLL is executed.
Definition of the transfer buffer
This is similar to the above explained DMA buffer transfer. The value „notify size" is ignored and should be set to 4k (4096).
Buffer handling
The buffer handling is also similar to the DMA transfer. As soon as one of the registers SPC_TS_AVAIL_USER_LEN or
SPC_ABA_AVAIL_USER_LEN is read the driver will read out all available data from the hardware and will return the number of bytes that
has been read. In minimum this will be one DWORD = 4 bytes.
Buffer handling example for polling timestamp transfer (ABA transfer is similar, just using other registers)
char* pcData = new char[lBufSizeInBytes];
// we now define the transfer buffer with the minimum notify size of one page = 4 kByte
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR_CARDTOPC, 4096, (void*) pcData, 0, lBufSizeInBytes);
// we start the polling mode
dwError = spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_POLL);
// this is pure polling loop
do
{
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lAvailBytes);
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_POS, &lBytePos);
if (lAvailBytes > 0)
{
printf ("We now have %d new bytes available\n", lAvailBytes);
printf ("The available data starts at position %d\n", lBytesPos);
// we take care not to go across the end of the buffer
if ((lBytePos + lAvailBytes) >= lBufSizeInBytes)
lAvailBytes = lBufSizeInBytes - lBytePos;
// our do function get's a pointer to the start of the available data section and the length
vProcessTimestamps (&pcData[lBytesPos], lAvailBytes);
// the buffer section is now immediately set available for the card
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lAvailBytes);
}
}
while (!dwError); // we loop forever if no error occurs
Comparison of DMA and polling commands
This chapter shows you how small the difference in programming is between the DMA and the polling mode:
DMA mode
Define the buffer
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR...);
Start the transfer
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_STARTDMA)
Wait for data
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_WAITDMA)
Available bytes?
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
Min available bytes
programmed notify size
Current position?
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
Free buffer for card
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lBytes);
162
digitizerNETBOX DN2.44x Manual / DN6.44x Manual
Polling mode
spcm_dwDefTransfer_i64 (hDrv, SPCM_BUF_TIMESTAMP, SPCM_DIR...);
spcm_dwSetParam_i32 (hDrv, SPC_M2CMD, M2CMD_EXTRA_POLL)
not in polling mode
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
4 bytes
spcm_dwGetParam_i32 (hDrv, SPC_TS_AVAIL_USER_LEN, &lBytes);
spcm_dwSetParam_i32 (hDrv, SPC_TS_AVAIL_CARD_LEN, lBytes);
ABA mode (dual timebase)
Need help?
Do you have a question about the digitizerNETBOX DN2.44 Series and is the answer not in the manual?