All Classes Namespaces Files Functions Variables Enumerations Enumerator
libs/range_sensor/scip_samples/scip_20_vv.cpp
00001 
00011 #include "SerialDevice.h"
00012 #include "DetectOS.h"
00013 #include "ConnectionUtils.h"
00014 #include <cstdio>
00015 #include <cstdlib>
00016 
00017 using namespace qrk;
00018 
00019 
00021 int main(int argc, char *argv[])
00022 {
00023   // Change the port name appropriately
00024 #if defined(WINDOWS_OS)
00025   const char device[] = "COM3";
00026 #elif defined(LINUX_OS)
00027   const char device[] = "/dev/ttyACM0";
00028 #else
00029   const char device[] = "/dev/tty.usbmodem1d11";
00030 #endif
00031 
00032   SerialDevice con;
00033   if (! con.connect(device, 19200)) {
00034     printf("SerialDevice::connect: %s\n", con.what());
00035 #if defined(WINDOWS_OS)
00036     printf("Hit return key.\n");
00037     getchar();
00038 #endif
00039     exit(1);
00040   }
00041 
00042   //Call Scip2.0 and neglect the response.
00043   enum { Timeout = 200 };
00044   con.send("SCIP2.0\n", 8);
00045   skip(&con, Timeout);
00046 
00047   // Send VV command
00048   con.send("VV\n", 3);
00049 
00050   // Display received command
00051   enum { LineMax = 64 + 1 };
00052   char buffer[LineMax];
00053   int n;
00054   while ((n = readline(&con, buffer, LineMax, Timeout)) > 0) {
00055     printf("%s\n", buffer);
00056   }
00057 
00058 #if defined(WINDOWS_OS)
00059   printf("Hit return key.\n");
00060   getchar();
00061 #endif
00062 
00063   return 0;
00064 }