Select Git revision
main.cc 7.42 KiB
// **************************************************************************
// File: main.cc
//
// Author: Phil Gillaspy
//
// Description: Demonstration program for GQ GMC (geiger-muller counter).
//
// Usage: gqgmc <usb-port-device-name>
// Example: gqgmc /dev/ttyUSB0
//
// **************************************************************************
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace std;
#include <unistd.h>
#include "gqgmc.hh"
using namespace GQLLC;
void mypause()
{
cout << "Paused: to continue, press ENTER.. " << flush;
cin.ignore(1, '\n');
return;
}
// Utility to show message to user. To be adapted to a pop-up window
// when code developed for GUI.
void Display_message(string msg)
{
cout << msg << endl;
}
// Utility to encapsulate the code to display an error message. This is
// separated from Display_message() because this is specialized to
// accessing and formulating the GQGMC error status, but not displaying.
void Display_error(const GQGMC & gmc)
{
gmc_error_t err;
err = const_cast<GQGMC &>(gmc).getErrorCode();
stringstream msg;
msg << const_cast<GQGMC &>(gmc).getErrorText(err);
Display_message(msg.str());
return;
}
int
main(int argc, char **argv)
{
// Open the USB port using a USB to serial converter device driver.
// Using UDEV rule file 51-gqgmc.rules to create symlink to /dev/gqgmc.
string usb_device = "/dev/gqgmc";
if (argc > 1)
usb_device = argv[1];
else
{
cout << "Usage: gqgmc <usb-port-device-name>" << endl;
cout << "Example: gqgmc /dev/ttyUSB0" << endl;
return 0;
}
// cout << usb_device << endl; // debug
// Instantiate the GQGMC object on the heap
GQGMC * gqgmc = new GQGMC;