National Instruments NI-488.2 User Manual page 75

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

Advertisement

Chapter 7
NI-488.2 Programming Techniques
// 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';
// Convert the data into a numeric value.
sscanf (ReadBuffer, "%f", &Readings[ReadingsTaken]);
// Display the data.
printf("Reading : %f\n", Readings[ReadingsTaken]);
ReadingsTaken += 1;
if (ReadingsTaken >= 1000)
return 0;
}
else
{
// Issue a request to the device to send the data and rearm
// callback on RQS.
LocalIbsta = ibwrt (LocalUd, "SEND DATA", 9L);
if (LocalIbsta & ERR)
NI-488.2 User Manual for Windows
SpollByte);
{
{
{
printf ("ibwrt failed. No more callbacks.\n");
DeviceError = TRUE;
7-8
{
www.natinst.com

Advertisement

Table of Contents
loading

Table of Contents