名称错误"TCPIP0::10.41.129.111::inst0::INSTR"
viOpen返回错误代码:–1073807342VI_ERROR_INV_RSRC_NAMEInvalid resource reference specified. Parsing error.
已经知道是名称错误,但是度过好多,都不能正确
[解决办法]
大哥啊,你为什么不照着人家的例子来写呢,你都不找资源就直接用有没有搞错啊
int FindRSrc(void)
{
char instrDescriptor[VI_FIND_BUFLEN];
ViUInt32 numInstrs;
ViFindList findList;
status = viOpenDefaultRM(&defaultRM);
if ( status < VI_SUCCESS ) {
DebugLogf("Could not open a session to the VISA Resource Manager!");
return status;
}
status = viFindRsrc( defaultRM, "TCPIP?*INSTR", &findList, &numInstrs, instrDescriptor );
if ( status < VI_SUCCESS ) {
DebugLogf("An error occurred while finding resources.");
return status;
}
if ( numInstrs > 0 ) {
Agilent->ComboBox_GPIB->Items->Add(instrDescriptor);
}
status = viOpen( defaultRM, instrDescriptor, VI_NULL, VI_NULL, &instr );
while ( --numInstrs ) {
status = viFindNext( findList, instrDescriptor );
if ( status < VI_SUCCESS ) {
DebugLogf("An error occurred finding the next resource.");
return status;
}
//这个时候的instrDescriptor就是你电脑上找到的资源,并且可用,如果为空就说明你的连线有问题
}
viClose(instr);
viClose(findList);
return status;
}