version_info.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9  * Includes
10  ****************************************************************************/
11 
12 #include <string>
13 #include <ecl/time.hpp>
14 #include <ecl/sigslots.hpp>
15 #include <ecl/command_line.hpp>
16 #include "xbot_driver/xbot.hpp"
17 
18 /*****************************************************************************
19 ** Classes
20 *****************************************************************************/
21 
22 class XbotManager {
23 public:
24  XbotManager(const std::string &device_port) :
25  acquired(false)
26  {
27  xbot::Parameters parameters;
28  parameters.sigslots_namespace = "/xbot"; // configure the first part of the sigslot namespace
29  parameters.base_port = device_port; // the serial port to connect to (windows COM1..)
30  xbot.init(parameters);
31  xbot.enable();
32  }
33 
35  xbot.disable();
36  }
37 
38 
39  bool isAcquired() { return acquired; }
40  std::string& getHardwareVersion() { return hardware; }
41  std::string& getFirmwareVersion() { return firmware; }
42  std::string& getSoftwareVersion() { return software; }
43  std::string& getUDID() { return udid; }
44 
45 private:
46  volatile bool acquired;
48  std::string hardware, firmware, software, udid;
49 };
50 
51 /*****************************************************************************
52 ** Main
53 *****************************************************************************/
54 
55 int main(int argc, char** argv)
56 {
57  ecl::CmdLine cmd_line("version_info program", ' ', "0.2");
58  ecl::UnlabeledValueArg<std::string> device_port("device_port", "Path to device file of serial port to open, connected to the xbot", false, "/dev/xbot", "string");
59  cmd_line.add(device_port);
60  cmd_line.parse(argc, argv);
61  //std::cout << "device_port: " << device_port.getValue() << std::endl;
62 
63  std::cout << "Version Info:" << std::endl;
64  XbotManager xbot_manager(device_port.getValue());
65 
66  while (!xbot_manager.isAcquired());
67  std::cout << " * Hardware Version: " << xbot_manager.getHardwareVersion() << std::endl;
68  std::cout << " * Firmware Version: " << xbot_manager.getFirmwareVersion() << std::endl;
69  std::cout << " * Software Version: " << xbot_manager.getSoftwareVersion() << std::endl;
70  std::cout << " * Unique Device ID: " << xbot_manager.getUDID() << std::endl;
71 
72  return 0;
73 }
std::string firmware
std::string base_port
The serial device port name [/dev/xbot].
Definition: parameters.hpp:51
Parameter list and validator for the xbot.
Definition: parameters.hpp:35
void add(Arg &a)
Definition: cmd_line.hpp:349
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/xbot"].
Definition: parameters.hpp:53
std::string software
XbotManager(const std::string &device_port)
xbot::Xbot xbot
EndOfLine endl
Device driver core interface.
Keyboard remote control for our robot core (mobile base).
std::string & getFirmwareVersion()
std::string & getSoftwareVersion()
int main(int argc, char **argv)
Manages the command line parsing object.
Definition: cmd_line.hpp:49
volatile bool acquired
std::string udid
std::string & getHardwareVersion()
void parse(int argc, char **argv)
Definition: cmd_line.hpp:368
std::string hardware
std::string & getUDID()
Definition: command.hpp:30
bool isAcquired()
The core xbot driver class.
Definition: xbot.hpp:86


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:38