Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

How To Setup viOpen Sessions Limit

$
0
0

I want to alloc some buffer to buffering DMA data from PCIe FPGA, my idea is create 512KB * 2048 buffer about 1GB, and i want to use the buffer by virtual address(VI_ATTR_WIN_ACCESS = VI_DEREF_ADDR), it looks like the max times of viOpen is 500, i tried use many Resource Manager. can I break the limit ? Or some kind of other method ? here is my code. thx.

 

int main(int argc, char **argv) {
	const UINT size = 0x80000;
	ViSession          rsrcManager;
	ViSession          vi;
	ViBusAddress       viBusAdr;
	ViAddr             viAddr;
	ViUInt32           viUint32;
	ViPUInt32		   viPUint32;
	list<ViBusAddress> viBusAdrs;
	ViUInt16           viUint16;
	int                nBlockIndex;
	int                nRsrcMgrIndex;

	list<ViBusAddress>::const_iterator iter;
	EmptyAllSet();
	viOpenDefaultRM(&rsrcManager);

	nRsrcMgrIndex = 0;
	while (1) {
		viOpenDefaultRM(&rsrcManager);
		for (nBlockIndex = 0; nBlockIndex < 100; nBlockIndex++) {
			if (viOpen(rsrcManager, "PXI::MEMACC", VI_NULL, VI_NULL, &vi) < VI_SUCCESS) {
				printf("Open Error %d %d\n", nRsrcMgrIndex, nBlockIndex);
				goto print_result;
			}
			if (viMemAlloc(vi, size, &viBusAdr) < VI_SUCCESS) {
				break;
			} else {
				if (viMapAddressEx(vi, VI_PXI_ALLOC_SPACE, viBusAdr, size, VI_FALSE, VI_NULL, &viAddr) < VI_SUCCESS) {
					printf("Map Error\n");
				}
				if (viGetAttribute(vi, VI_ATTR_WIN_ACCESS, &viUint16) < VI_SUCCESS) {
					printf("Get Attribute Error\n");
				}
				if (viUint16 != 3) {
					printf("Map Result Error\n");
				}
				viBusAdrs.push_back(viBusAdr);
			}
		}
		nRsrcMgrIndex++;
	}
print_result:
 	printf("%dK * %d = %dM\n", size / 1024, viBusAdrs.size(), size * viBusAdrs.size() / 1024 / 1024);
 	getch();
	return 0;
}

 


Viewing all articles
Browse latest Browse all 5565

Trending Articles