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 "kobuki_driver/kobuki.hpp"
17 
18 /*****************************************************************************
19 ** Classes
20 *****************************************************************************/
21 
22 class KobukiManager {
23 public:
24  KobukiManager(const std::string &device_port) :
25  acquired(false),
27  {
28  kobuki::Parameters parameters;
29  parameters.sigslots_namespace = "/kobuki"; // configure the first part of the sigslot namespace
30  parameters.device_port = device_port; // the serial port to connect to (windows COM1..)
31  kobuki.init(parameters);
32  kobuki.enable();
33  slot_version_info.connect("/kobuki/version_info");
34  }
35 
37  kobuki.disable();
38  }
39 
40  void processVersionInfo(const kobuki::VersionInfo &version_info) {
43  //software = kobuki::VersionInfo::toString(version_info.software);
45  udid = kobuki::VersionInfo::toString(version_info.udid0, version_info.udid1, version_info.udid2);
46  acquired = true;
47  }
48 
49  bool isAcquired() { return acquired; }
50  std::string& getHardwareVersion() { return hardware; }
51  std::string& getFirmwareVersion() { return firmware; }
52  std::string& getSoftwareVersion() { return software; }
53  std::string& getUDID() { return udid; }
54 
55 private:
56  volatile bool acquired;
58  std::string hardware, firmware, software, udid;
59  ecl::Slot<const kobuki::VersionInfo&> slot_version_info;
60 };
61 
62 /*****************************************************************************
63 ** Main
64 *****************************************************************************/
65 
66 int main(int argc, char** argv)
67 {
68  ecl::CmdLine cmd_line("version_info program", ' ', "0.2");
69  ecl::UnlabeledValueArg<std::string> device_port("device_port", "Path to device file of serial port to open, connected to the kobuki", false, "/dev/kobuki", "string");
70  cmd_line.add(device_port);
71  cmd_line.parse(argc, argv);
72  //std::cout << "device_port: " << device_port.getValue() << std::endl;
73 
74  std::cout << "Version Info:" << std::endl;
75  KobukiManager kobuki_manager(device_port.getValue());
76 
77  while (!kobuki_manager.isAcquired());
78  std::cout << " * Hardware Version: " << kobuki_manager.getHardwareVersion() << std::endl;
79  std::cout << " * Firmware Version: " << kobuki_manager.getFirmwareVersion() << std::endl;
80  std::cout << " * Software Version: " << kobuki_manager.getSoftwareVersion() << std::endl;
81  std::cout << " * Unique Device ID: " << kobuki_manager.getUDID() << std::endl;
82 
83  return 0;
84 }
const uint32_t udid0
const uint32_t udid2
KobukiManager(const std::string &device_port)
void processVersionInfo(const kobuki::VersionInfo &version_info)
ecl::Slot< const kobuki::VersionInfo & > slot_version_info
std::string & getFirmwareVersion()
const uint32_t hardware
const uint32_t firmware
std::string & getSoftwareVersion()
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:54
static std::string getSoftwareVersion()
std::string & getHardwareVersion()
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:55
volatile bool acquired
Device driver core interface.
std::string software
kobuki::Kobuki kobuki
const uint32_t udid1
std::string udid
std::string hardware
static std::string toString(const uint32_t &version)
Parameter list and validator for the kobuki.
Definition: parameters.hpp:36
Keyboard remote control for our robot core (mobile base).
int main(int argc, char **argv)
The core kobuki driver class.
Definition: kobuki.hpp:87
std::string & getUDID()
std::string firmware


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Mar 27 2017 01:02:59