Compare commits

..

209 Commits

Author SHA1 Message Date
c66bcc656a Minor JSON fixes
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-30 17:19:30 -07:00
d52c2df7c6 JSON: Adding ctest
This commit adds node based tests provided by Nico to the ctest
framework already established in UPM.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-28 17:15:07 -07:00
02d8a16d4b check for examples and images path 2017-08-17 13:30:41 -07:00
4bb652cb4b use sensortemplate.json metadata to test json files 2017-08-17 11:17:24 -07:00
59dfed087e sensortemplate: added JSON for sensortemplate
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-08-16 11:56:57 -07:00
e7f4529711 add initial jsonlint and mocha test for json files
[ci skip]
2017-08-16 07:56:02 -07:00
9e09f899cf Travis CI and Documentation Generation Improvements
* Use docker images from docker hub instead of building them on Travis
* Fix doxygen warnings for Markdown Files
* Modify Travis build matrix to include stages and additional jobs
* Add doxygen2jsdoc submodule
* Add doxyport submodule
* Remove duplicated code in doxy/node directory
* Generate documentation for each language in Travis

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-08-14 12:46:31 -07:00
ae77966204 java: added some of the missing samples
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-10 16:57:11 -07:00
b0a842229a Added another batch of JSONs(39)
Signed-off-by: msgtfrank <frankww1@gmail.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-10 16:50:18 -07:00
0f3f0e02ae Added another JSON file...
Signed-off-by: msgtfrank <frankww1@gmail.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-10 16:20:11 -07:00
287d716401 Added Another set of JSON files(61)
Signed-off-by: msgtfrank <frankww1@gmail.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-08-10 16:19:47 -07:00
db89d872b4 docs: updated manufacturer field for bosch sensors
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-08-02 17:19:12 -07:00
c46fb64cac json: fix typo and misplaced comma
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-08-02 16:20:21 -07:00
1f97840fee sonar: add sonar.java.binaries parameter
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-07-31 11:35:50 -07:00
7bee29ba62 sonar: fix sonar scan
remove utf8 characters from:
  * examples/c++/mcp9808.cxx
  * examples/c++/tmp006.cxx
  * src/bmp280/bmp280.c
  * src/max30100/max30100.c

add -j8 options to make command in scripts/sonar-scan.sh

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-07-28 14:56:57 -07:00
24b6cbcc85 permissions: No need for files to be executable
chmod ugo-x for the following files.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-27 11:12:59 -07:00
ab4eeea61e travis: improve build process and expand build matrix
Make a build heriarchy to reduce images size.
Add Android Things builds to build matrix.
Drop gcc-4 builds, use gcc-5 and gcc-6 instead.
Add SonarQube static analysis scans.

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
2017-07-25 13:19:44 -07:00
98811b0fb7 BUZZER: Fixing firmata related issue
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-07-17 10:33:51 -07:00
f92c0c120e ms5611: Fix for i2cbus assignment
Make sure I2c bus is initialized with provided bus number.

Removed unnecessary mraa::Result variable in favor of immediate checks.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-14 16:05:39 -07:00
01036f7dae autodoc: Removed autodoc directive from py swig
Since UPM uses doxy2swig, there is no need for the swig interface
file autodoc for python.

Also, turned on the doxy2swig --quiet switch which cleans up the build
log a tiny bit.

This removes a redundant chunk of documentation from python modules
(per each function).

Old:

           def pH(self, samples=15):
         +->   """
         |     pH(DFRPH self, unsigned int samples=15) -> float
         |
         |     Parameters
         |     ----------
     swig|     samples: unsigned int
         |
         |     pH(DFRPH self) -> float
         |
         |     Parameters
         |     ----------
         +->   self: upm::DFRPH *

         +->   float pH(unsigned int
         |     samples=15)
         |
         |     Take a number of samples and return the detected pH value. The default
         |     number of samples is 15.
         |
doxy2swig|     Parameters:
         |     -----------
         |
         |     samples:  The number of samples to average over, default 15
         |
         |     The pH value detected
         |     """
         +->   return _pyupm_dfrph.DFRPH_pH(self, samples)

   New:

           def pH(self, samples=15):
         +->    """
         |      float pH(unsigned int
         |      samples=15)
         |
         |      Take a number of samples and return the detected pH value. The default
         |      number of samples is 15.
         |
doxy2swig|      Parameters:
         |      -----------
         |
         |      samples:  The number of samples to average over, default 15
         |
         |      The pH value detected
         +->    """

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-14 15:33:59 -07:00
5e7a8b41a3 memory: Hide all copy/assignment ops for class w/heap allocation
Many of the UPM libraries allocate space on the heap but do not
explicitly handle copying and assignment.  This commit uses C++11 delete
to forbit both the copy and assignment operator for these classes.

The C++ examples which used assignment operators to initialize class
instances were also updated since it did not appear necessary in those
cases to use the assignment operator.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-14 11:47:06 -07:00
f59f3131bb dfrph.hpp: Don't allow copies of DFRPH - cont...
Also define an explicit private assignment operator.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-13 17:13:38 -07:00
539fbe7c75 dfrph.hpp: Don't allow copies of DFRPH
Small change to explicitly hide the copy constructor for DFRPH.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-13 14:26:37 -07:00
5a1f27a92d CMakeLists.txt: Cleanup MODULE_LIST usage
Removed redundant usage of MODULE_LIST and SUBDIRS variables.
Treat utilities and interfaces directories the same (add both if not
added when using MODULE_LIST).

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-13 10:31:39 -07:00
f4da94a06e cmake: Fix race condition to missing upm_interfaces.jar
The custom command used to create a per-library jar can hit a race
condition where upm_interfaces.jar is in the process of building when
the javac command runs for a target.  This is because the javac command
was provided a full path to the upm_interfaces.jar file for ALL java
targets (even targets which do NOT use the interfaces).

Example:
    javac -cp path/to/upm_interfaces.jar

If upm_interfaces.jar does not exist, javac is fine.
if upm_interfaces.jar exists and is a valid file, javac is fine.
If upm_interfaces.jar exists and is empty, javac throws an error.

For the targets which do not have a dependency on the interfaces,
it's possible one will run javac when the upm_interfaces.jar file is
building in parallel and will fail since the file is
open/incomplete/empty.

The fix is to only provide the full path to the upm_interfaces.jar file
for targets which depend on the interfaces.  These will pass since they
depend on the java interfaces target.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-07-13 10:29:53 -07:00
e190bb9d60 json: added another componet for ads1x15
Signed-off-by: Budanov <daniil.budanov@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-07-12 14:57:16 -07:00
bac9e3bbc0 P9813: Minor bit mask fix
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-07-11 17:38:39 -07:00
1647d8bc08 JSON: Making minor changes
JSONs changed:
- lp8860
- max44009
- ms5611

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-07-06 16:35:52 -07:00
6bfb07e46a bmp280.json: fix example names for bme280
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-07-06 14:35:40 -07:00
c25fa47e2f JSON: Fixed minor issues in JSON files
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-07-06 14:04:40 -07:00
7cd290901d json: changed JSON files to new spec
Signed-off-by: Budanov <daniil.budanov@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-07-05 18:28:51 -07:00
aaf733f41b JSON: Updated JSON files
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-07-05 17:12:07 -07:00
ac4a10e248 JSON: Changes to field names
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-07-05 15:34:32 -07:00
8a4e06d856 json: adding more JSON spec examples
JSON files for: bmp280, button, buzzer, led, mic, temperature.

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-07-05 14:54:17 -07:00
9482d6bb74 JSON: Adding JSON files for following sensors
hlg150h
    lp8860
    max44009
    ms5611
    si1132

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-07-05 07:50:31 -07:00
0cb93331ee JSON: Adding new files
Adding JSOn files for:
- sx1276
- tmp006
- abp
- rsc
- veml6070

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-06-30 16:12:58 -07:00
f01c89b95a added sensor JSON docs
Signed-off-by: Budanov <daniil.budanov@intel.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-06-30 16:08:06 -07:00
4344151405 java: Renamed stdvector interface file to reflect the fact that it is only used in Java
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-27 12:18:03 -07:00
74cb3504f3 java: updated examples to use AbstractList<> for data containers
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-27 12:17:12 -07:00
ac031ba9a8 java: converted wrappers for std::vector to inherit from AbstractList<>
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-27 12:16:19 -07:00
65726087bc java: removed unnecessary generated wrapper objects for std::vector
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-27 12:15:23 -07:00
dc03eec56f docker: enable gcc4, gcc6 and node6 builds
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-15 11:10:18 -07:00
c1903b8c39 docker: use default g++ and swig from container for build
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:46:29 -07:00
0cb7d3f9b4 tests: harden tests for handling universal line endings
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:30:54 -07:00
874eacf12e docker-compose.yaml: fix typo and node version
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:20 -07:00
3e6fb61a20 .travis.yml: update docker-compose to 1.9.0
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:20 -07:00
8e7ac713c4 docker-compose.yaml: enable environment configuration of build variables
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:19 -07:00
54c1b0ce4b Dockerfile: configure compiler first for library build
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:19 -07:00
53456d9138 .travis.yaml: add java with clang to build matrix
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:19 -07:00
7ec1765766 docker-compose: enable java build with clang
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:18:19 -07:00
bb122bfac4 Dockerfile: add additional build flags and ignore build directory
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 22:17:55 -07:00
0f8e578c62 Dockerfile: fix java build
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:05 -07:00
dcee721cb3 bacnet/libbacnet.pc: add temp .pc file for libbacnet
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:05 -07:00
b11ec1638e Dockerfile: install optional libraries
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:04 -07:00
fb6ae47b6d docker-compose.yaml: enable examples and paralell make
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:03 -07:00
be718d79af .travis.yml: unify python build and enable examples on every target
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:02 -07:00
87ffc81b65 Dockerfile: add python3 test dependencies
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:02 -07:00
afd9dd07e4 Dockerfile,docker-compose.yaml: run tests for every target
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:01 -07:00
ce9742b355 .travis.yml,docker-compose.yaml: set more specific command to run
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:17:00 -07:00
c402fbb5e8 .travis.yaml,docker-compose.yaml: add examples building to the matrix
Prevent building examples on every job

Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:59 -07:00
b757ccc617 Dockerfile: add sensor specific dependencies
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:59 -07:00
c5c57b523b .travis.yml: update build matrix and scripts
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:58 -07:00
bb4ce17d44 docker-compose.yaml: add build tasks for java python and node
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:57 -07:00
d4396c2ce3 .dockerignore: add simple ignore rules
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:57 -07:00
780b5df024 Dockerfile: add initial docker image for building
Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-06-12 21:16:56 -07:00
60379fca37 HCSR04: Fixing static analysis issues
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-06-07 16:32:55 -07:00
b90c5a7710 HCSR04: Modifying implementation and adding examples
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-06-07 11:46:12 -07:00
28f964cb48 ULN200XA: Adding Vcc and Vm info to doc 2017-06-02 11:55:44 -07:00
b68eb5f6a6 LSM303DLH: Adding separate i2c contexts
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-06-01 21:46:20 -07:00
50bb4ae1be I2C: Removing multiple address calls
~20 UPM modules have multiple I2C calls in them. As per MRAA API
the I2C address is set in the MRAA I2C context and used from there
for all I2C transactions. Setting the I2C address alone does not
actually result in an I2C transaction. This makes multiple set
address calls pointless. This commit removes these superflous set
address calls from the UPM modules. Setting the address once per
context per device should be enough, unless there are multiple
addresses or multiple devices with different addresses.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-31 21:56:12 -07:00
da18bac925 ims: Updated IMS sensor addressing
The IMS library will now change its I2C address after resetting the HW to a new
address.  It will attempt to close the mraa context and re-init each
time.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-31 14:39:07 -07:00
2b70bea44f java: Fixed HTU21DSample
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-31 11:43:54 -07:00
c64d04d084 ads1x15: fixed case logic in getThresh() function
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-30 15:14:09 -07:00
8186d093ec htu21d: updated function descriptions in header for clarity
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-30 13:09:01 -07:00
b2eb392a07 src/CMakeLists.txt: Fix for BINARY_DIR property
Both the .pc and .pom file creation flows rely on the per-target property
BINARY_DIR.  This target property was added in CMake 3.4 so .pc and .pom
file generation was broken for CMake versions < 3.4.  This commit
creates a new per-target property (TARGET_BINARY_DIR) which is set to
${CMAKE_CURRENT_BINARY_DIR} so that it's usable on CMake versions before
3.4.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-24 16:22:10 -07:00
274fd9b608 lsm6dsl: Initial implementation; C; C++ wraps C; FTI; examples
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-23 16:20:51 -06:00
27eec52e29 lsm6ds3h: fix some typos in the register map
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-23 16:20:51 -06:00
ee0aaa89eb lsm6ds3h: Initial implementation; C; FTI: C++; C++ wraps C; examples
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-22 16:43:49 -06:00
886deabfbb tcs37727: remove utf8 characters
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-22 16:43:49 -06:00
e740349355 lis2ds12: Fix up docs, bosch -> stmicro
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-22 16:43:49 -06:00
34f2799c53 CMakeLists.txt: Hint to libmraa/mraajava
Small change - updated from PATHS to HINTS.  Search HINTS paths first to
provide location for mraa libraries.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-19 16:25:08 -07:00
a03d8eb52f readme.cpp.md: updated example name for iotdk api pages
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-19 15:48:09 -07:00
07f3029f10 upm: enable LIDAR-Lite V3 Optical Distance Measurement sensor library
and example

LIDAR-Lite v3, a compact, high-performance optical distance measurement
sensor from Garmin™. It is the ideal solution for drone, robot or unmanned
vehicle applications.

The library provided is libupm-lidarlitev3.so
The example provided is lidarlitev3.cxx where it will print the distance
of object/obstacle from the sensor.

The image of the sensor is at docs/images/lidarlitev3.jpg

Signed-off-by: Saloni Jain <saloni.jain@tcs.com>
Signed-off-by: Niti Rohilla <niti.rohilla@tcs.com>
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-19 10:27:53 -07:00
a56b83fa37 VEML6070: Adding back documentation
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-18 15:42:07 -07:00
b4bc15201b VEML6070: Adding separate i2c contexts for separate addresses
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-18 14:28:29 -07:00
c70f378f72 lis2ds12: Initial implementation C; C++; FTI; examples
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-15 14:59:22 -06:00
106b6c7062 upm: v1.3.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-12 11:33:47 -07:00
6c3b161702 knownlimitations.md: describe solution for I2C capacitance issue on Edison
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-11 13:04:23 -07:00
c484056cf0 htu21d: add js and py samples, put sensor on known limitations list
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-11 13:04:21 -07:00
2931a9c24d carrays_uint32_t.i: Updated path to .i file
Standardized the usage path for carrays_uint32_t.i in bacnetmstp and
e50hx libraries.  Fixes some small mix-ups with java documentation when
looking for carrays_uint32_t.i.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-09 14:07:28 -07:00
aeefc758ee rn2903: Fix CI issues regarding encoding and enum confusion
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-09 14:41:13 -06:00
21a1860ec2 rn2903: Initial implementation; C; C++ wraps C; examples
This requires a new MRAA with UART sendbreak support.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-09 13:44:12 -06:00
c78da687d4 CMakeLists.txt: Removed force to -march=native
Setting the arch to native for arm.* should not generally be necessary.
If this is absolutely required, it can be passed manually.  Setting
-march=native seems to fail on some versions of gnu gcc for arm.
Removed the force to -march=native in favor of letting cmake set the
arch.

If at some point, this would be required, a better way would be to add
the compile flag after testing if it is supported.

Example:
    upm_add_compile_flags(CXX "-march=native")

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-09 11:28:20 -07:00
6c383dbd42 TMP006: Adding very basic support for TMP007
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-08 10:30:55 -07:00
7688e5f230 TCA9548A : initial implementation
merged with #413 from maleek

Signed-off-by: g-vidal <gerard.vidal@ens-lyon.fr>
Signed-off-by: Keelan Lightfoot <keelanlightfoot@gmail.com>
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-05-07 16:41:32 -06:00
1db6bd826a type: Small types in spelling for category
Fixed a few small typos electic -> electric for sensor categories.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-05-05 11:29:26 -07:00
e7ca8cf18b VEML6070: Initial Commit
This commit provides a basic driver for the Vishay VEML6070 UV
Sensor. Some functionality might be missing. Binding examples have
not been tested as of now.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-05-04 11:18:13 -07:00
cdb735c34e cmake: required mraajava version now checks against MRAA_MINIMUM
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-03 16:59:29 -07:00
90e4b5d385 cmake: remove old node include dirs from src/CMakelists.txt
Since they are now set by find_package(Node REQUIRED) when building the Node.js bindings

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-03 16:48:51 -07:00
6a37edcdac cmake: fixed Nodejs detection on Ubuntu systems when using apt installed nodejs packages
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-05-03 14:55:36 -07:00
563519ae4f unicode: Remove B7 unicode character from examples
The 00B7 unicode character in 4 of the Java examples can cause warnings
(and possible errors) when compiling.  Removed to minimize this risk.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-28 11:39:57 -07:00
7b812284c5 Interfaces: minor changes
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-04-25 16:15:54 -07:00
0082f54902 java: ignored function that returns output through pointers in C++ (single element arrays in Java), as the same functionality is provided by other methods of the class.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-04-25 11:57:55 -07:00
b32e4911ab java: removed unnecessary method definitions from htu21d and ozw interface file
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-04-25 11:57:54 -07:00
fe9254c004 java: Created a general interface that is no longer included in each package and updated examples
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-04-25 11:57:54 -07:00
e3a8b2fc13 pom: Do not generate pom files for blacklist
When generating pom files from CXX targets for JAVA, check against the
JAVA blacklist file.  Remove any targets in the blacklist prior to
generating the pom file.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 10:59:07 -07:00
21ecbd90eb ANDROID: Treat utilities as its own library
Since src/utilities now builds a C/C++ library, other targets which were
using symbols from utilities now need to include the correct target
dependency.  This is mainly for upm_delay* functions.  Added utilities-c
target to all sensor library CMakeLists.txt which require it.

Moved macro for __FILENAME__ from upm_utilities.h to upm_fti.h since
ONLY the FTI headers used this.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 10:27:44 -07:00
0bd68e4e2b ANDROID: CMake/src changes to build on android-24
* Updated pom file generation: Generate pom files after all sensor
      library targets have been created - allows for dependencies
    * Changes for compiling on Android
    * Check for mraa build options: Look at symbols in mraa library to
      determine UPM build options (example: mraa_iio_init, mraa_firmata_init)
    * Add per target summary for C/C++/java/nodejs/python
    * Added hierarchy to fti include directory...
        old: #include "upm_voltage.h"
        new: #include "fti/upm_voltage.h"
    * Removed unimplemented methods from mpu9150 library and java example
    * Add utilities-c target for all c examples.  Most of the C examples
      rely on the upm_delay methods.  Add a dependency on the utilities-c
      target for all c examples.
    * Updated the examples/CMakeLists.txt to add dependencies passed via
      TARGETS to the target name parsed from the example name.  Also updated
      the interface example names to start with 'interfaces'.
    * Updated src/examples/CMakeLists.txt to ALWAYS remove examples from the
      example_src_list (moved this from end of function to beginning).

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-24 10:27:35 -07:00
b2aa2515b0 upm_version: Added get version functionality for UPM as provided by MRAA
* Renamed version.c to version.hpp
    * Updated CMakelist file
    * Updated upm.i file to support version
    * Updated/modified src Cmakelists to support base upm and wrapper dependency

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-04-20 13:49:13 -07:00
5cc4e2120a lsm303d: Initial implementation, C, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-19 16:44:40 -06:00
fe4e97f5dc lsm303agr: fix some comments, move helper macros out of defs.h
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-19 16:44:40 -06:00
6e4faefe15 bma250e,bmg160,bmm150: add missing library header documentation to .hpp files
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-18 13:03:02 -06:00
460e9de94f groups.md: Add gyroscope (gyro) as a separate category
Previously, gyroscope were lumped in with compasses (magnetometers).
This isn't really proper as a gyroscope measures rotation rates in a
given axis, and has nothing to do with a magnetometer's use case.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-18 13:03:02 -06:00
1f5f466691 lsm303agr: Initial implementation, C, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-18 12:07:05 -06:00
12c59a6aca sample.mapping.txt: update for lsm303->lsm303dlh rename
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-12 12:52:55 -06:00
19c58ebba2 lsm303: rename to lsm303dlh
There are a variety of LSM303 devices out there with various
incompatibilities and differing capabilities.  The current lsm303
driver in UPM only supports the LSM303DLH variant, so it has been
renamed to lsm303dlh to avoid confusion and to make it clear which
variant is actually supported.

All examples and source files have been renamed, including header
files.  In addition, the class name, LSM303, has been renamed to
LSM303DLH.  No other functionality or behavior has been changed.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-12 11:52:50 -06:00
d9fd1af272 contributions: Updated assignments in template
Fixed bug in sensortemplate script.  Handled assinment operator with
export since exec'ed processes need these variables.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-11 17:52:03 -07:00
78eb975435 upm: v1.2.0
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:25 -07:00
a0ea3d5f3d es9257: updated min/max pulse values for C driver
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:25 -07:00
f77863dfb5 tcs3414cs: added I2C bus and address parameters to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 20:38:18 -07:00
7e5f6e9856 max31723: added bus parameter to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 18:37:08 -07:00
d004aa68b7 lpd8806: added bus parameter to constructor
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 18:36:05 -07:00
3aef2ea70e docs: updated @param tags, added missing function descriptions, other minor changes
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-10 16:59:39 -07:00
39df7fd10f examples: Handle additional example dependencies
Dependencies added via 'TARGETS' in add_example are 'in addition to' the
dependency provided by the example filename.

    * Small change to examples/CMakeLists.txt to handle additional
      dependencies
    * Prefix 'interfaces-' onto the interfaces examples

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-06 14:16:55 -07:00
b8738b32ca Removing example not required anymore
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-06 10:20:47 -07:00
cdb697fd7b nrf8001 examples: minor changes to avoid clang build failures
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 18:28:36 -06:00
27dc4a5742 Static Analysis fix and Documentation comment changes
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-05 16:24:07 -07:00
e2fe04927f examples: Added ending 'Interesting' tags
A handful of examples were missing the terminating 'Interesting' tag.
Added these.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:43:02 -07:00
a655235c70 snippet: Updated all snippet tags
Ensure all src C++ headers which have corresponding C++ examples have
doxygen tags which point to those examples.  Some were missing, some
were invalid, some needed to be updated to match the new example names.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
96b219d2fb examples: Added 'Interesting' tag to examples
* Added //! [Interesting] tag to all examples which were missing this
* Removed windows CR/LF
* Removed pointers from examples since these are not needed.  Removed
  try/catch which seems to be there only to handle failing pointers and
  return value from main.
* Reformatted examples when the formatting was wonky/inconstant.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
52879b0b04 contributions.md: Updated sensortemplate script
C/C++ CMakeLists.txt lines are no longer needed - removed.
Converted bash script to a function to add some error checking.
Removed redundant author/copyright entry.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
048f1ac08e examples: C/C++ examples use transitive dependencies
Updated the examples to comprehend transitive dependencies.  This means
that each example target will no longer have a giant list of -I includes
(the examples at the end of the list had includes for all previous
examples, upwards of 200 -I's on the command line).

    * Created a CMakeLists.txt in the upm/examples directory, moved
      common functionality to this level.
    * C/C++ examples now look to the filename for their dependency
      target name, ie; gas-mq2.cxx adds a dependency to the 'gas' target
    * Updated a handful of C/C++ example names to reflect this
    * Example CMake flow - glob the list of files, add targets for any
      special case examples, then att targets for all the rest

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-04-05 15:16:20 -07:00
76a12af15f apichanges.md: Add a section on the renames of constants for C ports
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 13:16:11 -06:00
e6ed49427a README.md: update MMA7660 snippet to reflect current reality
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 13:16:11 -06:00
c57a0d2c30 bmpx8x: rewrite in C; FTI; C++ wraps C
This driver has been rewritten from scratch.

See docs/apichanges.md for a list of API compatibility changes
compared to the original driver.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-04-05 11:29:08 -06:00
8d43c431f2 ABP: Making driver generic
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-04 14:34:11 -07:00
336251740d readme: update example and notice on API changes to grove and i2clcd
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-04-04 13:31:25 -07:00
356f0348ed RSC: Fixing static analysis issues
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 21:53:36 -07:00
dc7c012c24 RSC: Minor comment changes
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 14:16:52 -07:00
96eb834e9b RSC: Initial Commit
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-04-03 09:56:54 -07:00
b239866e99 bmm150 C example: use correct units in output
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 18:19:25 -06:00
6a4f06d51b mcp2515 C examples: add default config for Arduino 101
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 17:34:31 -06:00
e765dcf57b bma250e,bmc150,bmg160,bmi055,bmm150,bmx055: C++ examples: use instance rather than allocation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
a594036778 bma250e: correct some comments/documentation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
c014ffddcd bmx055: remove bmm150, use new bmm150 library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
aeaf84ccc6 bmm150: split into new library, C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
7d789ec208 bma250e: fix up some comments and error messages
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
3d0461b40a bmx055: remove bma250e, use new bma250e library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
5aed632782 bma250e: split into new library, C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
3c5a5b87c8 bmg160: use MRAA::Edge for interrupt edge specification
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
22a6c52795 bmg160: fixup some comments, add GPIO to FTI
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
b8fa948f7d src/CMakeLists.txt: always add upm include dirs to includes
Previously, the upm include dir was only added for C targets.  This
breaks when you have a C++ only target that depends on a C++/C driver.
Suddenly, you can't find header files like upm.h, upm_platform.h, etc.

This patch has the UPM include dirs always added for all targets.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
f61b615704 bmx055: remove bmg160, use new bmg160 library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
8dcd22794b bmg160: C port, FTI, C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
33f3c882b8 bno055: remove duplicate #defines from header
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-30 16:43:35 -06:00
5943dad78c rf22: Removed new from examples
Removed new from examples.  Client had new w/o delete.  These
don't need to be pointers.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
2f051a202c ldt0028: Removed new for example array
Not necessary in C++.  This was getting flagged as a memory
leak in the examples.  Not a big deal, but can be done differently.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
a760f2952a memleak: Free alloc'ed memory for device
Added free for device context.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
9549529faf p9813.cxx: Handle buffer overrun
Changed for loop iterator from <= to <.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
65969462d1 memleak: i2c init was getting called twice
Removed duplicate call to mraa_i2c_init which was allocating
space for the i2c device twice.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
13eea53090 memleak: Free alloc'ed memory for device
Added free for device context.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
fa8ab6194d memleak: Handle freeing return from spi call
mraa_spi_write_buf returns an allocated buffer.  Added call to free
the allocated memory.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-29 16:42:45 -07:00
8048e8734f doxygen: Relative paths in generated docs - update
Reverted changes to CMakeLists.txt, change is done solely in
Doxygen.in.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-28 12:29:11 -07:00
8262a4203b doxygen: Use relative paths in generated docs
Updated cmake to use strip the full path to the base UPM directory
from generated documentation.  This removes the build server full-
path from UPM documentation.

Old html:

upm: /iotdk/jenkins/workspace/upm-doc-stable/src/moisture/moisture.h File Reference

New html:

upm: src/moisture/moisture.h File Reference

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-28 11:35:11 -07:00
01f9dd2f41 ims/max30100: Fixed small typo
Changed Initilize -> Initialize.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 16:23:37 -07:00
ccb9fa2a4f doc: Updated spelling occured -> occurred
Fixed small typo.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 14:26:50 -07:00
05435eed4f docs: Small updates to descriptions.
Updated descriptions on four headers.  One header needed a description.
Replaced 'driver' with 'library' on the other three.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-20 10:30:20 -07:00
54a84af1c3 light: modify so C++ wraps C code
This also provides some more functionality.  get_raw() has been
deprecated in favor of using getNormalized().

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 16:24:15 -06:00
27c6ac1d31 java: solved unclean Java bindings for: htu21d, ozw
Signed-off-by: Bogdan Ichim <bogdan.ichim@rinftech.com>
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-03-17 11:44:41 -06:00
8779700d82 md: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
f9b5d7c52c sht1x: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
a10e798682 md: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
8cd91624ee mcp2515: remove carrays from java interface file
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
68e42a22d6 ims: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
fdef953859 bmi160: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
3f334ed1f3 bh1750: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-17 11:41:33 -06:00
1a0bdf00cf mmc35240: add mraa dependency to cmakelists
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-17 08:58:48 -07:00
54cd191d43 src/tmp006/tmp006.hpp: fixed encoding error
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:28:07 -07:00
9fa4dad1ab src/<sensor>/<sensor>.hpp: fixed file_encoding errors
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:27:35 -07:00
080c121e07 src/<sensor>/CMakeLists.txt: Added mraa dependency in 'upm_module_init'
Like Propanu commented, I changed the dependency of mraa library in each
CMakeLists.txt file of the sensors:
hdc1000 , mag3110 , mma8x5x , tcs37727 , tmp006

Signed-off-by: Norbert Wesp nwesp@phytec.de
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:27:00 -07:00
545e288967 examples/c++/<sensor>.cxx: changed cout / endl to std::cout / std::endl
Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:26:27 -07:00
aecdac255d hdc1000: Added upm support for sensor HDC1000
The HDC1000 is a digital humidity sensor with integrated temperature sensor.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:25:56 -07:00
5c837f22cb mag3110: Added upm support for sensor MAG3110
MAG3110 is a three-axis digital magnetometer.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:25:20 -07:00
12c81adeba mma8x5x: Added upm support for some MMA8X5X sensors
This commit adds support for following sensors:
MMA8652 , MMA8653, MMA8451 , MMA8452 , MMA8453
These sensors are three-axis accelerometer.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:24:41 -07:00
8342b4c079 tmp006: Added upm support for sensor TMP006
TMP006 is a infrared-thermopile sensor.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:24:01 -07:00
e83b8ef114 tcs37727: Added upm support for color sensor TCS37727
TCS37727 is a Color Light-To-Digital Converter.
I also added the manufacturer 'ams' of TCS37727.

Signed-off-by: Norbert Wesp <nwesp@phytec.de>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:23:16 -07:00
fabf4287d6 upm: enable MMC35240 3-axis magnetic sensor library and example
MMC35240 is 3-axis magnetic sensor from MEMSIC.

This sensor can measure magnetic fields within the full scale range of
+-24 Gauss (G).

The library provided is libupm-mmc35240.so
The example provided is mmc35240-example-cxx where it will print x,y,z axis
when trigger buffer data is ready. It's also print azimuth value.

This sensor requires calibration. Please shake the sensor in figure 8 pattern,
mmc35240-example will print the calibrated level.

As the sensor data is noisy, we have implemented denoise algorithm within the
sensor library.

The azimuth formula is provided by Han, He <he.han@intel.com>.

Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2017-03-16 17:22:40 -07:00
4ea01180a1 lcdks: renamed from sainsmartks, added backlight support
The sainsmartks driver has been reimplemented in it's own, new C/C++
library: lcdks (LCD Keypad Shield).

In addition, support for an optional backlight GPIO was added.

This was tested with the SainsmartKS and DFRobot LCD Keypad Shields.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-16 12:40:10 -06:00
ab171573f9 lcd/lcm1602/jhd1313m1: remove lcm1602 and jhd1313m1 from lcd library
The lcm1602 and jhd1313m1 drivers had been rewritten in C with a C++
wrapper some time ago, however the original lcm and jhd drivers were
still present in the lcd library.  In addition, to avoid header file
conflicts, the new, separated lcm and jhd header files were renamed
with a .hxx prefix.

This patch:

- renames the new lcm1602/ and jhd1313m1/ header files to have the
  usual .hpp prefix.

- removes the lcm1602, jhd1313m1, and sainsmartks drivers from the
  lcd/ (i2clcd) library.

- fixes the examples to use the "new" libraries (lcm1602 and
  jhd1313m1)

- changes the argument type for the createChar() (C++) to use a byte
  vector (std::vector<uint8_t>) rather than a typedef'd char array.
  The lcm1602_create_char() function (C) uses a standard char *.  The
  use of std::vector is well supported by SWIG.

- SWIG interface files changed to use upm_vectortypes.i, and removes
  the carrays helpers, which should no longer be needed for these
  drivers.

- removes the inclusion of the driver C .h header files into the SWIG
  interface files - this should not be needed for these drivers.

- the sainsmartks driver will be placed into it's own new lcdks (LCD
  Keypad Shield) library.  This library should support the
  SainsmartKS, DFRobot LCD Keypad Shield, and similar products from
  other manufacturers in a future commit.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-16 12:39:52 -06:00
d965b92af1 ABPDRRT005PG2A5: Initial Commit
This commit enables the ABP Honeywell sensor. Java examples is
yet to be tested and has not been provided with the current commit
and will be provided in a future commit.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-03-13 11:13:10 -07:00
cc0174910b ds18b20: fix delay timing error in ds18b20_update()
Due to the change of using upm_delay_ms() instead of usleep(), but
failing to adjust the delay time accordingly, ds18b20_update() was
waiting for 750000ms (12 minutes) before reading the result of a
measurement, instead of the more appropriate 750ms.

This should fix Issue #530.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-13 12:05:22 -06:00
c4a506f5a3 bmp280/bme280: C port, C++ wraps C
Some private methods (relating to calibration/compensation) are no
longer exposed.  In addition, the driver auto-detects the chip (BMP280
or BME280) and acts accordingly, rather than requiring the
specification of a chip id in the ctor.

The getHumidity() method no longer accepts an arguement representing
pressure at sea level.  A new method is provided to specify this.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-10 17:00:50 -07:00
58cdfadf4e p9813: Chainable LEDS
Initial commit of the p9813 chainable LED controller.
Added C, C++, python, java, and node examples.

Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-08 09:46:43 -08:00
b3a5275183 t6713: Static analysis fixes
Updated t6713 to use class instances vs class pointers.  Creating these
on the stack clears up some memory leaks where items created in the
heap are not deleted for a handful of the throw conditions.  Removed
all news/deletes.

Also reformatted to remove tabs and some spaces.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-07 22:10:16 -08:00
b314f56c00 l298: fix a potential divied-by-zero
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 14:24:04 -07:00
d4b536b593 bno055: C port; C++ wraps C
The API has been changed in some cases - see the apichanges.md
document.

In addition, this driver uses a new upm_vectortypes.i SWIG interface
file to provide a mechanism for methods that return a vector of floats
and ints instead of a pointer to an array.

This works much nicer than C array pointers, and results in Python/JS/Java
code that looks much more "natural" to the language in use.

The Python, JS, and Java examples have been changed to use these
methods.  Support for the "old" C-style pointer methods are still
provided for backward compatibility with existing code.

As an example - to retrieve the x, y, and z data for Euler Angles from
the bno055, the original python code would look something like:

       ...
       x = sensorObj.new_floatp()
       y = sensorObj.new_floatp()
       z = sensorObj.new_floatp()
       ...
       sensor.getEulerAngles(x, y, z)
       ...
       print("Euler: Heading:", sensorObj.floatp_value(x), end=' ')
       print(" Roll:", sensorObj.floatp_value(y), end=' ')
       ...

Now the equivalent code is simply:

       floatData = sensor.getEulerAngles()
       print("Euler: Heading:", floatData[0], ...
       print(" Roll:", floatData[1], end=' ')
       ...

Additionally, interrupt handling for Java is now implemented
completely in the C++ header file now rather than the .cxx file, so no
special SWIG processing is required anymore. See Issue #518 .

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:24 -07:00
2bdde21a2f src/upm_vectortypes.i: SWIG interface file for vector types
This interface file can be used to support some standard vector types
in our SWIG interface code.  The current vector types supported are:

%template(intVector)    vector<int>;
%template(int16Vector)  vector<int16_t>;
%template(floatVector)  vector<float>;
%template(doubleVector) vector<double>;
%template(byteVector)   vector<uint8_t>;

Using these makes it much easier and more "natural" for use with the
SWIG languages rather than the currently used mechanism of array
pointers and certain other pointer-based methods.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:14 -07:00
6ceebc9a17 ppd42ns_data.h: replace tabs with spaces
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2017-03-07 13:16:08 -07:00
65fc70a31a rf22: Static analysis fixes
A few small fixes for the rf22 to satisfy klocwork.

    * Converted malloc's to new's to be more C++'ish and since
      malloc return were not checked.
    * Initialize data, buf, and _lastInterruptFlags
    * Up'ed RF22_MAX_MESSAGE_LEN to 64.
        Reason:

void RF22::sendNextFragment()
{
    if (_txBufSentIndex < _bufLen)
    {
    // Some left to send?
    uint8_t len = _bufLen - _txBufSentIndex;
    // But dont send too much
    if (len > (RF22_FIFO_SIZE - RF22_TXFFAEM_THRESHOLD - 1))
        len = (RF22_FIFO_SIZE - RF22_TXFFAEM_THRESHOLD - 1);
    spiBurstWrite(RF22_REG_7F_FIFO_ACCESS, _buf + _txBufSentIndex, len);
    _txBufSentIndex += len;
    }
}

        RF22_FIFO_SIZE = 64
        RF22_TXFFAEM_THRESHOLD = 4
        RF22_MAX_MESSAGE_LEN = 50
        _buf[RF22_MAX_MESSAGE_LEN]
        Length of _buf *was* 50, so if the 'But dont send too much' above
        was to happen, the length is set to 63, which overruns
        _buf[RF22_MAX_MESSAGE_LEN]

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-06 12:13:27 -08:00
51a181a14f java_interfaces: Moved ifdefs for swig version
Moved the SWIG version check from each sensor library .i file to
the base SWIG .i file (per interface).  This cleans up the number
of #if SWIG_VERSION's across the code base, and will make cleanup
of these easier at a later date.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-03 10:27:12 -08:00
cfb4105dd8 docs: Added space to swig interface include
Documentation script was failing when parsing swig file.  Added
a space in the ads1x15 java swig file to make the doc parser happy.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-03 10:11:25 -08:00
b7faba556f sensortemplate: Added a template sensor
The purpose of the templatesensor is to get contributors up and running
faster when adding a new sensor.

    * Created library named 'sensortemplate'
    * Added C++ source
    * Added swig interface files for java, javascript, and python
    * Added sensortemplate image file
    * Added examples for c++, java, javascript, and python
    * Updated contributions.md with steps to create a new sensor from
      the sensortemplate library.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-03-02 23:05:51 -08:00
95801b395d Corrected typo in led.hpp. File includes led.h, not led.hpp
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
2017-03-02 20:19:24 -08:00
1f18369fbe SWIG_JAVA: C++ Interfaces to Java interfaces, Modified one Java Example
This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes.

    * Added java swig interface files for all C++ interfaces to simplify swig
    javaupm_iADC.i
    javaupm_iCO2Sensor.i
    javaupm_iHumiditySensor.i
    javaupm_iLightController.i
    javaupm_iLightSensor.i
    javaupm_iModuleStatus.i
    javaupm_interfaces.i
    javaupm_iPressureSensor.i
    javaupm_iTemperatureSensor.i

    <example Usage>
        %include"../interfaces/javaupm_iADC.i"

    * Modified swig interface files for few sensors that implements interfaces
    ads1x15
    bmp280
    bmpx8x
    ds1808lc
    hlg150h
    lp8860
    max44009
    ms5611
    si1132
    si7005
    t6713

    * Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden

    * Made IModuleStatus virtual to avoid ambiguity in multiple inheritance
    For example
    class A {};
    class B : public A {};
    class C : public A {};
    class D : public B, public C {};

    This can be solved as
    class A {};
    class B : virtual public A {};
    class C : virtual public A {};
    class D : public B, public C {};

    * Modified java interface files to support multiple swig versions

    * Modified javaupm interface file to support standard auto load library code

    * Fixed autoloadlibrary tests for interfaces

    * Created one interface example separately <BME280_InterfaceExample.java>,
    <example Usage>
        BME280_InterfaceExample.java
    since we cann't define swig versions inside java example file.
    So, instaed added swig versions in Cmake.
    <example Usage>
         if (SWIG_VERSION VERSION_GREATER 3.0.8)
           add_example_with_path(BME280_InterfaceExample bmp280 bmp280)
         endif()

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2017-03-02 20:14:03 -08:00
f8663c90f3 ctest: Fix for autoloadlibrary ctest
Update to fix a python indentation error.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-23 11:14:44 -08:00
1d6d660769 max30100: Small typo fix
Changed initializate->initialization...

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-17 16:49:39 -08:00
b57710cd78 groups.md: Removed redundant group maxbotix
Removed redundant group and renamed Maxbotixs to MaxBotix.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-17 16:40:09 -08:00
6d41566e93 doc: Changed <B5> to u for python doc run
The µ character (<B5>) fails the python documentation run.
Replacing with 'u'.

Signed-off-by: Noel Eck <noel.eck@intel.com>
2017-02-14 08:31:55 -08:00
7a60cd5abe AQI: Adding ugm3 calculation to ppd42ns and aqi calculation to upm_utilities
Contributions by: Rex Tsai <rex.cc.tsai@gmail.com>

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
2017-02-13 23:04:20 -08:00
1192 changed files with 60745 additions and 15823 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
Dockerfile
docker-compose.yaml
build

3
.gitignore vendored
View File

@ -11,3 +11,6 @@ build*/
# Temp files
*.swp
*~
# Node modules
**/node_modules

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "doxy/doxygen2jsdoc"]
path = doxy/doxygen2jsdoc
url = https://github.com/intel-iot-devkit/doxygen2jsdoc
[submodule "doxy/doxyport"]
path = doxy/doxyport
url = https://github.com/intel-iot-devkit/doxyport

View File

@ -1,48 +1,82 @@
dist: trusty
sudo: required
language: cpp
env:
global:
- MRAA_ROOT=/tmp/mraa
- MRAA_BUILD=$MRAA_ROOT/build
- UPM_ROOT=$TRAVIS_BUILD_DIR
- UPM_BUILD=$UPM_ROOT/build
- JAVA_HOME=/usr/lib/jvm/java-8-oracle
matrix:
- NODE010=true
- NODE012=true
- NODE4=true
- NODE5=true
compiler:
- clang
- gcc
install:
- sudo add-apt-repository --yes ppa:rosmo/swig3.0.7
- sudo apt-get update -qq
- sudo apt-get install -y --force-yes -qq swig3.0 git
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
- sudo update-java-alternatives -s java-8-oracle
before_script:
# Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
- if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
- if [ "${NODE012}" ]; then nvm install 0.12; fi
- if [ "${NODE4}" ]; then nvm install 4.1; fi
- if [ "${NODE5}" ]; then nvm install 5; fi
# Handle 0.10 NODE_ROOT_DIR differently than other versions
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
script:
# Build/install MRAA
- echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
- git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
- mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=ON -DFIRMATA=ON -DENABLEEXAMPLES=OFF $MRAA_ROOT
- sudo make install
- sudo ldconfig
# Build/install UPM
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDTESTS=ON -DBUILDFTI=ON .. && sudo make install && sudo ldconfig && ctest --output-on-failure -E examplenames_js
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
- g++-4.8
services:
- docker
before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
jobs:
fast_finish: true
allow_failures:
- env: TARGET=sonar-scan
- env: TARGET=ipk
include:
- &run-with-clang
stage: Clang 3.8
env: TARGET=python
before_script: docker-compose pull ${TARGET}
script:
- export CC=clang-3.8 CXX=clang++-3.8
- docker-compose run ${TARGET}
- <<: *run-with-clang
env: TARGET=node4
- <<: *run-with-clang
env: TARGET=node5
- <<: *run-with-clang
env: TARGET=node6
- <<: *run-with-clang
env: TARGET=java
- &run-with-gcc-5
stage: Gcc 5
env: TARGET=python
before_script: docker-compose pull ${TARGET}
script:
- export CC=gcc-5 CXX=g++-5
- docker-compose run ${TARGET}
- <<: *run-with-gcc-5
env: TARGET=node4
- <<: *run-with-gcc-5
env: TARGET=node5
- <<: *run-with-gcc-5
env: TARGET=node6
- <<: *run-with-gcc-5
env: TARGET=java
- &run-with-gcc-6
stage: Gcc 6
env: TARGET=python
before_script: docker-compose pull ${TARGET}
script:
- export CC=gcc-6 CXX=g++-6
- docker-compose run ${TARGET}
- <<: *run-with-gcc-6
env: TARGET=node4
- <<: *run-with-gcc-6
env: TARGET=node5
- <<: *run-with-gcc-6
env: TARGET=node6
- <<: *run-with-gcc-6
env: TARGET=java
- &run-additional-jobs
stage: Additional Jobs
env: TARGET=doc
before_script: docker-compose pull ${TARGET}
script:
- export CC=clang-3.8 CXX=clang++-3.8
- docker-compose run ${TARGET}
- <<: *run-additional-jobs
env: TARGET=android
- <<: *run-additional-jobs
env: TARGET=sonar-scan
- <<: *run-additional-jobs
env: TARGET=ipk
- <<: *run-additional-jobs
env: TARGET=rpm
- <<: *run-additional-jobs
env: TARGET=npm

View File

@ -95,7 +95,7 @@ set (C_CXX_WARNING_FLAGS -Wall -Wno-misleading-indentation -Wno-strict-aliasing)
# Warnings as errors?
if (WERROR)
set (C_CXX_WARNING_FLAGS "-Werror ${C_CXX_WARNING_FLAGS}")
list (APPEND C_CXX_WARNING_FLAGS -Werror)
message (STATUS "Warnings as errors enabled (-Werror), disable with -DWERROR=off")
endif (WERROR)
@ -113,15 +113,26 @@ upm_add_compile_flags(CXX ${C_CXX_WARNING_FLAGS}
-Woverloaded-virtual
-Wreorder)
# Allow exception error handling for Android C++
if (ANDROID)
upm_add_compile_flags(CXX -fexceptions)
endif (ANDROID)
find_package (Threads REQUIRED)
find_package (PkgConfig REQUIRED)
# Force a libmraa search and minimum required version every time a config is generated
unset(MRAA_FOUND CACHE)
set(MRAA_MINIMUM 1.4.0)
set(MRAA_MINIMUM 1.7.0)
pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM})
# Also, get full path to the mraa library
find_library(MRAA_LIBRARY NAMES mraa PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
find_library(MRAA_LIBRARY NAMES mraa HINTS ${MRAA_LIBDIR})
# Test MRAA for various compile options
include (CheckLibraryExists)
check_library_exists (${MRAA_LIBRARIES} mraa_iio_init "${MRAA_LIBDIR}" MRAA_IIO_FOUND)
check_library_exists (${MRAA_LIBRARIES} mraa_firmata_init "${MRAA_LIBDIR}" MRAA_FIRMATA_FOUND)
check_library_exists (${MRAA_LIBRARIES} mraa_uart_ow_init "${MRAA_LIBDIR}" MRAA_OW_FOUND)
# Check for BACNET
pkg_check_modules (BACNET libbacnet)
@ -138,15 +149,23 @@ find_package (JPEG)
# Find nodejs
if (BUILDSWIGNODE)
find_package (Node REQUIRED)
if (BUILDTESTS)
find_package (Npm REQUIRED)
if(NPM_EXECUTABLE)
message(STATUS "NPM Executable found at: ${NPM_EXECUTABLE}")
else()
message(FATAL_ERROR "Please install NPM first, you can't run tests without it")
endif()
endif (BUILDTESTS)
endif (BUILDSWIGNODE)
# Find JAVA/JNI
if (BUILDSWIGJAVA)
find_package (Java REQUIRED)
find_package (JNI REQUIRED)
pkg_check_modules (MRAAJAVA REQUIRED mraajava>=0.8.0)
pkg_check_modules (MRAAJAVA REQUIRED mraajava>=${MRAA_MINIMUM})
# Also, get full path to the mraajava library
find_library(MRAAJAVA_LIBRARY NAMES mraajava PATHS ${MRAA_LIBDIR} NO_DEFAULT_PATH)
find_library(MRAAJAVA_LIBRARY NAMES mraajava HINTS ${MRAA_LIBDIR})
endif (BUILDSWIGJAVA)
# Find swig if any wrapper is enabled
@ -197,7 +216,7 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
# If git_describe fails, use a dirty version
if (${VERSION} MATCHES -NOTFOUND)
set (VERSION "v1.1.0")
set (VERSION "v1.3.0")
message (WARNING "Failed to retrieve UPM version with 'git describe' (using "
"${VERSION}). Check that git is installed and this is a valid git repo.")
endif ()
@ -225,11 +244,6 @@ include (TargetArch)
target_architecture (DETECTED_ARCH)
message (STATUS "Target arch is ${DETECTED_ARCH}")
#-march=native for ARM when not defined/forced
if (DETECTED_ARCH MATCHES "arm.*" AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
# enable c++11 standards support unconditionally
include(CheckCXXCompilerFlag)
if (CMAKE_VERSION VERSION_LESS "3.1")
@ -312,7 +326,7 @@ if (BUILDDOC)
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
# Check if Sphinx is installed and add target to generate API documentationa
# Check if Sphinx is installed and add target to generate API documentation
# Currently, the per-module documentation for python is generated from the
# python2 modules.
if(BUILDSWIGPYTHON)
@ -337,14 +351,10 @@ if (BUILDDOC)
# Check if Yuidoc is installed and add target for API documentation
if(BUILDSWIGNODE)
find_package(Yuidoc REQUIRED)
file(GLOB_RECURSE JSDOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/doxy/node doxy/node/*)
foreach(JSDOC_FILE ${JSDOC_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
endforeach()
add_custom_target(jsdoc ALL
COMMAND ${NODEJS_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
COMMAND ${NODEJS_EXECUTABLE} tolower -i html/node
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/docgen.js -m upm -i xml -o jsdoc -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/helper.js --themedir ${CMAKE_SOURCE_DIR}/doxy/node/generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
COMMAND ${CMAKE_SOURCE_DIR}/doxy/doxygen2jsdoc/tolower.js -i html/node
DEPENDS doc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Yuidoc" VERBATIM
@ -415,22 +425,16 @@ if (RPM)
endif()
# UPM common headers
set (UPM_COMMON_HEADER_DIRS
${CMAKE_HOME_DIRECTORY}/include
${CMAKE_HOME_DIRECTORY}/include/fti)
set (UPM_COMMON_HEADER_DIRS ${CMAKE_HOME_DIRECTORY}/include)
# Generate a build-only C++ header to add functionality to SWIG'ed modules
configure_file (${PROJECT_SOURCE_DIR}/cmake/modules/version.hpp.in ${PROJECT_BINARY_DIR}/src/version.hpp @ONLY)
# UPM source
add_subdirectory (src)
if(BUILDEXAMPLES)
add_subdirectory (examples/c)
if(BUILDCPP)
add_subdirectory (examples/c++)
endif(BUILDCPP)
endif()
# Build java examples
if(BUILDSWIGJAVA AND BUILDEXAMPLES)
add_subdirectory (examples/java)
endif()
# UPM examples
add_subdirectory (examples)
# Python interp is previously found if BUILDTESTS=ON
if (BUILDTESTS)

View File

@ -30,28 +30,20 @@ sensors and actuators and provide feedback on interface design.
A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer API):
```C++
// Instantiate an MMA7660 on I2C bus 0
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_I2C_BUS,
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_DEFAULT_I2C_BUS,
MMA7660_DEFAULT_I2C_ADDR);
// place device in standby mode so we can write registers
accel->setModeStandby();
// enable 64 samples per second
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
accel->setSampleRate(MMA7660_AUTOSLEEP_64);
// place device into active mode
accel->setModeActive();
while (shouldRun)
{
int x, y, z;
accel->getRawValues(&x, &y, &z);
cout << "Raw values: x = " << x
<< " y = " << y
<< " z = " << z
<< endl;
float ax, ay, az;
accel->getAcceleration(&ax, &ay, &az);
@ -136,7 +128,8 @@ our API in a way that will break backwards compatibility. If you find yourself
unable to compile code that was working fine before a library update, make sure
you check the [API changes](docs/apichanges.md) section first.
**NOTE** - Our **C++ header files** changed extension from *.h* to *.hpp*!
**NOTE** - Several important API changes are currently underway for some of our
widely used libraries including `libupm-grove` and `libupm-i2clcd`!
### Changelog
Version changelog [here](docs/changelog.md).

View File

@ -23,13 +23,16 @@ if (UV_ROOT_DIR)
endif()
# Now look for node. Flag an error if not found
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h" "src/node.h"
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
if (NODE_ROOT_DIR)
add_include_dir(${NODE_ROOT_DIR}/include/src)
add_include_dir(${NODE_ROOT_DIR}/src)
add_include_dir(${NODE_ROOT_DIR}/include/node)
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
else()
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")

View File

@ -0,0 +1,13 @@
# Finding and pointing a variable to the npm executable if found
# Only works on Linux systems as of now
find_program(NPM_EXECUTABLE NAMES npm
HINTS
/usr
)
if(NPM_EXECUTABLE)
message(STATUS "NPM Executable found at ${NPM_EXECUTABLE}")
else()
message(ERROR "Unable to find NPM installation, please install NPM")
endif()

View File

@ -1,4 +0,0 @@
#include "version.h"
const char* gVERSION = "@VERSION@";
const char* gVERSION_SHORT = "@VERSION_SHORT@";

View File

@ -0,0 +1,6 @@
#include <string>
inline std::string getVersion()
{
return "@upm_VERSION_STRING@";
}

112
docker-compose.yaml Normal file
View File

@ -0,0 +1,112 @@
version: '2.1'
services:
base:
image: dnoliver/upm-base
environment:
- http_proxy
- https_proxy
- no_proxy
- BUILDDOC=${BUILDDOC:-OFF}
- BUILDCPP=${BUILDCPP:-ON}
- BUILDFTI=${BUILDFTI:-ON}
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
- BUILDEXAMPLES=${BUILDEXAMPLES:-ON}
- IPK=${IPK:-OFF}
- RPM=${RPM:-OFF}
- NPM=${NPM:-OFF}
- BUILDTESTS=${BUILDTESTS:-ON}
- CC=${CC:-clang-3.8}
- CXX=${CXX:-clang++-3.8}
- NODE_VERSION=${NODE_VERSION:-v4.4.7}
- WERROR=${WERROR:-ON}
volumes:
- .:${UPM_SRC_DIR:-/usr/src/app}
doc:
extends: base
image: dnoliver/upm-all
environment:
- BUILDSWIGPYTHON=ON
- BUILDSWIGJAVA=ON
- BUILDSWIGNODE=ON
- BUILDDOC=ON
command: bash -c "./scripts/run-cmake.sh && ./scripts/build-doc.sh"
ipk:
extends: base
environment:
- IPK=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
rpm:
extends: doc
environment:
- RPM=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
npm:
extends: doc
environment:
- NPM=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 npmpkg"
sonar-scan:
extends: base
image: dnoliver/upm-all
environment:
- BUILDSWIGPYTHON=ON
- BUILDSWIGNODE=ON
- BUILDSWIGJAVA=ON
- BUILDSWIGEXAMPLES=ON
- SONAR_TOKEN
- SONAR_ORG
- SONAR_PROJ_KEY
- TRAVIS_BRANCH
- TRAVIS_PULL_REQUEST
- TRAVIS_REPO_SLUG
- TRAVIS_PULL_REQUEST_SLUG
- GITHUB_TOKEN
command: bash -c "./scripts/run-cmake.sh && cd build && ../scripts/sonar-scan.sh"
python:
extends: base
image: dnoliver/upm-python
environment:
- BUILDSWIGPYTHON=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure"
java:
extends: base
image: dnoliver/upm-java
environment:
- BUILDSWIGJAVA=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure"
android:
extends: java
image: dnoliver/upm-android
environment:
- BUILDTESTS=OFF
command: bash -c "./scripts/build-android.sh"
node4:
extends: base
image: dnoliver/upm-node4
environment:
- BUILDSWIGNODE=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8 install && ldconfig && ctest --output-on-failure -E examplenames_js"
node5:
extends: node4
image: dnoliver/upm-node5
node6:
extends: node4
image: dnoliver/upm-node6

View File

@ -4,6 +4,178 @@ API Changes {#apichanges}
Here's a list of other API changes made to the library that break source/binary
compatibility between releases:
# v1.3.0
* **The lsm303 driver has been renamed** There are a variety of
LSM303 devices out there with various incompatibilities and differing
capabilities. The current lsm303 driver in UPM only supports the
LSM303DLH variant, so it has been renamed to lsm303dlh to avoid
confusion and to make it clear which variant is actually supported.
All examples and source files have been renamed, including header
files. In addition, the class name, LSM303, has been renamed to
LSM303DLH. No other functionality or behavior has been changed.
# v1.2.0
* **Note for all drivers ported to C** As a general note concerning
all of the drivers that have been ported to C: **external constants
have likely been renamed**. Previously in C++, most of these constants
were defined as enums in the *upm::classname* namespace.
For drivers written in C, all of these constants are no longer in
a class (or UPM) namespace, and instead have the driver name
prefixed to the original value.
The driver name is prefixed to these constants to avoid name
collisions when using multiple drivers in a given application, and
to make it clear which constants belong to which driver.
For drivers that used *#define* for constants, only the prefix has
been added if not already present. In some cases, names that were
not very descriptive were changed, for example *ADDR* renamed to
*BMPX8X_DEFAULT_I2C_ADDR*.
So for example, a constant that might once have been referred to
in a C++ example as *upm::MMA7660::AUTOSLEEP_64*, would now be
referenced as *MMA7660_AUTOSLEEP_64*.
This holds true for most, if not all drivers that have been ported
to C. Not all of these changes are listed in this file due to the
sheer number of them.
If you run into problems with constants that were working
previously, and now cannot be found, this is likely the reason.
Check the driver documentation and the source code to see what the
new name is.
In C, constants are now usually implemented in a separate header
file named *drivername_defs.h* or *drivername_regs.h*, for easier
integration into the SWIG languages, and shared use between C++ and
C implementations.
* **bmpx8x** This driver has been rewritten from scratch in C, with a
C++ wrapper.
All exported symbols have been renamed for consistency and to
avoid symbol collisions by having a *BMPX8X_* prefix. As an example,
*ADDR* has been renamed to *BMPX8X_DEFAULT_I2C_ADDR*. Most C
ported drivers follow this rule.
The *getPressureRaw()* and *getTemperatureRaw()* functions have
been removed. This functionality was only needed internally to
the driver.
The constructor no longer accepts a mode argument. Only the I2C
bus and I2C address are accepted. By default, the device will be
configured for it's maximum resolution *BMPX8X_OSS_ULTRAHIGHRES*,
the previous default. You can use the new method
*setOversampling()* to change the mode to something else if
desired.
The methods related to calibration, like *computeB5()* are no
longer exposed.
New methods, *init()* and *reset()* have been added. *reset()*
resets the device to a freshly powered up state. *init()* can be
used to re-initialize the device after a reset (reload calibration
data) and set a default oversampling mode.
A new method, *update()* has been added. This method will update
all internal state from the device, and **must** be called before
querying the pressure, temperature, sea level and altitude values.
The *getSeaLevelPressure()* method has been split into two
overloaded methods. One which **requires** an argument in meters
(previously, a default was provided), and another which does not
accept arguments at all and computes the sea level pressure based
on current altitude.
The *i2cReadReg_16()*, *i2CWriteReg()* and *i2cReadReg_8()* have
been replaced with *readReg()*, *readRegs()*, and *writeReg()*, in
line with other I2C/SPI drivers of this type. They are marked
protected (in C++) now as well. Please see the updated
documentation and examples for this driver.
* **mma7660** This driver has been rewritten in C. Some exported
symbols have been changed, for example, *MMA7660_I2C_BUS* was renamed
to *MMA7660_DEFAULT_I2C_BUS*.
See updated documentation and examples for other changes.
* **bmx055, bmi055, bmc150, bma250e, bmg160, bmm150** This driver has
been split up. The *bma250e*, *bmg160*, *bmm150* drivers have been
rewritten in C (with C++ wrappers) and now reside in their own
libraries. The versions of these drivers that used to be present in
*bmx055* have been removed, and *bmx055* now uses the new libraries
for it's functionality. The other two composite devices, *bmi055*,
and *bmc150* are still contained within the *bmx055* library, and
also use the new libraries for their functionality.
In addition, for all of these drivers some private methods are no
longer exposed (such as the compensation routines).
The C++ driver methods that once returned pointers to a floating
point array now return *std::vectors* of the appropriate type.
The SWIG language examples for these drivers have been modified to
use these methods instead of the C pointer based SWIG methods
previously used.
* **sainsmartks** This driver has been renamed to *lcdks* (LCD Keypad
Shield) and moved into it's own library. It uses the *lcm1602*
library to do most of it's work. In addition, an additional argument
was added to the constructor to optionally allow specifying a GPIO
pin to be used to control the backlight. This driver supports the
SainsmartKS and DFRobot LCD Keypad Shields. Similar devices from
other manufacturers should also work with this driver.
* **lcm1602/jhd1313m1** These drivers had been rewritten in C, with
C++ wrappers and placed into their own libraries in the previous
version of UPM, however, the original C++ implementation was kept in
the lcd/i2clcd library for compatibility reasons with existing code.
To avoid collisions with the header files, the new *lcm1602* and
*jhd1313m1* drivers had their C++ headers renamed to use a **.hxx**
suffix.
In this version of UPM, the *lcm1602* and *jhd1313m1* drivers have
been removed from the lcd/i2clcd library. In addition, the header
files for the new implementation have been renamed from their
**.hxx** suffix to the normal **.hpp** suffix.
A change was also made to the new *lcm1602* and *jhd1313m1* C++
drivers. The *createChar()* function now accepts a byte vector
*std::vector<uint8_t>* rather than the *char ** pointer that was
used previously. This should make it easier to use with the SWIG
language bindings (Python, JavaScript, and especially Java).
* **bmp280/bme280** Some private methods are no longer exposed (such
as the calibration and compensation routines). In addition,
the *getHumidity()* method no longer accepts an argument representing
pressure at sea level. A separate method is provided to set this now.
* **bno055** This module no longer uses std::strings to pass around
binary data (*read/writeCalibrationData()*). Rather, now *std::vectors* of
the appropriate type are used. In addition, methods that previously
returned certain data in the form of an array, like *getEulerAngles()*,
now return a *std::vector* instead. This simplifies the Python,
JavaScript, and Java bindings considerably, and leads to more
"natural" looking Python/JavaScript/Java code. For JavaScript, Java,
and Python, the examples have been modified to use these methods
rather than the methods that return data in argument pointers or
arrays.
* **lpd8806** The constructor for this driver was updated to allow specifying
a SPI bus number. This is now the first parameter, the number of LEDs on the
strip is now the last (3rd) parameter instead.
* **max31723** The constructor for this driver was updated to allow specifying
a SPI bus number. This is now the first parameter, CS pin second.
* **tcs3414cs** The constructor for this can now accept an I2C bus and
address.
# v1.1.0 and prior
* **i2clcd/jhd1313m1/lcm1602** LCD devices supported by the i2clcd module are
being separated into individual libraries. The APIs will be preserved, but
we recommend changing your code to use the new libraries as they become

View File

@ -64,10 +64,6 @@ Building with an older version of swig (swig 2.0+) requires the disabling of jav
~~~~~~~~~~~~~
-DBUILDSWIGNODE=OFF
~~~~~~~~~~~~~
Generating python3 modules instead of python2.7
~~~~~~~~~~~~~
-DBUILDPYTHON3=ON
~~~~~~~~~~~~~
Disabling python module building
~~~~~~~~~~~~~
-DBUILDSWIGPYTHON=OFF
@ -130,3 +126,101 @@ autotools on linux.
~~~~~~~~~~~
pkg-config --cflags --libs upm-i2clcd
~~~~~~~~~~~
## Building with Docker
You can use `docker` and `docker-compose` to generate a complete build environment
for upm without having to install any other tool.
Requirements:
* [docker](https://www.docker.com/get-docker) >= 1.12.6
* [docker-compose](https://docs.docker.com/compose/install/) >= 1.9.0
**NOTE:** docker-compose is an optional requirement. It actually make running complex
docker build and run command easier. But you can just use docker to build and run.
### Using Docker Images to build Upm
**tl;dr:** Just use this commands to build upm:
```sh
# Build upm documentation
$ docker-compose run doc
# Build upm python2 and python3 packages and run python tests
$ docker-compose run python
# Build upm java package and run java tests
$ docker-compose run java
# Build upm node4 package and run node tests
$ docker-compose run node4
# Build upm node5 package and run node tests
$ docker-compose run node5
# Build upm node6 package and run node tests
$ docker-compose run node6
# Build upm for android things package
$ docker-compose run android
```
**docker-compose** will take a look at the `docker-compose.yaml` file in the repository
root directory, and run an specific command to build upm for the requested target.
Once the build is completed, you will have a `build/` folder in the repository root with all
the compiled code. This `build/` folder is created by using a docker volume. The `build\`
folder contents is reused each time you execute `docker-compose run [TARGET]`.
To know more about volumes in Docker, visit the [Docker Volume Documentation](https://docs.docker.com/engine/tutorials/dockervolumes/).
You can also start an interactive session inside the docker container if you need to run some
custom build commands:
```sh
# Start an interactive bash shell inside the container
$ docker-compose run python bash
# From now, all the commands are executed inside the container
$ cd build && cmake -DBUILDSWIGPYTHON=ON .. && make clean all
```
If you don't want to use docker-compose, you can also use `docker run` to build upm.
For example, to build upm for python, you can do:
```sh
# From the repository root folder
$ docker run \
--volume=$(pwd):/usr/src/app \
--env BUILDSWIGPYTHON=ON \
--env BUILDSWIGJAVA=OFF \
--env BUILDSWIGNODE=OFF \
dnoliver/upm-python \
bash -c "./scripts/run-cmake.sh && make -Cbuild"
```
### Proxy considerations
If, for some reason, you are behind a proxy, find below a list of common problems related
to proxy settings:
**docker cannot pull images from docker.io**
Visit [this link](https://docs.docker.com/engine/admin/systemd/#httphttps-proxy)
to configure docker daemon behind a proxy.
**docker run fails to access the internet**
docker-compose will automatically take `http_proxy`, `https_proxy`, and `no_proxy`
environment variables and use it as build arguments. Be sure to properly configure
this variables before building.
docker, unlinke docker-compose, do not take the proxy settings from the environment
automatically. You need to send them as environment arguments:
```sh
# From the repository root folder
$ docker run \
--volume=$(pwd):/usr/src/app \
--env BUILDSWIG=ON \
--env BUILDSWIGPYTHON=ON \
--env BUILDSWIGJAVA=OFF \
--env BUILDSWIGNODE=OFF \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env no_proxy=$no_proxy \
dnoliver/upm-python \
bash -c "./scripts/run-cmake.sh && make -Cbuild"
```

View File

@ -4,6 +4,31 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
### v1.3.0
* Finalized all required build system and JAVA binding changes to release the
UPM libraries for Android Things targets
* Enhanced the modules for lsm303 and tmp006 to support newer variants of the
chips
* Fixed Node.js detection on Ubuntu when installed with apt using official
packages
* Minor documentation changes
* New sensors: lsm303agr, lsm303d, veml6070, tca9548a, rn2903
### v1.2.0
* Improved JAVA binding compiler compatibility and added JAVA interfaces that
match existing C++ interfaces
* Ported Bosch drivers to C thus now they can be used on supported MCUs
* Completely redesigned C/C++ example handling by cmake to avoid maintaining
a list by hand
* Fixed several existing drivers, mostly based on static code analysis reports
* Added a sensor driver template plus bash script that can be easily used by
developers to start writing their own sensor driver
* Numerous documentation improvements
* New sensors: p9813, abp, rsc, mmc35240, tcs37727, tmp006, mma8x6x, mag3110,
hdc1000
### v1.1.0
* Reworked cmake handling of internal and external dependencies

View File

@ -94,3 +94,56 @@ then you just add a line to each of your commits with `--signoff` saying
using your real name (sorry, no pseudonyms or anonymous contributions.)
Unsigned commits will not be accepted.
Creating a new sensor library using the sensortemplate
=======================================
A stubbed-out sensor library is available which can be leveraged to get
up-and-running quickly when writing a new sensor library. Use the shell
commands below to generate collateral files for your new sensor library.
```shell
#!/bin/bash
function make_new_sensor {
export SensorName=$1
# Get a lowercase version of the string
export sensorname=${SensorName,,}
# Make sure this is run from the root UPM directory
if ! grep -q 'UPM ' README.md; then echo "Please run from the root UPM directory"; return -1; fi
printf "Generating new sensor: ${SensorName}\n"
# Copy sensortemplate files to ${sensorname}
find docs/ examples/ src/ -name '*sensortemplate*' -exec bash -c 'cp -r $0 ${0/sensortemplate/${sensorname}}' {} \;
# Copy SensorTemplate files to ${SensorName}
find examples/ src/ -name '*SensorTemplate*' -exec bash -c 'cp -r $0 ${0/SensorTemplate/${SensorName}}' {} \;
# Rename sernsortemplate src files
rename "s/sensortemplate/${sensorname}/" src/${sensorname}/*
# Search/replace the new files, replacing all instances of sensortemplate
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
# Add mynewmodule example target for java
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
# Add mynewmodule example mappings for doxygen
perl -p -i -e "s/^(.*SensorTemplateSample.*)$/\1\n${sensorname}.cxx\t${SensorName}Sample.java\t${sensorname}.js\t${sensorname}.py/g" doxy/samples.mapping.txt
# Display TODO's
printf "Generation complete for sensor library: ${SensorName}\n"
printf "TODO's:\n"
printf "\t1. Update src/hdr files: src/${sensorname}/${sensorname}.hpp src/${sensorname}/${sensorname}.cxx\n"
printf "\t\tChange the Author\n"
printf "\t\tChange the Copyright\n"
printf "\t\tUpdate all doxygen tags (follow directions for @tags)\n"
printf "\t2. Update examples: examples/*/${sensorname}.* examples/java/*${SensorName}*.java\n"
printf "\t3. Overwrite docs/images/${sensorname}.png with a valid image of your sensor\n"
}
# Call make_new_sensor with your new sensor name, example: 'MyNewSensor1234'
make_new_sensor MyNewSensor1234
```
Once all files have been created, they can be used as a starting-point for your
new library. They will need additional customization (your name/email address,
documentation, sensor images, etc).

BIN
docs/images/lidarlitev3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
docs/images/p9813.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
docs/images/tca9548a.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 KiB

View File

@ -7,6 +7,9 @@ such sensors and known workarounds if they exist.
#### Grove Sensors
* **RN2903** Click 2 version. This device will not work using the
Edison UART on the Arduino breakout. It does work on Edison using a
USB->serial interface.
* **Grove LCD RGB Backlit** (JHD1313M1) requires 5V and should be used with an
external power supply connected to the board to function properly. Although
some high powered USB ports might be enough, in most cases you will encounter
@ -50,11 +53,11 @@ such sensors and known workarounds if they exist.
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board due to
known UART limitation.
* **Grove Hall Sensor** (A11X) if the base shield is set to 3V on Intel Edison,
it will trigger continous callbacks when the sensor is not reading anything.
it will trigger continuous callbacks when the sensor is not reading anything.
* **Grove RTC** (DS1307) is not compatible with the Intel Edison Arduino board
but will work with the Mini-breakout.
* **Grove Tempture & Humidity (High-Accuracy & Mini) Sensor** (TH02) only works
with the Intel Edison Arduino board when powered from the 3.3V rail.
* **Grove Temperature & Humidity (High-Accuracy & Mini) Sensor** (TH02) only
works with the Intel Edison Arduino board when powered from the 3.3V rail.
#### Adafruit Sensors
@ -75,6 +78,8 @@ This affects the **DS18B20**, **DS2413** and **DFREC** drivers.
#### Other Sensors
* **HTU21D** is unstable on the Intel Edison with the Arduino breakout and
will throw an error when it can't complete an update call.
* **MLX90614** is not compatible with the Intel Galileo due to the inability
to change the I2C bus speed to 100 KHz.
* **MICSV89** is not compatible with the Intel Galileo due to the inability to
@ -89,10 +94,9 @@ This affects the **DS18B20**, **DS2413** and **DFREC** drivers.
Some *I2C* sensors add too much capacitance to the SDA line of the Intel Edison
Arduino breakout board, thus the signal sticks to a logic 1. When this happens,
other sensors connected to the I2C bus are unusable. While there is no generic
solution for this limitation, in most cases the sensor works on the Intel
Edison Mini-breakout. When this board is not an option, the sensor can be
sometimes replaced with the same model from a different vendor.
other sensors connected to the I2C bus also become unusable. In order to solve
this problem, an I2C repeater that isolates the capacitance on the bus, such as
the PCA9517 can be used.
The Intel Edison *SPI* bus can corrupt data being sent across when certain
sensors are connected to it, if using an old image. This has been resolved with

View File

@ -129,8 +129,6 @@ ABBREVIATE_BRIEF = "The $name class" \
ALWAYS_DETAILED_SEC = NO
DETAILS_AT_TOP = YES
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
@ -156,7 +154,7 @@ FULL_PATH_NAMES = YES
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
STRIP_FROM_PATH =
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# path mentioned in the documentation of a class, which tells the reader which
@ -1861,18 +1859,6 @@ GENERATE_XML = YES
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
# validating XML parser to check the syntax of the XML files.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_SCHEMA =
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
# validating XML parser to check the syntax of the XML files.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
# listings (including syntax highlighting and cross-referencing information) to
# the XML output. Note that enabling this will significantly increase the size

View File

@ -129,8 +129,6 @@ ABBREVIATE_BRIEF = "The $name class" \
ALWAYS_DETAILED_SEC = NO
DETAILS_AT_TOP = YES
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
@ -1818,18 +1816,6 @@ GENERATE_XML = YES
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
# validating XML parser to check the syntax of the XML files.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_SCHEMA =
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
# validating XML parser to check the syntax of the XML files.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
# listings (including syntax highlighting and cross-referencing information) to
# the XML output. Note that enabling this will significantly increase the size

View File

@ -15,7 +15,7 @@ sensor in order to reduce load when doing multiple reads to sensor data.
### Example
A sensor/actuator is expected to work as such (here is the servo ES08A API):
@snippet es08a.cxx Interesting
@snippet servo-es08a.cxx Interesting
However implementation and API design is completely up to the developer, some
enumerable sensors for example may provide much clever instantiation. Displays

1
doxy/doxygen2jsdoc Submodule

Submodule doxy/doxygen2jsdoc added at 67cad69272

1
doxy/doxyport Submodule

Submodule doxy/doxyport added at db3e1a6eb8

View File

@ -1,59 +0,0 @@
/*
* Author: Heidi Pan <heidi.pan@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var xml2js = require('./xml2js')
, fs = require('fs')
, Promise = require('bluebird')
, opts = require('commander')
, _ = require('lodash')
, mkdirp = require('mkdirp');
// parse command line arguments
_.extend(opts, { addOptions: function(module) { return module.addOptions(opts); } });
opts
.option('-m, --module [module]', 'module name for which to build documentation', 'mraa')
.option('-f, --formats [formats]', 'format for js comments', 'yuidoc,ternjs')
.option('-o, --outdir [directory]', 'top directory to build documentation', __dirname + '/jsdoc')
.addOptions(xml2js)
.parse(process.argv);
// use promise-style programming rather than spaghetti callbacks
Promise.promisifyAll(fs);
Promise.promisifyAll(mkdirp);
// main
xml2js.parse().then(function(specjs) {
var formats = opts.formats.split(',');
Promise.all(_.map(formats, function(format) {
var generateDocs = require(__dirname + '/generators/' + format + '/generator');
var dir = opts.outdir + '/' + format + '/' + specjs.MODULE;
return mkdirp.mkdirpAsync(dir).then(function() {
return fs.writeFileAsync(dir + '/doc.js', generateDocs(specjs));
});
}));
});

View File

@ -1,7 +0,0 @@
{
"templates": {
"default": {
"outputSourceFiles": false
}
}
}

View File

@ -1,89 +0,0 @@
/*
* Author: Heidi Pan <heidi.pan@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var _ = require('lodash');
// generate JSDoc-style documentation
function generateDocs(specjs) {
var docs = GENERATE_MODULE(specjs.MODULE);
docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) {
return memo += GENERATE_METHOD(methodName, methodSpec);
}, docs);
docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) {
return memo += GENERATE_ENUM(enumName, enumSpec);
}, docs);
docs = _.reduce(specjs.CLASSES, function(memo, classSpec, parentClass) {
return _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
return memo += GENERATE_METHOD(methodName, methodSpec, parentClass);
}, memo);
}, docs);
return docs;
}
// comment wrapper around entire spec
function GENERATE_DOC(text) {
return '/**\n' + text + ' */\n';
}
// generate module spec
function GENERATE_MODULE(module) {
return GENERATE_DOC('@module ' + module + '\n');
}
// generate method spec with parent module/class
function GENERATE_METHOD(name, spec, parent) {
name = name.replace(/!+$/, '');
return GENERATE_DOC(spec.description + '\n'
+ '@method ' + name + '\n'
+ '@instance\n'
+ (parent ? ('@memberof ' + parent + '\n') : '')
+ _.reduce(spec.params, function(memo, paramSpec, paramName) {
return '@param {' + paramSpec.type + '} ' + paramName + ' ' + paramSpec.description + '\n';
}, '')
+ ( !_.isEmpty(spec.return) ? ('@return {' + spec.return.type + '} ' + spec.return.description + '\n') : ''));
}
// generate enum spec
function GENERATE_ENUM(name, spec) {
return GENERATE_DOC(spec.description + '\n\n'
+ '@var ' + name + '\n'
+ '@type Enum(' + spec.type + ')\n'
+ '@instance\n');
}
// TODO
// generate link spec
function GENERATE_LINK(text) {
return '{@link ' + text + '}';
}
module.exports = generateDocs;

View File

@ -1,132 +0,0 @@
/*
* Author: Heidi Pan <heidi.pan@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var _ = require('lodash');
// generate json for ternjs input
function generateDocs(specjs) {
GENERATE_TYPE = (function(enums) {
return function(type) {
return (_.contains(enums, type) ? ('Enum ' + type) : type);
}
})(_.keys(specjs.ENUMS_BY_GROUP));
var docs = { '!name': specjs.MODULE + 'library' };
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
_.each(specjs.ENUMS, function(enumSpec, enumName) {
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
});
_.each(specjs.METHODS, function(methodSpec, methodName) {
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
});
if (_.isEmpty(specjs.CLASSGROUPS)) {
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
} else {
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
_.extend(docs, GENERATE_MODULE(groupName));
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
});
}
return JSON.stringify(docs, null, 2);
}
// generate module spec
function GENERATE_MODULE(module) {
var docs = {};
docs[module] = {};
return docs;
}
// generate the spec for the given list of classes
function GENERATE_CLASSES(classes) {
var docs = {};
_.each(classes, function(classSpec, parentClass) {
var constructor = classSpec.methods[parentClass];
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
if (_.has(docs, parentClass)) {
_.each(classSpec.enums, function(enumSpec, enumName) {
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
});
docs[parentClass].prototype = {};
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
});
_.each(classSpec.variables, function(variableSpec, variableName) {
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
});
}
});
return docs;
}
// generate method spec
function GENERATE_METHOD(name, spec) {
var doc = {};
doc[name] = {
'!type': 'fn(' + GENERATE_PARAMS(spec.params) + ')' + GENERATE_RETURN(spec.return),
'!doc': spec.description
}
return doc;
}
// generate parameter signatures for method
function GENERATE_PARAMS(spec) {
return _.map(spec, function(paramSpec, paramName) {
return paramName + ': ' + paramSpec.type;
}).join(', ');
}
// generate return signature for method
function GENERATE_RETURN(spec) {
return (_.isEmpty(spec) ? '' : (' -> ' + spec.type));
}
// generate enum spec
function GENERATE_ENUM(name, spec) {
var doc = {};
doc[name] = 'Enum ' + spec.type ;
return doc;
}
// generate variable spec
function GENERATE_VARIABLE(name, spec) {
var doc = {};
doc[name]= spec.type ;
return doc;
}
module.exports = generateDocs;

View File

@ -1,144 +0,0 @@
/*
* Author: Heidi Pan <heidi.pan@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var _ = require('lodash');
// generate YuiDocs-style documentation
function generateDocs(specjs) {
var docs = GENERATE_MODULE(specjs.MODULE, '');
GENERATE_TYPE = (function(enums) {
return function(type) {
return (_.contains(enums, type) ? ('Enum ' + type) : type);
}
})(_.keys(specjs.ENUMS_BY_GROUP));
docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) {
return memo += GENERATE_METHOD(methodName, methodSpec);
}, docs);
docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) {
return memo += GENERATE_ENUM(enumName, enumSpec);
}, docs);
if (_.isEmpty(specjs.CLASSGROUPS)) {
docs += GENERATE_CLASSES(specjs.CLASSES);
} else {
docs += GENERATE_MODULE('common', '');
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
});
// TODO: figure out why yuidoc won't associate the class with the right module if module definitions are interspersed
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
docs += GENERATE_MODULE(groupName, groupSpec.description);
});
}
return docs;
}
// comment wrapper around entire spec
function GENERATE_DOC(text) {
return '/**\n' + text + ' */\n';
}
// generate module spec
function GENERATE_MODULE(name, description) {
return GENERATE_DOC(description + '\n'
+ '@module ' + name + '\n');
}
// generate spec for the given list of classes
function GENERATE_CLASSES(classes, parent) {
return _.reduce(classes, function(memo, classSpec, className) {
return memo
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
return memo += GENERATE_METHOD(methodName, methodSpec, className);
}, '')
+ _.reduce(classSpec.variables, function(memo, variableSpec, variableName) {
return memo += GENERATE_VAR(variableName, variableSpec, className);
}, '')
+ _.reduce(classSpec.enums, function(memo, enumSpec, enumName) {
return memo += GENERATE_ENUM(enumName, enumSpec, className);
}, '');
}, '');
}
// generate class spec
function GENERATE_CLASS(name, description, namespace, parent) {
return GENERATE_DOC(description + '\n'
+ '@class ' + name + '\n'
+ (namespace ? ('@module ' + namespace + '\n') : '')
/*
TODO: leave out until figure out what swig does with inheritance
+ (parent ? ('@extends ' + parent + '\n') : '')
*/
);
}
// generate method spec with parent module/class
function GENERATE_METHOD(name, spec, parent) {
name = name.replace(/!+$/, '');
return GENERATE_DOC(spec.description + '\n'
+ '@method ' + name + '\n'
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')
+ _.reduce(spec.params, function(memo, paramSpec, paramName) {
return memo + '@param {' + GENERATE_TYPE(paramSpec.type) + '} ' + paramName + ' ' + paramSpec.description + '\n';
}, '')
+ ( !_.isEmpty(spec.return) ? ('@return {' + GENERATE_TYPE(spec.return.type) + '} ' + spec.return.description + '\n') : ''));
}
// generate enum spec
function GENERATE_ENUM(name, spec, parent) {
return GENERATE_DOC(spec.description + '\n'
+ '@property ' + name + '\n'
+ '@type Enum ' + spec.type + '\n'
+ '@for ' + (parent ? parent : 'common') + '\n');
}
// generate variable specs
function GENERATE_VAR(name, spec, parent) {
return GENERATE_DOC(spec.description + '\n'
+ '@property ' + name + '\n'
+ '@type ' + spec.type + '\n'
+ '@for ' + parent + '\n');
}
// TODO
// generate link spec
function GENERATE_LINK(text) {
return '{{#crossLink "' + text + '"}}{{/crossLink}}';
}
module.exports = generateDocs;

View File

@ -1,45 +0,0 @@
document
= _ ignore* _ "<doxygen " _ attr:attr* _ ">" body:elements _ "</doxygen>" _ { return body; }
elements
= element*
element
= _ "<" startTag:id _ attr:attr* _ ">" _ children:elements _ "</" endTag:id ">" _ {
if (startTag != endTag) {
throw new Error("Expected </" + startTag + "> but </" + endTag + "> found.");
}
return {name: startTag, attr: attr, children: children }
}
/ "<" tag:id _ attr:attr* _ "/>" _ {
return {name: tag, attr: attr }
}
/ _ text:text _ { return text }
ignore
= "<?xml" _ attr* _ "?>" { return }
attr
= name:id _ "=" _ value:string { return { name:name, value:value } }
string
= '"' '"' _ { return ""; }
/ "'" "'" _ { return ""; }
/ '"' text:quoted '"' _ { return text; }
/ "'" text:quoted "'" _ { return text; }
quoted
= chars:[^<>'" \t\n\r]+ { return chars.join(""); }
text
= chars:[^<> \t\n\r]+ { return chars.join(""); }
id
= chars:[^<>/'"=? \t\n\r]+ { return chars.join(""); }
_ "whitespace"
= whitespace*
whitespace
= [ \t\n\r]

View File

@ -1,125 +0,0 @@
/*
* Author: Dina M Suehiro <dina.m.suehiro@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var opts = require('commander'), // for command line args
fs = require('fs'), // for file system access
path = require('path'); // for file path parsing
// parse command line arguments
opts
.option('-i, --inputdir [directory]', 'product documents directory', __dirname + '/docs/yuidoc/upm')
.parse(process.argv);
// Set to true for console output
var debug = true;
// Global arrays tracking the files that have been renamed
var originalFiles = [];
var renamedFiles = [];
// Filter to get html files from different directories
var rootFiles = getHtmlFilenames(opts.inputdir);
var classesFiles = getHtmlFilenames(opts.inputdir + "/classes");
var modulesFiles = getHtmlFilenames(opts.inputdir + "/modules");
// Rename files in the classes directory to have lower-cased file names.
renameFiles(classesFiles);
classesFiles = getHtmlFilenames(opts.inputdir + "/classes");
// Go through the html files and update links to reflect the file names that we changed.
renameLinks(rootFiles);
renameLinks(classesFiles);
renameLinks(modulesFiles);
// Helper function that returns paths to the html files in the specified directory
function getHtmlFilenames (directory)
{
return fs.readdirSync(directory).map(function (file) {
return path.join(directory, file);
}).filter(function (file) {
return fs.statSync(file).isFile();
}).filter(function (file) {
return path.extname(file).toLowerCase() == ".html";
});
}
// Goes through the files and renames them to be lower-cased and tracks them the
// renamed files in the originalFiles[] and renamedFiles[] arrays.
function renameFiles(files)
{
files.forEach(function (file)
{
var originalName = path.basename(file);
var newFileName = originalName.toLowerCase();
var directory = path.dirname(file);
if (originalName != newFileName)
{
fs.renameSync(file, directory + "/" + newFileName); //, function(err)
if (debug)
console.log('Renamed: %s --> %s', originalName, newFileName);
originalFiles.push(originalName);
renamedFiles.push(newFileName);
}
});
}
// Helper function goes through the specified files and does a file/replace of the
// originalFiles to the renamedFiles so that the .html links match what has been renamed.
function renameLinks (files)
{
if (originalFiles.length <= 0)
{
if (debug)
console.log("No links to rename.");
return;
}
files.forEach(function (file)
{
// Read the file
data = fs.readFileSync(file, 'ascii');
// Find/replace the file names that were renamed
for (var i = 0; i < originalFiles.length; i++)
{
var findString = '/' + originalFiles[i] + '\"';
var replaceString = '/' + renamedFiles[i] + '\"';
data = data.replace(findString, replaceString);
}
// Write back
fs.writeFile(file, data, 'ascii', function (err) {
if (err)
throw err;
});
if (debug)
console.log('Renamed links in: %s', file);
});
}

View File

@ -1,935 +0,0 @@
/*
* Author: Heidi Pan <heidi.pan@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
// dependencies
var peg = require('pegjs')
, fs = require('fs')
, path = require('path')
, Promise = require('bluebird')
, _ = require('lodash')
, util = require('util');
// use promise-style programming rather than spaghetti callbacks
Promise.promisifyAll(fs);
var xml2js = {
// js-format specs
// MODULE: <module name>
// ENUMS: {
// <enum name>: {
// type: <enum type>,
// description: <enum description>
// }, ...
// }
// ENUMS_BY_GROUP: {
// <enum type>: {
// description: <enum group description>
// members: [ <enum name>, ... ]
// }, ...
// }
// METHODS: {
// <method name>: {
// description: <method description>,
// params: {
// <param name>: {
// type: <param type>,
// description: <param description >
// }, ...
// },
// return: {
// type: <return type>,
// description: <return description>
// }
// }, ...
// }
// CLASSES: {
// <class name>: {
// description: <class description>,
// parent: <parent class name>,
// group: <group name>,
// methods: { ... },
// variables: {
// <variable name>: {
// type: <variable type>,
// description: <variable description>
// }
// },
// enums: { ... },
// enums_by_group: { ... }
// }, ...
// }
// CLASSGROUPS: {
// <group name>: {
// description: <group description>,
// classes: [ <class name>, ... ],
// enums: { ... },
// enums_by_group: { ... }
// }, ...
// }
MODULE: '',
ENUMS: {},
ENUMS_BY_GROUP: {},
METHODS: {},
CLASSES: {},
CLASSGROUPS: {},
// baseline c -> js type mapping
TYPEMAPS: {
'^(const)?\\s*(unsigned|signed)?\\s*(int|short|long|float|double|size_t|u?int\\d{1,2}_t)?$': 'Number',
'^bool$': 'Boolean',
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String', // TODO: verify that swig does this mapping
'^void\\s*\\(\\s*\\*\\s*\\)\\s*\\(\\s*void\\s*\\*\\)\\s*$': 'Function'
},
// custom c -> js type mapping for pointers
// ARRAY_TYPEMAPS: {
// <pointer data type>: {
// arrayType: <swig generated array type that will replace pointers of data type>,
// classes: [ <class that contains arrayType>, ... ]
// }, ...
// }
// POINTER_TYPEMAPS: {
// <class that contains pointerType>: {
// <c pointer data type>: <js swig generated pointer type that will replace pointers of data type>, ...
// }, ...
// }
ARRAY_TYPEMAPS: {},
POINTER_TYPEMAPS: {},
// add command line options for this module
addOptions: function(opts) {
xml2js.opts = opts;
return opts
.option('-i, --inputdir [directory]', 'directory for xml files', __dirname + '/xml/mraa')
.option('-c, --custom [file]', 'json for customizations')
.option('-t, --typemaps [directory]', 'directory for custom pointer type maps')
.option('-g, --imagedir [directory]', 'directory to link to where the images will be kept', '')
.option('-s, --strict', 'leave out methods/variables if unknown type')
},
// parse doxygen xml -> js-format specs
// TODO: figure out whether we need to document any protected methods/variables
parse: function() {
var XML_GRAMMAR_SPEC = 'grammars/xml.peg';
var NAMESPACE_SPEC = xml2js.opts.inputdir + '/namespace' + xml2js.opts.module + '.xml';
var CLASS_SPEC = function(c) { return xml2js.opts.inputdir + '/' + c + '.xml'; }
var TYPES_SPEC = xml2js.opts.inputdir + '/types_8h.xml';
xml2js.MODULE = xml2js.opts.module;
return Promise.join(createXmlParser(XML_GRAMMAR_SPEC),
xml2js.opts.typemaps ? initCustomPointerTypemaps(xml2js.opts.typemaps) : Promise.resolve(),
fs.readFileAsync(NAMESPACE_SPEC, 'utf8'),
fs.existsSync(TYPES_SPEC) ? fs.readFileAsync(TYPES_SPEC, 'utf8') : Promise.resolve(null),
function(xmlparser, ignore, xml, xml_types) {
if (xml_types != null) {
_.extend(xml2js.ENUMS, getEnums(xmlparser.parse(xml_types)[0], false));
_.extend(xml2js.ENUMS_BY_GROUP, getEnums(xmlparser.parse(xml_types)[0], true));
}
var spec_c = xmlparser.parse(xml)[0];
_.extend(xml2js.ENUMS, getEnums(spec_c, false));
_.extend(xml2js.ENUMS_BY_GROUP, getEnums(spec_c, true));
_.extend(xml2js.METHODS, getMethods(spec_c));
_.each(getSubclassNames(spec_c), function(className) { xml2js.CLASSES[className] = {} });
var parseClasses = _.map(getSubclasses(spec_c), function(c) {
return fs.readFileAsync(CLASS_SPEC(c), 'utf8').then(function(xml) {
try {
var spec_c = xmlparser.parse(xml)[0];
var className = getName(spec_c);
_.extend(xml2js.CLASSES[className], {
description: getDescription(spec_c),
parent: getParent(spec_c, className),
enums: getEnums(spec_c, false, className),
enums_by_group: getEnums(spec_c, true, className),
variables: getVariables(spec_c, className),
methods: getMethods(spec_c, className)
});
} catch(e) {
console.log(e.toString() + ': class ' + className + ' was not parsed correctly.');
}
});
});
var parseGroups = fs.readdirAsync(xml2js.opts.inputdir).then(function(files) {
var groupxmlfiles = _.filter(files, function(fn) {
return ((path.extname(fn) == '.xml') && (path.basename(fn).search(/^group/) != -1));
});
return Promise.all(_.map(groupxmlfiles, function(fn) {
return fs.readFileAsync(xml2js.opts.inputdir + '/' + fn, 'utf8').then(function(xml) {
var spec_c = xmlparser.parse(xml)[0];
if (_.isEmpty(getSubmodules(spec_c))) {
var group = getName(spec_c);
var classes = getSubclassNames(spec_c);
xml2js.CLASSGROUPS[group] = {
description: getDescription(spec_c),
classes: classes
};
_.each(classes, function(c) {
if (_.has(xml2js.CLASSES, c)) {
xml2js.CLASSES[c].group = group;
} else {
console.log('Warning: Group ' + group + ' has unknown class ' + c);
}
});
}
});
}));
});
return Promise.all(parseClasses.concat(parseGroups));
}).then(function() {
if (!_.isEmpty(xml2js.CLASSGROUPS)) {
// try to categorize ungrouped classes, if any
var grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
_.each(ungrouped, function(c) {
_.each(findUsage(c), function(group) {
xml2js.CLASSGROUPS[group].classes.push(c);
});
});
grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
// try to categorize ungrouped enums, if any
_.each(xml2js.ENUMS_BY_GROUP, function(enumGroupSpec, enumGroupName) {
_.each(findUsage(enumGroupName, true), function(c) {
xml2js.CLASSES[c].enums_by_group[enumGroupName] = enumGroupSpec;
_.each(enumGroupSpec.members, function(enumName) {
xml2js.CLASSES[c].enums[enumName] = xml2js.ENUMS[enumName];
delete xml2js.ENUMS[enumName];
});
delete xml2js.ENUMS_BY_GROUP[enumGroupName];
});
});
}
}).then(function() {
if (xml2js.opts.custom && fs.existsSync(xml2js.opts.custom)) {
return fs.readFileAsync(xml2js.opts.custom, 'utf8').then(function(custom) {
try {
customizeMethods(JSON.parse(custom));
} catch(e) {
console.log('invalid custom.json, ignored. ' + e.toString());
}
});
} else {
console.log(xml2js.opts.custom ? ('Error: No such customization file exists: ' + xml2js.opts.custom) : 'No customizations given.');
}
}).then(function() {
generateCustomPointerClasses();
validateMethods();
validateVars();
return _.pick(xml2js, 'MODULE', 'ENUMS', 'ENUMS_BY_GROUP', 'METHODS', 'CLASSES', 'CLASSGROUPS');
});
}
};
// create an xml parser
function createXmlParser(XML_GRAMMAR_SPEC) {
return fs.readFileAsync(XML_GRAMMAR_SPEC, 'utf8').then(function(xmlgrammar) {
return peg.buildParser(xmlgrammar);
});
}
// configure c->js typemaps from custom swig directives
// TODO: many built in assumptions based on current upm file structures & .i customizations
function initCustomPointerTypemaps(typemapsdir) {
return fs.readdirAsync(typemapsdir).then(function(dirs) {
return Promise.all(_.map(dirs, function(dir) {
// get all js*.i directives from class-specific subdirectories, to be parsed below for %typemaps directives
return fs.readdirAsync(typemapsdir + '/' + dir).then(function(files) {
var directive = _.find(files, function(fn) {
return ((path.extname(fn) == '.i') && (path.basename(fn).search(/^js/) != -1));
});
var data = {};
if (directive) {
data[dir] = typemapsdir + '/' + dir + '/' + directive;
}
return data;
}).catch(function(e) {
// get all .i directives from top level directory, and parse for %array_class directives
if (e.code == 'ENOTDIR') {
var fn = dir;
if (path.extname(fn) == '.i') {
return fs.readFileAsync(typemapsdir + '/' + fn, 'utf8').then(function(directives) {
var arraytypes = _.filter(directives.split(/\n/), function(line) {
return (line.search(/^%array_class/) != -1);
});
_.each(arraytypes, function(arraytype) {
var parsed = arraytype.match(/%array_class\(([A-Za-z0-9_]+)[\s]*,[\s]*([A-Za-z0-9_]+)\)/);
if (parsed) {
var from = parsed[1];
var to = parsed[2];
xml2js.ARRAY_TYPEMAPS[from] = { arrayType: to, classes: [] };
} else {
console.log('Incorrectly parsed array_class from ' + fn + ': ' + arraytype);
}
});
});
}
} else {
throw e;
}
});
}));
}).then(function(__directivesFiles) {
// parse for %typemaps & %pointer_functions directives
var _directivesFiles = _.filter(__directivesFiles, function(data) { return !_.isEmpty(data); });
var directivesFiles = _.object(_.map(_directivesFiles, _.keys), _.flatten(_.map(_directivesFiles, _.values)));
return Promise.all(_.map(directivesFiles, function(directivesFn, className) {
return fs.readFileAsync(directivesFn, 'utf8').then(function(directives) {
var typemaps = _.filter(directives.split(/\n/), function(line) {
return (line.search(/^%typemap/) != -1);
});
_.each(typemaps, function(typemap) {
var parsed = typemap.match(/%typemap\((in|out)\)[\s]+([A-Za-z0-9_]+[\s]*[\*])/);
if (parsed) {
var dir = parsed[1]; // TODO: ignored for now
var type = normalizePointer(parsed[2]);
var datatype = getPointerDataType(type);
if (_.has(xml2js.ARRAY_TYPEMAPS, datatype)) {
xml2js.ARRAY_TYPEMAPS[datatype].classes.push(className);
} else {
console.log('Ignored typemap from ' + directivesFn + ': ' + typemap.replace('{', '') + ' (no %array_class directive found for ' + datatype + ')');
}
} else {
console.log('Ignored typemap from ' + directivesFn + ': ' + typemap.replace('{', '') + ' (only considering in/out typemaps of pointer types)');
}
});
var ptrfns = _.filter(directives.split(/\n/), function(line) {
return (line.search(/^%pointer_functions/) != -1);
});
_.each(ptrfns, function(ptrfn) {
var parsed = ptrfn.match(/%pointer_functions\(([A-Za-z0-9_]+)[\s]*,[\s]*([A-Za-z0-9_]+)\)/);
if (parsed) {
var from = parsed[1];
var to = parsed[2];
if (!_.has(xml2js.POINTER_TYPEMAPS, className)) {
xml2js.POINTER_TYPEMAPS[className] = {};
}
xml2js.POINTER_TYPEMAPS[className][from] = to;
}
});
});
}));
});
}
// generate class specs for custom pointer types
function generateCustomPointerClasses() {
var arrayTypes = _.pluck(_.values(xml2js.ARRAY_TYPEMAPS), 'arrayType');
var pointerTypes = _.uniq(_.flatten(_.map(_.values(xml2js.POINTER_TYPEMAPS), _.values)));
_.each(arrayTypes, function(arrayType) {
var dataType = _.findKey(xml2js.ARRAY_TYPEMAPS, function(to) { return to.arrayType == arrayType; });
xml2js.CLASSES[arrayType] = {
description: 'Array of type ' + dataType + '.',
enums: {},
enums_by_group: {},
variables: {},
methods: {}
};
xml2js.CLASSES[arrayType].methods[arrayType] = {
description: 'Instantiates the array.',
params: {
nelements: {
type: 'Number',
description: 'number of elements in the array'
}
},
return: {}
};
xml2js.CLASSES[arrayType].methods.getitem = {
description: 'Access a particular element in the array.',
params: {
index: {
type: 'Number',
description: 'index of array to read from'
},
},
return: {
type: getType(dataType),
description: 'the value of the element found at the given index of the array'
}
};
xml2js.CLASSES[arrayType].methods.setitem = {
description: 'Modify a particular element in the array.',
params: {
index: {
type: 'Number',
description: 'index of array to write to'
},
value: {
type: getType(dataType),
description: 'the value to set the element found at the given index of the array'
}
},
return: {}
};
});
var pointerDataTypeMap = _.reduce(_.map(_.values(xml2js.POINTER_TYPEMAPS), _.invert), function(memo, typemap) {
return _.extend(memo, typemap);
}, {});
_.each(pointerTypes, function(pointerType) {
var dataType = pointerDataTypeMap[pointerType];
xml2js.CLASSES[pointerType] = {
description: 'Proxy object to data of type ' + dataType + '.',
enums: {},
enums_by_group: {},
variables: {},
methods: {}
};
xml2js.CLASSES[pointerType].methods[pointerType] = {
description: 'Instantiates the proxy object.',
params: {},
return: {}
};
xml2js.CLASSES[pointerType].methods.value = {
description: 'Get the value of the object.',
params: {},
return: {
type: getType(dataType),
description: 'the value of the object'
}
};
xml2js.CLASSES[pointerType].methods.assign = {
description: 'Set the value of the object.',
params: {
value: {
type: getType(dataType),
description: 'the value to set the object to'
}
},
return: {}
};
});
}
// search for usage of a type
function findUsage(type, classOnly) {
var filterClasses = function(fn) { return _.without(_.map(xml2js.CLASSES, fn), undefined); };
var usesType = function(classSpec, className) {
var methodsOfType = (_.find(classSpec.methods, function(methodSpec, methodName) {
return ((!_.isEmpty(methodSpec.return) && methodSpec.return.type == type) ||
(_.contains(_.pluck(methodSpec.params, 'type'), type)));
}) != undefined);
var variablesOfType = _.contains(_.pluck(classSpec.variable, 'type'), type);
return ((methodsOfType || variablesOfType) ? className : undefined);
};
var extendsType = function(classSpec, className) {
return ((classSpec.parent == type) ? className : undefined);
};
var classes = _.union(filterClasses(usesType), filterClasses(extendsType));
if (classOnly) {
return classes;
} else {
return _.without(_.uniq(_.pluck(_.pick(xml2js.CLASSES, classes), 'group')), undefined);
}
}
// override autogenerated methods with custom configuration
function customizeMethods(custom) {
_.each(custom, function(classMethods, className) {
_.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
return isValidMethodSpec(methodSpec, className + '.' + methodName);
}));
});
}
// make sure methods have valid types, otherwise warn (& don't include if strict)
function validateMethods() {
xml2js.METHODS = _.pick(xml2js.METHODS, function(methodSpec, methodName) {
return hasValidTypes(methodSpec, methodName);
});
_.each(xml2js.CLASSES, function(classSpec, className) {
var valid = _.pick(classSpec.methods, function(methodSpec, methodName) {
return hasValidTypes(methodSpec, className + '.' + methodName, className);
});
if (xml2js.opts.strict) {
xml2js.CLASSES[className].methods = valid;
}
});
}
// make sure variables have valid types, otherwise warn (& don't include if strict)
function validateVars() {
_.each(xml2js.CLASSES, function(classSpec, className) {
var valid = _.pick(classSpec.variables, function(varSpec, varName) {
return ofValidType(varSpec, className + '.' + varName, className);
});
if (xml2js.opts.strict) {
xml2js.CLASSES[className].variables = valid;
}
});
}
// verify that the json spec is well formatted
function isValidMethodSpec(methodSpec, methodName) {
var valid = true;
var printIgnoredMethodOnce = _.once(function() { console.log(methodName + ' from ' + path.basename(xml2js.opts.custom) + ' is omitted from JS documentation.'); });
function checkRule(rule, errMsg) {
if (!rule) {
printIgnoredMethodOnce();
console.log(' ' + errMsg);
valid = false;
}
}
checkRule(_.has(methodSpec, 'description'), 'no description given');
checkRule(_.has(methodSpec, 'params'), 'no params given (specify "params": {} for no params)');
_.each(methodSpec.params, function(paramSpec, paramName) {
checkRule(_.has(paramSpec, 'type'), 'no type given for param ' + paramName);
checkRule(_.has(paramSpec, 'description'), 'no description given for param ' + paramName);
});
checkRule(_.has(methodSpec, 'return'), 'no return given (specify "return": {} for no return value)');
checkRule(_.has(methodSpec.return, 'type'), 'no type given for return value');
checkRule(_.has(methodSpec.return, 'description'), 'no description given for return value');
return valid;
}
// get enum specifications
function getEnums(spec_c, bygroup, parent) {
var spec_js = {};
var enumGroups = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
var kind = getAttr(section, 'kind');
return ((kind == 'enum') || (kind == 'public-type'));
});
if (enumGroups) {
_.each(enumGroups.children, function(enumGroup) {
var enumGroupName = getText(getChild(enumGroup, 'name'), 'name');
var enumGroupDescription = getText(getChild(enumGroup, 'detaileddescription'), 'description');
var enumGroupVals = getChildren(enumGroup, 'enumvalue');
if (bygroup) {
spec_js[enumGroupName] = {
description: enumGroupDescription,
members: []
};
}
_.each(enumGroupVals, function(e) {
// TODO: get prefix as option
var enumName = getText(getChild(e, 'name'), 'name').replace(/^MRAA_/, '');
var enumDescription = getText(getChild(e, 'detaileddescription'), 'description');
if (!bygroup) {
spec_js[enumName] = {
type: enumGroupName,
description: enumDescription
};
} else {
spec_js[enumGroupName].members.push(enumName);
}
});
});
}
return spec_js;
}
// get the name for the module/group/class
function getName(spec_c) {
return getText(getChild(spec_c, 'compoundname'), 'name').replace(xml2js.opts.module + '::', '');
}
// get the description for the module/group/class
function getDescription(spec_c) {
return getText(getChild(spec_c, 'detaileddescription'), 'description');
}
// get the classes (xml file names) for the given module
function getSubclasses(spec_c) {
return _.map(getChildren(spec_c, 'innerclass'), function(innerclass) {
return getAttr(innerclass, 'refid');
});
}
// get the classes (class names) for the given module
function getSubclassNames(spec_c) {
return _.map(getChildren(spec_c, 'innerclass'), function(innerclass) {
return getText(innerclass).replace(xml2js.opts.module + '::', '');
});
}
// get the submodules (xml file names) for the given module
function getSubmodules(spec_c) {
return _.map(getChildren(spec_c, 'innergroup'), function(innergroup) {
return getAttr(innergroup, 'refid');
});
}
// get parent class, if any
function getParent(spec_c, className) {
var parent = getChild(spec_c, 'basecompoundref');
if (parent) {
parent = getText(parent);
if (!_.has(xml2js.CLASSES, parent)) {
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
}
}
return parent;
}
function hasParams(paramsSpec) {
return !(_.isEmpty(paramsSpec) ||
((_.size(paramsSpec) == 1) && getText(getChild(paramsSpec[0], 'type')) == 'void'));
}
// get method specifications for top-level module or a given class
// TODO: overloaded functions
// TODO: functions w/ invalid parameter(s)/return
function getMethods(spec_c, parent) {
var spec_js = {};
var methods = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
var kind = getAttr(section, 'kind');
return ((kind == 'public-func') || (kind == 'func'));
});
if (methods) {
_.each(methods.children, function(method) {
var methodName = getText(getChild(method, 'name'), 'name');
if (methodName[0] != '~') { // filter out destructors
try {
var description = getChild(method, 'detaileddescription');
var methodDescription = getText(description, 'description');
var paramsSpec = getChildren(method, 'param');
var params = {};
if (hasParams(paramsSpec)) {
params = getParams(paramsSpec, getParamsDetails(description), methodName, parent);
}
var returnSpec = getChild(method, 'type');
var retval = {};
if (!_.isEmpty(returnSpec)) {
retval = getReturn(returnSpec, getReturnDetails(description), methodName, parent);
}
methodName = getUniqueMethodName(methodName, spec_js, parent);
spec_js[methodName] = {
description: methodDescription,
params: params,
return: retval
};
} catch(e) {
console.log((parent ? (parent + '.') : '') + methodName + ' is omitted from JS documentation.');
console.log(' ' + e.toString());
}
}
});
}
return spec_js;
}
// get a unique string to represent the name of an overloaded method
function getUniqueMethodName(methodName, module, parent) {
if (methodName in module) {
do {
methodName += '!';
} while (methodName in module);
}
return methodName;
}
// get variable specifications for a class
function getVariables(spec_c, parent) {
var spec_js = {};
var vars = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
var kind = getAttr(section, 'kind');
return (kind == 'public-attrib');
});
if (vars) {
_.each(_.filter(vars.children, function(variable) {
return (getAttr(variable, 'kind') == 'variable');
}), function(variable) {
var varName = getText(getChild(variable, 'name'), 'name');
var varType = getType(getText(getChild(variable, 'type')), parent);
var varDescription = getText(getChild(variable, 'detaileddescription'));
spec_js[varName] = {
type: varType,
description: varDescription
}
});
}
return spec_js;
}
// get return value specs of a method
function getReturn(spec_c, details, method, parent) {
var retType = getType(getText(spec_c, 'type'), parent);
var retDescription = (details ? getText(details, 'description') : '');
return ((retType == 'void') ? {} : {
type: retType,
description: retDescription
});
}
// get paramater specs of a method
function getParams(spec_c, details, method, parent) {
var spec_js = {};
_.each(spec_c, function(param) {
try {
var paramType = getType(getText(getChild(param, 'type'), 'type'), parent);
var paramName = getText(getChild(param, 'declname'), 'name');
spec_js[paramName] = { type: paramType };
} catch(e) {
if (paramType == '...') {
spec_js['arguments'] = { type: paramType };
} else {
throw e;
}
}
});
_.each(details, function(param) {
var getParamName = function(p) { return getText(getChild(getChild(p, 'parameternamelist'), 'parametername'), 'name'); }
var paramName = getParamName(param);
var paramDescription = getText(getChild(param, 'parameterdescription'), 'description');
if (_.has(spec_js, paramName)) {
spec_js[paramName].description = paramDescription;
} else {
var msg = ' has documentation for an unknown parameter: ' + paramName + '. ';
var suggestions = _.difference(_.keys(spec_js), _.map(details, getParamName));
var msgAddendum = (!_.isEmpty(suggestions) ? ('Did you mean ' + suggestions.join(', or ') + '?') : '');
console.log('Warning: ' + (parent ? (parent + '.') : '') + method + msg + msgAddendum);
}
});
return spec_js;
}
// get the equivalent javascript type from the given c type
function getType(type_c, parent) {
var type_js = type_c;
_.find(xml2js.TYPEMAPS, function(to, from) {
var pattern = new RegExp(from, 'i');
if (type_c.search(pattern) == 0) {
type_js = to;
return true;
}
});
if (isPointer(type_js)) {
var dataType = getPointerDataType(type_js);
var className = parent.toLowerCase();
if (_.has(xml2js.ARRAY_TYPEMAPS, dataType) && _.contains(xml2js.ARRAY_TYPEMAPS[dataType].classes, className)) {
type_js = xml2js.ARRAY_TYPEMAPS[dataType].arrayType;
} else if (_.has(xml2js.POINTER_TYPEMAPS, className) && _.has(xml2js.POINTER_TYPEMAPS[className], dataType)) {
type_js = xml2js.POINTER_TYPEMAPS[className][dataType];
} else if (_.has(xml2js.CLASSES, dataType)) { // TODO: verify that swig does this mapping
type_js = dataType;
} else {
type_js = dataType + ' &#42;'
}
}
return type_js;
}
// verify that all types associated with the method are valid
function hasValidTypes(methodSpec, methodName, parent) {
var valid = true;
var msg = (xml2js.opts.strict ? ' is omitted from JS documentation.' : ' has invalid type(s).');
var printIgnoredMethodOnce = _.once(function() { console.log(methodName + msg); });
_.each(methodSpec.params, function(paramSpec, paramName) {
if (!isValidType(paramSpec.type, parent)) {
valid = false;
printIgnoredMethodOnce();
console.log(' Error: parameter ' + paramName + ' has invalid type ' + typeToString(paramSpec.type));
}
});
if (!_.isEmpty(methodSpec.return) && !isValidType(methodSpec.return.type, parent)) {
valid = false;
printIgnoredMethodOnce();
console.log(' Error: returns invalid type ' + typeToString(methodSpec.return.type));
}
return valid;
}
// verify that type of variable is valid
function ofValidType(varSpec, varName, parent) {
if (isValidType(varSpec.type, parent)) {
return true;
} else {
var msgAddendum = (xml2js.opts.strict ? ' Omitted from JS documentation.' : '');
console.log('Error: ' + varName + ' is of invalid type ' + typeToString(varSpec.type) + '.' + msgAddendum);
return false;
}
}
// verify whether the given type is valid JS
function isValidType(type, parent) {
return (_.contains(_.values(xml2js.TYPEMAPS), type) ||
_.has(xml2js.CLASSES, type) ||
_.has(xml2js.ENUMS_BY_GROUP, type) ||
_.contains(['Buffer', 'Function', 'mraa_result_t'], type) ||
_.has((parent ? xml2js.CLASSES[parent].enums_by_group : []), type) ||
isValidPointerType(type, parent));
}
function isValidPointerType(type, parent) {
var className = parent.toLowerCase();
var arrayTypemap = _.find(xml2js.ARRAY_TYPEMAPS, function(to) { return to.arrayType == type; });
var valid = ((arrayTypemap && _.contains(arrayTypemap.classes, className)) ||
(_.has(xml2js.POINTER_TYPEMAPS, className) && (_.contains(_.values(xml2js.POINTER_TYPEMAPS[className]), type))));
return valid;
}
// determines whether a type looks like a c pointer
function isPointer(type) {
return (type.search(/\w+\s*(\*|&amp;)$/) != -1);
}
// remove extraneous whitespace from pointer types as canonical representation
function normalizePointer(ptr) {
return ptr.replace(/\s*$/, '');
}
// get the data type of a pointer (e.g. int is the data type of int*)
function getPointerDataType(ptr) {
return ptr.replace(/\s*(\*|&amp;)$/, '');
}
// print more human friendly type for error messages
function typeToString(type) {
return type.replace('&#42;', '*');
}
// get the detailed description of a method's parameters
function getParamsDetails(spec_c) {
var paras = getChildren(spec_c, 'para');
var details = _.find(_.map(paras, function(para) {
return getChild(para, 'parameterlist');
}), function(obj) { return (obj != undefined); });
return (details ? details.children : undefined);
}
// get the detailed description of a method's return value
function getReturnDetails(spec_c) {
var paras = getChildren(spec_c, 'para');
return _.find(_.map(paras, function(para) {
return getChild(para, 'simplesect');
}), function(obj) { return ((obj != undefined) && (getAttr(obj, 'kind') == 'return')); });
}
// get (and flatten) the text of the given object
function getText(obj, why) {
// TODO: links ignored for now, patched for types for
var GENERATE_LINK = function(x) { return x + ' '; }
return _.reduce(obj.children, function(text, elem) {
if (_.isString(elem)) {
return text += elem.trim() + ' ';
} else if (_.isPlainObject(elem)) {
switch(elem.name) {
case 'para':
return text += getText(elem, why) + ' \n';
case 'ref':
return text += GENERATE_LINK(getText(elem, why));
case 'parameterlist':
case 'simplesect':
return text; // to be handled elsewhere
case 'programlisting':
case 'htmlonly':
return text; // ignored
// TODO: html doesn't seem to work for yuidoc, using markdown for now
case 'itemizedlist':
return text += '\n' + getText(elem, why) + ' \n \n';
case 'listitem':
return text += '+ ' + getText(elem, why) + '\n';
case 'bold':
return text += '__' + getText(elem, why).trim() + '__ ';
case 'ulink':
return text += '[' + getText(elem, why).trim() + '](' + getAttr(elem, 'url').trim() + ') ';
case 'image':
// TODO: copy images over; hard coded for now
var fn = getAttr(elem, 'name');
return text += ' \n \n![' + fn + '](' + xml2js.opts.imagedir + '/' + fn + ') ';
case 'linebreak':
return text += ' \n';
case 'ndash':
return text += '&ndash; ';
default:
// TODO: incomplete list of doxygen xsd implemented
console.warn('NYI Unknown Object Type: ' + elem.name);
return text;
//throw new Error('NYI Unknown Object Type: ' + elem.name);
}
} else {
throw new Error('NYI Unknown Type: ' + (typeof elem));
}
}, '').trim();
}
// get the value of attribute with the given name of the given object
function getAttr(obj, name) {
return _.find(obj.attr, function(item) {
return item.name == name;
}).value;
}
// get the child object with the given name of the given object
function getChild(obj, name) {
return _.find(obj.children, function(child) {
return child.name == name;
});
}
// get all children objects with the given name of the given object
function getChildren(obj, name) {
return _.filter(obj.children, function(child) {
return child.name == name;
});
}
// debug helper: print untruncated object
function printObj(obj) {
console.log(util.inspect(obj, false, null));
}
module.exports = xml2js;

View File

@ -5,15 +5,16 @@ adc121c021.cxx ADC121C021Sample.java adc121c021.js adc121c021.py
adxl345.cxx Adxl345Sample.java adxl345.js adxl345.py
biss0001.cxx BISS0001Sample.java biss0001.js biss0001.py
bmpx8x.cxx BMPX8XSample.java bmpx8x.js bmpx8x.py
bno055.cxx BNO055_Example.java bno055.js bno055.py
button.cxx ButtonSample.java button.js button.py
buzzer.cxx BuzzerSample.java buzzer.js buzzer.py
cjq4435.cxx CJQ4435Sample.java cjq4435.js cjq4435.py
ds1307.cxx DS1307Sample.java ds1307.js ds1307.py
enc03r.cxx ENC03RSample.java enc03r.js enc03r.py
es08a.cxx ES08ASample.java es08a.js es08a.py
servo-es08a.cxx ES08ASample.java es08a.js es08a.py
groveehr.cxx GroveEHRSample.java groveehr.js groveehr.py
groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
groveled.cxx GroveLEDSample.java groveled.js groveled.py
my9221-groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
grove-groveled.cxx GroveLEDSample.java groveled.js groveled.py
grovelinefinder.cxx GroveLineFinderSample.java grovelinefinder.js grovelinefinder.py
grovemoisture.cxx GroveMoistureSample.java grovemoisture.js grovemoisture.py
grovescam.cxx GROVESCAMSample.java grovescam.js grovescam.py
@ -32,7 +33,7 @@ lcm1602-i2c.cxx Lcm1602_i2cSample.java lcm1602-i2c.js lcm1602-i2c.py
ldt0028.cxx LDT0028Sample.java ldt0028.js ldt0028.py
light.cxx LightSample.java light.js light.py
lol.cxx LoLSample.java lol.js lol.py
lsm303.cxx LSM303Sample.java lsm303.js lsm303.py
lsm303dlh.cxx LSM303DLHSample.java lsm303dlh.js lsm303dlh.py
m24lr64e.cxx M24LR64ESample.java m24lr64e.js m24lr64e.py
max44000.cxx MAX44000Sample.java max44000.js max44000.py
mic.cxx MicrophoneSample.java mic.js mic.py
@ -41,9 +42,9 @@ mma7660.cxx MMA7660Sample.java mma7660.js mma7660.py
mpl3115a2.cxx MPL3115A2Sample.java mpl3115a2.js mpl3115a2.py
mpr121.cxx MPR121Sample.java mpr121.js mpr121.py
mpu9150.cxx MPU9150Sample.java mpu9150.js mpu9150.py
mq2.cxx MQ2Sample.java mq2.js mq2.py
gas-mq2.cxx MQ2Sample.java mq2.js mq2.py
mq303a.cxx MQ303ASample.java mq303a.js mq303a.py
mq5.cxx MQ5Sample.java mq5.js mq5.py
gas-mq5.cxx MQ5Sample.java mq5.js mq5.py
nrf24l01-receiver.cxx NRF24L01_receiverSample.java nrf24l01-receiver.js nrf24l01-receiver.py
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java nrf24l01-transmitter.js nrf24l01-transmitter.py
nunchuck.cxx NUNCHUCKSample.java nunchuck.js nunchuck.py
@ -58,12 +59,12 @@ rpr220.cxx RPR220Sample.java rpr220.js rpr220.py
rpr220-intr.cxx RPR220_intrSample.java rpr220-intr.js rpr220-intr.py
slide.cxx SlideSample.java slide.js slide.py
speaker.cxx SpeakerSample.java speaker.js speaker.py
ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
i2clcd-ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
i2clcd-ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
st7735.cxx ST7735Sample.java st7735.js st7735.py
stepmotor.cxx StepMotorSample.java stepmotor.js stepmotor.py
tm1637.cxx TM1637Sample.java tm1637.js tm1637.py
tp401.cxx TP401Sample.java tp401.js tp401.py
gas-tp401.cxx TP401Sample.java tp401.js tp401.py
tsl2561.cxx TSL2561Sample.java tsl2561.js tsl2561.py
ttp223.cxx TTP223Sample.java ttp223.js ttp223.py
uln200xa.cxx ULN200XASample.java uln200xa.js uln200xa.py
@ -71,3 +72,10 @@ vdiv.cxx VDivSample.java vdiv.js vdiv.py
water.cxx WaterSample.java water.js water.py
wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
sensortemplate.cxx SensorTemplateSample.java sensortemplate.js sensortemplate.py
p9813.cxx P9813Sample.java p9813.js p9813.py
tcs37727.cxx tcs37727.py
tmp006.cxx tmp006.py
mma8x5x.cxx mma8x5x.py
mag3110.cxx mag3110.py
hdc1000.cxx hdc1000.py

120
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,120 @@
# Add an example executable target for the provided source file which depends
# on a UPM library target. Strings after the first '-' are ignored.
#
# Usage:
# add_example(source_file TARGETS <target0> <target1> <targetn> SUFFIX <target_suffix>)
#
# Parameters:
# source_file - C/C++ source file. Filename must follow a specific format:
# <library>-[additional].c(xx)
# library: Name of UPM library required by example
# -additional: Any other string used to identify the example
# TARGETS - Additional dependency target/s required to BUILD/RUN this example. If TARGETS is
# set, these are in addition to the dependency library provided by the example filename.
# SUFFIX - Provide a means to differentiate between C/C++ dependency targets and
# example names. Leave empty for CXX examples. Use '-c' for c targets.
# SUFFIX Example file Dependency target Example binary
# ------ ------------ ----------------- --------------
# "-c" foo.c foo-c foo-example-c
# foo.cxx foo foo-example-cxx
#
# Parent scope variable:
# example_src_list - Any example target which is successfully created by
# add_example will be removed from the parent scope variable
# example_src_list (if it exists). This provides a means to handle
# special case examples BEFORE handling all files in example_src_list.
#
# Examples:
# # Creates sensorfoo-example-cxx, depends on target: sensorfoo
# add_example(sensorfoo.cxx)
#
# # Creates sensorfoo-example-c, depends on target: sensorfoo-c
# add_example(sensorfoo.c SUFFIX "-c")
#
# # Creates sensorfoo-bar-example-c, depends on target: sensorfoo-c
# add_example(sensorfoo-bar.c SUFFIX "-c")
#
# # Creates testfoobar-cxx, depends on targets: blib, blah
# add_example(testfoobar.c TARGETS blib blah)
#
# Examples:
# a110x.c Requires libupmc-a110x
# lcm1602-i2c.c Requires libupmc-lcm1602
# bmp280-bme280.c Requires libupmc-bmp280
# i2clcd-eboled.cxx Requires libupm-i2clcd
#
#
function (add_example example_src)
set (oneValueArgs SUFFIX)
set (multiValueArgs TARGETS)
# Parse function parameters
cmake_parse_arguments(add_example "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Attempt to remove this example source file from a list of example
# sources. This allows for handling special case examples.
list (REMOVE_ITEM example_src_list ${example_src})
set (example_src_list ${example_src_list} PARENT_SCOPE)
# Get the base filename from the full filename
# For file /some/path/to/sensorfoo-bar.c, example_name = sensorfoo-bar
get_filename_component(example_name ${example_src} NAME_WE)
# Parse out <library>
# Example: sensorfoo-bar.c, library = sensorfoo
string (REPLACE "-" ";" split_name ${example_name})
list (GET split_name 0 library_name)
# Parse dependency target name from example_src filename (add on suffix)
# For sensorfoo, lib_target_names = sensorfoo-c
set (lib_target_names "${library_name}${add_example_SUFFIX}")
# If TARGETS is provided, add additional dependency targets
if (add_example_TARGETS)
list (APPEND lib_target_names "${add_example_TARGETS}")
endif ()
# Unfortunately, c++ and c library targets are not named the same. If
# no suffix is provided, assume C++ and add a suffix of -cxx to the
# example target name
# library example target
# c: sensorfoo-c sensorfoo-bar-example-c
# cxx: sensorfoo sensorfoo-bar-example-cxx
if (NOT add_example_SUFFIX)
set(add_example_SUFFIX "-cxx")
endif ()
# Create the target name for this example: mylibrary-bar-example-c
set (this_target_name "${example_name}-example${add_example_SUFFIX}")
# If a dependency target does NOT exist, print a warning and skip
foreach(_dep_target ${lib_target_names})
if (NOT TARGET ${_dep_target})
message(STATUS "Example ${example_src} is missing a required CMake target (${_dep_target}), skipping...")
return()
endif ()
endforeach ()
# Create an executable target for this example
add_executable (${this_target_name} ${example_src})
# Add each dependency to the library target
foreach(_dep_target ${lib_target_names})
target_link_libraries(${this_target_name} ${_dep_target} ${CMAKE_THREAD_LIBS_INIT})
endforeach ()
endfunction (add_example example_src)
# Add subdirectories if BUILDEXAMPLES=on
if(BUILDEXAMPLES)
# Add C examples
add_subdirectory (c)
# Add C++ examples?
if (BUILDCPP)
add_subdirectory (c++)
endif ()
# Add java examples?
if(BUILDSWIGJAVA)
add_subdirectory (java)
endif()
endif()

View File

@ -1,378 +1,20 @@
# Selectively disable certain warnings for the examples
# nrf examples flag -Wtautological-compare
set (CXX_DISABLED_WARNINGS -Wno-tautological-compare)
# Create an list of all C++ source files in this directory
file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx")
# Extract module name from non-standard example name
macro(get_module_name example_name module_name)
string(LENGTH ${example_name} length)
string(FIND ${example_name} "-" index)
if (${index} GREATER 1)
string(SUBSTRING ${example_name} 0 ${index} substr)
set(${module_name} ${substr})
elseif (${example_name} MATCHES "^grove")
set (${module_name} "grove")
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
set (${module_name} "gas")
else()
set(${module_name} ${example_name})
endif()
endmacro()
# - Handle special cases here --------------------------------------------------
# Set source file, include and linker settings for an example
# If example cannot be built, example_bin is cleared
macro(add_custom_example example_bin example_src example_module_list)
set(found_all_modules TRUE)
foreach (module ${example_module_list})
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
set(found_all_modules FALSE)
endif()
if (MODULE_LIST)
list(FIND MODULE_LIST ${module} index)
if (${index} EQUAL -1)
set(found_all_modules FALSE)
endif()
endif()
endforeach()
if (found_all_modules)
add_executable (${example_bin} ${example_src})
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
# Test humidity interface for 2 sensor libraries
add_example(interfaces-humiditysensor.cxx TARGETS si7005 bmp280)
# Test pressure interface for 2 sensor libraries
add_example(interfaces-pressuresensor.cxx TARGETS bmp280 bmpx8x)
# Test temperature interface for 3 sensor libraries
add_example(interfaces-temperaturesensor.cxx TARGETS bmp280 bmpx8x si7005)
# Test light interface for 2 sensor libraries
add_example(interfaces-lightsensor.cxx TARGETS si1132 max44009)
# Test light controller interface for 3 sensor libraries
add_example(interfaces-lightcontroller.cxx TARGETS lp8860 ds1808lc hlg150h)
# Disable warnings from CXX_DISABLED_WARNINGS
foreach(flag ${CXX_DISABLED_WARNINGS})
compiler_flag_supported(CXX is_supported ${flag})
if (is_supported)
target_compile_options(${example_bin} PRIVATE "${flag}")
endif(is_supported)
endforeach(flag ${CXX_DISABLED_WARNINGS})
foreach (module ${example_module_list})
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
include_directories (${module_dir})
if (${module} STREQUAL "lcd")
set(module "i2clcd")
endif()
target_link_libraries (${example_bin} ${module})
endforeach()
else()
message (WARNING "Ignored ${example_bin}")
set (example_bin "")
endif()
endmacro()
# Add specified example by name
# Note special case for grove based examples
macro(add_example example_name)
set(example_src "${example_name}.cxx")
set(example_bin "${example_name}-example-cxx")
get_module_name(${example_name} module_name)
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
AND EXISTS ${module_dir}
AND IS_DIRECTORY ${module_dir})
add_custom_example(${example_bin} ${example_src} ${module_name})
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
if (EXISTS ${grove_module_path})
include_directories(${grove_module_path})
target_link_libraries (${example_bin} ${example_name})
endif()
endif()
else()
message (WARNING "Ignored ${example_bin}")
endif()
endmacro()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
# UPM c include directories
include_directories (${PROJECT_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/utilities)
# Set the mraa include and link directories prior to adding examples
include_directories (${MRAA_INCLUDE_DIRS})
link_directories (${MRAA_LIBDIR})
# If your sample source file matches the name of the module it tests, add it here
# Exceptions are as follows:
# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
# mq? will use module gas
# grove* will use module grove
add_example (hmc5883l)
add_example (led)
add_example (groveled)
add_example (relay)
add_example (groverelay)
add_example (light)
add_example (grovelight)
add_example (temperature)
add_example (grovetemp)
add_example (button)
add_example (grovebutton)
add_example (rotary)
add_example (groverotary)
add_example (slide)
add_example (groveslide)
add_example (buzzer)
add_example (nrf24l01-transmitter)
add_example (nrf24l01-receiver)
add_example (nrf24l01-broadcast)
add_example (hcsr04)
add_example (max44000)
add_example (mma7455)
add_example (st7735)
add_example (max31855)
add_example (bmpx8x)
add_example (stepmotor)
add_example (pulsensor)
add_example (mic)
add_example (mpu9150)
add_example (maxds3231m)
add_example (max31723)
add_example (max5487)
add_example (nrf8001-broadcast)
add_example (nrf8001-helloworld)
add_example (lpd8806)
add_example (mlx90614)
add_example (ecs1030)
add_example (mq2)
add_example (mq3)
add_example (mq4)
add_example (mq5)
add_example (mq6)
add_example (mq7)
add_example (mq8)
add_example (mq9)
add_example (tp401)
add_example (tcs3414cs)
add_example (th02)
add_example (ttp223)
add_example (lsm303)
add_example (joystick12)
add_example (lol)
add_example (tsl2561)
add_example (htu21d)
add_example (mpl3115a2)
add_example (ldt0028)
add_example (am2315)
add_example (itg3200)
add_example (enc03r)
add_example (adc121c021)
add_example (ds1307)
add_example (a110x)
add_example (gp2y0a)
add_example (moisture)
add_example (grovemoisture)
add_example (ehr)
add_example (groveehr)
add_example (ta12200)
add_example (grovelinefinder)
add_example (linefinder)
add_example (vdiv)
add_example (grovevdiv)
add_example (water)
add_example (grovewater)
add_example (guvas12d)
add_example (mpr121)
add_example (yg1006)
add_example (wt5001)
add_example (ppd42ns)
add_example (mq303a)
add_example (speaker)
add_example (grovespeaker)
add_example (rfr359f)
add_example (biss0001)
add_example (rotaryencoder)
add_example (adxl345)
add_example (rpr220)
add_example (rpr220-intr)
add_example (mma7660)
add_example (cjq4435)
add_example (adxl335)
add_example (hmtrp)
add_example (nunchuck)
add_example (otp538u)
add_example (collision)
add_example (grovecollision)
add_example (electromagnet)
add_example (groveelectromagnet)
add_example (emg)
add_example (groveemg)
add_example (o2)
add_example (groveo2)
add_example (gsr)
add_example (grovegsr)
add_example (ina132)
add_example (l298)
add_example (l298-stepper)
add_example (at42qt1070)
add_example (grovemd)
add_example (md)
add_example (grovemd-stepper)
add_example (md-stepper)
add_example (pca9685)
add_example (eldriver)
add_example (groveeldriver)
add_example (adafruitss)
add_example (adafruitms1438)
add_example (adafruitms1438-stepper)
add_example (hx711)
add_example (flex)
add_example (a110x-intr)
add_example (mhz16)
add_example (apds9002)
add_example (waterlevel)
add_example (tm1637)
add_example (zfm20)
add_example (zfm20-register)
add_example (uln200xa)
add_example (grovewfs)
add_example (wfs)
add_example (isd1820)
add_example (sx6119)
add_example (si114x)
add_example (maxsonarez)
add_example (hm11)
add_example (ht9170)
add_example (h3lis331dl)
add_example (ad8232)
add_example (grovescam)
add_example (scam)
add_example (m24lr64e)
add_example (rgbringcoder)
add_example (hp20x)
add_example (pn532)
add_example (pn532-writeurl)
add_example (lsm9ds0)
add_example (loudness)
add_example (mg811)
add_example (wheelencoder)
add_example (sm130)
add_example (gprs)
add_example (grovegprs)
add_example (lm35)
add_example (micsv89)
add_example (xbee)
add_example (urm37)
add_example (urm37-uart)
add_example (adxrs610)
add_example (bma220)
add_example (dfrph)
add_example (mcp9808)
add_example (groveultrasonic)
add_example (ultrasonic)
add_example (sx1276-lora)
add_example (sx1276-fsk)
add_example (ili9341)
add_example (nlgpio16)
add_example (ads1x15)
if (MODBUS_FOUND)
include_directories(${MODBUS_INCLUDE_DIRS})
add_example (t3311)
add_example (hwxpxx)
add_example (h803x)
endif()
add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
add_example (ssd1351)
add_example (ds1808lc)
add_example (hlg150h)
add_example (lp8860)
add_example (max44009)
add_example (si1132)
add_example (si7005)
add_example (t6713)
add_example (cwlsxxa)
add_example (teams)
add_example (apa102)
add_example (tex00)
add_example (bmi160)
add_example (smartdrive)
if (HAVE_FIRMATA)
add_example (curieimu)
endif ()
if (BACNET_FOUND)
include_directories(${BACNET_INCLUDE_DIRS})
# we need access to bacnetmstp headers too
include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
add_example (e50hx)
add_example (t8100)
add_example (tb7300)
endif()
if (JPEG_FOUND)
add_example (vcap)
endif (JPEG_FOUND)
add_example (ds2413)
add_example (ds18b20)
add_example (bmp280)
add_example (bno055)
add_example (l3gd20)
add_example (l3gd20-i2c)
add_example (bmx055)
add_example (ms5611)
add_example (nmea_gps)
add_example (mma7361)
add_example (bh1750)
add_example (hka5)
add_example (dfrorp)
add_example (dfrec)
add_example (sht1x)
add_example (ms5803)
add_example (ims)
add_example (ecezo)
add_example (mb704x)
add_example (rf22-server)
add_example (rf22-client)
add_example (mcp2515)
add_example (max30100)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
add_custom_example (groveled-multi-example-cxx groveled-multi.cxx grove)
add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcd)
add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcd)
add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx lcd)
add_custom_example (es08a-example-cxx es08a.cxx servo)
add_custom_example (ssd1306-oled-example-cxx ssd1306-oled.cxx lcd)
add_custom_example (ssd1308-oled-example-cxx ssd1308-oled.cxx lcd)
add_custom_example (ssd1327-oled-example-cxx ssd1327-oled.cxx lcd)
add_custom_example (sainsmartks-example-cxx sainsmartks.cxx lcd)
add_custom_example (eboled-example-cxx eboled.cxx lcd)
add_custom_example (mpu60x0-example-cxx mpu60x0.cxx mpu9150)
add_custom_example (ak8975-example-cxx ak8975.cxx mpu9150)
add_custom_example (mpu9250-example-cxx mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example-cxx groveledbar.cxx my9221)
add_custom_example (grovecircularled-example-cxx grovecircularled.cxx my9221)
add_custom_example (temperature-sensor-example-cxx temperature-sensor.cxx "si7005;bmpx8x;bmp280")
add_custom_example (humidity-sensor-example-cxx humidity-sensor.cxx "si7005;bmp280")
add_custom_example (pressure-sensor-example-cxx pressure-sensor.cxx "bmpx8x;bmp280")
add_custom_example (co2-sensor-example-cxx co2-sensor.cxx "t6713")
add_custom_example (adc-example-cxx adc-sensor.cxx "ads1x15")
add_custom_example (light-sensor-example-cxx light-sensor.cxx "si1132;max44009")
add_custom_example (light-controller-example-cxx light-controller.cxx "lp8860;ds1808lc;hlg150h")
add_custom_example (bme280-example-cxx bme280.cxx bmp280)
add_custom_example (bma250e-example-cxx bma250e.cxx bmx055)
add_custom_example (bmg160-example-cxx bmg160.cxx bmx055)
add_custom_example (bmm150-example-cxx bmm150.cxx bmx055)
add_custom_example (bmc150-example-cxx bmc150.cxx bmx055)
add_custom_example (bmi055-example-cxx bmi055.cxx bmx055)
if (OPENZWAVE_FOUND)
include_directories(${OPENZWAVE_INCLUDE_DIRS})
add_custom_example (ozwdump-example-cxx ozwdump.cxx ozw)
add_custom_example (aeotecss6-example-cxx aeotecss6.cxx ozw)
add_custom_example (aeotecsdg2-example-cxx aeotecsdg2.cxx ozw)
add_custom_example (aeotecdw2e-example-cxx aeotecdw2e.cxx ozw)
add_custom_example (aeotecdsb09104-example-cxx aeotecdsb09104.cxx ozw)
add_custom_example (tzemt400-example-cxx tzemt400.cxx ozw)
endif()
add_custom_example (nmea_gps_i2c_example-cxx nmea_gps_i2c.cxx nmea_gps)
add_custom_example (mcp2515-txrx-example-cxx mcp2515-txrx.cxx mcp2515)
add_custom_example (ads1015-example-cxx ads1015.cxx ads1x15)
add_custom_example (le910-example-cxx le910.cxx uartat)
add_custom_example (speaker_pwm-example-cxx speaker_pwm.cxx speaker)
add_custom_example (ads1115-example-cxx ads1015.cxx ads1x15)
# - Create an executable for all other src files in this directory -------------
foreach (_example_src ${example_src_list})
add_example(${_example_src})
endforeach ()

61
examples/c++/abp.cxx Normal file
View File

@ -0,0 +1,61 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.com>
* Copyright (c) 2017 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "abp.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main ()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an ABP sensor on i2c bus 0
upm::ABP* abp = new upm::ABP(0, ABP_DEFAULT_ADDRESS);
while (shouldRun) {
abp->update();
cout << "Retrieved pressure: " << abp->getPressure() << endl;
cout << "Retrieved Temperature: " << abp->getTemperature() << endl;
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete abp;
return 0;
}

View File

@ -40,7 +40,7 @@
#include <iostream>
#include <signal.h>
#include "adis16448.h"
#include "adis16448.hpp"
int
main(int argc, char **argv)

View File

@ -49,6 +49,7 @@ void stop()
int main()
{
//! [Interesting]
long id = 0; // Sample number
string fileName = "./ads1015.data"; // Output filename
ofstream f;
@ -97,6 +98,7 @@ int main()
return 1;
}
cout << "Wrote " << id << " samples to file: " << fileName << endl;
//! [Interesting]
return 0;
}

View File

@ -48,6 +48,7 @@ void stop()
int main()
{
//! [Interesting]
long id = 0; // Sample number
string fileName = "./ads1115.data"; // Output filename
ofstream f;
@ -100,6 +101,7 @@ int main()
return 1;
}
cout << "Wrote " << id << " samples to file: " << fileName << endl;
//! [Interesting]
return 0;
}

View File

@ -37,6 +37,7 @@ int main()
using namespace std;
using namespace upm;
int command;
//! [Interesting]
//Select the device you are testing here and adjust case 6 for the correct sample rates.
//upm::ADS1015 *ads = new upm::ADS1015(1);
upm::ADS1115 *ads = new upm::ADS1115(1, 0x49);
@ -315,6 +316,7 @@ int main()
}while (command != -1 );
delete ads;
//! [Interesting]
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMA250E using default I2C parameters
upm::BMA250E *sensor = new upm::BMA250E();
upm::BMA250E sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMA250E(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
@ -64,8 +64,8 @@ int main(int argc, char **argv)
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
@ -77,7 +77,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMG160 using default I2C parameters
upm::BMG160 *sensor = new upm::BMG160();
upm::BMG160 sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMG160(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
@ -64,8 +64,8 @@ int main(int argc, char **argv)
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
@ -77,7 +77,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMM150 using default I2C parameters
upm::BMM150 *sensor = new upm::BMM150();
upm::BMM150 sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMM150(0, -1, 10);
@ -54,9 +54,9 @@ int main(int argc, char **argv)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -72,7 +72,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -31,7 +31,7 @@
using namespace std;
using namespace upm;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{

View File

@ -1,6 +1,8 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
* Copyright (c) 2016-2017 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -31,7 +33,7 @@
using namespace std;
using namespace upm;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{

View File

@ -1,6 +1,11 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* This driver was rewritten based on the original driver written by:
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,57 +29,50 @@
#include <unistd.h>
#include <iostream>
#include "bmpx8x.hpp"
#include <signal.h>
int doWork = 0;
upm::BMPX8X *sensor = NULL;
#include "bmpx8x.hpp"
void
sig_handler(int signo)
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
printf("got signal\n");
if (signo == SIGINT) {
printf("exiting application\n");
doWork = 1;
}
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char **argv)
int main(int argc, char **argv)
{
//! [Interesting]
uint32_t presure = 0;
float temperature = 0;
float altitude = 0;
uint32_t sealevel = 0;
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a BMPX8X sensor on I2C
sensor = new upm::BMPX8X(0, ADDR);
// Instantiate a BMPX8X sensor on I2C using defaults.
upm::BMPX8X sensor;
// Print the pressure, altitude, sea level, and
// temperature values every 0.1 seconds
while (!doWork) {
presure = sensor->getPressure ();
temperature = sensor->getTemperature ();
altitude = sensor->getAltitude ();
sealevel = sensor->getSealevelPressure ();
// temperature values every 0.5 seconds
while (shouldRun)
{
sensor.update();
std::cout << "pressure value = " <<
presure <<
", altitude value = " <<
altitude <<
", sealevel value = " <<
sealevel <<
", temperature = " <<
temperature << std::endl;
usleep (100000);
cout << "Pressure: "
<< sensor.getPressure()
<< " Pa, Temperature: "
<< sensor.getTemperature()
<< " C, Altitude: "
<< sensor.getAltitude()
<< " m, Sea level: "
<< sensor.getSealevelPressure()
<< " Pa"
<< endl;
usleep(500000);
}
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
cout << "Exiting..." << endl;
//! [Interesting]
return 0;
}

View File

@ -44,23 +44,23 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMC150 using default I2C parameters
upm::BMC150 *sensor = new upm::BMC150();
upm::BMC150 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -76,7 +76,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,23 +44,23 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMI055 using default I2C parameters
upm::BMI055 *sensor = new upm::BMI055();
upm::BMI055 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
@ -76,7 +76,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -44,30 +44,30 @@ int main(int argc, char **argv)
//! [Interesting]
// Instantiate an BMX055 using default I2C parameters
upm::BMX055 *sensor = new upm::BMX055();
upm::BMX055 sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor.update();
sensor->getAccelerometer(&x, &y, &z);
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " degrees/s"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
@ -83,7 +83,5 @@ int main(int argc, char **argv)
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -26,6 +26,7 @@
#include <iostream>
#include <signal.h>
#include "buzzer.hpp"
#include "upm_utilities.h"
int

View File

@ -76,6 +76,7 @@ main(int argc, char **argv)
printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
delete sensor;
//! [Interesting]
return 0;
}

View File

@ -8,44 +8,36 @@
#define EDISON_I2C_BUS 1 // Edison I2C-1
#define DS1808_GPIO_PWR 15 // Edison GP165
void printState(upm::ILightController *lightController)
void printState(upm::ILightController &lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::ILightController* lightController = nullptr;
try {
lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
delete lightController;
return status;
//! [Interesting]
upm::DS1808LC lightController(DS1808_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
return 0;
}

View File

@ -29,15 +29,13 @@
#include <stdlib.h>
#include <sys/time.h>
upm::HCSR04 *sonar = NULL;
int shouldRun = true;
void
sig_handler(int signo)
{
printf("got signal\n");
if (signo == SIGINT) {
printf("exiting application\n");
sonar->m_doWork = 1;
shouldRun = false;
}
}
@ -45,20 +43,20 @@ sig_handler(int signo)
int
main(int argc, char **argv)
{
sonar = new upm::HCSR04(5, 6);
upm::HCSR04 *sonar = new upm::HCSR04(2, 4);
signal(SIGINT, sig_handler);
sleep(1);
for(;;){
while(shouldRun){
std::cout << "get distance" << std::endl;
double distance = sonar->getDistance(CM);
double distance = sonar->getDistance(HCSR04_CM);
std::cout << "distance " << distance << std::endl;
sleep(5);
sleep(2);
}
std::cout << "Exiting... " << std::endl;
delete sonar;
return 0;
}
//! [Interesting]

67
examples/c++/hdc1000.cxx Normal file
View File

@ -0,0 +1,67 @@
/* Author: Norbert Wesp <nwesp@phytec.de>
* Copyright (c) 2017 Phytec Messtechnik GmbH.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "hdc1000.hpp"
using namespace upm;
bool run = true;
void sig_handler(int sig)
{
if (sig == SIGINT)
run = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
std::cout << "Initializing test-application..." << std::endl;
// Instantiate an HDC1000 instance on bus 1
upm::HDC1000 *mySensor = new upm::HDC1000(1);
// update and print available values every second
while (run)
{
std::cout << "Humidity: " << mySensor->getHumidity(true) << std::endl
<< "Temperature: " << mySensor->getTemperature(true) << std::endl;
std::cout << std::endl;
sleep(1);
}
std::cout << "Exiting test-application..." << std::endl;
delete mySensor;
//! [Interesting]
return 0;
}

View File

@ -8,44 +8,37 @@
#define HLG150H_GPIO_RELAY 21
#define HLG150H_GPIO_PWM 22
void printState(upm::ILightController *lightController)
void printState(upm::ILightController &lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::ILightController* lightController;
//! [Interesting]
upm::HLG150H lightController(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
try {
lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
delete lightController;
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
return status;
return 0;
}

View File

@ -46,19 +46,25 @@ int main(int argc, char **argv)
// Instantiate a IMS instance using i2c bus 0 and default address
upm::IMS sensor(0);
int i2c_addr_cur = IMS_ADDRESS_DEFAULT + 1;
while (shouldRun)
{
std::cout << "Version: "
std::cout << std::hex << "Version: 0x"
<< sensor.get_version()
<< " light: "
<< " light: 0x"
<< sensor.get_light()
<< " moisture: "
<< " moisture: 0x"
<< sensor.get_moisture()
<< " temp: "
<< sensor.get_temperature()
<< " C"
<< std::endl;
// Change the address and continue
if (i2c_addr_cur >= 128) i2c_addr_cur = 1;
std::cout << "Changing device address to 0x" << i2c_addr_cur
<< std::endl;
sensor.reset_i2c_address(i2c_addr_cur++);
sleep(1);
}
//! [Interesting]

View File

@ -95,4 +95,4 @@ int main( int argc, char **argv )
return status;
}
//! [Interesting]

View File

@ -23,7 +23,10 @@
*/
#include <signal.h>
#include <string>
#include "jhd1313m1.hpp"
#include "upm_utilities.h"
int shouldRun = true;
@ -64,7 +67,7 @@ main(int argc, char **argv)
// Echo via printf
printf("Hello World %d rgb: 0x%02x%02x%02x\n", ndx++, r, g, b);
sleep(1);
upm_delay(1);
}
//! [Interesting]

73
examples/c++/lcdks.cxx Normal file
View File

@ -0,0 +1,73 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "lcdks.hpp"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a LCDKS (LCD Keypad Shield) using default pins
// NOTE: The default pins do not include support for a gpio
// controlled backlight. If you need one, you will need to specify
// all neccessary pins to the constructor.
upm::LCDKS* lcd = new upm::LCDKS();
lcd->setCursor(0,0);
lcd->write("LCDKS driver");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getKeyValue() << endl;
sleep(1);
}
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -23,6 +23,7 @@
*/
#include "lcm1602.hpp"
#include "upm_utilities.h"
int
main(int argc, char **argv)
@ -32,16 +33,16 @@ main(int argc, char **argv)
lcd->setCursor(0,0);
lcd->write("Hello World");
//! [Interesting]
sleep(3);
upm_delay(3);
lcd->setCursor(1,2);
lcd->write("Hello World");
sleep(3);
upm_delay(3);
lcd->setCursor(2,4);
lcd->write("Hello World");
sleep(3);
upm_delay(3);
lcd->setCursor(3,6);
lcd->write("Hello World");
sleep(3);
upm_delay(3);
delete lcd;
return 0;

View File

@ -23,7 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <lcm1602.hpp>
#include "lcm1602.hpp"
#include "upm_utilities.h"
int
main(int argc, char **argv)
@ -47,7 +48,7 @@ main(int argc, char **argv)
lcd->write("Hello World");
printf("Sleeping for 5 seconds\n");
sleep(5);
upm_delay(5);
delete lcd;
//! [Interesting]
return 0;

View File

@ -44,7 +44,7 @@ main(int argc, char **argv)
std::cout << "For the next " << NUMBER_OF_SECONDS << " seconds, "
<< SAMPLES_PER_SECOND << " samples will be taken every second."
<< std::endl << std::endl;
uint16_t* buffer = new uint16_t[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
uint16_t buffer[NUMBER_OF_SECONDS * SAMPLES_PER_SECOND];
for (int i=0; i < NUMBER_OF_SECONDS * SAMPLES_PER_SECOND; i++) {
buffer[i] = (uint16_t) sensor->getSample();
usleep(MICROSECONDS_PER_SECOND / SAMPLES_PER_SECOND);

View File

@ -0,0 +1,64 @@
/*
* Author: Saloni Jain <saloni.jain@tcs.com>
* Author: Niti Rohilla <niti.rohilla@tcs.com>
* Copyright (c) 2014 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lidarlitev3.hpp"
volatile int doWork = 0;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
printf("\nCtrl-C received.\n");
doWork = 1;
}
}
int
main(int argc, char **argv)
{
// Register signal handler
signal(SIGINT, sig_handler);
//! [Interesting]
upm::LIDARLITEV3 *sensor = new upm::LIDARLITEV3(0, ADDR);
while (!doWork) {
std::cout << "Distance = " << sensor->getDistance () << std::endl;
usleep (50000);
}
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
return 0;
}

View File

@ -34,10 +34,11 @@ main(int argc, char **argv)
// Create the light sensor object using AIO pin 0
upm::Light* light = new upm::Light(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
// Read the input and print both the normalized ADC value and a
// rough lux value, waiting one second between readings
while( 1 ) {
std::cout << light->name() << " raw value is " << light->raw_value() <<
std::cout << light->name() << " normalized value is "
<< light->getNormalized() <<
", which is roughly " << light->value() << " lux" << std::endl;
sleep(1);
}

81
examples/c++/lis2ds12.cxx Normal file
View File

@ -0,0 +1,81 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lis2ds12.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LIS2DS12 using default I2C parameters
upm::LIS2DS12 sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: LIS2DS12(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor.update();
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -9,44 +9,37 @@
#define LP8860_GPIO_PWR 45 // Edison GP45
void printState(upm::ILightController *lightController)
void printState(upm::ILightController &lightController)
{
if (lightController->isPowered())
{
std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
if (lightController.isPowered())
{
std::cout << "Light is powered, brightness = " << lightController.getBrightness() << std::endl;
}
else
{
std::cout << "Light is not powered." << std::endl;
}
}
int main( int argc, char **argv )
{
int status = 0;
upm::LP8860* lightController;
//! [Interesting]
upm::LP8860 lightController(LP8860_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0)
{
lightController.setPowerOn();
lightController.setBrightness(brightness);
}
else
lightController.setPowerOff();
}
std::cout << "Now: ";printState(lightController);
//! [Interesting]
try {
lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
std::cout << "Existing state: "; printState(lightController);
if (argc == 2)
{
std::string arg = argv[1];
int brightness = ::atoi(argv[1]);
if (brightness > 0) {
lightController->setPowerOn();
lightController->setBrightness(brightness);
} else
lightController->setPowerOff();
}
std::cout << "Now: ";printState(lightController);
delete lightController;
} catch (std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
status = 1;
}
return status;
return 0;
}

View File

@ -46,7 +46,7 @@ int
main(int argc, char **argv)
{
//! [Interesting]
sensor = new upm::LPD8806(10, 7);
sensor = new upm::LPD8806(0, 7, 10);
usleep (1000000);
sensor->show ();

View File

@ -0,0 +1,87 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm303agr.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM303AGR using default I2C parameters
upm::LSM303AGR sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor.update();
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
<< " uT"
<< endl;
cout << "Temperature: "
<< sensor.getTemperature()
<< " C"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

87
examples/c++/lsm303d.cxx Normal file
View File

@ -0,0 +1,87 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm303d.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM303D using default I2C parameters
upm::LSM303D sensor;
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor.update();
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor.getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
<< " uT"
<< endl;
cout << "Temperature: "
<< sensor.getTemperature()
<< " C"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -25,13 +25,13 @@
#include <iostream>
//! [Interesting]
#include "lsm303.hpp"
#include "lsm303dlh.hpp"
int
main(int argc, char **argv)
{
// Instantiate LSM303 compass on I2C
upm::LSM303 *sensor = new upm::LSM303(0);
// Instantiate LSM303DLH compass on I2C
upm::LSM303DLH *sensor = new upm::LSM303DLH(0);
// Get the coordinate data
sensor->getCoordinates();

88
examples/c++/lsm6ds3h.cxx Normal file
View File

@ -0,0 +1,88 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm6ds3h.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM6DS3H using default I2C parameters
upm::LSM6DS3H sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: LSM6DS3H(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor.update();
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " dps"
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

88
examples/c++/lsm6dsl.cxx Normal file
View File

@ -0,0 +1,88 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2016 Intel Corporation.
*
* 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:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm6dsl.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM6DSL using default I2C parameters
upm::LSM6DSL sensor;
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: LSM6DSL(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor.update();
sensor.getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor.getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " dps"
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor.getTemperature()
<< " C / " << sensor.getTemperature(true) << " F"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

Some files were not shown because too many files have changed in this diff Show More