HP (Hewlett-Packard) B Network Router User Manual


 
/* set number of bytes placed in memory, and number of bytes read */
swap = sizeof(int); /* place 2 bytes/reading in memory */
bytes = 20 * swap; /* read 40 bytes */
IOOUTPUTS(ADDR, "READ?", 5); /* retrieve the readings */
IOENTERAB(ADDR, rdgs, &bytes, swap); /* enter the readings and */
/* remove the block header */
/* Remove line feed which trails the last data byte */
length = 1;
IOENTERS(ADDR, lf_remove, &length);
/* print label */
label = (rdgs[0] & 0x000F);
printf("\nLabel #: %d", label);
/* convert and print each reading as a voltage */
for (i = 0; i < 20; i++)
{
rdgs[i] /= 16; /* remove label from each reading */
if (rdgs[i] >= 2047 || rdgs[i] <= -2046)
printf("\nReading overrange");
else
printf("\nReading %d = %.6E", i, (rdgs[i]
*
0.0005));
}
free(rdgs);
}
/****************************************************************************/
void rst_clr(void)
{
/* Reset and clear the digitizer */
IOOUTPUTS(ADDR, "*RST;*CLS", 9); /* Send (9) characters */
}
Continued on Next Page
Chapter 2 Usin
g
the Di
g
itizer 61