Main MRPT website > C++ reference for MRPT 1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
11 #include <mrpt/system/os.h>
12 #include <mrpt/system/datetime.h>
13 
14 #include <cstdio>
15 #include <iostream>
16 #include <thread>
17 #include <iostream>
18 
19 using namespace mrpt;
20 using namespace mrpt::comms;
21 using namespace std;
22 
23 // ------------------------------------------------------
24 // Test_EnumerateDevices
25 // ------------------------------------------------------
27 {
28  CInterfaceFTDI usbDevice;
29 
30  unsigned long nConectedDevices;
31 
32  TFTDIDeviceList lstDevs;
33 
34  while (!mrpt::system::os::kbhit())
35  {
36  // Create list of devices:
37  usbDevice.ListAllDevices(lstDevs);
38 
39  nConectedDevices = (unsigned long)lstDevs.size();
40 
41  cout << "There are " << nConectedDevices << " USB devices - "
43  << endl;
44 
45  for (size_t i = 0; i < nConectedDevices; i++)
46  cout << lstDevs[i] << endl;
47 
48  printf("\nPRESS ANY KEY TO END THE PROGRAM...\n\n");
49  cout.flush();
50  std::this_thread::sleep_for(500ms);
51  };
52 }
53 
54 int main()
55 {
56  try
57  {
59  return 0;
60  }
61  catch (std::exception& e)
62  {
63  std::cout << "EXCEPCION: " << e.what() << std::endl;
64  return -1;
65  }
66  catch (...)
67  {
68  printf("Another exception!!");
69  return -1;
70  }
71 }
mrpt::system::os::kbhit
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390
os.h
mrpt::comms::CInterfaceFTDI::ListAllDevices
void ListAllDevices(TFTDIDeviceList &outList)
Generates a list with all FTDI devices connected right now.
Definition: CInterfaceFTDI_WIN.cpp:242
mrpt::system::dateTimeToString
std::string dateTimeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
Definition: datetime.cpp:248
mrpt::comms::TFTDIDeviceList
std::deque< TFTDIDevice > TFTDIDeviceList
Used in CInterfaceFTDI::ListAllDevices.
Definition: CInterfaceFTDI.h:46
mrpt::comms
Serial and networking devices and utilities.
Definition: CClientTCPSocket.h:21
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::comms::CInterfaceFTDI
A definition of a CStream actually representing a USB connection to a FTDI chip.
Definition: CInterfaceFTDI.h:75
CInterfaceFTDI.h
mrpt::system::getCurrentTime
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
Definition: datetime.cpp:74
Test_EnumerateDevices
void Test_EnumerateDevices()
Definition: vision_stereo_rectify/test.cpp:26
datetime.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST