// // "Hello World" example for the Crandun Technologies CTI-AR4000 // software library. // Copyright (c) 2001, Crandun Technologies Inc. // #include "CTI_AR4000.h" // required header #include // needed for cout, cerr, cin using namespace std; // we use cout, cerr and cin using namespace Crandun; // all library symbols are in this namespace int main() { char c; long rc; const int MAXSAMPLES = 20; float rangeData[MAXSAMPLES]; CTI_AR4000 my_Sensor; cout << "Crandun Technologies CTI-AR4000 Library 'Hello World' example." << endl; rc = my_Sensor.setCommOpen("COM1:", 9600); if (rc != CTI_SUCCESS) { cerr << "ERROR: setCommParams returned error: " << rc << endl; cerr << "Please enter any character to exit: "; cin >> c; return -1; } rc = my_Sensor.getSamples(rangeData, MAXSAMPLES, 10); if (rc < 0) { cerr << "ERROR: getSamples returned error: " << rc << endl; my_Sensor.setCommClosed(); cerr << "Please enter any character to exit: "; cin >> c; return -1; } cout << "Read " << rc << " range samples from the sensor." << endl; for (int i = 0; i < rc; i++) cout << "Range " << i << " is " << rangeData[i] << endl; cout << my_Sensor.getNumBytesSkipped() << " bytes of data were skipped." << endl; my_Sensor.setCommClosed(); cout << "Please enter any character to exit: "; cin >> c; return 0; }