National Instruments ENET-232 Series User Manual page 90

Serial, for windows 2000/nt 4.0 and linux x86/solaris 2.x
Hide thumbs Also See for ENET-232 Series:
Table of Contents

Advertisement

/* Now we will open a session to the instrument we just found. */
status = viOpen (defaultRM, instrDescriptor, VI_NULL, VI_NULL, &instr);
if (status < VI_SUCCESS)
{
printf ("An error occurred opening a session to %s\n",instrDescriptor);
viClose(defaultRM);
return -1;
}
/* Set the baud rate to 115200.
/* Error checking has been removed from this point on for clarity. */
status = viSetAttribute(instr, VI_ATTR_ASRL_BAUD, 115200);
/* Write a value to the port */
strcpy(buf, "This is a test string\n");
status = viWrite(instr, buf, strlen(buf), &retCount);
/* See how many bytes are available to be read in the port. */
/* Note: In viGetAttribute, the third parameter type changes based on the */
/* value of the second parameter. */
status = viGetAttribute(instr, VI_ATTR_ASRL_AVAIL_NUM, &numAvailBytes);
printf("%d bytes available to be read at this instance in time.\n",
numAvailBytes);
/* Read the next numAvailBytes bytes or until a TERMCHAR is sent ('\n' by */
/* default)
(see
/* VI_ATTR_ASRL_END_IN for more details). */
status = viRead(instr, buf, numAvailBytes, &retCount);
/* Close the session to the port. */
viClose(instr);
/* Close the resource manager session. */
viClose(defaultRM);
return 0;
}
© National Instruments Corporation
This takes effect immediately. */
VI_ATTR_TERMCHAR, VI_ATTR_TERMCHAR_EN, and */
F-3
Appendix F
VISA and Serial APIs on UNIX
ENET-232 and ENET-485 Series User Manual

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enet-485 series

Table of Contents