Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I am a beginner. Can anyone tell me how to detemine the servant area size of a message based controller

. I am trying to use viOut16 to the data low register with 0xCEFF, 'Read Servant Area'command. I am waiting on the read ready/write ready bits of the response register but the write ready bit is never 1! The device I am writing to is an E8491B. Thank you."code section (variables left out!, no error handling incl.):
#define MSG_DESCR "VXI0::0::INSTR"
#define RESPONSE 0x0a
#define DATA_LOW 0x0e
#define READREADY 0x0400
#define WRITEREADY 0x0200
#define TIMEOUT 300
int main( void )
{
status = viOpenDefaultRM(&defaultRM);
if(status < VI_SUCCESS)
{
printf("viOpenDefaultRM error : 0x%04x\n", status);
return -1;
}

status = viOpen(defaultRM, MSG
_DESCR, VI_NULL, VI_NULL, &instr);
if(status < VI_SUCCESS)
{
printf("viOpen error : 0x%04x\n", status);
return -1;
}

status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 1000);

viIn16(instr, VI_A16_SPACE, RESPONSE, ®);
// reg == 0x09c0
while((reg != WRITEREADY) && (timeoutCnt < TIMEOUT))
{
viIn16(instr, VI_A16_SPACE, RESPONSE, ®);
reg = (WRITEREADY & reg);
timeoutCnt++;
}

if(timeoutCnt >= TIMEOUT)
{
status = viClose(instr);
status = viClose(defaultRM);
return 0;
}

printf("'Read Servant Area' command\n");
viOut16(instr, VI_A16_SPACE, DATA_LOW, 0xceff);

viIn16(instr, VI_A16_SPACE, RESPONSE, ®);
timeoutCnt = 0;
while((reg != READREADY) && (timeoutCnt < TIMEOUT))
{
viIn16(instr, VI_A16_SPACE, RESPONSE, ®);
reg = (READREADY & reg);
timeoutCnt++;
}

if(timeoutCnt >= TIMEOUT)
{
status = viClose(instr);
status = viClose(defaultRM);
return 0;
}

viIn16(instr, VI_A16_SPACE, DATA_LOW, ®);
printf("'Read Servant Area' command contents :
0x%04x\n", reg);

return 0;
}
0 Kudos
Message 1 of 1
(2,964 Views)