Appendix F
VISA and Serial APIs on UNIX
ENET-232 and ENET-485 Series User Manual
F-2
ni.com
viSetAttribute
. VISA attributes are robust and cover many types of
information and configuration functions, including port settings and
modem lines.
VISA is extensible to other hardware interfaces and is supported on various
platforms. Therefore, if you are programming multiple devices that
communicate over more than one bus type, it may be easier to use VISA for
your entire system.
The default settings for a serial VISA session are 9600 baud, 8 data bits,
1 stop bit, no parity, and no flow control. A port is set to these settings
following a successful call to
viOpen
. However, once a session to the port
is opened, you can change these settings on a per session basis using
viSetAttribute
. To have a different set of default values following a
successful
viOpen
operation, use the
visaconf
utility to change
the default settings in use when a port is opened. (You must use the
VI_LOAD_CONFIG
parameter in
viOpen
for this option.) See the
NI-VISA
User Manual
for more details.
The following example shows how to use some of the VISA operations.
int main(void)
{
char instrDescriptor[VI_FIND_BUFLEN];
char buf[1024];
ViSession defaultRM, instr;
ViStatus status;
ViUInt32 numAvailBytes, retCount;
ViEventType eventType;
ViEvent eventContext;
int i;
/* First we will need to open the default resource manager. */
status = viOpenDefaultRM (&defaultRM);
if (status < VI_SUCCESS)
{
printf("Could not open a session to the VISA Resource Manager!\n");
return -1;
}
/* Set descriptor to a serial port at port 2 of the serial device server
at IP address 130.164.41.41 */
strcpy(instrDescriptor, "ASRL::130.164.41.41::2::INSTR");
printf("Opening %s \n",instrDescriptor);