Deploy upm.mraa.io to github.com/intel-iot-devkit/upm.git:gh-pages

This commit is contained in:
Deployment Bot (from Travis CI) 2018-11-07 21:32:23 +00:00
commit c515bd76c9
2945 changed files with 357940 additions and 0 deletions

1
CNAME Executable file
View File

@ -0,0 +1 @@
upm.mraa.io

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:latest
# Install Ruby Tools
RUN apt-get update && apt-get install -y ruby ruby-dev && \
gem install sass bundler --no-user-install
# Install Global Node.js Tools
RUN npm install -g gulp
# Expose port for development
EXPOSE 1234
EXPOSE 3001
# Set Workdir to the mounted directory
WORKDIR /usr/src/app
CMD bash

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<!doctype html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700|Roboto:100,300,400,500,700,900" rel="stylesheet"><link rel="shortcut icon" type="image/png" href="/assets/images/favicon.png"/><link rel="stylesheet" href="/assets/css/style.css"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/dracula.min.css"> <script src="/assets/js/library/jquery-2.2.4.min.js"></script> <script src="/assets/js/library/handlebars.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> <script type="text/javascript">hljs.initHighlightingOnLoad();</script> <script type="text/javascript"> $(function(){ var current = location.pathname; $('.nav li a').each(function(){ var $this = $(this); /* if the current path is like this link, make it active */ if($this.attr('href').indexOf(current) !== -1){ $this.addClass('active'); } }) }); </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-17890616-13', 'auto'); ga('send', 'pageview'); </script><body><header><nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"><div class="container"><div class="row"><div class="col-xs-12 col-sm-5"> <a class="navbar-logo pull-left" href="/"> <img src="/assets/images/logo.png" class="logo-img"> </a><div class="navbar-header pull-right" style="display: inline-block;"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button></div></div><div class="col-sm-7 col-xs-12 menu-inner"><div id="navbar" class="navbar-collapse collapse"><ul class="nav navbar-nav navbar-right nav-list"><li> <a href="/findSensor.html"><span class="icon find-sensor" ></span> <span class="">Find</span></a><li> <a href="/addSensor.html"><span class="icon add-sensor" ></span> <span class="">Join</span></a><li> <a href="/Documentation/docindex.html"><span class="icon documentation" ></span> <span class="">Documentation</span></a><li> <a href="https://github.com/intel-iot-devkit/upm" target="_blank"><span class="icon github github-mobile"></span> <span class="github-desktop">Github</span></a></ul></div></div></div></div></nav></header><main><div class="main-container inner-pages"><div class="container"><div class="row"><div class="col-sm-8 col-xs-12 "><div class="page-heading"> Naming your module</div></div></div></div><div class="section-wrapper installingMraa"><div class="container"><div class="row "><div class=" col-sm-12"><div class="description"> UPM attempts to follow a clear naming pattern. Modules should be sensibly named and then placed in ${libdir}/upm and headers in ${includedir}/upm, all modules should be prefixed with libupm-. The upm_module_init will automatically name python UPM modules as pyupm_ and javascript modules as jsupm_. For example for src/grove/ the library built will be libupm-grove.so, the python module pyupm_grove and the js module jsupm_grove.</div><div class="title">Choosing a name for a new module</div><div class="description"> Pick a name and stick with it. Usually, the chip name makes the most sense. If not, try to pick a generic name so people with a similar sensor can inherit your class if they only have minor changes.<div>• All modules should be prefixed with libupm-.</div><div>• Avoid brand names.</div><div>• Your lib must belong to the UPM namespace.</div></div><div class="title">Questions?</div><div class="description">Ping us via email: mihai.tudor.panu@intel.com or brendan.le.foll@intel.com and we'll suggest some useful names.</div></div></div></div></div></div><footer class="site-footer"><div class="container"><div class="row"><div class="col-xs-6"><p class="text-muted">(* Trademarks)</div><div class="col-xs-6 text-right"><p class="text-muted">&copy; 2017 UPM</div></div></div><script src="/assets/js/library/bootstrap.min.js"></script></footer></main>

1
Documentation/mraa.html Normal file

File diff suppressed because one or more lines are too long

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Intel® IoT Developer Kit
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.

47
README.md Executable file
View File

@ -0,0 +1,47 @@
# UPM Website [![Build Status](https://travis-ci.org/intel-iot-devkit/upm-site.svg?branch=master)](https://travis-ci.org/intel-iot-devkit/upm-site)
## GitHub Pages URL: https://upm.mraa.io
## Dependencies:
* [NodeJs](https://nodejs.org/en/)
* [Gulp](https://github.com/gulpjs/gulp)
* [Python](https://www.python.org/), specifically Python 2!
* [Ruby](https://www.ruby-lang.org/en/)
* [Sass](http://sass-lang.com/)
* [Bundler](http://bundler.io/)
* A bunch of other stuff installed through bundle and ruby gems
## Prepare Dev Environment:
* Run `npm install`, in the same directory as the code. This will install all the dependencies automatically
* Run `bundler install` to install Gems dependencies automatically
## Gulp Tasks:
1. `gulp clean`: to clean local build directories and resources
2. `gulp build`: to generate the build for production using _config.yml, deploys to /_site
3. `gulp build:local`: to generated the build using _config_dev.yml
4. `gulp serve`: runs the app locally, using the _config_dev.yml file
## Global.yml
* Urls defined for fetching images, source code, and apis
* Whenever there are changes in facets.json/sensordetail.json files, increment the value in ajaxVersion to refresh the cache
* Whenever there are changes in css/js resources, increment the value in resourceVersion to refresh the cache
## _assets/gulp_config/paths.js
* Set paths.sensorDataSrc to the root of UPM /src
## Static Content:
* The sensor data is kept under /_assets/content/sensorDetail.json
To generate this file with `jq` and latest `upm` sources use:
```
find upm/src/ -iname "*.json" | sort | xargs jq -s -c '.' >sensorDetail.json
```
* The facets data is kept under /_assets/content/facets.json
* If images are missing, copy it over from _assets/gulp_config/images to _/site/assets/images
## Miscellaneous:
* _config_dev.yml has configurable properties for local
* _config.yml has properties for production deployment
* CNAME corresponds to the mapped cname in DNS provider
## Site Deployment using Travis CI
Documentation can be found [here](https://docs.travis-ci.com/user/deployment/pages/)

1
addSensor.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/content/facets.json Executable file
View File

@ -0,0 +1 @@
{"facets":[{"name":"Project Type","id":"1","type":["Prototyping","Industrial","Medical","Commercial","Extended"]},{"name":"Categories","id":"2","type":["Pressure","Color sensor","Humidity","Temperature","Accelerometer","Button","Analog Input","Light","Radio","Light Controller","Compass","Gyroscope","Motor","Led","Servos","Other"]},{"name":"Connections","id":"3","type":["gpio","i2c","spi","AIO","PWM","Analog"]},{"name":"Starter Kit","id":"4","type":["GSK","DFRobot 3PA","DFRobot 4WD","Robok","Environment & Agriculture Kit","Grove Starter Kit","Home Automation Kit","Robotics Kit","Transportation & Safety Kit"]},{"name":"API Language Support","id":"5","type":["C++","Python","Java","Node.js","C"]},{"name":"Manufacturer","id":"6","type":["Amsys","Silabs","Semtech","Texas Instruments","Meanwell","Seeed","Maxim Integrated","Vishay","DFrobot","Sparkfun","Generic","Honeywell","Emax","Bosch","Acme Co","Max","Kernel","adafruit","Studio"]}]}

File diff suppressed because one or more lines are too long

5
assets/css/style.css Normal file

File diff suppressed because one or more lines are too long

BIN
assets/images/FPO-Detail.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
assets/images/FPO.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/images/HowItWorks.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets/images/carousel1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

BIN
assets/images/client1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/images/client2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
assets/images/client3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
assets/images/client4.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
assets/images/detect.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

BIN
assets/images/down_arrow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
assets/images/favicon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
assets/images/filter_arrow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

BIN
assets/images/header-bg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
assets/images/header.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/images/homePage.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
assets/images/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
assets/images/menu1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
assets/images/right_arrow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
assets/images/sensor-img.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

1
assets/js/common.js Executable file
View File

@ -0,0 +1 @@
function ConcatenateArray(e){for(var t="",r=0,a=e.length;r<a;r++)0==r?t=e[r]:t+=r==a-1?" & "+e[r]:", "+e[r];return t}function SanitizeToken(e){return e.replace(/(_\|_)/g," ")}function ResizeImage(e){var t=$(e).parent();t.width()/t.height()>e.width/e.height?$(e).css({height:"98%",width:"auto"}):$(e).css({height:"auto",width:"100%"}),$(e).show()}function getQueryVariable(e){for(var t=window.location.search.substring(1),r=t.split("&"),a=0;a<r.length;a++){var n=r[a].split("=");if(decodeURIComponent(n[0])==e)return decodeURIComponent(n[1])}return""}function PrepareLunrIndex(e){idx=elasticlunr.Index.load(e)}var idx,parsedObject;Handlebars.registerHelper("ifnonempty",function(e,t){return e=e||"",""!=e?t.fn(this):""}),Handlebars.registerHelper("ifMultipleElements",function(e,t){var r=!1;for(key in e)if(e[key].length>1){r=!0;break}return 1==r?t.fn(this):t.inverse(this)}),Handlebars.registerHelper("concat",function(e,t){var r="";try{a=e.length}catch(e){a=0}for(var a,n=0;n<a;n++)0==n?r=SanitizeToken(e[n]):r+=n==a-1?" & "+SanitizeToken(e[n]):", "+SanitizeToken(e[n]);return r}),Handlebars.registerHelper("ifeven",function(e,t){return e%2==0?t.fn(this):t.inverse(this)}),Handlebars.registerHelper("ifarray",function(e,t){return"[object Array]"===Object.prototype.toString.call(e)?t.fn(this):t.inverse(this)}),Handlebars.registerHelper("ifobject",function(e,t){return"[object Object]"===Object.prototype.toString.call(e)?t.fn(this):t.inverse(this)}),Handlebars.registerHelper("ifequal",function(e,t,r){return"[object Array]"===Object.prototype.toString.call(e)&&(e=e[0]),"[object Array]"===Object.prototype.toString.call(t)&&(t=t[0]),e.toString().toLowerCase()===t.toString().toLowerCase()?r.fn(this):r.inverse(this)}),Handlebars.registerHelper("getfirst",function(e,t){return"[object Array]"===Object.prototype.toString.call(e)&&e.length>0?e[0]:""}),Handlebars.registerHelper("getCategoryBacklinks",function(e,t){for(var r=e.join(","),a=0;a<e.length;a++)e[a]=e[a].toLowerCase();return r=e.join(","),'<a class="link" href="/findSensor.html?category='+encodeURIComponent(r)+'">See all </a>'}),Handlebars.registerHelper("getKitsBacklinks",function(e,t){return'<a class="link" href="/findSensor.html?category='+encodeURIComponent(e)+'">'+e+"</a>"}),Handlebars.registerHelper("language",function(e){return"Node.js"==e?"javascript":"C++"==e?"cpp":"Java"==e?"java":"Python"==e?"python":"C"==e?"cpp":void 0}),Handlebars.registerHelper("imagelinkDetail",function(e){return e?"https://raw.githubusercontent.com/intel-iot-devkit/upm/master/docs/images/"+e:"/assets/images/FPO-Detail.png"}),Handlebars.registerHelper("codeSnippetFolder",function(e){return"Node.js"==e?"javascript":"C++"==e?encodeURIComponent("c++"):"Java"==e?"java":"Python"==e?"python":"C"==e?"c":void 0}),Handlebars.registerHelper("sourceURL",function(e){switch(e){case"Java":return"http://iotdk.intel.com/docs/master/upm/java/group__";case"Python":return"http://iotdk.intel.com/docs/master/upm/python/pyupm_";case"C++":return"http://iotdk.intel.com/docs/master/upm/group__";case"Node.js":return"http://iotdk.intel.com/docs/master/upm/node/modules/";case"C":return"http://iotdk.intel.com/docs/master/upm/group__";default:return"http://iotdk.intel.com/docs/master/upm/group__"}}),Handlebars.registerHelper("imagelink",function(e){return e?"https://raw.githubusercontent.com/intel-iot-devkit/upm/master/docs/images/"+e:"/assets/images/FPO.png"});

2
assets/js/library/bootstrap.min.js vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
assets/js/library/handlebars.min.js vendored Executable file

File diff suppressed because one or more lines are too long

1
assets/js/library/highlight.js Executable file

File diff suppressed because one or more lines are too long

3
assets/js/library/jquery-2.2.4.min.js vendored Executable file

File diff suppressed because one or more lines are too long

8
assets/js/library/jquery-ui.min.js vendored Executable file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(e){e.fn.pajinate=function(a){function i(i){new_page=parseInt(d.data(u))-1,1==e(i).siblings(".active_page").prev(".page_link").length?(t(i,new_page),s(new_page)):a.wrap_around&&s(f-1)}function n(i){new_page=parseInt(d.data(u))+1,1==e(i).siblings(".active_page").next(".page_link").length?(l(i,new_page),s(new_page)):a.wrap_around&&s(0)}function s(e){e=parseInt(e,10);var i=parseInt(d.data(g));start_from=e*i,end_on=start_from+i;var n=o.hide().slice(start_from,end_on);n.show(),c.find(a.nav_panel_id).children(".page_link[longdesc="+e+"]").addClass("active_page "+m).siblings(".active_page").removeClass("active_page "+m),d.data(u,e);var s=parseInt(d.data(u)+1),l=p.children().size(),t=Math.ceil(l/a.items_per_page);c.find(a.nav_info_id).html(a.nav_label_info.replace("{0}",start_from+1).replace("{1}",start_from+n.length).replace("{2}",o.length).replace("{3}",s).replace("{4}",t)),_(),r(),void 0!==a.onPageDisplayed&&a.onPageDisplayed.call(this,e+1)}function l(i,n){var s=n;"none"==e(i).siblings(".active_page").siblings(".page_link[longdesc="+s+"]").css("display")&&h.each(function(){e(this).children(".page_link").hide().slice(parseInt(s-a.num_page_links_to_display+1),s+1).show()})}function t(i,n){var s=n;"none"==e(i).siblings(".active_page").siblings(".page_link[longdesc="+s+"]").css("display")&&h.each(function(){e(this).children(".page_link").hide().slice(s,s+parseInt(a.num_page_links_to_display)).show()})}function _(){h.children(".page_link:visible").hasClass("last")?h.children(".more").hide():h.children(".more").show(),h.children(".page_link:visible").hasClass("first")?h.children(".less").hide():h.children(".less").show()}function r(){h.children(".last").hasClass("active_page")?h.children(".next_link").add(".last_link").addClass("no_more "+b):h.children(".next_link").add(".last_link").removeClass("no_more "+b),h.children(".first").hasClass("active_page")?h.children(".previous_link").add(".first_link").addClass("no_more "+b):h.children(".previous_link").add(".first_link").removeClass("no_more "+b)}var d,p,c,o,h,f,u="current_page",g="items_per_page",v={item_container_id:".content",items_per_page:10,nav_panel_id:".page_navigation",nav_info_id:".info_text",num_page_links_to_display:20,start_page:0,wrap_around:!1,nav_label_first:"First",nav_label_prev:"Prev",nav_label_next:"Next",nav_label_last:"Last",nav_order:["first","prev","num","next","last"],nav_label_info:"Showing {0}-{1} of {2} results",show_first_last:!0,abort_on_small_lists:!1,jquery_ui:!1,jquery_ui_active:"ui-state-highlight",jquery_ui_default:"ui-state-default",jquery_ui_disabled:"ui-state-disabled"},a=e.extend(v,a),k=a.jquery_ui?a.jquery_ui_default:"",m=a.jquery_ui?a.jquery_ui_active:"",b=a.jquery_ui?a.jquery_ui_disabled:"";return this.each(function(){if(c=e(this),p=e(this).find(a.item_container_id),o=c.find(a.item_container_id).children(),a.abort_on_small_lists&&a.items_per_page>=o.size())return c;d=c,d.data(u,0),d.data(g,a.items_per_page);for(var v=p.children().size(),b=Math.ceil(v/a.items_per_page),w=a.show_first_last?'<a class="first_link '+k+'" href="">'+a.nav_label_first+"</a>":"",y=a.show_first_last?'<a class="last_link '+k+'" href="">'+a.nav_label_last+"</a>":"",x="",C=0;C<a.nav_order.length;C++)switch(a.nav_order[C]){case"first":x+=w;break;case"last":x+=y;break;case"next":x+='<a class="next_link '+k+'" href="">'+a.nav_label_next+"</a>";break;case"prev":x+='<a class="previous_link '+k+'" href="">'+a.nav_label_prev+"</a>";break;case"num":x+='<span class="ellipse less">...</span>';for(var j=0;b>j;)x+='<a class="page_link '+k+'" href="" longdesc="'+j+'">'+(j+1)+"</a>",j++;x+='<span class="ellipse more">...</span>'}h=c.find(a.nav_panel_id),h.html(x).each(function(){e(this).find(".page_link:first").addClass("first"),e(this).find(".page_link:last").addClass("last")}),h.children(".ellipse").hide(),h.find(".previous_link").next().next().addClass("active_page "+m),o.hide(),o.slice(0,d.data(g)).show(),f=c.find(a.nav_panel_id+":first").children(".page_link").size(),a.num_page_links_to_display=Math.min(a.num_page_links_to_display,f),h.children(".page_link").hide(),h.each(function(){e(this).children(".page_link").slice(0,a.num_page_links_to_display).show()}),c.find(".first_link").click(function(a){a.preventDefault(),t(e(this),0),s(0)}),c.find(".last_link").click(function(a){a.preventDefault();var i=f-1;l(e(this),i),s(i)}),c.find(".previous_link").click(function(a){a.preventDefault(),i(e(this))}),c.find(".next_link").click(function(a){a.preventDefault(),n(e(this))}),c.find(".page_link").click(function(a){a.preventDefault(),s(e(this).attr("longdesc"))}),s(parseInt(a.start_page)),_(),a.wrap_around||r()})}}(jQuery);

1
assets/js/library/lunr.js Executable file

File diff suppressed because one or more lines are too long

1
assets/js/library/prism.js Executable file

File diff suppressed because one or more lines are too long

1
assets/js/search.js Executable file
View File

@ -0,0 +1 @@
function GetLunrIndex(){$.ajax({cache:!0,url:"/assets/content/LunrIndex.json?_=2",type:"GET",dataType:"json",success:function(e){PrepareLunrIndex(e);var t="",n=getQueryVariable("category")||"";if(""!=n){var a=n.split(",");for(i=0;i<a.length;i++){var r=$('input[type="checkbox"][value="'+a[i]+'"]');r.prop("checked",!0);var o=r.parentsUntil(".panel-default",".panel-body");o.hasClass("read-more")&&o.siblings(".show-more").click()}t=PrepareFilter()}Search(t)},error:function(e){alert("Error! Please try again."+e.responseText),console.log(e)}})}function FilterLurData(){Search(PrepareFilter())}function PrepareFilter(){var e=[];return $filterCheckboxes.filter(":checked").length>0?$filterCheckboxes.filter(":checked").each(function(){var t=this.name.replace(/\s/g,"");e.hasOwnProperty(t)||(e[t]=[]),e[t].push(this.value.replace(/\s+/g,"_|_"))}):e=null,e}function Search(e){var t=null;if(e)for(var n in e){var a=Object(),r=new Object;r[n]={boost:1},a.fields=r;var o=[];o.push(idx.search(e[n].join(" "),a)),o.length>0&&(o=o[0],t?(t=t||[],t=Intersect(t,o)):t=o)}else{t=[];for(var n in idx.documentStore.docs)t.push(idx.documentStore.docs[n])}BindSensorResult(t)}function Intersect(e,t){for(var n=[],a=0;a<e.length;a++)for(var r=0;r<t.length;r++)if(e[a].ref===t[r].ref){n.push(e[a]);break}return n}function bindPagination(){$(".page_navigation").show(),$("#findSensor").pajinate({num_page_links_to_display:6,items_per_page:50})}function hidePagination(){$(".page_navigation").hide()}function BindSensorResult(e){var t=Handlebars.compile($("#findSensorDetail").html()),n=$("#findSensor .content");n.html("");var a=[];if(e.length>0){if(e[0].ref)for(var r=0;r<e.length;r++)a.push(e[r].doc);else a=e;n.html(t(a)),bindPagination()}else{n.html('<div class="no-results">No sensors match the selected filters.</div>'),hidePagination()}}function GetFacetsData(){$.ajax({cache:!0,url:"/assets/content/facets.json?_=2",type:"GET",dataType:"json",success:function(e){PrepareFacetOptions(e),$filterCheckboxes=$('#leftSection input[type="checkbox"]')},error:function(e){alert("Error! Please try again."+e.responseText),console.log(e)}})}function PrepareFacetOptions(e){var t=$("#accordianTemplate").html(),n=Handlebars.compile(t),a=n(e);$("#accordion").html(a),checkSeeMoreOption()}function checkSeeMoreOption(){var e=$(".panel-body");for(i=0;i<e.length;i++)e[i].children.length>5?(e[i].nextElementSibling.style.display="block",e[i].style.height="160px"):e[i].style.height="auto"}function LoadMoreData(){$(this).parent().find(".panel-body").toggleClass("read-less").toggleClass("read-more"),"See more..."==$(this).text()?$(this).text("See less..."):$(this).text("See more...")}var searchterm=[];$(document).ready(function(){GetFacetsData(),GetLunrIndex()}),jQuery.ui.autocomplete.prototype._resizeMenu=function(){this.menu.element.outerWidth(this.element.outerWidth())},$("#searchBox").length>0&&($("#searchBox").autocomplete({source:function(e,t){var n=idx.search(e.term,{fields:{PartNumbers:{boost:2},Brief:{boost:2}},expand:!0});if(0==n.length){var a=new Object;a.ref=-1,n.push(a)}t(n)},focus:function(e,t){return(t.item.ref||"").length>0&&$("#searchBox").val(t.item.doc.Brief),!1},select:function(e,t){e.preventDefault(),(t.item.ref||"").length>0&&(location.href="/sensorDetail.html?name="+t.item.ref)}}).autocomplete("instance")._renderItem=function(e,t){return-1!=t.ref?$("<li>").addClass("ui-menu-item").attr("data-id",t.ref).append("<div class='ui-menu-item-wrapper'>"+t.doc.Brief+" ("+ConcatenateArray(t.doc.PartNumbers)+")</div>").appendTo(e):$("<li>").addClass("ui-autocomplete-noresult").append("<div class='ui-menu-item-wrapper'>No Results Found !!</div>").appendTo(e)},$(window).resize(function(){$("#searchBox").autocomplete("close")})),$("body").on("click",".show-more",LoadMoreData),$("#menu-hide").click(function(){$(".left-container").hasClass("open")?$(".left-container").removeClass("open"):$(".left-container").addClass("open")}),$(document).ready(function(){$("#menu-hide").click(function(){$(this).toggleClass("open")})});

1
assets/js/sensorDetail.js Executable file
View File

@ -0,0 +1 @@
function loadSensorDetailData(a,e){for(var t=0;t<e.length;t++){var l=e[t]["Sensor Class"];for(var r in l)if(r==a){var i=l[a];i.Library=e[t].Library;var o=$("#sensorDetailPageTemplate").html(),s=Handlebars.compile(o),n=s(i);$("#sensorDetailPage").html(n)}}}function GetSensorData(){$.ajax({cache:!0,url:"/assets/content/sensorDetail.json?_=2",type:"GET",dataType:"json",success:function(a){loadSensorDetailData(getQueryVariable("name"),a),InitializeCarousel(a),InitializeCodeSample()},error:function(a){alert("Error! Please try again."+a.responseText),console.log(a)}})}function InitializeCarousel(a){$(".carousel .item").length?($(".carousel").find(".item").first().addClass("active"),$(".carousel").find(".carousel-indicators li").first().addClass("active"),$(".carousel").carousel({interval:2e3})):$("#carousel-section").hide()}function InitializeCodeSample(){$('a[data-toggle="tab"]').on("show.bs.tab",function(a){loadCodeSamples($(a.target).parent())}),loadCodeSamples($(".nav-pills li:first"))}function loadCodeSamples(a){var e=a;"false"==(e.attr("data-flag")||"false")&&$.ajax({cache:!1,url:"https://raw.githubusercontent.com/intel-iot-devkit/upm/master/examples/"+a.attr("data-parent")+"/"+a.attr("data-value").split(",")[0],success:function(a,t,l){var r=a;r="python"==e.attr("data-parent")?a.replace(/(#.*?\n){4,}/g,""):a.replace(/\/\*[^]*?\*\//g,""),r=r.replace(/^[\s]*$\n/m,""),$("#"+e.attr("data-id")).find("code").text(r),hljs.highlightBlock($("#"+e.attr("data-id")).find("code")[0]),e.attr("data-flag","true")}})}$(document).ready(function(){GetSensorData()});

23
docker-compose.yaml Normal file
View File

@ -0,0 +1,23 @@
version: '3'
services:
app:
image: upm-site
build:
context: .
dockerfile: Dockerfile
args:
- http_proxy
- https_proxy
- no_proxy
environment:
- http_proxy
- https_proxy
- no_proxy
volumes:
- .:/usr/src/app
ports:
- 1234:1234
- 3001:3001
command: bash -c 'npm install && bundle install && gulp serve'

1
feed.xml Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.4.3">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2018-11-07T21:31:58+00:00</updated><id>/</id></feed>

1
findSensor.html Normal file

File diff suppressed because one or more lines are too long

65
howitworks.html Normal file

File diff suppressed because one or more lines are too long

1
index.html Normal file

File diff suppressed because one or more lines are too long

9867
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
var shjs = require('shelljs');
var path = require('path');
var assert = require('assert');
/**
* @returns {string} A relative path from this repository root
*/
function getRelativePath(absolutePath) {
return path.relative(process.cwd(), absolutePath)
}
// Find all .json files in upm/src directory
var upmSrcPath = path.resolve(__dirname, '../upm/src');
console.log('Finding json files in ' + getRelativePath(upmSrcPath));
var jsonFiles = shjs.find(upmSrcPath).filter(function(file) {
return file.match(/\.json$/);
});
// Report the ammount of json files found in upm/src
console.log('Found ' + jsonFiles.length + ' json files');
// Load _assets/content/sensorDetail.json
var sensorDetailPath = path.resolve(__dirname, '../_assets/content/sensorDetail.json');
console.log('Loading sensor details from ' + getRelativePath(sensorDetailPath));
var sensorDetailJson = require(sensorDetailPath);
// Check if the ammount of json files match the sensor details
console.log('Checking if sensor detail contains an entry for every json file in ' + getRelativePath(upmSrcPath));
console.log('jsonFiles.length: ' + jsonFiles.length);
console.log('sensorDetailJson.length: ' + sensorDetailJson.length);
var errorMessage = 'Sensor Details and Json files count does not match.';
assert.equal(jsonFiles.length, sensorDetailJson.length, errorMessage);

1
sensorDetail.html Normal file

File diff suppressed because one or more lines are too long

508
upm/CMakeLists.txt Normal file
View File

@ -0,0 +1,508 @@
cmake_minimum_required (VERSION 2.8.11)
project (upm)
# Before going any further, define build options
option (BUILDDOC "Build all doc" OFF)
option (BUILDCPP "Build CPP sensor libraries" ON)
option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF)
option (BUILDSWIGPYTHON "Build swig python modules" ON)
option (BUILDSWIGNODE "Build swig node modules" ON)
option (BUILDSWIGJAVA "Build swig java modules" OFF)
option (BUILDCORDOVA "Build cordova bindings" OFF)
option (BUILDEXAMPLES "Build C/C++/JAVA examples" OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
option (NPM "Generate NPM/GYP tarballs" OFF)
option (BUILDTESTS "Generate check-ups for upm" OFF)
option (WERROR "Make all warnings into errors." ON)
# Warn if building in source root
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message (WARNING "Building into sources dir can be risky, prefer other directory")
endif ()
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
# Check if provided compiler supports target flag
# usage:
# compiler_flag_supported(C/CXX is_supported flag)
#
# The result of output_variable is set to the sanitized flag name if supported
# or cleared if the flag is not supported.
function (compiler_flag_supported compiler output_variable flag)
# Currently only C and CXX compile flags, clear and return if not supported
if (NOT ${compiler} MATCHES "C|CXX")
message (WARNING "Unknown compiler: ${compiler}")
set ("${output_variable}" "" PARENT_SCOPE)
return ()
endif (NOT ${compiler} MATCHES "C|CXX")
string (REPLACE "-" "_" SANITIZED_FLAG_NAME "${flag}")
string (REPLACE "/" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
string (REPLACE "=" "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
string (REPLACE " " "_" SANITIZED_FLAG_NAME "${SANITIZED_FLAG_NAME}")
# Disable messages from CHECK_C/XX_COMPILER_FLAGS macros
set (CMAKE_REQUIRED_QUIET_SAVED ${CMAKE_REQUIRED_QUIET})
set (CMAKE_REQUIRED_QUIET ON)
# C or CXX?
if (${compiler} STREQUAL C)
CHECK_C_COMPILER_FLAG("${flag}" HAS_${SANITIZED_FLAG_NAME})
elseif (${compiler} STREQUAL CXX)
CHECK_CXX_COMPILER_FLAG("${flag}" HAS_${SANITIZED_FLAG_NAME})
endif ()
# Restore previous CMAKE_REQUIRED_QUIET state
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVED})
# Does the compiler support this flag?
if (HAS_${SANITIZED_FLAG_NAME})
set ("${output_variable}" "${SANITIZED_FLAG_NAME}" PARENT_SCOPE)
else ()
set ("${output_variable}" "" PARENT_SCOPE)
endif()
endfunction ()
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
# Add scoped compile flag/s using add_compile_options.
# This function checks to see if each flag is supported
# by the compiler before setting the compile option.
function (upm_add_compile_flags compiler)
set (_TMP_COMPILER_FLAGS "")
# Iterate the flags, check if supported
foreach (flag ${ARGN})
# Check if this compile flag is supported
compiler_flag_supported(${compiler} is_supported ${flag})
# Add if supported, warn and skip if not supported
if (is_supported)
set (_TMP_COMPILER_FLAGS "${_TMP_COMPILER_FLAGS} ${flag}")
else ()
message (WARNING "${compiler} compiler does not support flag \"${flag}\"")
endif ()
endforeach (flag ${ARGN})
# Set the variable in the parent scope
set (CMAKE_${compiler}_FLAGS "${CMAKE_${compiler}_FLAGS} ${_TMP_COMPILER_FLAGS}" PARENT_SCOPE)
endfunction ()
# Compiler flags common to both C and CXX
# Enable -Wall
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
set (C_CXX_WARNING_FLAGS -Wall
-Wno-misleading-indentation
-Wno-strict-aliasing
-Wno-deprecated-declarations # Temp fix for MRAA deprecated methods
)
# Warnings as errors?
if (WERROR)
list (APPEND C_CXX_WARNING_FLAGS -Werror)
message (STATUS "Warnings as errors enabled (-Werror), disable with -DWERROR=off")
endif (WERROR)
# Set C compiler warning flags at top-level scope and emit a warning about
# unsupported flags
upm_add_compile_flags(C ${C_CXX_WARNING_FLAGS}
-Winit-self
-Wimplicit
-Wsign-compare
-Wmissing-parameter-type)
# Set CXX compiler warning flags at top-level scope and emit a warning about
# unsupported flags
upm_add_compile_flags(CXX ${C_CXX_WARNING_FLAGS}
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wsign-compare
-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 2.0.0)
pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM})
# Also, get full path to the mraa library
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)
# Check for MODBUS
pkg_check_modules (MODBUS libmodbus>=3.1.2)
# Check for OPENZWAVE
pkg_check_modules (OPENZWAVE libopenzwave)
# Find JPEG
find_package (JPEG)
# Find nodejs
if (BUILDSWIGNODE)
find_package (Node REQUIRED)
if (BUILDTESTS)
find_package (Npm REQUIRED)
endif (BUILDTESTS)
endif (BUILDSWIGNODE)
# Find JAVA/JNI
if (BUILDSWIGJAVA)
find_package (Java REQUIRED)
find_package (JNI REQUIRED)
pkg_check_modules (MRAAJAVA REQUIRED mraajava>=${MRAA_MINIMUM})
# Also, get full path to the mraajava library
find_library(MRAAJAVA_LIBRARY NAMES mraajava HINTS ${MRAA_LIBDIR})
endif (BUILDSWIGJAVA)
# Cordova binding
if (BUILDCORDOVA)
if (NOT BUILDSWIGJAVA)
message(FATAL_ERROR "Cordova bindings require JAVA packages, please enable BUILDSWIGJAVA (-DBUILDSWIGJAVA=on).")
endif()
find_package (Node REQUIRED)
find_package (Npm REQUIRED)
find_package (UpmCordovaGenerator 0.2.1 REQUIRED)
endif (BUILDCORDOVA)
# Find swig if any wrapper is enabled
if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA)
find_package (SWIG 3.0.5 REQUIRED)
include (${SWIG_USE_FILE})
endif ()
# Python is required for swig generated python and for UPM tests.
# The UPM build can generated modules for both python2 AND python3
# with the corresponding PYTHONLIBS. Currently, BUILDTESTS has a
# hard dependency on the PYTHON2INTERP.
# OpenCV python detect will attempt to find python2/3
if (BUILDSWIGPYTHON OR BUILDTESTS)
include (cmake/modules/OpenCVDetectPython.cmake)
# Fail if building tests but no python interpreter was found
if (BUILDTESTS AND NOT PYTHON2INTERP_FOUND)
message(FATAL_ERROR "BUILDTESTS=ON requires the python2 interpreter")
endif (BUILDTESTS AND NOT PYTHON2INTERP_FOUND)
# Fail if no LIBS were found
if (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND)
message(FATAL_ERROR "At least one python lib is required")
endif (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND)
endif (BUILDSWIGPYTHON OR BUILDTESTS)
# Which versions of python were found?
if (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON)
message(STATUS "Building python2 modules with python-${PYTHON2LIBS_VERSION_STRING}")
endif (PYTHON2LIBS_FOUND AND BUILDSWIGPYTHON)
if (PYTHON3LIBS_FOUND AND BUILDSWIGPYTHON)
message(STATUS "Building python3 modules with python-${PYTHON3LIBS_VERSION_STRING}")
endif (PYTHON3LIBS_FOUND AND BUILDSWIGPYTHON)
# Python2 is currently required for python documentation
if (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND)
message(FATAL_ERROR "Failed to find python2 interpreter which is required "
"to build python documentation.")
endif (BUILDSWIGPYTHON AND BUILDDOC AND NOT PYTHON2INTERP_FOUND)
# Set CMAKE_INSTALL_LIBDIR if not defined
include(GNUInstallDirs)
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
# Make a version file containing the current version from git.
include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
# If git_describe fails, use a dirty version
if (${VERSION} MATCHES -NOTFOUND)
set (VERSION "v1.7.1")
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 ()
message (STATUS "UPM Version ${VERSION}")
# Parse the version information into pieces.
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${VERSION}")
string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+\\-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
if ("${VERSION_COMMIT}" MATCHES "^v.*")
set (VERSION_COMMIT "")
endif()
set (upm_VERSION_MAJOR ${VERSION_MAJOR})
set (upm_VERSION_MINOR ${VERSION_MINOR})
set (upm_VERSION_PATCH ${VERSION_PATCH})
set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH})
# Detect arch
include (TargetArch)
target_architecture (DETECTED_ARCH)
message (STATUS "Target arch is ${DETECTED_ARCH}")
# enable c++11 standards support unconditionally
include(CheckCXXCompilerFlag)
if (CMAKE_VERSION VERSION_LESS "3.1")
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(FATAL_ERROR "A C++11 compliant compiler is required to build UPM.")
endif()
else()
# 3.1+ uses this generic method to enable c++11
set (CMAKE_CXX_STANDARD 11)
set (CXX_STANDARD_REQUIRED ON)
set (CXX_EXTENSIONS OFF)
endif()
include(CheckCCompilerFlag)
if (CMAKE_VERSION VERSION_LESS "3.1")
CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11)
if (COMPILER_SUPPORTS_C11)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
else()
message(FATAL_ERROR "A C11 compliant C compiler is required to build UPM.")
endif()
else()
# 3.1+ uses this generic method to enable c11
set (CMAKE_C_STANDARD 11)
set (C_STANDARD_REQUIRED ON)
set (C_EXTENSIONS OFF)
endif()
# The doc target depends on the C/C++ source and all libraries
#
# doc
# > src
# > include
# > libupm_sensor0
# > libupm_sensor1
# > ...
# > libupm_sensor_n
#
# The pydoc target builds documentation with sphinx via inspection by loading
# each python2 module. Those modules must include the CXX documentation via
# a monolithic swig file generated by doxy2swig
#
# pydoc
# > _pyupm_sensor0_python2
# > libupm_sensor0
# > doxy2swig
#
# The doxy2swig target is dependent upon the doc target IF BUILDDOC=ON,
#
# doxy2swig
# > BUILDDOC=ON> doc
#
# The jsdoc target builds js documentation via yuidoc and only requires
# the doc target
#
# jsdoc > doc
#
function (CreateDocumentationTargets)
# Add a target to generate API documentation with Doxygen
find_package (Doxygen 1.8 REQUIRED)
if (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
if (BUILDSWIGJAVA)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-java @ONLY)
endif()
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
foreach(PNG_FILE ${PNG_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
endforeach()
# Custom command to run doxygen (note depends on ALL UPM C++ targets)
add_custom_command (
OUTPUT ${CMAKE_BINARY_DIR}/xml/index.xml
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${UPM_TARGETS_CXX}
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND tar -czf html/xml.tar.gz -C xml .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating C/C++ API documentation with Doxygen"
VERBATIM)
add_custom_target(doc DEPENDS ${CMAKE_BINARY_DIR}/xml/index.xml)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Doxygen. API doc will not be generated")
endif (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_GREATER "1.8")
# 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.
# Since python2 is required for documentation, only copy from python2 paths, this
# ensures that sphinx doesn't run across python2 and python3 binaries. When running
# the sphinx tools, explicitly run from the python2 interpreter (tested with the sphinx
# 1.3.6 python2 and python3 modules).
if(BUILDSWIGPYTHON)
# Generate python module documentation from doxygen collateral
#
# doxygen index.xml -> doxy2swig.py -> pyupm_doxy2swig.i
add_custom_command (
OUTPUT ${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i
COMMAND ${PYTHON2_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/doxy2swig.py
${CMAKE_BINARY_DIR}/xml/index.xml --quiet
${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i
COMMENT "Generating pyupm_doxy2swig.i from Doxygen output for use by SWIG"
DEPENDS doc
VERBATIM)
add_custom_target(pyupm_doxy2swig DEPENDS ${CMAKE_BINARY_DIR}/src/pyupm_doxy2swig.i)
foreach (_python2_target ${UPM_TARGETS_PYTHON2})
add_dependencies(${_python2_target} pyupm_doxy2swig)
endforeach()
find_package (Sphinx 1.3 REQUIRED)
if (SPHINX_FOUND AND SPHINX_VERSION VERSION_GREATER "1.3")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY)
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp
COMMAND rm -r -f ${CMAKE_BINARY_DIR}/pyupm && mkdir -p ${CMAKE_BINARY_DIR}/pyupm
COMMAND find ${CMAKE_BINARY_DIR}/src -path "*python${MIN_VER_PYTHON2}/_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
COMMAND find ${CMAKE_BINARY_DIR}/src -path "*python${MIN_VER_PYTHON2}/pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
COMMAND ${PYTHON2_EXECUTABLE} ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
# TODO: use a separate cmake FILE module for string replacement instead
COMMAND ${PYTHON2_EXECUTABLE} ${SPHINX_EXECUTABLE} -b html pydoc html/python
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Python API documentation with Sphinx"
DEPENDS doc ${UPM_TARGETS_PYTHON2}
VERBATIM)
add_custom_target(pydoc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pydoc.stamp)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Sphinx. Python API doc will not be generated")
endif ()
endif(BUILDSWIGPYTHON)
# Check if Yuidoc is installed and add target for API documentation
if(BUILDSWIGNODE)
find_package (Yuidoc 0.10 REQUIRED)
if (YUIDOC_FOUND AND YUIDOC_VERSION VERSION_GREATER "0.10")
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp
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
COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Javascript API documentation with Yuidoc"
DEPENDS doc
VERBATIM)
add_custom_target(jsdoc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/jsdoc/jsdoc.stamp)
else ()
message (SEND_ERROR "ERROR - Failed to find a compatible version of Yuidoc. Node.js API doc will not be generated")
endif ()
endif(BUILDSWIGNODE)
endfunction()
if (IPK)
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
else ()
# Debian uses amd64 to denote x86_64
if (DETECTED_ARCH STREQUAL "x86_64")
set (TARGET_ARCH "amd64")
else ()
set (TARGET_ARCH ${DETECTED_ARCH})
endif ()
endif ()
message (STATUS "Package arch is ${TARGET_ARCH}")
set(CPACK_GENERATOR "DEB")
set(OPKG_ARCH ${TARGET_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
set(upm_PACKAGE_ON_TAG ".")
if ("${VERSION_COMMIT}" STREQUAL "")
set(upm_PACKAGE_ON_TAG "")
endif()
set(CPACK_PACKAGE_VERSION
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_NAME "upm")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "mraa (>= ${MRAA_VERSION})")
set(CPACK_DEBIAN_PACKAGE_PROVIDES "upm-dev, upm-dbg, upm-doc")
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
include (CPack)
endif()
if (RPM)
message (STATUS "RPM packaging enabled for ${DETECTED_ARCH}")
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "upm")
set(upm_PACKAGE_ON_TAG ".")
if ("${VERSION_COMMIT}" STREQUAL "")
set(upm_PACKAGE_ON_TAG "")
endif()
set(CPACK_PACKAGE_VERSION
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_REQUIRES "mraa >= ${MRAA_VERSION}")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
EXECUTE_PROCESS(COMMAND rpm --showrc
COMMAND grep -E "dist[[:space:]]*\\."
COMMAND sed -e "s/^.*dist\\s*\\.//"
COMMAND tr \\n \\t
COMMAND sed -e s/\\t//
OUTPUT_VARIABLE DIST_TAG)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${DIST_TAG}.${DETECTED_ARCH}")
include(CPack)
endif()
# UPM common headers
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)
# UPM examples
add_subdirectory (examples)
# Python interp is previously found if BUILDTESTS=ON
if (BUILDTESTS)
enable_testing ()
add_subdirectory (tests)
endif()
# Setup documentation AFTER all source targets have been added
if (BUILDDOC)
CreateDocumentationTargets()
endif()
# Install C headers
install(DIRECTORY include/ DESTINATION include/upm
COMPONENT ${CMAKE_PROJECT_NAME}-dev
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")

21
upm/LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright © 2014-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.

147
upm/README.md Normal file
View File

@ -0,0 +1,147 @@
<p align="center">
<img src="https://github.com/intel-iot-devkit/upm/blob/master/docs/icons/upm_logo.png" height="150px" width="auto" algt="UPM Logo"/>
</p>
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
==============
The UPM repository provides software drivers for a wide variety of commonly
used sensors and actuators. These software drivers interact with the
underlying hardware platform (or microcontroller), as well as with the attached
sensors, through calls to [MRAA](https://github.com/intel-iot-devkit/mraa) APIs.
Programmers can access the interfaces for each sensor by including the sensors
corresponding header file and instantiating the associated sensor class. In the
typical use case, a constructor initializes the sensor based on parameters that
identify the sensor, the I/O protocol used and the pin location of the sensor.
We endorse additions that implement the generic C and C++ interfaces provided
with the libraries. Multiple sensor and actuator types have been defined, for
instance:
* Light controller
* Light sensor
* Temperature sensor
* Humidity sensor
* Pressure sensor
* Gas sensor
* Analog to digital converter
The developer community is welcome to submit feedback on existing categories or
suggest new ones.
### Example
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_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(MMA7660_AUTOSLEEP_64);
// place device into active mode
accel->setModeActive();
while (shouldRun)
{
float ax, ay, az;
accel->getAcceleration(&ax, &ay, &az);
cout << "Acceleration: x = " << ax
<< "g y = " << ay
<< "g z = " << az
<< "g" << endl;
usleep(500000);
}
```
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
Multi-sensor samples for the starter and specialized kits can be found in the
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
### Supported Sensors
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
You can also refer to the [Intel® IoT Developer Zone](https://software.intel.com/iot/hardware/sensors).
### IDE Support
The UPM sensor libraries are directly supported by the IDEs listed on the Intel®
Developer Zone Tools & IDEs page.
<a href="https://software.intel.com/iot/tools"><img src="docs/icons/iss.png"/></a>
Intel® System Studio integration offers IoT specific features such as a sensor explorer,
library sync tools and the ability to easily import existing projects and samples that
use the UPM libraries. For further details please refer to the IoT User Guides on IDZ.
### Installing UPM
Find notes on how to install UPM on various OS'es on this [page](docs/installing.md).
### Building UPM
See building documentation [here](docs/building.md).
[![Build Status](https://travis-ci.org/intel-iot-devkit/upm.svg?branch=master)](https://travis-ci.org/intel-iot-devkit/upm)
### Making your own UPM module
A quick way to add a new sensor driver is to port existing code from another
platform (e.g. Arduino) and swap the IO calls to the MRAA API. This of course
assumes either ownership of the original code or licensing that allows
unrestricted redistribution.
The [porting](docs/porting.md) section has more information on this process,
and there is an example available based on the max31855 [sensor](docs/max31855.md).
Read more on creating Java [bindings](docs/creating_java_bindings.md) for your
new driver.
### Guidelines and rules for new UPM contributions
Before you begin development, take a look at our naming [conventions](docs/naming.md).
The name you pick for a newly added sensor needs to be unique in the UPM library.
Then, please go over this short set of rules for new [contributions](docs/contributions.md).
Make sure you add yourself as an author on every new code file submitted.
If you are providing a fix with significant changes, feel free to add yourself
as a contributor. Signing-off your commits is mandatory.
Documenting your code is also a big part of the task. We have a strict set of
tags used to classify our sensors and their capabilities. You can find out more
about this in our [section](docs/documentation.md) on documenting a sensor API.
Finally, if you really want to ensure consistency with the rest of the library,
and the intel-iot-devkit repositories in general, take a look at our extensive
[author guide](docs/guidelines.md).
API Documentation
==============
<a href="http://iotdk.intel.com/docs/master/upm"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/java"><img src="docs/icons/java.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
### API Compatibility
Even if we try our best not to, every once in a while we are forced to modify
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** - Several important API changes are currently underway for some of our
widely used libraries including `libupm-grove`
### Changelog
Version changelog [here](docs/changelog.md).
### Known Limitations
List of known limitations [here](docs/knownlimitations.md).

View File

@ -0,0 +1,25 @@
# this toolchain file comes from gnuradio project
set( CMAKE_SYSTEM_NAME Linux )
#set( CMAKE_C_COMPILER $ENV{CC} )
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
# for java
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)

View File

@ -0,0 +1,222 @@
# - The builtin (binary) CPack Deb generator (Unix only)
# CPackDeb may be used to create Deb package using CPack.
# CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
#
# However CPackRPM has specific features which are controlled by
# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on
# the wiki:
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
# However as a handy reminder here comes the list of specific variables:
#
# CPACK_DEBIAN_PACKAGE_NAME
# Mandatory : YES
# Default : CPACK_PACKAGE_NAME (lower case)
# The debian package summary
# CPACK_DEBIAN_PACKAGE_VERSION
# Mandatory : YES
# Default : CPACK_PACKAGE_VERSION
# The debian package version
# CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# Mandatory : YES
# Default : Output of dpkg --print-architecture or i386
# The debian package architecture
# CPACK_DEBIAN_PACKAGE_DEPENDS
# Mandatory : NO
# Default : -
# May be used to set deb dependencies.
# CPACK_DEBIAN_PACKAGE_MAINTAINER
# Mandatory : YES
# Default : CPACK_PACKAGE_CONTACT
# The debian package maintainer
# CPACK_DEBIAN_PACKAGE_DESCRIPTION
# Mandatory : YES
# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY
# The debian package description
# CPACK_DEBIAN_PACKAGE_SECTION
# Mandatory : YES
# Default : 'devel'
# The debian package section
# CPACK_DEBIAN_PACKAGE_PRIORITY
# Mandatory : YES
# Default : 'optional'
# The debian package priority
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
# CPack script for creating Debian package
# Author: Mathieu Malaterre
#
# http://wiki.debian.org/HowToPackageForDebian
IF(CMAKE_BINARY_DIR)
MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
ENDIF(CMAKE_BINARY_DIR)
IF(NOT UNIX)
MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
ENDIF(NOT UNIX)
# Let's define the control file found in debian package:
# Binary package:
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
# DEBIAN/control
# debian policy enforce lower case for package name
# Package: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
# Version: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
IF(NOT CPACK_PACKAGE_VERSION)
MESSAGE(FATAL_ERROR "Debian package requires a package version")
ENDIF(NOT CPACK_PACKAGE_VERSION)
SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
# Architecture: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# There is no such thing as i686 architecture on debian, you should use i386 instead
# $ dpkg --print-architecture
FIND_PROGRAM(DPKG_CMD dpkg)
IF(NOT DPKG_CMD)
MESSAGE(WARNING "Can not find dpkg in your path, default to i386.")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
ENDIF(NOT DPKG_CMD)
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
# have a look at GET_PROPERTY(result GLOBAL PROPERTY ENABLED_FEATURES),
# this returns the successful FIND_PACKAGE() calls, maybe this can help
# Depends:
# You should set: DEBIAN_PACKAGE_DEPENDS
# TODO: automate 'objdump -p | grep NEEDED'
IF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
MESSAGE(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
# Maintainer: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
IF(NOT CPACK_PACKAGE_CONTACT)
MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
ENDIF(NOT CPACK_PACKAGE_CONTACT)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
# Description: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
# Section: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
# Priority: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
# Recommends:
# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
# Suggests:
# You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
# Typical examples are:
# - conffiles
# - postinst
# - postrm
# - prerm"
# Usage:
# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
# For debian source packages:
# debian/control
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
# .dsc
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
# Builds-Depends:
#IF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
# SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
# "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
# )
#ENDIF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
# Description: (mandatory)
#if(NOT CPACK_SECTION)
# message(FATAL_ERROR "opkg package requires a package section")
#endif(NOT CPACK_SECTION)
# Package for opkg
FIND_PROGRAM(OPKG_CMD opkg-build)
if( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
message("CPack: opkg-build not found. Skipping packaging")
else( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
SET(CPACK_OPKG_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
FILE(MAKE_DIRECTORY ${CPACK_OPKG_ROOTDIR}/CONTROL)
set(CPACK_OPKG_CONTROL_FILE "${CPACK_OPKG_ROOTDIR}/CONTROL/control")
# Write controlfile
FILE(WRITE ${CPACK_OPKG_CONTROL_FILE}
"Package: ${CPACK_PACKAGE_NAME}
Version: ${CPACK_PACKAGE_VERSION}
Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}
Section: ${CPACK_DEBIAN_PACKAGE_SECTION}
Priority: optional
Maintainer: ${CPACK_DEBIAN_PACKAGE_MAINTAINER}
Depends: ${CPACK_DEBIAN_PACKAGE_DEPENDS}
Provides: ${CPACK_DEBIAN_PACKAGE_PROVIDES}
Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES}
Conflicts: ${CPACK_DEBIAN_PACKAGE_CONFLICTS}
Source: https://github.com/intel-iot-devkit/upm
#Essential: no
")
set(OPKG_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
execute_process(
COMMAND "${OPKG_CMD}" "-o" "0" "${CPACK_PACKAGE_FILE_NAME}" "."
RESULT_VARIABLE _result
OUTPUT_VARIABLE _res_output
ERROR_VARIABLE _res_error
WORKING_DIRECTORY ${CPACK_TOPLEVEL_DIRECTORY}
)
if(${_result})
message("Result '${_result}'")
message("Output '${_res_output}'")
message("Error '${_res_error}'")
else(${_result})
message("CPack: Package ${OPKG_FILE_NAME}.ipk generated.")
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
file(RENAME ${CPACK_TOPLEVEL_DIRECTORY}/${OPKG_FILE_NAME}.ipk ${CPACK_BINARY_DIR}/${OPKG_FILE_NAME}.ipk)
endif(${_result})
endif( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )

View File

@ -0,0 +1,99 @@
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
macro(add_include_dir dir)
if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
endif()
endmacro()
find_program (NODEJS_EXECUTABLE NAMES node nodejs
HINTS
$ENV{NODE_DIR}
PATH_SUFFIXES bin
DOC "Node.js interpreter")
include (FindPackageHandleStandardArgs)
# If compat-libuv package exists, it must be at start of include path
find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
if (UV_ROOT_DIR)
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
add_include_dir(${UV_ROOT_DIR})
endif()
# Now look for node. Flag an error if not found
find_path (NODE_ROOT_DIR
NAMES node.h src/node.h
PATH_SUFFIXES node node4 node5 node6 node7 node8 nodejs
PATHS /usr/include /usr/local/include)
if (NODE_ROOT_DIR)
add_include_dir(${NODE_ROOT_DIR})
add_include_dir(${NODE_ROOT_DIR}/deps/uv/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}/include/deps/v8/include)
add_include_dir(${NODE_ROOT_DIR}/include/node)
add_include_dir(${NODE_ROOT_DIR}/include/src)
add_include_dir(${NODE_ROOT_DIR}/src)
else()
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - node.h not found")
endif()
# Check that v8.h is in NODEJS_INCLUDE_DIRS
find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
if (NOT V8_ROOT_DIR)
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - v8.h not found")
endif()
# Check that uv.h is in NODEJS_INCLUDE_DIRS
find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
if (NOT UV_ROOT_DIR)
unset(NODEJS_INCLUDE_DIRS)
message(ERROR " - uv.h not found")
endif()
if (NODEJS_EXECUTABLE)
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _NODE_VERSION_RESULT)
execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
OUTPUT_VARIABLE _V8_VERSION
RESULT_VARIABLE _V8_RESULT)
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
string (REPLACE "v" "" NODE_VERSION_STRING "${_VERSION}")
string (REPLACE "." ";" _VERSION_LIST "${NODE_VERSION_STRING}")
list (GET _VERSION_LIST 0 NODE_VERSION_MAJOR)
list (GET _VERSION_LIST 1 NODE_VERSION_MINOR)
list (GET _VERSION_LIST 2 NODE_VERSION_PATCH)
set (V8_VERSION_STRING ${_V8_VERSION})
string (REPLACE "." ";" _V8_VERSION_LIST "${_V8_VERSION}")
string (REPLACE "." "" V8_DEFINE_STRING "${_V8_VERSION}")
string (STRIP ${V8_DEFINE_STRING} V8_DEFINE_STRING)
list (GET _V8_VERSION_LIST 0 V8_VERSION_MAJOR)
list (GET _V8_VERSION_LIST 1 V8_VERSION_MINOR)
list (GET _V8_VERSION_LIST 2 V8_VERSION_PATCH)
# we end up with a nasty newline so strip everything that isn't a number
string (REGEX MATCH "^[0-9]*" V8_VERSION_PATCH ${V8_VERSION_PATCH})
else ()
set (NODE_VERSION_STRING "0.10.30")
set (NODE_VERSION_MAJOR "0")
set (NODE_VERSION_MINOR "10")
set (NODE_VERSION_PATCH "30")
set (V8_VERSION_MAJOR "3")
set (V8_VERSION_MINOR "28")
set (V8_VERSION_PATCH "72")
set (V8_VERSION_STRING "3.28.72")
message (STATUS "defaulted to node 0.10.30")
endif ()
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
mark_as_advanced (NODEJS_EXECUTABLE)
find_package_handle_standard_args (Nodejs
REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS
VERSION_VAR NODE_VERSION_STRING)
message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")")
endif ()

View File

@ -0,0 +1,71 @@
# FindNpm
# --------
#
# Find npm
#
# This module finds an installed npm. It sets the following variables:
#
# NPM_FOUND - Set to true if npm is found
# NPM_DIR - The directory where npm is installed
# NPM_GLOBAL_NODE_MODULE_DIR - The global node_modules directory
# NPM_EXECUTABLE - The path to the npm executable
# NPM_VERSION - The version number of the npm executable
find_program(NPM_EXECUTABLE NAMES npm HINTS /usr)
# If npm was found, fill in the rest
if (NPM_EXECUTABLE)
# Set the global node_modules location
execute_process(COMMAND ${NPM_EXECUTABLE} root -g
OUTPUT_VARIABLE NPM_GLOBAL_NODE_MODULE_DIR
ERROR_VARIABLE NPM_root_g_error
RESULT_VARIABLE NPM_root_g_result_code)
# Remove and newlines
string (STRIP ${NPM_GLOBAL_NODE_MODULE_DIR} NPM_GLOBAL_NODE_MODULE_DIR)
if(NPM_root_g_result_code)
if(NPM_FIND_REQUIRED)
message(SEND_ERROR "Command \"${NPM_EXECUTABLE} root -g\" failed with output:\n${NPM_root_g_error}")
else ()
message(STATUS "Command \"${NPM_EXECUTABLE} root -g\" failed with output:\n${NPM_root_g_error}")
endif ()
endif()
unset(NPM_root_g_error)
unset(NPM_root_g_result_code)
# Set the NPM dir
if (EXISTS "${NPM_GLOBAL_NODE_MODULE_DIR}/npm")
set(NPM_DIR "${NPM_GLOBAL_NODE_MODULE_DIR}/npm")
endif()
# Set the VERSION
execute_process(COMMAND ${NPM_EXECUTABLE} -v
OUTPUT_VARIABLE NPM_VERSION
ERROR_VARIABLE NPM_version_error
RESULT_VARIABLE NPM_version_result_code)
if(NPM_version_result_code)
if(NPM_FIND_REQUIRED)
message(SEND_ERROR "Command \"${NPM_EXECUTABLE} -v\" failed with output:\n${NPM_version_error}")
else()
message(STATUS "Command \"${NPM_EXECUTABLE} -v\" failed with output:\n${NPM_version_error}")
endif ()
endif ()
unset(NPM_version_error)
unset(NPM_version_result_code)
# Remove and newlines
string (STRIP ${NPM_VERSION} NPM_VERSION)
set (NPM_FOUND TRUE)
else()
# Fail on REQUIRED
if (Npm_FIND_REQUIRED)
message(SEND_ERROR "Failed to find npm executable")
endif()
endif ()
find_package_handle_standard_args(NPM
REQUIRED_VARS NPM_EXECUTABLE NPM_DIR
VERSION_VAR NPM_VERSION )
mark_as_advanced(NPM_DIR NPM_GLOBAL_NODE_MODULE_DIR NPM_EXECUTABLE NPM_VERSION)

View File

@ -0,0 +1,33 @@
find_program (SPHINX_EXECUTABLE NAMES sphinx-build
HINTS $ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation html generator"
)
find_program (SPHINX_API_EXECUTABLE NAMES sphinx-apidoc
HINTS $ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation rst generator"
)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Sphinx DEFAULT_MSG
SPHINX_EXECUTABLE
SPHINX_API_EXECUTABLE
)
# Get Sphinx Version
if (SPHINX_EXECUTABLE)
execute_process(COMMAND ${SPHINX_EXECUTABLE} --version
OUTPUT_VARIABLE SPHINX_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if (SPHINX_VERSION_STRING)
string(REPLACE "Sphinx (sphinx-build) " "" SPHINX_VERSION ${SPHINX_VERSION_STRING})
message (STATUS "Sphinx version is ${SPHINX_VERSION}")
endif ()
endif ()
mark_as_advanced (SPHINX_EXECUTABLE)
mark_as_advanced (SPHINX_API_EXECUTABLE)

View File

@ -0,0 +1,20 @@
find_program (UPM_CORDOVA_BINDING NAMES upm-cordova-binding
DOC "UPM Cordova binding generator")
include (FindPackageHandleStandardArgs)
# Get version
if (UPM_CORDOVA_BINDING)
execute_process(COMMAND ${NPM_EXECUTABLE} info upm-cordova-binding version
OUTPUT_VARIABLE UPM_CORDOVA_BINDING_VERSION
ERROR_VARIABLE UPM_CORDOVA_BINDING_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
find_package_handle_standard_args(UpmCordovaGenerator
REQUIRED_VARS UPM_CORDOVA_BINDING
VERSION_VAR UPM_CORDOVA_BINDING_VERSION
FAIL_MESSAGE "Unable to find the npm package for generating UPM Cordova bindings. The generator can be installed via: 'npm install -g upm-cordova-binding'")
mark_as_advanced (UPM_CORDOVA_BINDING UPM_CORDOVA_BINDING_VERSION)

View File

@ -0,0 +1,25 @@
find_program (YUIDOC_EXECUTABLE NAMES yuidoc
HINTS $ENV{YUIDOC_DIR}
PATHS usr usr/local
PATH_SUFFIXES bin
DOC "Yuidoc documentation generator"
)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Yuidoc DEFAULT_MSG
YUIDOC_EXECUTABLE
)
# Get Yuidoc version
if (YUIDOC_EXECUTABLE)
execute_process(COMMAND ${YUIDOC_EXECUTABLE} --version
ERROR_VARIABLE YUIDOC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if(YUIDOC_VERSION)
message (STATUS "Yuidoc version is ${YUIDOC_VERSION}")
endif()
endif ()
mark_as_advanced (YUIDOC_EXECUTABLE)

View File

@ -0,0 +1,130 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,38 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,160 @@
# Find specified Python version
# Arguments:
# preferred_version (value): Version to check for first
# min_version (value): Minimum supported version
# library_env (value): Name of Python library ENV variable to check
# include_dir_env (value): Name of Python include directory ENV variable to check
# found (variable): Set if interpreter found
# executable (variable): Output of executable found
# version_string (variable): Output of found version
# version_major (variable): Output of found major version
# version_minor (variable): Output of found minor version
# libs_found (variable): Set if libs found
# libs_version_string (variable): Output of found libs version
# libraries (variable): Output of found Python libraries
# library (variable): Output of found Python library
# debug_libraries (variable): Output of found Python debug libraries
# debug_library (variable): Output of found Python debug library
# include_path (variable): Output of found Python include path
# include_dir (variable): Output of found Python include dir
# include_dir2 (variable): Output of found Python include dir2
# packages_path (variable): Output of found Python packages path
function(find_python preferred_version min_version library_env include_dir_env
found executable version_string version_major version_minor
libs_found libs_version_string libraries library debug_libraries
debug_library include_path include_dir include_dir2 packages_path)
if(NOT ${found})
if(${executable})
set(PYTHON_EXECUTABLE "${${executable}}")
endif()
find_package(PythonInterp "${preferred_version}")
if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp "${min_version}")
endif()
if(PYTHONINTERP_FOUND)
# Copy outputs
set(_found ${PYTHONINTERP_FOUND})
set(_executable ${PYTHON_EXECUTABLE})
set(_version_string ${PYTHON_VERSION_STRING})
set(_version_major ${PYTHON_VERSION_MAJOR})
set(_version_minor ${PYTHON_VERSION_MINOR})
set(_version_patch ${PYTHON_VERSION_PATCH})
# Clear find_host_package side effects
unset(PYTHONINTERP_FOUND)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_VERSION_STRING)
unset(PYTHON_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR)
unset(PYTHON_VERSION_PATCH)
endif()
if(_found)
set(_version_major_minor "${_version_major}.${_version_minor}")
if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
# not using _version_string here, because it might not conform to the CMake version format
if(CMAKE_CROSSCOMPILING)
# builder version can differ from target, matching base version (e.g. 2.7)
find_package(PythonLibs "${_version_major_minor}")
else()
find_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT)
endif()
if(PYTHONLIBS_FOUND)
# Copy outputs
set(_libs_found ${PYTHONLIBS_FOUND})
set(_libraries ${PYTHON_LIBRARIES})
set(_include_path ${PYTHON_INCLUDE_PATH})
set(_include_dirs ${PYTHON_INCLUDE_DIRS})
set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES})
set(_libs_version_string ${PYTHONLIBS_VERSION_STRING})
set(_debug_library ${PYTHON_DEBUG_LIBRARY})
set(_library ${PYTHON_LIBRARY})
set(_library_debug ${PYTHON_LIBRARY_DEBUG})
set(_library_release ${PYTHON_LIBRARY_RELEASE})
set(_include_dir ${PYTHON_INCLUDE_DIR})
set(_include_dir2 ${PYTHON_INCLUDE_DIR2})
# Clear find_package side effects
unset(PYTHONLIBS_FOUND)
unset(PYTHON_LIBRARIES)
unset(PYTHON_INCLUDE_PATH)
unset(PYTHON_INCLUDE_DIRS)
unset(PYTHON_DEBUG_LIBRARIES)
unset(PYTHONLIBS_VERSION_STRING)
unset(PYTHON_DEBUG_LIBRARY CACHE)
unset(PYTHON_LIBRARY)
unset(PYTHON_LIBRARY_DEBUG)
unset(PYTHON_LIBRARY_RELEASE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
unset(PYTHON_LIBRARY_RELEASE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_INCLUDE_DIR2 CACHE)
endif()
endif()
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
RESULT_VARIABLE _cvpy_process
OUTPUT_VARIABLE _std_packages_path
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${_std_packages_path}" MATCHES "site-packages")
set(_packages_path "python${_version_major_minor}/site-packages")
else() #debian based assumed, install to the dist-packages.
set(_packages_path "python${_version_major_minor}/dist-packages")
endif()
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}")
set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}")
else()
set(_packages_path "lib/${_packages_path}")
endif()
endif()
# Export return values
set(${found} "${_found}" CACHE INTERNAL "")
set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor")
set(${version_string} "${_version_string}" CACHE INTERNAL "")
set(${version_major} "${_version_major}" CACHE INTERNAL "")
set(${version_minor} "${_version_minor}" CACHE INTERNAL "")
set(${libs_found} "${_libs_found}" CACHE INTERNAL "")
set(${libs_version_string} "${_libs_version_string}" CACHE INTERNAL "")
set(${libraries} "${_libraries}" CACHE INTERNAL "Python libraries")
set(${library} "${_library}" CACHE FILEPATH "Path to Python library")
set(${debug_libraries} "${_debug_libraries}" CACHE INTERNAL "")
set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug")
set(${include_path} "${_include_path}" CACHE INTERNAL "")
set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir")
set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2")
set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.")
endif()
endfunction(find_python)
set(MIN_VER_PYTHON2 2.7)
set(MIN_VER_PYTHON3 3.2)
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH)
find_python(3 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND
PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY
PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH)
if(PYTHON_DEFAULT_EXECUTABLE)
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
elseif(PYTHON3INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 2)
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
endif()

View File

@ -0,0 +1,136 @@
# Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source,
# "There are many more known variants/revisions that we do not handle/detect."
set(archdetect_c_code "
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
#error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
#error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
#error cmake_ARCH armv5
#else
#error cmake_ARCH arm
#endif
#elif defined(__i586) || defined(__i586__)
#error cmake_ARCH i586
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
")
# Set ppc_support to TRUE before including this file or ppc and ppc64
# will be treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
# First let's normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are using
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
# disable it by default
# See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
set(osx_arch_ppc TRUE)
elseif("${osx_arch}" STREQUAL "i386")
set(osx_arch_i386 TRUE)
elseif("${osx_arch}" STREQUAL "x86_64")
set(osx_arch_x86_64 TRUE)
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
set(osx_arch_ppc64 TRUE)
else()
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
endif()
endforeach()
# Now add all the architectures in our normalized order
if(osx_arch_ppc)
list(APPEND ARCH ppc)
endif()
if(osx_arch_i386)
list(APPEND ARCH i386)
endif()
if(osx_arch_x86_64)
list(APPEND ARCH x86_64)
endif()
if(osx_arch_ppc64)
list(APPEND ARCH ppc64)
endif()
else()
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
enable_language(C)
# Detect the architecture in a rather creative way...
# This compiles a small C program which is a series of ifdefs that selects a
# particular #error preprocessor directive whose message string contains the
# target architecture. The program will always fail to compile (both because
# file is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this
# way, we can detect the correct target architecture even when cross-compiling,
# since the program itself never needs to be run (only the compiler/preprocessor)
try_run(
run_result_unused
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
# Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# Get rid of the value marker leaving just the architecture name
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if (NOT ARCH)
set(ARCH unknown)
endif()
endif()
set(${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

View File

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

138
upm/docker-compose.yaml Normal file
View File

@ -0,0 +1,138 @@
version: '2.1'
services:
base:
image: inteliotdevkit/upm-base
environment:
- http_proxy
- https_proxy
- no_proxy
- BUILDDOC=${BUILDDOC:-OFF}
- BUILDCPP=${BUILDCPP:-ON}
- BUILDFTI=${BUILDFTI:-ON}
- BUILDSWIGPYTHON=${BUILDSWIGPYTHON:-OFF}
- BUILDSWIGJAVA=${BUILDSWIGJAVA:-OFF}
- BUILDCORDOVA=${BUILDCORDOVA:-OFF}
- BUILDSWIGNODE=${BUILDSWIGNODE:-OFF}
- BUILDEXAMPLES=${BUILDEXAMPLES:-OFF}
- CMAKE_BUILD_TYPE
- 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}
all:
extends: base
image: inteliotdevkit/upm-all
minimal:
extends: base
environment:
- BUILDFTI=OFF
command: bash -c "./scripts/run-cmake.sh && cd build && make && ctest -R unit --output-on-failure"
doc:
extends: all
environment:
- BUILDSWIGPYTHON=ON
- BUILDSWIGJAVA=ON
- BUILDSWIGNODE=ON
- BUILDDOC=ON
command: bash -c "./scripts/run-cmake.sh && ./scripts/build-doc.sh"
examples:
extends: all
environment:
- BUILDSWIGPYTHON=ON
- BUILDSWIGJAVA=ON
- BUILDSWIGNODE=ON
- BUILDEXAMPLES=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8"
ipk:
extends: all
environment:
- IPK=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
rpm:
extends: all
environment:
- RPM=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 package"
npm:
extends: all
environment:
- NPM=ON
- BUILDDOC=OFF
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 npmpkg"
sonar-scan:
extends: all
environment:
- BUILDSWIGPYTHON=ON
- BUILDSWIGNODE=ON
- BUILDSWIGJAVA=ON
- BUILDEXAMPLES=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: inteliotdevkit/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: inteliotdevkit/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: inteliotdevkit/upm-android
environment:
- BUILDTESTS=OFF
command: bash -c "./scripts/build-android.sh"
cordova:
extends: all
environment:
- BUILDSWIGJAVA=ON
- BUILDCORDOVA=ON
command: bash -c "./scripts/run-cmake.sh && cd build && make -j8 && make -j8"
node4:
extends: base
image: inteliotdevkit/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: inteliotdevkit/upm-node5
node6:
extends: node4
image: inteliotdevkit/upm-node6

271
upm/docs/apichanges.md Normal file
View File

@ -0,0 +1,271 @@
API Changes {#apichanges}
===============
Here's a list of other API changes made to the library that break source/binary
compatibility between releases:
# v1.7.0
* The interface of **kx122** has been modified to return values instead
of receiving pointers. This applies to member functions: getWhoAmI,
getInterruptSource, getBufferStatus, getRawBufferSamples, and
getBufferSamples.
* The **tm1637** constructor has been updated and the fast GPIO parameter
has been removed with the deprecation of supporting MRAA functions. The
GPIO lines will initialize by default in fast mode when available.
* The generic **nmea_gps** library for GPS devices has been greatly enhanced
with new APIs to offer better control over acquisition intervals and simplify
parsing of the returned data.
# v1.6.0
* Several C libraries had their init function pin type modified from uint8_t
to int allowing usage with subplatforms
* Our **led** class constructor has been overloaded with a string based
variant that uses the new MRAA LED APIs
* The **i2clcd** library has finally been renamed to **lcd** and is now
mostly considered a bundle for ssd lcd display controllers only
* The **zfm20** class constructor has been overloaded with a string variant
that allows initialization using any UART device
# v1.5.0
* **VEML6070** This sensor class no longer needs an I2C address when
initialized, since they are fixed. Only the I2C bus number needs to
be provided.
# 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 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 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
available. Once this transition is complete, the i2clcd module will be
deprecated. So far, the following libraries have been made available
separately: jhd1313m1, lcm1602.
* **nunchuck** This driver no longer supports the init() function.
All initialization is now done in the C nunchuck_init() function,
or the C++ constructor. In addition, the *NUNCHUCK_I2C_ADDR*
define is no longer exposed, as it is not possible to use any other
I2C address than *0x52*. The readBytes() and writeByte() functions
are also no longer exposed, since aside from what the driver does
to initialize and read data, there are no other options available.
* **enc03r** This driver no longer supports the value() function. In
addition, an update() function has been added. This function must be
called prior to calling angularVelocity(). angularVelocity() no
longer accepts an argument. Additional functions have been added,
however they do not affect compatibility with previous versions.
* **ds18b20** The C++ interface init() function has been deprecated.
It is still present, but currently does nothing. It will be removed
in a future release.
* **grove<name>** Starting with UPM 1.0 the Grove libraries have been renamed
from *upm-grove<name>* to simply *upm-<name>*. Class names also match this new
format, with old classes marked as deprecated throughout the documentation.
List of affected libraries: grovecollision, groveehr, groveeldriver,
groveelectromagnet, groveemg, grovegprs, grovegsr, grovelinefinder, grovemd,
grovemoisture, groveo2, grovescam, grovespeaker, groveultrasonic, grovevdiv,
grovewater, grovewfs.
* **grove** As of UPM 1.0 the Grove classes for sensors in the starter kit are
being separated into individual libraries. The old classes will be deprecated
over time and eventually removed. Corresponding libraries have the grove
prefix removed. Affected classes are GroveButton, GroveLed, GroveLight,
GroveRelay, GroveRotary, GroveSlide and GroveTemp.
* The **ublox6** driver has been replaced with a generic implementation called
nmea_gps as of UPM 1.0. This driver should handle all generic serial GPS
devices that output NMEA data going forward. This new driver has been tested
with ublox6, DFRobot VK2828U7 (ublox7) and ublox LEA-6H GPS devices.
* **grove** Binary compatibility was broken for the GroveTemp class as of UPM
v0.7.3. C++ code using this class has to be recompiled.
* There were frequent misspellings of the word *Celsius* in the UPM
code. In some cases, these were in method names, which will cause
some API compatibility issues. These have all been corrected for UPM
versions after v.0.7.2.
* Our **C++ header files** changed their extension from *.h* to *.hpp* in
version 0.7.0, Intel provided examples and code samples also reflect this
change but you will need to modify your `#include` directives in existing
code.
* **my9221**, **groveledbar** and **grovecircularled** are now all part of the
same library (my9221) and new functionality was added going to v.0.5.1.
* **stepmotor** driver API was changed significantly from v.0.4.1 to v.0.5.0.
* **eboled** library was greatly improved in version 0.4.0 and the `draw()`
function was removed in favor of a more complete GFX library implementation.

262
upm/docs/building.md Normal file
View File

@ -0,0 +1,262 @@
Building UPM {#building}
============
UPM uses cmake in order to make compilation relatively painless. Cmake runs
build out of tree so the recommended way is to clone from git and make a build/
directory.
**Dependencies**
* basic: libmraa, cmake, swig, pkgconfig, pthreads, librt
* bindings: python-dev, nodejs-dev, openjdk
* documentation: doxygen, graphviz, sphinx, yuidoc
* sensor specific: bacnet-mstp, modbus, openzwave, jpeg
This project depends on libmraa, so that needs to be installed first. Append
the install location of mraa pkgconfig to the following environment variable:
~~~~~~~~~~~~~
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:.../mraa/build/lib/pkgconfig
~~~~~~~~~~~~~
If you are building the Java or Node.js bindings make sure you set the
`JAVA_HOME` and `NODE_PATH` environment variables respectively.
UPM will attempt to build all directories inside src/ and they must contain
individual CMakeLists.txt files.
~~~~~~~~~~~~~{.sh}
mkdir build
cd build
cmake ..
make
make install
~~~~~~~~~~~~~
The last command will create the include/ and lib/ directories with a copy of
the headers and library objects respectively in your build location. Note that
doing an out-of-source build may cause issues when rebuilding later on. In many
cases you'll need elevated permissions to install:
~~~~~~~~~~~~~{.sh}
sudo make install
~~~~~~~~~~~~~
Our cmake configure has a number of options, *cmake-gui* or *ccmake* can show
you all the options. The interesting ones are detailed below:
Changing install path from /usr/local to /usr
~~~~~~~~~~~~~
-DCMAKE_INSTALL_PREFIX:PATH=/usr
~~~~~~~~~~~~~
Building debug build:
~~~~~~~~~~~~~
-DCMAKE_BUILD_TYPE=DEBUG
~~~~~~~~~~~~~
Using clang instead of gcc:
~~~~~~~~~~~~~
-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
~~~~~~~~~~~~~
Cross-compiling on a different system:
~~~~~~~~~~~~~
-DCMAKE_CXX_FLAGS:STRING=-m32 -march=i586
-DCMAKE_C_FLAGS:STRING=-m32 -march=i586
~~~~~~~~~~~~~
Enabling Java module building
~~~~~~~~~~~~~
-DBUILDSWIGJAVA=ON
~~~~~~~~~~~~~
Building with an older version of swig (swig 2.0+) requires the disabling of javascript:
~~~~~~~~~~~~~
-DBUILDSWIGNODE=OFF
~~~~~~~~~~~~~
Disabling python module building
~~~~~~~~~~~~~
-DBUILDSWIGPYTHON=OFF
~~~~~~~~~~~~~
Setting the python library to use:
~~~~~~~~~~~~~
-DPYTHON_LIBRARY:FILEPATH=/usr/lib/libpython2.7.so.1.0
~~~~~~~~~~~~~
Building documentation
~~~~~~~~~~~~~
-DBUILDDOC=ON
~~~~~~~~~~~~~
Build C/C++/JAVA examples
~~~~~~~~~~~~~
-DBUILDEXAMPLES=ON
~~~~~~~~~~~~~
If you intend to turn on all the options and build everything at once
(C++, Java, Node, Python and Documentation) you will have to edit the
src/doxy2swig.py file and change the line endings from Windows style to Linux
format. This has to be repeated every time to sync with the master branch since
our Github repository stores files using CR LF line breaks.
You can also generate the include and lib directories containing all the sensor
headers and library files respectively with *make install*. Further, you may
choose to generate these only for a specific sensor you modified, and this can
be achieved by building from the individual makefile of the sensor. Assuming
you're in the build directory, to build/install the lcd module you would:
~~~~~~~~~~~~~
cd src/lcd
make install
~~~~~~~~~~~~~
Note: 'make install' under src/lcd will build all targets (and dependencies)
for the lcd but will NOT install dependencies.
Often developers are only interested in building one module or even just the
python/node module to do some quick testing using scripting. In order to do
this you need to use the target name for the python or node module you want to
rebuild. For example, the lcd module target will have a python2 target prefixed
by _pyupm_ (_pyupm_lcd-python2). Modules not using the UPM cmake macros may
have different naming. To build the python2 lcd module (and all dependencies),
use the following make target:
~~~~~~~~~~~~~
make _pyupm_lcd-python2
~~~~~~~~~~~~~
Sometimes you want to build a small C++ example against an installed library.
This is fairly easy if installed system-wide. Just link against the correct
library (in this case libupm-lcd) and then add /usr/include/upm to the
loader path:
~~~~~~~~~~~~
g++ test.cxx -lupm-lcd -I/usr/include/upm
~~~~~~~~~~~~
You can also use pkg-config to return the information to you, which is
considered the correct way if including UPM in a build system like cmake or
autotools on linux.
~~~~~~~~~~~
pkg-config --cflags --libs upm-lcd
~~~~~~~~~~~
## Building for Android Things
Requirements:
* [io.mraa.at](https://search.maven.org/#artifactdetails%7Cio.mraa.at%7Cmraa%7C1.8.0%7Caar)
* [io.mraa.at.upm](https://search.maven.org/#artifactdetails%7Cio.mraa.at.upm%7Cupm_zfm20%7C1.3.0%7Caar)
* [Android NDK](https://developer.android.com/ndk/downloads/index.html) >= 14b
### Android NDK r14b
~~~~~~~~~~~~~{.sh}
NDK_HOME="/path/to/android-ndk-r14b"
MRAA_INSTALL_DIR="/path/to/mraa/install"
cmake -DBUILDSWIG=ON \
-DBUILDSWIGPYTHON=OFF \
-DBUILDSWIGNODE=OFF \
-DBUILDSWIGJAVA=ON \
-DANDROID_COMPILER_FLAGS_CXX='-std=c++11' \
-DANDROID_PIE=1 \
-DANDROID_PLATFORM=android-24 \
-DANDROID_STL_FORCE_FEATURES=ON \
-DANDROID_STL=c++_shared \
-DANDROID_TOOLCHAIN_NAME=x86-i686 \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DCMAKE_FIND_ROOT_PATH=$MRAA_INSTALL_DIR \
..
~~~~~~~~~~~~~
## 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 \
inteliotdevkit/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 \
inteliotdevkit/upm-python \
bash -c "./scripts/run-cmake.sh && make -Cbuild"
```

362
upm/docs/changelog.md Normal file
View File

@ -0,0 +1,362 @@
Changelog {#changelog}
===============
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
### v1.7.1
* Bumped library compatibility to new MRAA 2.0 APIs
* Added installation details for Fedora
* Minor fixes based on static analysis vulnerability report
### v1.7.0
* Added Cordova bindings based on Java packages
* Complete rework of the nmea_gps library giving more control over data
acquisition and parsing
* Added GTest support for unit tests
* Removed calls to deprecated MRAA fast GPIO functions
* Several bug fixes and improvements around SWIG type maps and gcc8 support
* New sensors: kx122, kxtj3, bh1792, bh1749
### v1.6.0
* Extended LED library to support the new MRAA gpio-leds APIs
* Many CMake changes around SWIG wrapper generation and improved FindNodejs
detection module
* Several code fixes based on static code analysis
* Improved documentation generation and Travis CI builds
* Cleaned-up doxygen tags in headers and class names in JSON library files
* New sensor: lis3dh
### v1.5.0
* Introduced a flexible JSON format for technical sensor specifications, notes
and classification. This is also used by our [new UPM website](http://upm.mraa.io)
* Revised all C++ sensor examples and switched to stack allocations where
possible along with other code and formatting clean-up
* Significantly improved docker workflow, CI integration, sanity and
consistency tests, static code scans and documentation generation
* Several improvements to a couple of existing sensor drivers and better
compatibility with subplatforms
* Added new std::vector to AbstractList<> typemap for Java bindings and
examples
* New sensors: lis2ds12, lsm6ds3h, lsm6dsl, lidarlitev3
### 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
* Documentation improvements for sensor names, sensor descriptions, external
contributor guides and added new section on installing UPM on a supported OS
* Fixed issues with C11 builds on some WRLinux gateways and Debian systems
* New examples and functionality for speaker and ads1x15 modules
* Modified JAVA builds to ensure the SWIG generated wrappers include all
functionality and typemaps
* New sensors: mcp2515, max30100, uartat, le910
### v1.0.2
* Minor cmake changes for Java builds and Java examples are now toggled with
the same BUILDEXAMPLES cmake switch
* Made some improvements in the utilities class for our C drivers
* Fixed issue with some drivers not being usable on subplatforms due to pin
numbers using uint8 type
* New sensors: ims, ecezo, mb704x, rf22
### v1.0.1
* Warnings as errors enabled for C/CXX (fixed warnings from -Wall and others)
* Fix for C/CXX compile flag append issue #485
* C sensor libraries for: my9221, otp538u, guvas12d, ppd42ns
* New sensor: ms5803
### v1.0.0
* Added approximately 50 C sources for UPM drivers that can be used on both
Unix and RTOS boards
* Provided generic alternatives to the Grove set of classes as they will be
deprecated over time and eventually removed
* UPM modules are now being packed and published on NPM as sources rather than
binaries to enhance compatibility with various boards and systems
* Build both python2 and python3 modules if the corresponding python libs are
available and removed cmake BUILDPYTHON3 switch
* Converted python examples to run on both python2 and python3
* Added 'upm' hierarchy to python module install path which changes the way
UPM modules are imported
Example:
old: import pyupm_dfrph
new: from upm import pyupm_dfrph
or
import upm.pyupm_dfrph
* Added ctests for consistancy checking UPM repo as well as sanity checking
for python2/3 modules and examples
* Various documentation and driver fixes throughout
* New sensors: nmea_gps, mma7361, bh1750, hka5, dfrorp, dfrec, sht1x
### v0.8.0
* Extended l3gd20 driver to support I2C connections in addition to IIO
* Updated ads1x15, mcp9808 and ssd1306 I2C drivers to not throw a fatal
exception if they fail to set a different I2C speed
* Added extra functionality to apa102 driver, backlight control to jhd1313m1
LCDs and fixed htu21d
* Improved documentation with build dependencies, refreshed the list of known
limitations and simplified the component name for a few sensors
### v0.7.3
* Fixed several existing drivers and updated Grove Temperature sensor to use
new formula for v1.1+ by default
* Separated codebase for upm_grove module that bundles some of the starter kit
sensors into individual source files
* Documentation and doxygen tag updates with correct spelling for Celsius in
several places, this also affects API compatibility
* Removed superfluous BUILDSWIG option, some build recipes might be impacted
* New sensor: ms5611
### v0.7.2
* Mraa 1.1.1 required changes to UPM drivers and examples for IIO core
kernel support
* Rev'ed libmraa requirement to 1.1.1
### v0.7.1
* Fix for building python2 vs python3 bindings
* Fixes for jhd1313m1 row/font size and reset
* Added bacnet utility class
* New sensors: bmx055, bmi055, bmc160, bma250e, bmg150, bmm150, t8100, tb7300
### v0.7.0
* C++ header files have been renamed from *.h to *.hpp along with all Intel
provided examples and code samples to allow for native C drivers
* Updated driver compatibility to new MRAA 1.0 API
* First sensor implementations for our newly added Dallas One Wire support
* Several fixes based on issues reported on Github
* Changed SWIG linking strategy, more robust Travis CI build checks
* New sensors: ds2413, ds18b20, bmp280, bno055, l3gd20
### v0.6.2
* Added a generic driver for taking snapshots from an USB camera device
* New API changes section in documentation to let users know when the UPM API
gets modified
* Fixed some spelling errors and improved JavaScript documentation builds with
newer versions of YUI and Node
* Enhanced Cmake scripts and the build process
* New sensors: vcap, e50hx
### v0.6.1
* Fixed library build process for different configurations across multiple
environments reported by users.
* Fixed multiple GFX library header clash and improved SSD1351 compatibility
by changing SPI mode
* Added Node and Python array typemaps for nrf24l01
* Added 2 new JAVA examples
### v0.6.0
* Introduced C++ Interfaces for several sensor categories that will help
consolidate the sensor APIs with uniform function names upon implementation
* Greatly improved Node.js detection and handling during build and install,
and should be now compatible with all major versions
* Added a driver for the Curie IMU (accelerometer + gyroscope) that works with
the new Firmata support implemented by MRAA
* Continued to provide several JAVA fixes and examples
* Many new industrial and maker sensors: cwlsxxa, teams, tex00, h803x, apa102,
smartdrive, bmi160, bme280, ds1808lc, hlg150, lp8860, max44009, si1132, t6713,
si7005, ssd1351
### v0.5.1
* Updated the API and added new functionality for the MY9221 class and derived
sensors: grovecircularled and groveledbar, along with new code samples that
show these changes
* Provided a fix for one JAVA example that uses interrupts and updated library
install paths
* Several documentation improvements and pictures were added for new sensors
* A few other sensors received minor patches
### v0.5.0
* First implementations for industrial grade Modbus sensors, along with first
sensor examples that use the new iio system driver in MRAA
* Significant improvements to the stepmotor driver that will now allow precise
control using any GPIO pin and extended the API with new functionality
* Further improved JAVA bindings and sensor ISRs have been modified to
implement Runnable objects
* Improved Python typemaps and error checking, documentation now includes
detailed function descriptions
* Simplified the build process by eliminating the need to define redundant
MRAA related environment variables
* New sensors: nlgpio16, ads1x15, t3311, hdxxvxta, hwxpxx, rhusb, ili9341,
apds9930, kxcjk1013
### v0.4.1
* Over 150 supported sensor drivers including some industrial grade devices
* Improved the JAVA bindings, added a large number of examples for sensors,
enabled JAVA builds in Travis CI, and introduced automatic loading for the
JAVA shared libraries
* Continued to improve existing sensor drivers and to enhance them with the
new C++ coding style and exception types
* Several cmake improvements to allow building on various Linux distributions
and with a newer version of Node.JS
* Simplified adding and building of C++ sensor examples via cmake
* New sensors: micsv89, xbee, urm37, adxrs610, bma220, dfrph, mcp9808, sx1276,
groveultrasonic, ozw
### v0.4.0
* Fully functional and documented JAVA language bindings for sensors with
several examples also available
* Added standardized exception handling support across all language bindings
and updated sensors to use this feature
* Sensor drivers are now available and can be installed individually using NPM
for Node.js users
* Continuous Integration with Travis CI ensures new contributions are built
automatically once they are received
* API rewrite and improvements for hcsr04, sm130, eboled, loudness
* Documentation improvements and code style changes from C to C++
* New sensors: hyld9767, mg811, wheelencoder, grovegprs, mpu9250, ssd1306,
es9257, lm35, mq4, mq6, mq7, mq8
### v0.3.2
* Introduced RPM package generation feature from cmake via cpack
* Performed a thorough documentation review and merged resulting changes,
includes last remaining images and grouping sensors by kits
* Added support for Sparkfun Sensor Blocks (OLED & IMU)
* Fully reworked API for at42qt1070, mpu9150 and lcd classes, while
maintaining backwards compatibility for existing lcd displays
* Extended doxygen tags for better integration with automated documentation
generators
* New sensors: rgbringcoder, hp20x, pn532, sainsmartks, lsm9ds0, eboled
### v0.3.1
* Updated index pages for API documentation and cross-linked them
* More images were added for Grove, Adafruit and Sparkfun sensors along with
licensing information
* Applied a set of patches to improve code robustness
* Added support for Grove NFC Tag sensor
* Fixed several typos in library and sensor names
* New sensor: m24lr64e
### v0.3.0
* Provided automated, updated and comprehensive sensor API documentation for
C++, Python and JavaScript
* Edited sensor names, library descriptions and doxygen tags for consistency
* Fixed the TH02 sensor driver and made major improvements to i2clcd driver
* Added new and updated images for numerous new and existing sensors
* Started this changelog
* New sensors: sx6119, si114x, maxsonarez, hm11, ht9170, h3lis331dl, ad8232,
grovescam
### v0.2.0
* Passed 100 supported sensor drivers
* Updated header files with new doxygen tags for improved API documentation
generation
* Added python examples for sensors
* Fixed the buzzer and servo drivers for the Intel Edison
* Renamed bmp and gp2y sensor classes to be more generic
* Completely revamped implementation for tm1637
* New sensors: mma7660, cjq4435, adxl335, hmtrp, nunchuck, otp538u, l298,
groveelectromagnet, grovecollision, adis16448, at42qt1070, grovemd, ina132,
grovegsr, groveo2, groveemg, pca9685, pca9685ss, adafruitms1438, hx711, flex,
groveeldriver, mhz16, apds9002, waterlevel, zfm20, uln200xa, grovewfs, isd1820
### v0.1.9
* Passed 50 supported sensor drivers
* Starter Kit and Additional Roadshow and Hackaton sensors added
* Several examples and documentation updates submitted
* Wrote new proper SWIG typemaps for arrays
* Fixed the i2clcd write function, improved several other sensors
* New sensors: rpr220, rotaryencoder, biss0001, rfr359f, grovespeaker, mq303a,
ppd42ns, wt5001, yg1006, ublox6, mpr121, groveloudness, guvas12d, grovewater,
grovevdiv, grovelinefinder, ta12200, groveehr, grovemoisture, gp2y0a, a110x,
ds1307, adc121c021, enc03r, ttp223, itg3200, am2315, tp401, ldt0028, htu21d,
mpl3115a2, lsm303, joystick12, tsl2561, groverotary, groveslider, adxl345,
grovebutton, lol, groverelay
### v0.1.8
* Added MQ series gas sensors and a few others
* Generated Doxygen layout file to improve API look and feel
* Several sensor documentation updates
### v0.1.7
* Fixed SWIG node build issues
* Added lpd8806 digital led strip
### v0.1.6
* Fixed SWIG python builds
* Extended i2clcd devices with new functions
* Made SWIG interface improvements and added extra types
* Added nrf8001 BLE support
* Few other sensor additions and fixes
### v0.1.5
* New drivers for microphone and mpu9150
* Added generic driver for stepper motors
* Updated all code to use MRAA and version dependency
### v0.1.4
* Added new bmp/gy pressure sensor and updated servo
* Started UPM documentation and related pages
* Updated MRAA dependencies
### v0.1.3
* Updated SWIG support for some sensors
* New sensor support for mma7455 accelerometer
### v0.1.2
* Several new sensors added
* Documentation fixes
* IPK generation
### v0.1.1
* Updated MRAA dependency
### v0.1.0
* Initial release with some basic grove sensors and hmc5883
* Doxygen and SWIG support implemented

151
upm/docs/contributions.md Normal file
View File

@ -0,0 +1,151 @@
Contributing a module {#contributions}
=====================
Here are the rules of contribution:
- Your new module must have an example that builds against your UPM library.
- Each commit must have a sign-off line by everyone who authored or reviewed
them.
- Commits must be named `<file/module>: Some decent description`.
- You must license your module under a FOSS license. The recommended license
is MIT but any permissive license is fine. Please consider that people using
UPM may want to write proprietary programs with your sensors so we like to
avoid GPL. If your license is not MIT please include a LICENSE file in
src/mymodule/.
- The top of each source file must contain a comment block containing the
license information.
- Please test your module builds before contributing and make sure it works on
the latest version of libmraa. If you tested on a specific board/platform
please tell us what this was in your PR.
- Try not to break master. In any commit.
- Attempt to have some decent API documentation as described in the the @ref
documentation [guide](documentation.md).
Including the MIT license
=========================
Choosing the [MIT license](http://opensource.org/licenses/MIT) is preferred for
the UPM repository. Below is the comment block needed at the top each source
file:
/*
* The MIT License (MIT)
*
* Author: <your full name>
* Copyright (c) <year> <copyright holder>
*
* Author: <contributing author full name - if applicable>
* Copyright (c) <year> <copyright holder>
*
* 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.
*/
Code signing
============
The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to pass it
on as an open-source patch. The rules are pretty simple: if you can certify
the below:
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
then you just add a line to each of your commits with `--signoff` saying
Signed-off-by: Random J Developer <random@developer.example.org>
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}*
# Remove objects starting with "//" from the new library descriptor .json file
perl -p -i -e 'BEGIN{undef $/;} s/\s+"\/\/.*?},//smg' src/${sensorname}/${sensorname}.json
# 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).

View File

@ -0,0 +1,302 @@
Creating Java Bindings Guide
==============
* [Overview](#overview)
* [Tools of trade](#tools-of-trade)
* [Recommendations for the native API](#recommendations-for-the-native-api)
* [Pointers](#pointers)
* [Throwing Exceptions in Java](#throwing-exceptions-in-java)
* [Caveats & Challenges](#caveats--challenges)
* [Wrapping C arrays with Java arrays](#wrapping-c-arrays-with-java-arrays)
* [Wrapping unbound C arrays with Java arrays if array is output](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-output)
* [Wrapping unbound C arrays with Java arrays if array is input](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-input)
* [Implementing callbacks in Java](#implementing-callbacks-in-java)
## Overview
The "Creating Java Bindings Guide" serves as a basic tutorial for using the SWIG software development tool to create 'glue code' required for Java to call into C/C++ code. It contains: guides for dealing with type conversions, exception handling, callbacks; recommendations on how to write/modify the native API to avoid issues on the Java side, and also workarounds for those issues that can't be avoided.
This guide was created with the [upm](https://github.com/intel-iot-devkit/upm/) and [mraa](https://github.com/intel-iot-devkit/mraa) libraries in mind, and uses examples taken from these sources, but its usage can be extended to any project of creating Java bindings for C/C++ libraries.
## Tools of trade
[SWIG General Documentation](http://www.swig.org/Doc3.0/SWIGDocumentation.html)
[SWIG Java-specific Documentation](http://www.swig.org/Doc3.0/Java.html)
## Recommendations for the native API
### Pointers
As much as possible, avoid passing values/returning values through pointers given as as arguments to methods. As the Java language does not have pointers, SWIG provides a [workaround](http://www.swig.org/Doc3.0/Java.html#Java_tips_techniques) in the typemaps.i library.
#### Alternatives:
1. Functions that read data from a driver, return it through a pointer given as argument, and return a bool value, should be __replaced by__ functions that return the value directly and throw a std::runtime_error if a read error occurs. E.g.:
```c++
/*
* Function reads from sensor, places read value in variable bar and
* returns true if succesful. Function returns false if read failed.
*/
bool func(int *bar);
```
__Replaced by:__
```c++
/*
* Function reads from sensor and returns read value.
* Or throws std::runtime_error if a read error occurs
*/
int func();
```
2. Functions that return multiple values through pointers, that make sense to be grouped together into an array<sup>1</sup> (e.g. speed values, acceleration values), should be __replaced by__ functions that return a pointer to an array in which the elements are the returned values. Afterwards, [wrap the C array with a Java array](#wrapping-unbound-c-arrays-with-java-arrays-if-array-is-output). E.g.:
```c++
/*
* Function returns the acceleration on the three
* axis in the given variables.
*/
void getAccel(int *accelX, int *accelY, int *accelZ);
```
__Replaced by:__
```c++
/*
* Function returns the acceleration on the three
* axis as elements of a 3-element array.
*/
int *getAccel();
```
3. Functions that return N values through pointers, that do not make sense to grouped together (e.g. a general purpose function that returns both the light intensity and air pollution), should be __replaced by__ N functions (one for each value) that read only one specific value. E.g.:
```c++
/*
* Function returns the light intensity and air pollution
*/
void getData(int *light, int *air);
```
__Replaced by:__
```c++
int getLight();
int getAir();
```
4. Functions that return N values through pointers; values that do not make sense to be grouped together, but are time dependent, and make sense to be read at the same time. For example, a sensor that reads air humidity and temperature. A user may want to know the temperature value _temp_ read at the exact moment the humidity value _humid_ was read. These should be __replaced by__ N+1 functions: a _getData()_ function that reads all values at the same time and stores them in global variables; and N getter functions, one for each value. E.g.
```c++
/*
* Function returns the light intensity and air pollution
*/
void getData(int *temp, int *humid);
```
__Replaced by:__
```c++
void getData();
int getTemp();
int getHumid();
```
<sup>1</sup>this depends on the interpretation of the returned data. For example, arguments that return the temperature and light intensity, don't make sense to be grouped into an array of size 2. But acceleration on the three axis can be grouped together in an array of size 3. where accelX is accel[0], accelY is accel[1], accelZ is accel[2].
__Notice:__
Sometimes, you may be required to write JNI code. Be aware of the difference between the C JNI calling syntax and the C++ JNI calling syntax.The C++ calling syntax will not compile as C and also vice versa. It is however possible to write JNI calls which will compile under both C and C++ and is covered in the [Typemaps for both C and C++ compilation](http://www.swig.org/Doc3.0/Java.html#Java_typemaps_for_c_and_cpp) section of the SWIG Documentation.
### Throwing Exceptions in Java
#### Language independent:
The %exception directive allows you to define a general purpose exception handler. For example, you can specify the following:
```c++
%exception [method_name] {
try {
$action
}
catch (std::invalid_argument& e) {
... handle error ...
}
}
```
If [method_name] is not specified then the directive is applied to all methods in its scope.
The usual thing you'd want to do is catch the C++ exception and throw an equivalent exception in your language.
The exception.i library file provides support for creating language independent exceptions in your interfaces. To use it, simply put an "%include exception.i" in your interface file. This provides a function SWIG_exception() that can be used to raise common language exceptions in a portable manner. For example :
```c++
// Language independent exception handler
%include exception.i
%exception {
try {
$action
} catch(OutOfMemory) {
SWIG_exception(SWIG_MemoryError, "Out of memory");
} catch(...) {
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
}
}
```
In the upm library, the upm_exception.i interface file provides the functionality to catch common exceptions and propagate them through SWIG. It uses the exception.i library file and is language independent.
The upm_exception.i interface file is included in the upm.i file, therefor SWIG wraps all generated methods' body in a try-catch statement for the following exceptions:
* std::invalid_argument
* std::domain_error
* std::overflow_error
* std::out_of_range
* std::length_error
* std::logic_error
* std::bad_alloc
* std::runtime_error
* std::exception
#### Java specific:
To throw a specific Java exception:
```c++
%exception {
try {
$action
} catch (std::out_of_range &e) {
jclass clazz = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(clazz, "Range error");
return $null;
}
}
```
Where FindClass and ThrowNew are [JNI functions](http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html).
Java defines two tipes of exceptions: checked exception and unchecked exceptions (errors and runtime exceptions). Checked exceptions are subject to the [Catch or Specify Requirement](https://docs.oracle.com/javase/tutorial/essential/exceptions/catchOrDeclare.html).
The C++ compiler does not force the code to catch any exception.
The %exception directive does not specify if a method throws a checked exception (does not add classes to the throws clause). For this, the %javaexception(classes) directive is used; where classes is a string containing one or more comma separated Java classes.
```c++
%javaexception("java.lang.Exception") {
try {
$action
} catch (std::out_of_range &e) {
jclass clazz = jenv->FindClass("java/lang/Exception");
jenv->ThrowNew(clazz, "Range error");
return $null;
}
}
```
In the upm library, the java_exceptions.i library file provides the functionality to catch exceptions and propagate them through SWIG as Java checked exceptions. The file provides SWIG wrappers, in the form of macros, that can be applied to methods.E.g. use the __READDATA_EXCEPTION(function)__ macro for functions that read data from a sensor and throw a std::runtime_error in case of a read failure. This will result in:
```java
void function throws IOException ();
```
## Caveats & Challenges
### Wrapping C arrays with Java arrays
SWIG can wrap arrays in a more natural Java manner than the default by using the arrays_java.i library file. Just include this file into your SWIG interface file.
### Wrapping unbound C arrays with Java arrays if array is output
Functions that return arrays, return a pointer to that array. E.g.:
```c++
/*
* Function returns the acceleration on the three
* axis as elements of a 3-element array.
*/
int *getAccel();
```
__SWIG:__
```c++
%typemap(jni) int* "jintArray"
%typemap(jstype) int* "int[]"
%typemap(jtype) int* "int[]"
%typemap(javaout) int* {
return $jnicall;
}
%typemap(out) int *getAccel {
$result = JCALL1(NewIntArray, jenv, 3);
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
}
```
### Wrapping unbound C arrays with Java arrays if array is input
In C, arrays are tipically passed as pointers, with an integer value representig the length of the array. In Java, the length of an array is always known, so the length argument is redundant. This example shows how to wrap the C array and also get rid the length argument. E.g.:
```c++
void func(uint8_t *buffer, int length);
```
__SWIG:__
```c++
%typemap(jtype) (uint8_t *buffer, int length) "byte[]"
%typemap(jstype) (uint8_t *buffer, int length) "byte[]"
%typemap(jni) (uint8_t *buffer, int length) "jbyteArray"
%typemap(javain) (uint8_t *buffer, int length) "$javainput"
%typemap(in,numinputs=1) (uint8_t *buffer, int length) {
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
```
!!!! There is a difference between TYPE *name and TYPE * name in typemaps!!!!!
### Implementing callbacks in Java
Callbacks in the UPM Java library (as well as the MRAA Java library) make use of the _void mraa\_java\_isr\_callback(void\* data\)_ method from MRAA.
__Callbacks in the UPM Java library are implemented as follows (we use the a110x Hall Effect sensors as example):__
We extend the sensor class with another method, _installISR\(jobject runnable\)_, which is a wrapper over the original _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ method. This will install the _mraa\_java\_isr\_callback\(\)_ method as the interrupt service routine \(ISR\) to be called, with _jobject runnable_ as argument.
Java callbacks are added at the SWIG interface level. For ease-of-use, a collection of macros are available in src/_upm.i.
src/a110x/a110x.i:
```c++
JAVA_ADD_INSTALLISR(upm::A110X)
```
Will expand to the following SWIG wrapper code:
```c++
SWIGINTERN void upm_A110X_installISR__SWIG_1(upm::A110X *self,jobject runnable){
self->installISR(mraa_java_isr_callback, runnable);
}
```
To use callback in java, we create a ISR class, which implements the Java Runnable interface, and we override the _run\(\)_ method with the code to be executed when the interrupt is received. An example for the a110x Hall sensor that increments a counter each time an interrupt is received:
```java
public class A110X_intrSample {
public static int counter=0;
public static void main(String[] args) throws InterruptedException {
upm_a110x.A110X hall = new upm_a110x.A110X(2);
A110XISR callback = new A110XISR();
hall.installISR(callback);
while(true){
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}
}
}
class A110XISR implements Runnable {
public A110XISR(){
super();
}
public void run(){
A110X_intrSample.counter++;
}
}
```

192
upm/docs/documentation.md Normal file
View File

@ -0,0 +1,192 @@
Writing sensor documentation {#documentation}
=====================
It is highly encouraged to provide at least some basic documentation for the
sensors that you want to add to UPM:
- If you don't add documentation, the code review will take very long and
your contribution could be rejected.
- Try to have no warnings in doxygen, this is generally fairly easy.
- Have the specific sensor manufacturer/model & version that you used, if you
support multiple versions please list.
- Simple comments do not need full stops.
- Stick to <80 chars per line where possible.
- No text is allowed on the same line as the start or end of a comment /** */.
We currently document our libraries in the following way:
* **Doxygen** is used for documenting the API and generating the categories on
the [UPM Libraries page](https://iotdk.intel.com/docs/master/upm/modules.html).
You can learn more about the Doxygen syntax [here](http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html).
* **JSON** is used to provide sensor specifications, descriptions, supported
platforms, links and other details.
When submitting a new driver, you will have to at least fill out the mandatory
fields as described below.
### The library JSON file
Let's use the BME280 class snippet from the bmp280.json file as an example:
```json
{
"Library": "bmp280",
"Description": "Bosch Atmospheric Sensor Library",
"Sensor Class":
{
"BME280":
{
"Name": "Digital Humidity, Pressure, and Temperature Sensor",
"Description": "The BME280 is as combined digital humidity, pressure and temperature sensor based on proven sensing principles. The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93 mm. Its small dimensions and its low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches. The BME280 is register and performance compatible to the Bosch Sensortec BMP280 digital pressure sensor",
"Aliases": ["bme280", "Grove - Barometer Sensor(BME280)"],
"Categories": ["pressure", "humidity", "temperature"],
"Connections": ["gpio", "i2c", "spi"],
"Project Type": ["prototyping", "industrial"],
"Manufacturers": ["adafruit", "seeed", "bosch"],
"Examples":
{
"Java": ["BMP280_Example.java"],
"Python": ["bmp280.py"],
"Node.js": ["bmp280.js"],
"C++": ["bmp280.cxx"],
"C": ["bmp280.c"]
},
"Specifications":
{
"Vdd": {"unit": "v", "low" : 1.7, "high": 3.6},
"Ioff" : {"unit": "mA", "low" : 0.0, "high": 0.0},
"Iavg": {"unit": "mA", "low" : 1, "high": 2},
"Pressure Range": {"unit": "hpA", "low" : 300, "high": 1100},
"Temperature Range": {"unit": "C", "low" : -40, "high": 85}
},
"Platforms":
{
"Intel Joule Module":
{
"Notes": ["Requires pull-up resistors with carrier board"]
}
},
"Urls" :
{
"Product Pages": ["https://www.adafruit.com/products/2652"],
"Datasheets": ["https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf"],
"Schematics": ["https://learn.adafruit.com/assets/26693"]
}
}
}
}
```
#### Mandatory fields:
For the library:
- `Library` The name of the library. This is appended to the upm prefix during
a build.
- `Description` A short description of the library and what it contains.
For the sensor classes:
- `Sensor Class` This is the object containing the sensor class(es) within the
library. Class objects need to match the name used in code.
- `Name` Title Case descriptive names for your sensor. Multiple values can be
used to capture the chip name, generic name, or specific name for a vendor.
Examples: Digital Pressure Sensor, Serial MP3 Module
- `Description` A more detailed explanation what the sensor does and how it
works.
- `Categories` Mention one or more categories the sensor fits in. Accepted
values are listed in the groups.md file.
- `Connections` Specifies how does the sensor connect to the board. Accepted
values are listed in the groups.md file.
- `Project Type` What time of projects is the sensor suited for. For example:
prototyping, industrial, commercial.
- `Manufacturers` List of sensor manufacturers or vendors. Can be 'generic',
other accepted values in groups.md.
- `Examples` Names of the example files provided with the library. At a minimum,
the `C++` example needs to be provided.
- `Urls` At least one link for `Product Pages` needs to be provided. Additional
links to `Datasheets` or `Schematics` can be added.
#### Optional and customizable fields
- `Kits` Specifies if the sensor is part of a kit. Accepted values are listed
in the groups.md file.
- `Image` Name of the image file provided with the sensor class.
- `Specifications` Relevant sensor specifications as listed in the datasheet.
- `Platforms` Platform specific notes or known limitations and workarounds.
As mentioned, accepted values for some of the fields are listed under the
[groups.md](../src/groups.md) file. If needed, you can add new categories
for your sensor library following the existing format.
JSON files are automatically checked for correctness and required fields on
code submissions.
**Please do not use copyrighted images with your sensors!**
Images from Seeed, DFRobot, Sparkfun or Adafruit are permitted.
### Doxygen tags
#### The library doxygen block
New libraries must have the "@brief", "@defgroup" and "@ingroup" tags in one
block. This usually follows the namespace and it is common to have one sensor
per library.
You should end up with something like this (disregard the "@verbatim" tags in
your actual code):
```
@verbatim
/**
* @brief Short description for entire library
*
* Optional longer description.
*
* @defgroup <lib-name> libupm-<lib-name>
* @ingroup <manufacturer> <connection> <category> (<kit>)
*/
@endverbatim
```
Use `<lib-name>` to name the library.
For "@ingroup" add the same values as in the sensor block for manufacturer,
category, connection type and kit. If you have multiple classes or sensors
per library, only use the "@ingroup" tags that are common for all of them.
Existing groups that can be used for the manufacturer, connection, category and
kit tags are found in the *src/groups.md* file.
#### The sensor doxygen block
This is added just before the class declaration in your header(.hpp) file and has
one mandatory field. For single sensor libraries, this block will actually follow
immediately after the library block. If you have multiple sensor classes, add
this to every one.
Here's an example:
```
@verbatim
/**
* @library <lib-name>
* @brief Short class/sensor description
*
* Then add a longer
* description here.
*/
@endverbatim
```
When adding to an existing library, `<lib-name>` needs to match that library's
"@defgroup".
For more examples take a look at the existing headers in our github repository.
Also, make sure to check our [sensortemplate](contributions.md#creating-a-new-sensor-library-using-the-sensortemplate)
as it can facilitate new sensor additions.
Existing header files might have additional fields under the sensor block. These
have been used in the past to generate sensor pages outside of doxygen, but they
are now deprecated and not required for new additions.

348
upm/docs/guidelines.md Normal file
View File

@ -0,0 +1,348 @@
# Code Commenting And Documentation Authoring Guidelines
#### [Part I. Code Commenting](#code-commenting)
[Grammar](#grammar)
- [Active vs passive voice](#voice)
- [Capitalization](#capitalization)
- [No possessive case](#possessive-case)
- [Present tense](#present-tense)
- [Second person vs the user / reader / programmer / engineer](#second-person)
- [Third person vs infinitive](#third-person)
[Punctuation](#punctuation)
- [Comma in enumerations](#comma)
- [No period at the end of description](#period)
[Specific word usage](#word-usage)
- [Abbreviations and acronyms](#abbr-acr)
- [Adjectives containing numbers](#adj-num)
- [App vs application](#app)
- [Function vs method](#func-meth)
- [Onboard vs on-board](#onboard)
- [Sensor name vs sensor model](#name-model)
- [Setup vs set up](#setup)
- [Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi](#setup)
[Trademarks](#trademarks)
- [Intel products](#intel-prod)
- [Third-party technology](#third-party)
- [Trademark + noun](#tm-noun)
#### [Part II. Documentation Authoring](#doc-authoring)
[Grammar](#da-grammar)
- [Capitalization](#da-capitalization)
[Styling](#da-styling)
- [Bolding](#da-bolding)
- [Backticks](#da-backticks)
- [Links](#da-links)
- [Numbered list vs bullet points](#da-lists)
[Specific word usage](#da-word-usage)
- [Login vs log in](#da-login)
- [Click](#da-click)
- [SSH](#da-ssh)
# <a name="code-commenting"></a>Code Commenting Guidelines
## <a name="grammar"></a>Grammar
### <a name="voice"></a>Active vs passive voice
Where possible, prefer active voice over passive.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It can be put into the configuration mode by grounding the CONFIG pin on the transceiver. | - You can put it into the configuration mode by grounding the CONFIG pin on the transceiver.<br>- To put it into the configuration mode, ground the CONFIG pin on the transceiver.<br>- Put it into the configuration mode by grounding the CONFIG pin on the transceiver. |
### <a name="capitalization"></a>Capitalization
- Capitalize the first word in the description of an entity.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| checks to see if there is data available for reading | Checks to see if there is data available for reading |
| @param len length of the buffer | @param len Length of the buffer |
- Be consistent with the capitalization of boolean values.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns True on success, false otherwise | - Returns true on success, false otherwise<br>- Returns True on success, False otherwise |
### <a name="possessive-case"></a>No possessive case
Do not use possessive case to avoid unnecessary personalization.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| method's output | - method output<br>- output of the method |
### <a name="present-tense"></a>Present tense
Use the present simple tense instead of future, past, or present perfect.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| When specified, this value will be used in computing the voltage. | When specified, this value is used in computing the voltage. |
| Once the data has been read… | Once the data is read… |
### <a name="second-person"></a>Second person vs the user / reader / programmer / engineer
Use second person when addressing the target reader of your comment.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The user can easily override this method. | You can easily override this method. |
### <a name="third-person"></a>Third person vs infinitive
Use third-person verb forms in short descriptions of classes, methods, functions, etc., not infinitive.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Get the proximity value from the sensor | Gets the proximity value from the sensor |
## <a name="punctuation"></a>Punctuation
### <a name="comma"></a>Comma in enumerations
Add an extra comma before the last item in a list joined by **and** / **or**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns raw values for the X, Y and Z axes. | Returns raw values for the X, Y, and Z axes. |
### <a name="period"></a>No period at the end of description
Do not put a period if the description of an entity is one sentence long.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Returns the name of the sensor. | Returns the name of the sensor |
| Sets the frequency modulation<br>Valid values are between 10 and 160 (in kHz) | Sets the frequency modulation. Valid values are between 10 and 160 (in kHz). |
| @param millis Maximum time in milliseconds to wait for the input<br>-1 means waiting forever (default) | @param millis Maximum time in milliseconds to wait for the input. -1 means waiting forever (default). |
<font color="purple">**Exception:**</font> if the description contains more than one sentence, put periods after each sentence.
## <a name="word-usage"></a>Specific word usage
### <a name="abbr-acr"></a>Abbreviations and acronyms
- Spell out the first occurrence or the first prominent use of an abbreviation or acronym, followed by a shortened form.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| @brief API for the GP2Y0A family of IR Proximity Sensors | @brief API for the GP2Y0A family of infrared (IR) Proximity Sensors |
- Do not use Latin abbreviations.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Works best with halved values; e.g., 1.0, 0.5, 0.25, etc. | Works best with halved values; for example, 1.0, 0.5, 0.25, and so on. |
- Know exactly what the abbreviation or acronym means to avoid unnecessary duplication.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| - LCD display<br>- ISR routine | - LCD / liquid-crystal display<br>- ISR / interrupt service routine |
### <a name="adj-num"></a>Adjectives containing numbers
Adjectives of the form **number + noun / participle** should be hyphenated. It does not matter if a number is represented by one or more digits or spelled out.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| - 4 wire stepper motor<br>- 3 axis gyroscope<br>- zero based indexing<br>- one byte register | - 4-wire stepper motor<br>- 3-axis gyroscope<br>- zero-based indexing<br>- one-byte register |
### <a name="app"></a>App vs application
Use **app** when referring to a program running on a device, and **application** when referring to a program running on a desktop / laptop computer.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The wiki page for this device includes a link to an Android\* application that can be used to read the device via NFC. | The wiki page for this device includes a link to an Android\* app that can be used to read the device via NFC. |
### <a name="func-meth"></a>Function vs method
If a function is associated with a class, use **method** instead.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This function also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); | class WheelEncoder {<br>...<br>/**<br>* Starts the counter. This method also clears<br>* the current count and resets the clock.<br>*/<br>void startCounter(); |
### <a name="onboard"></a>Onboard vs on-board
Use **onboard**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| This ADC features an on-board reference and oscillator. | This ADC features an onboard reference and oscillator. |
### <a name="name-model"></a>Sensor name vs sensor model
Use a sensor name alone or a sensor model followed by a sensor name, not a sensor model alone.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| ADXL345 is compatible with… | - The ADXL345 3-axis digital accelerometer is compatible with…<br>- The accelerometer is compatible with… |
<font color="purple">**Exception:**</font> you can use a sensor model alone when introducing a
sensor for the first time:
ADXL345 is a 3-axis digital accelerometer…
### <a name="setup"></a>Setup vs set up
**Setup** is a noun, **set up** is a verb.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It does not require any additional set up. | It does not require any additional setup. |
| For instructions on how to setup…, refer to... | For instructions on how to set up…, refer to... |
### <a name="wi-fi"></a>Wi-Fi vs WiFi / Wifi / Wi-fi / wifi / wi-fi
Use **Wi-Fi**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It was tested with the XBee\* S6B WiFi module. | It is tested with the XBee\* S6B Wi-Fi\* module. |
## <a name="trademarks"></a>Trademarks
### <a name="intel-prod"></a>Intel products
Use the correct official names of Intel products. When in doubt, check the TM names database.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It is a 64x48 pixel OLED display that connects directly to an edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
**Note:** if an Intel product has a legally approved short name, you may use it in subsequent instances, after spelling it out the first time.
### <a name="third-party"></a>Third-party technology
Add an asterisk (\*) after a name to indicate a third-party trademark or registered intellectual property. If you are not sure whether an asterisk is necessary after a particular name, the rule of thumb is to put one, to be on the safe side.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| The Grove MQ2 Gas Sensor module is useful for gas leakage detection. | The Grove\* MQ2 Gas Sensor module is useful for gas leakage detection. |
### <a name="tm-noun"></a>Trademark + noun
Always follow trademarks by an appropriate noun. For a list of approved nouns for a particular trademark, check the TM names database.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison via its 80-pin connector. | It is a 64x48 pixel OLED display that connects directly to an Intel(R) Edison board via its 80-pin connector. |
# <a name="doc-authoring"></a>Documentation Authoring Guidelines
## <a name="da-grammar"></a>Grammar
### <a name="da-capitalization"></a>Capitalization
For titles, use sentence capitalization.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Add a New Device | Add a new device |
## <a name="da-styling"></a>Styling
### <a name="da-bolding"></a>Bolding
For GUI elements and file names, use bolding instead of quotes.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| In the “Environment Variables” window, click “OK”. | In the **Environment Variables** window, click **OK**. |
| Copy the “example.zip” archive into the installation directory. | Copy the **example.zip** archive into the installation directory. |
### <a name="da-backticks"></a>Backticks
Enclose program commands, code blocks, and file paths in backticks (\`).
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| To create a new device, use the **create-thing** command. | To create a new device, use the \`create-thing\` (rendered as `create-thing`) command. |
| Go to **C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws**. | Go to \`C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws\` (rendered as `C:\Users\me\Documents\GitHub\intel-iot-examples-mqtt\support\aws`). |
### <a name="da-links"></a>Links
Do not use embedded links to third-party websites.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Create an account on [Microsoft Azure](https://azure.microsoft.com/en-us), if you do not yet have one. | Create an account on [https://azure.microsoft.com/en-us](https://azure.microsoft.com/en-us), if you do not yet have one. |
### <a name="da-lists"></a>Numbered list vs bullet points
- For a logical sequence of steps, use a numbered list.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| When running your C++ code on the Edison, you need to set the MQTT parameters in Eclipse. Go to "Run configurations", and change the "Commands to execute before application" to the following:<br><br>Click on the "Apply" button to save these settings.<br>Click on the "Run" button to run the code on the Edison. | When running your C++ code on the Intel® Edison board, you need to set the MQTT\* client parameters in Eclipse\*. To do that:<br>1. Go to **Run configurations** and, in the **Commands to execute before application** field, type the following:<br><br>2. Click the **Apply** button to save these settings.<br>3. Click the **Run** button to run the code on your board. |
- For a list of equally important options, use a bulleted list.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| From this exercise, developers will learn how to:<br>1. Connect the Intel® Edison board...<br>2. Run these code samples in the Intel® System Studio IoT Edition...<br>3. Set up a web application server... | From this exercise, developers will learn how to:<br>- Connect the Intel® Edison board…<br>- Run these code samples in the Intel® System Studio IoT Edition…<br>- Set up a web application server… |
## <a name="da-word-usage"></a>Specific word usage
### <a name="da-login"></a>Login vs log in
**Login** is a noun, **log in** is a verb.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Provide your log in and password. | Provide your login and password. |
| Login to your account. | Log in( )to your account. |
### <a name="da-click"></a>Click
Omit **on** after **click**.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| Click on **Advanced system settings**. | Click **Advanced system settings**. |
### <a name="da-ssh"></a>SSH
Do not use SSH as a verb. It is considered slang and is to be avoided.
| <font color="red">**Incorrect**</font> | <font color="green">**Correct**</font> |
| --- | --- |
| SSH into your Intel® Edison board. | Establish an SSH connection to your Intel® Edison board. |

BIN
upm/docs/icons/c++.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
upm/docs/icons/iss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
upm/docs/icons/java.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
upm/docs/icons/node.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
upm/docs/icons/python.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
upm/docs/icons/upm_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
upm/docs/images/1wire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
upm/docs/images/a110x.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
upm/docs/images/ad8232.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
upm/docs/images/ads1015.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
upm/docs/images/ads1115.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
upm/docs/images/adxl335.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
upm/docs/images/am2315.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
upm/docs/images/apa102.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

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