How to Build a Simple Test Application for LPMS Devices

This page is outdated!

Please refer to our OpenZen library for the latesdt and greatest instruction on building a test application: https://lpresearch.bitbucket.io/openzen/latest/


Old content ------->

For the time being this tutorial works with Windows (7 or later) and the MS  Visual Studio command line. Building via the Vidual Studio IDE and Linux build instructions will be added soon.

  1. Download example code from our GIT repository here: https://bitbucket.org/lpresearch/lpmsexamples

  2. In this tutorial we will work the code in LpmsExamples/LpmsSimpleExample/

  3. Let's look at the files we are dealing with.

    1. main.cpp: This file contains all the source code to do simple data acquisition using an LPMS device.

    2. CMakeLists.txt: This is the source file for Makefile / project file generator CMake.

     
  4. To build the test program the following prerequisites are necessary:

    1. Install the lastest OpenMAT version. At the time of writing this is it: https://bitbucket.org/lpresearch/openmat/downloads/OpenMAT-1.3.5-Setup-Build20170518.exe

    2. Install CMake from here: https://cmake.org/files/v3.8/cmake-3.8.0-rc1-win32-x86.msi

    3. You need to have MS Visual Studio 2013 or later installed on your system. If you don't have it installed yet, a free version (Community Edition) can be downloaded from here: https://www.visualstudio.com/post-download-vs/?sku=community&clcid=0x409&telem=ga#

    4. Include the path to the CMake executable (usually C:\Program Files (x86)\CMake\bin) to your Windows PATH system variable. More information on how to do that is here: http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path

    5. Include the path to your OpenMAT dynamic link libraries to your system path (e.g. C:\OpenMAT\OpenMAT-1.3.5\lib\x86)

     
  5. Now, in the following I will explain how to build the application in my favorite way, that is via the command line. I will explain how to use the Visual Studio IDE later on:

    1. Open the Visual Studio command line (e.g. VS2013 x86 Native Tools Command Prompt).

    2. Change directory to the directory where you saved LpmsSimpleExample.

    3. In an editor (Notepad++ recommended) open CMakeLists.txt and find the lines:

          if (BUILD_ARCHITECTURE STREQUAL "32-bit") 
              include_directories("C:/OpenMAT/OpenMAT-1.3.5/include")
              link_directories("C:/OpenMAT/OpenMAT-1.3.5/lib/x86")
          endif()

      Edit these lines to reflect the location of your OpenMAT include and library files. In case of a default install of version 1.3.5 the directory in the example can be left unchanged.


    4. Open main.cpp and find the following lines

      	// List of LPMS type identifiers
          // DEVICE_LPMS_B        LPMS-B (Bluetooth)
          // DEVICE_LPMS_U        LPMS-CU / LPMS-USBAL (USB)
          // DEVICE_LPMS_C        LPMS-CU / LPMS-CANAL(CAN bus)
          // DEVICE_LPMS_BLE      LPMS-BLE (Bluetooth low energy)
          // DEVICE_LPMS_RS232    LPMS-UARTAL (RS-232)
          // DEVICE_LPMS_B2       LPMS-B2
          // DEVICE_LPMS_U2       LPMS-CU2/URS2/UTTL2/USBAL2 (USB)
          // DEVICE_LPMS_C2       LPMS-CU2/CANAL2 (CAN)
      
          // Connects to LPMS-B2 sensor with address 00:11:22:33:44:55 
          LpmsSensorI* lpms = manager->addSensor(DEVICE_LPMS_B2, "00:11:22:33:44:55");

      To connect to a sensor we use the method addSensor. addSenor takes as an argument the sensor type (Bluetooth, USB etc.) and the device ID (e.g. the Bluetooth MAC address for LPMS-B2). Insert the sensor type and ID of your device here.
       

    5. On the command line enter the following command: cmake -G"NMake Makefiles"This generates the Makefile for the following build process.

      The result should be something like this:

      C:\develop\lpmsexamples\LpmsSimpleExample>cmake -G"NMake Makefiles"
      -- The C compiler identification is MSVC 18.0.40629.0
      -- The CXX compiler identification is MSVC 18.0.40629.0
      -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
      -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
      -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Configuring done
      -- Generating done
      -- Build files have been written to: C:/develop/lpmsexamples/LpmsSimpleExample


    6. On the command line enter: nmake

      Example output:

      C:\develop\lpmsexamples\LpmsSimpleExample>nmake
      
      Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
      Copyright (C) Microsoft Corporation.  All rights reserved.
      
      Scanning dependencies of target LpmsSimpleExample
      [ 50%] Building CXX object CMakeFiles/LpmsSimpleExample.dir/main.obj
      main.cpp
      [100%] Linking CXX executable LpmsSimpleExample.exe
      [100%] Built target LpmsSimpleExample

           

    7. The application should build without error or warnings. Run the application by typing: LpmsSimpleExample