~vibhavp/ubuntu/saucy/urg/merge-from-debian

« back to all changes in this revision

Viewing changes to samples/scip_samples/scip_20_pp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Albert Huang
  • Date: 2010-03-30 01:43:55 UTC
  • Revision ID: james.westby@ubuntu.com-20100330014355-hz6mntlogs1uep7u
Tags: upstream-0.8.11
ImportĀ upstreamĀ versionĀ 0.8.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
  \example scip_20_pp.cpp
 
3
 
 
4
  \brief Get PP command response
 
5
 
 
6
  \author Satofumi KAMIMURA
 
7
 
 
8
  $Id: scip_20_pp.cpp 1701 2010-02-16 05:33:25Z satofumi $
 
9
*/
 
10
 
 
11
#include "SerialDevice.h"
 
12
#include "DetectOS.h"
 
13
#include "ConnectionUtils.h"
 
14
#include <cstdio>
 
15
#include <cstdlib>
 
16
 
 
17
using namespace qrk;
 
18
 
 
19
 
 
20
//! main
 
21
int main(int argc, char *argv[])
 
22
{
 
23
  // Change the port name appropriately
 
24
#if defined(WINDOWS_OS)
 
25
  const char device[] = "COM3";
 
26
#elif defined(LINUX_OS)
 
27
  const char device[] = "/dev/ttyACM0";
 
28
#else
 
29
  const char device[] = "/dev/tty.usbmodem1d11";
 
30
#endif
 
31
 
 
32
  SerialDevice con;
 
33
  if (! con.connect(device, 19200)) {
 
34
    printf("SerialDevice::connect: %s\n", con.what());
 
35
#if defined(WINDOWS_OS)
 
36
    printf("Hit return key.\n");
 
37
    getchar();
 
38
#endif
 
39
    exit(1);
 
40
  }
 
41
 
 
42
  // Call Scip2.0 and neglect the response.
 
43
  enum { Timeout = 200 };
 
44
  con.send("SCIP2.0\n", 8);
 
45
  skip(&con, Timeout);
 
46
 
 
47
  // Send PP command
 
48
  con.send("PP\n", 3);
 
49
 
 
50
  // Display received data
 
51
  enum { LineMax = 64 + 1 };
 
52
  char buffer[LineMax];
 
53
  int n;
 
54
  while ((n = readline(&con, buffer, LineMax, Timeout)) > 0) {
 
55
    printf("%s\n", buffer);
 
56
  }
 
57
 
 
58
#if defined(WINDOWS_OS)
 
59
  printf("Hit return key.\n");
 
60
  getchar();
 
61
#endif
 
62
 
 
63
  return 0;
 
64
}