National Instruments NI-488.2 NI-488.2 User Manual page 80

National instruments network hardware - networking hardware user manual
Hide thumbs Also See for NI-488.2 NI-488.2:
Table of Contents

Advertisement

Chapter 8
NI-488.2 Programming Techniques
// If the ERR bit is set in LocalIbsta, then print an error
// message and return.
if (LocalIbsta & ERR)
printf ("GPIB error %d has occurred. No more callbacks.\n",
DeviceError = TRUE;
return 0;
}
// Read the serial poll byte from the device. If the ERR bit is set
// in ibsta, then print an error message and return.
LocalIbsta = ibrsp (LocalUd, &SpollByte);
if (LocalIbsta & ERR)
printf ("ibrsp failed. No more callbacks.\n");
DeviceError = TRUE;
return 0;
}
// If the returned status byte equals the expected response, then
// the device has valid data to send; otherwise it has a fault
// condition to report.
if (SpollByte != expectedResponse)
printf("Device returned invalid response. Status byte = 0x%x\n",
DeviceError = TRUE;
return 0;
}
// Read the data from the device. If the ERR bit is set in ibsta,
// then print an error message and return.
LocalIbsta = ibrd (LocalUd, ReadBuffer, 40L);
if (LocalIbsta & ERR)
printf ("ibrd failed. No more callbacks.\n");
DeviceError = TRUE;
return 0;
}
// The string returned by ibrd is a binary string whose length is
// specified by the byte count in ibcntl. However, many GPIB
// instruments return ASCII data strings and this example makes this
// assumption. Because of this, it is possible to add a NULL
// character to the end of the data received and use the printf()
// function to display the ASCII data. The following code
// illustrates that.
ReadBuffer[ibcntl] = '\0';
NI-488.2 User Manual
{
LocalIberr);
{
SpollByte);
{
8-8
{
ni.com

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents