/* C-Language "Hello World" example for the Crandun Technologies CTI-AR600 software library. Copyright (c) 2001, Crandun Technologies Inc. */ #include "CTI_AR600.h" /* required header */ #include #define maxSamples 20 int main() { char c; long i, rc; float fullScaleSpan, rangeData[maxSamples]; long numSkipped; long sensorHandle = -1; printf("Crandun Technologies CTI-AR600 Library 'Hello World' example.\n"); sensorHandle = getNewCTIAR600(); if (sensorHandle < 0) { printf("ERROR: getNewCTIAR600 returned error code %ld\n", sensorHandle); return -1; } printf("Enter the Full Scale Span of the AR600 sensor you are using (e.g. 4.0): "); scanf("%f", &fullScaleSpan); rc = setCommOpen(sensorHandle, "COM1:", 9600, fullScaleSpan); if (rc != CTI_SUCCESS) { printf("ERROR: setCommOpen returned error: %ld\n", rc); return -1; } printf("Reading samples from sensor ...\n"); rc = getSamples(sensorHandle, rangeData, maxSamples, 10, 3000); if (rc < 0) { printf("ERROR: getSamples returned error: %ld", rc); setCommClosed(sensorHandle); return -1; } printf("Read %ld range samples from the sensor.\n", rc); for (i = 0; i < rc; i++) printf("Range %d is %8.3f inches\n", i, rangeData[i]); numSkipped = getNumBytesSkipped(sensorHandle); printf("%ld bytes of data were skipped.\n", numSkipped); setCommClosed(sensorHandle); setReleaseHandle(sensorHandle); printf("Please enter any character to exit: "); scanf("%c\n", &c); return 0; }