ISLogReaderExample.cpp
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright 2014 Inertial Sense, LLC - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #include <stdio.h>
14 
15 // STEP 1: Add Includes
16 // Change these include paths to the correct paths for your project
17 #include "../../src/InertialSense.h"
18 
19 static void dataCallback(InertialSense* i, p_data_t* data, int pHandle)
20 {
21  static uint64_t dataCount;
22  printf("Data count: %" PRIu64 " \r", ++dataCount);
23 }
24 
25 int main(int argc, char* argv[])
26 {
27  if (argc < 1)
28  {
29  printf("Please pass the data log directory path (i.e. \"C:\\Users\\[username]\\Documents\\Inertial Sense\\Logs\\20180716_172323)\"\r\n");
30  // In Visual Studio IDE, this can be done through "Project Properties -> Debugging -> Command Arguments: COM3 kml"
31  return -1;
32  }
33 
34 
35  // STEP 2: Instantiate InertialSense class
36  // InertialSense class wraps communications and logging in a convenient, easy to use class
37  InertialSense inertialSense(dataCallback);
38  if (!inertialSense.Open(argv[1]))
39  {
40  std::cout << "Failed to open com port at " << argv[1] << std::endl;
41  }
42 
43 
44  // STEP 3: Enable data logger
45  // get log type from command line
46  cISLogger::eLogType logType = (argc < 3 ? cISLogger::eLogType::LOGTYPE_DAT : cISLogger::ParseLogType(argv[2]));
47  inertialSense.SetLoggerEnabled(true, "", logType);
48 
49  // utility class for display and ctrl-c handling
50  cInertialSenseDisplay display;
51 
52  std::cout << "Started logger..." << std::endl;
53 
54  while (!display.ControlCWasPressed())
55  {
56  inertialSense.Update();
57  }
58 
59  inertialSense.Close();
60 }
61 
int main(int argc, char *argv[])
#define printf(...)
std::ostream & cout()
bool SetLoggerEnabled(bool enable, const string &path=cISLogger::g_emptyString, cISLogger::eLogType logType=cISLogger::eLogType::LOGTYPE_DAT, uint64_t rmcPreset=RMC_PRESET_PPD_BITS, float maxDiskSpacePercent=0.5f, uint32_t maxFileSize=1024 *1024 *5, const string &subFolder=cISLogger::g_emptyString)
static eLogType ParseLogType(const string &logTypeString)
Definition: ISLogger.h:134
USBInterfaceDescriptor data
bool Open(const char *port, int baudRate=IS_COM_BAUDRATE_DEFAULT, bool disableBroadcastsOnClose=false)
static void dataCallback(InertialSense *i, p_data_t *data, int pHandle)


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:04