Compare commits
552 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d6f76ff8c2 | ||
![]() |
8ae7f89e03 | ||
![]() |
3f7dcc6e0b | ||
![]() |
0a0c352614 | ||
![]() |
89d5de43e0 | ||
![]() |
dc843c0bd7 | ||
![]() |
c37a48255e | ||
![]() |
ab25e56212 | ||
![]() |
f5a66936be | ||
![]() |
5cf20df96c | ||
![]() |
33d0aee280 | ||
![]() |
7d0600df1c | ||
![]() |
b454862649 | ||
![]() |
9501488709 | ||
![]() |
8f3f2a7de2 | ||
![]() |
4c6fde84f4 | ||
![]() |
2c7fff24c7 | ||
![]() |
e3d054086b | ||
![]() |
2b6f2c5b53 | ||
![]() |
2a948ca687 | ||
![]() |
d282d479bb | ||
![]() |
d256a225bf | ||
![]() |
9cddd4a8b1 | ||
![]() |
223b6028bf | ||
![]() |
b08eef0197 | ||
![]() |
e0be90589b | ||
![]() |
bf315ee5c6 | ||
![]() |
066385d9ac | ||
![]() |
934d571964 | ||
![]() |
ef92026253 | ||
![]() |
a106345527 | ||
![]() |
3044bc6b49 | ||
![]() |
d2428ca5da | ||
![]() |
bd445385a7 | ||
![]() |
402739fa74 | ||
![]() |
5b97b0a98e | ||
![]() |
d3ce509334 | ||
![]() |
f608b0fa98 | ||
![]() |
6cbfa60729 | ||
![]() |
8a2ef9a648 | ||
![]() |
1c0ed9c9bd | ||
![]() |
fe3dcc01b2 | ||
![]() |
1111a830c9 | ||
![]() |
660b34c2ce | ||
![]() |
9869b31a3e | ||
![]() |
90167f6ac1 | ||
![]() |
03bc2ae26e | ||
![]() |
a8cd0f72ec | ||
![]() |
cb27acbc04 | ||
![]() |
2975bae075 | ||
![]() |
8f11061de3 | ||
![]() |
a3bf6d76a9 | ||
![]() |
582decd4f7 | ||
![]() |
d38339ab9f | ||
![]() |
fc0c0fdbaa | ||
![]() |
b675b89e1b | ||
![]() |
ebe84f96b2 | ||
![]() |
c5287adf36 | ||
![]() |
9f545f10af | ||
![]() |
40f6bd9c6c | ||
![]() |
71cb3606ee | ||
![]() |
6103516884 | ||
![]() |
55f749529f | ||
![]() |
742150feea | ||
![]() |
87dc660bd6 | ||
![]() |
48ecaeaea9 | ||
![]() |
56f4dd9a92 | ||
![]() |
93196d62cb | ||
![]() |
cca6a86268 | ||
![]() |
4faf4ee816 | ||
![]() |
d00dc3e332 | ||
![]() |
50961c6020 | ||
![]() |
82edcec766 | ||
![]() |
db3b99a792 | ||
![]() |
aa87b14126 | ||
![]() |
550e48e806 | ||
![]() |
d7fe4e717b | ||
![]() |
7352aab3b0 | ||
![]() |
7b5b02d859 | ||
![]() |
9db28cd4fc | ||
![]() |
dfdc362c2c | ||
![]() |
d23183897d | ||
![]() |
9ba309bc48 | ||
![]() |
32b73a1d25 | ||
![]() |
58ee51c767 | ||
![]() |
e4f106a0c7 | ||
![]() |
f28a6d2561 | ||
![]() |
aa966946d5 | ||
![]() |
34bb12933d | ||
![]() |
b6e53f7da8 | ||
![]() |
f992876461 | ||
![]() |
90524273ec | ||
![]() |
bfdd2c37c0 | ||
![]() |
57c0c8c235 | ||
![]() |
664c6dd8c6 | ||
![]() |
1f1510f38d | ||
![]() |
c642e02a18 | ||
![]() |
864e1eb073 | ||
![]() |
ddcc4f467e | ||
![]() |
c16b33ae31 | ||
![]() |
9669f226b9 | ||
![]() |
2abfd3f1ba | ||
![]() |
2f0ae1cc49 | ||
![]() |
079e444fce | ||
![]() |
2405f933de | ||
![]() |
c3d5d951e1 | ||
![]() |
bbcee52880 | ||
![]() |
87fc11adbe | ||
![]() |
4addac7e01 | ||
![]() |
57f03b79aa | ||
![]() |
52b3087de9 | ||
![]() |
efd36e57b0 | ||
![]() |
8312e1d18f | ||
![]() |
b917f0ca54 | ||
![]() |
b058d341c0 | ||
![]() |
1949916a8e | ||
![]() |
f5f2920c70 | ||
![]() |
fd34b9669d | ||
![]() |
8693a72ed6 | ||
![]() |
75c7bd8d12 | ||
![]() |
6d8e6d8a9f | ||
![]() |
2b36d30243 | ||
![]() |
a589f92cec | ||
![]() |
f035470822 | ||
![]() |
6bf21a23e7 | ||
![]() |
16e72d2ff7 | ||
![]() |
94be00a63d | ||
![]() |
d5cb613ad0 | ||
![]() |
c0c37028e4 | ||
![]() |
eb8d64f52b | ||
![]() |
1ddf969020 | ||
![]() |
85608a9f61 | ||
![]() |
4927311a0c | ||
![]() |
b50b93272d | ||
![]() |
ed4fe56ef8 | ||
![]() |
67b77b78aa | ||
![]() |
bc01f710ea | ||
![]() |
1af38e060e | ||
![]() |
62f84dcc47 | ||
![]() |
6ae7e9125b | ||
![]() |
07a9af07fe | ||
![]() |
89e2ec870a | ||
![]() |
4935a16530 | ||
![]() |
9ef90ccb81 | ||
![]() |
5f2557b159 | ||
![]() |
09208e90d0 | ||
![]() |
e0105cb601 | ||
![]() |
c2ce3e8222 | ||
![]() |
db3c73cbd1 | ||
![]() |
be46240b8c | ||
![]() |
ef81a20140 | ||
![]() |
8a617aa904 | ||
![]() |
a16d279b6f | ||
![]() |
3e84b74bdf | ||
![]() |
186bbfab76 | ||
![]() |
01cc3a0734 | ||
![]() |
09e536b4ff | ||
![]() |
dc45cd7859 | ||
![]() |
3790c0bbc1 | ||
![]() |
7a2332fa7d | ||
![]() |
330c94f1e2 | ||
![]() |
9a959b578c | ||
![]() |
cdfb68c381 | ||
![]() |
6228498147 | ||
![]() |
8b4e1020f4 | ||
![]() |
3a077df5f6 | ||
![]() |
1b5087105b | ||
![]() |
ec9143e976 | ||
![]() |
37642f3b01 | ||
![]() |
17110d41d0 | ||
![]() |
dd73c4aa45 | ||
![]() |
8f63914d76 | ||
![]() |
306872619a | ||
![]() |
ad15b27cb1 | ||
![]() |
b55501e327 | ||
![]() |
e99f1d73fd | ||
![]() |
fc56e56048 | ||
![]() |
757683b2ca | ||
![]() |
b09944f4b8 | ||
![]() |
f45429e1f0 | ||
![]() |
54c6d294af | ||
![]() |
83f541a5db | ||
![]() |
090ce2040e | ||
![]() |
76dd42a47d | ||
![]() |
63c3b4bc69 | ||
![]() |
7254d5f75e | ||
![]() |
f907ebcf2e | ||
![]() |
334f7365f0 | ||
![]() |
41e80d611e | ||
![]() |
92b0919f56 | ||
![]() |
c54d6de054 | ||
![]() |
86e8471cad | ||
![]() |
2c17998ac9 | ||
![]() |
a43bcfe8d2 | ||
![]() |
1be36ec1df | ||
![]() |
e4dd6457bb | ||
![]() |
ad36f83857 | ||
![]() |
2a17fe094e | ||
![]() |
8f99289a48 | ||
![]() |
829da899fc | ||
![]() |
20aa4962f0 | ||
![]() |
3d674efb51 | ||
![]() |
cc7fec9ae0 | ||
![]() |
4a1eb99d6d | ||
![]() |
a12baf379f | ||
![]() |
38817b72dc | ||
![]() |
fe7bd75c91 | ||
![]() |
460fdc2eb5 | ||
![]() |
9d51454290 | ||
![]() |
6f72c52a44 | ||
![]() |
7d83e8c569 | ||
![]() |
96bcfc9128 | ||
![]() |
6be656d5b0 | ||
![]() |
3cfea676e2 | ||
![]() |
f64060b9d2 | ||
![]() |
36ebd15abc | ||
![]() |
23a57b8c90 | ||
![]() |
666452e873 | ||
![]() |
d49ab2ac95 | ||
![]() |
d06e632f3b | ||
![]() |
e192a125f3 | ||
![]() |
63b2b33df7 | ||
![]() |
2551596309 | ||
![]() |
6725559669 | ||
![]() |
680649ba6f | ||
![]() |
74b5ec00dc | ||
![]() |
abefdfc756 | ||
![]() |
f97a62b055 | ||
![]() |
7422ec937c | ||
![]() |
a842898bd5 | ||
![]() |
76949d9358 | ||
![]() |
b244fe45d1 | ||
![]() |
b367a63010 | ||
![]() |
a5680d9b9a | ||
![]() |
a6111a83b5 | ||
![]() |
450f071f7d | ||
![]() |
82c8acf0fe | ||
![]() |
a65cd2e59b | ||
![]() |
c154ec6cb8 | ||
![]() |
d9d48e939f | ||
![]() |
b1a49f0d3c | ||
![]() |
ac89a4a130 | ||
![]() |
f848deb35b | ||
![]() |
71b2b9b1fc | ||
![]() |
18b8ca2633 | ||
![]() |
a96c607fb5 | ||
![]() |
bc4f124d54 | ||
![]() |
35e4fc012e | ||
![]() |
4037ec517c | ||
![]() |
40084ea651 | ||
![]() |
91876d48ed | ||
![]() |
b9010059ad | ||
![]() |
166332744e | ||
![]() |
614c4a516b | ||
![]() |
40e73e648a | ||
![]() |
153d8cfb12 | ||
![]() |
cffaf5c6ba | ||
![]() |
ab841ef591 | ||
![]() |
5228df9a8b | ||
![]() |
b75a9daee4 | ||
![]() |
6cc5c9691d | ||
![]() |
e8aeaff162 | ||
![]() |
694034d052 | ||
![]() |
fc17744104 | ||
![]() |
3b8f215590 | ||
![]() |
e22f62f948 | ||
![]() |
5cefe7f5f3 | ||
![]() |
bd6e4ec786 | ||
![]() |
2f9132c429 | ||
![]() |
e734459ddd | ||
![]() |
cc3721128e | ||
![]() |
28380f2bfa | ||
![]() |
303323fa3a | ||
![]() |
0bf4a38f5e | ||
![]() |
e441c343d8 | ||
![]() |
60816d8f2a | ||
![]() |
ef681a0ab5 | ||
![]() |
f37236fa01 | ||
![]() |
aa047d6b5c | ||
![]() |
0345a8e9f1 | ||
![]() |
5bdd7a4c03 | ||
![]() |
3ca7889755 | ||
![]() |
c5cdfc702c | ||
![]() |
a99e32fc13 | ||
![]() |
9e09f899cf | ||
![]() |
ae77966204 | ||
![]() |
b0a842229a | ||
![]() |
0f3f0e02ae | ||
![]() |
287d716401 | ||
![]() |
db89d872b4 | ||
![]() |
c46fb64cac | ||
![]() |
1f97840fee | ||
![]() |
7bee29ba62 | ||
![]() |
24b6cbcc85 | ||
![]() |
ab4eeea61e | ||
![]() |
98811b0fb7 | ||
![]() |
f92c0c120e | ||
![]() |
01036f7dae | ||
![]() |
5e7a8b41a3 | ||
![]() |
f59f3131bb | ||
![]() |
539fbe7c75 | ||
![]() |
5a1f27a92d | ||
![]() |
f4da94a06e | ||
![]() |
e190bb9d60 | ||
![]() |
bac9e3bbc0 | ||
![]() |
1647d8bc08 | ||
![]() |
6bfb07e46a | ||
![]() |
c25fa47e2f | ||
![]() |
7cd290901d | ||
![]() |
aaf733f41b | ||
![]() |
ac4a10e248 | ||
![]() |
8a4e06d856 | ||
![]() |
9482d6bb74 | ||
![]() |
0cb93331ee | ||
![]() |
f01c89b95a | ||
![]() |
4344151405 | ||
![]() |
74cb3504f3 | ||
![]() |
ac031ba9a8 | ||
![]() |
65726087bc | ||
![]() |
dc03eec56f | ||
![]() |
c1903b8c39 | ||
![]() |
0cb7d3f9b4 | ||
![]() |
874eacf12e | ||
![]() |
3e6fb61a20 | ||
![]() |
8e7ac713c4 | ||
![]() |
54c1b0ce4b | ||
![]() |
53456d9138 | ||
![]() |
7ec1765766 | ||
![]() |
bb122bfac4 | ||
![]() |
0f8e578c62 | ||
![]() |
dcee721cb3 | ||
![]() |
b11ec1638e | ||
![]() |
fb6ae47b6d | ||
![]() |
be718d79af | ||
![]() |
87ffc81b65 | ||
![]() |
afd9dd07e4 | ||
![]() |
ce9742b355 | ||
![]() |
c402fbb5e8 | ||
![]() |
b757ccc617 | ||
![]() |
c5c57b523b | ||
![]() |
bb4ce17d44 | ||
![]() |
d4396c2ce3 | ||
![]() |
780b5df024 | ||
![]() |
60379fca37 | ||
![]() |
b90c5a7710 | ||
![]() |
28f964cb48 | ||
![]() |
b68eb5f6a6 | ||
![]() |
50bb4ae1be | ||
![]() |
da18bac925 | ||
![]() |
2b70bea44f | ||
![]() |
c64d04d084 | ||
![]() |
8186d093ec | ||
![]() |
b2eb392a07 | ||
![]() |
274fd9b608 | ||
![]() |
27eec52e29 | ||
![]() |
ee0aaa89eb | ||
![]() |
886deabfbb | ||
![]() |
e740349355 | ||
![]() |
34f2799c53 | ||
![]() |
a03d8eb52f | ||
![]() |
07f3029f10 | ||
![]() |
a56b83fa37 | ||
![]() |
b4bc15201b | ||
![]() |
c70f378f72 | ||
![]() |
106b6c7062 | ||
![]() |
6c3b161702 | ||
![]() |
c484056cf0 | ||
![]() |
2931a9c24d | ||
![]() |
aeefc758ee | ||
![]() |
21a1860ec2 | ||
![]() |
c78da687d4 | ||
![]() |
6c383dbd42 | ||
![]() |
7688e5f230 | ||
![]() |
1db6bd826a | ||
![]() |
e7ca8cf18b | ||
![]() |
cdb735c34e | ||
![]() |
90e4b5d385 | ||
![]() |
6a37edcdac | ||
![]() |
563519ae4f | ||
![]() |
7b812284c5 | ||
![]() |
0082f54902 | ||
![]() |
b32e4911ab | ||
![]() |
fe9254c004 | ||
![]() |
e3a8b2fc13 | ||
![]() |
21ecbd90eb | ||
![]() |
0bd68e4e2b | ||
![]() |
b2aa2515b0 | ||
![]() |
5cc4e2120a | ||
![]() |
fe4e97f5dc | ||
![]() |
6e4faefe15 | ||
![]() |
460e9de94f | ||
![]() |
1f5f466691 | ||
![]() |
12c59a6aca | ||
![]() |
19c58ebba2 | ||
![]() |
d9fd1af272 | ||
![]() |
78eb975435 | ||
![]() |
a0ea3d5f3d | ||
![]() |
f77863dfb5 | ||
![]() |
7e5f6e9856 | ||
![]() |
d004aa68b7 | ||
![]() |
3aef2ea70e | ||
![]() |
39df7fd10f | ||
![]() |
b8738b32ca | ||
![]() |
cdb697fd7b | ||
![]() |
27dc4a5742 | ||
![]() |
e2fe04927f | ||
![]() |
a655235c70 | ||
![]() |
96b219d2fb | ||
![]() |
52879b0b04 | ||
![]() |
048f1ac08e | ||
![]() |
76a12af15f | ||
![]() |
e6ed49427a | ||
![]() |
c57a0d2c30 | ||
![]() |
8d43c431f2 | ||
![]() |
336251740d | ||
![]() |
356f0348ed | ||
![]() |
dc7c012c24 | ||
![]() |
96eb834e9b | ||
![]() |
b239866e99 | ||
![]() |
6a4f06d51b | ||
![]() |
e765dcf57b | ||
![]() |
a594036778 | ||
![]() |
c014ffddcd | ||
![]() |
aeaf84ccc6 | ||
![]() |
7d789ec208 | ||
![]() |
3d0461b40a | ||
![]() |
5aed632782 | ||
![]() |
3c5a5b87c8 | ||
![]() |
22a6c52795 | ||
![]() |
b8fa948f7d | ||
![]() |
f61b615704 | ||
![]() |
8dcd22794b | ||
![]() |
33f3c882b8 | ||
![]() |
5943dad78c | ||
![]() |
2f051a202c | ||
![]() |
a760f2952a | ||
![]() |
9549529faf | ||
![]() |
65969462d1 | ||
![]() |
13eea53090 | ||
![]() |
fa8ab6194d | ||
![]() |
8048e8734f | ||
![]() |
8262a4203b | ||
![]() |
01f9dd2f41 | ||
![]() |
ccb9fa2a4f | ||
![]() |
05435eed4f | ||
![]() |
54a84af1c3 | ||
![]() |
27c6ac1d31 | ||
![]() |
8779700d82 | ||
![]() |
f9b5d7c52c | ||
![]() |
a10e798682 | ||
![]() |
8cd91624ee | ||
![]() |
68e42a22d6 | ||
![]() |
fdef953859 | ||
![]() |
3f334ed1f3 | ||
![]() |
1a0bdf00cf | ||
![]() |
54cd191d43 | ||
![]() |
9fa4dad1ab | ||
![]() |
080c121e07 | ||
![]() |
545e288967 | ||
![]() |
aecdac255d | ||
![]() |
5c837f22cb | ||
![]() |
12c81adeba | ||
![]() |
8342b4c079 | ||
![]() |
e83b8ef114 | ||
![]() |
fabf4287d6 | ||
![]() |
4ea01180a1 | ||
![]() |
ab171573f9 | ||
![]() |
d965b92af1 | ||
![]() |
cc0174910b | ||
![]() |
c4a506f5a3 | ||
![]() |
58cdfadf4e | ||
![]() |
b3a5275183 | ||
![]() |
b314f56c00 | ||
![]() |
d4b536b593 | ||
![]() |
2bdde21a2f | ||
![]() |
6ceebc9a17 | ||
![]() |
65fc70a31a | ||
![]() |
51a181a14f | ||
![]() |
cfb4105dd8 | ||
![]() |
b7faba556f | ||
![]() |
95801b395d | ||
![]() |
1f18369fbe | ||
![]() |
f8663c90f3 | ||
![]() |
1d6d660769 | ||
![]() |
b57710cd78 | ||
![]() |
6d41566e93 | ||
![]() |
7a60cd5abe | ||
![]() |
b9988469ba | ||
![]() |
4fff3a500d | ||
![]() |
a53ab5cb80 | ||
![]() |
bd8104f6ee | ||
![]() |
dbac88d225 | ||
![]() |
70bcdfefa4 | ||
![]() |
762c28f000 | ||
![]() |
283fce619e | ||
![]() |
7a5c8a6cb3 | ||
![]() |
4342b880b9 | ||
![]() |
ddddbd024d | ||
![]() |
67e0ceb48d | ||
![]() |
2298846fef | ||
![]() |
567476b89a | ||
![]() |
d345006c03 | ||
![]() |
7f0e03b0e3 | ||
![]() |
08a46ee8e6 | ||
![]() |
fb88fda5cb | ||
![]() |
90d856d128 | ||
![]() |
d2e0327c30 | ||
![]() |
2e97aa9979 | ||
![]() |
cdb75e8c13 | ||
![]() |
dac31a0347 | ||
![]() |
0749f130e1 | ||
![]() |
1bbb9386b7 | ||
![]() |
f914159e21 | ||
![]() |
849711c47d | ||
![]() |
0a91eb0b46 | ||
![]() |
806b00c2b7 | ||
![]() |
e8151640a1 | ||
![]() |
123e611f45 | ||
![]() |
8d5278b9d4 | ||
![]() |
ab96e8f3a3 | ||
![]() |
d3b864362d | ||
![]() |
6769d976a0 | ||
![]() |
bd47b9ed45 | ||
![]() |
6ea65a16a4 | ||
![]() |
0849fbc674 | ||
![]() |
e25be536a1 | ||
![]() |
a70629e3b2 | ||
![]() |
fed0478dc9 | ||
![]() |
fcb4d9d36d | ||
![]() |
5eb8af6d70 | ||
![]() |
3c93eba4af | ||
![]() |
78953b110f | ||
![]() |
53124e9704 | ||
![]() |
cde747439f | ||
![]() |
dfc7a710d4 | ||
![]() |
130cb822e4 | ||
![]() |
c057fa6708 | ||
![]() |
c6ad8cb5ee | ||
![]() |
024b43dfa3 | ||
![]() |
6667646d32 | ||
![]() |
e1e9067744 | ||
![]() |
c4656bf8ba | ||
![]() |
232089f400 | ||
![]() |
09144e712b | ||
![]() |
2d94c2ed90 | ||
![]() |
91652a2da5 | ||
![]() |
929244b27a | ||
![]() |
9a4f0cae0c | ||
![]() |
402de082d3 | ||
![]() |
ad275e1d41 | ||
![]() |
d4559878df | ||
![]() |
971cb4ab51 |
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
Dockerfile
|
||||
docker-compose.yaml
|
||||
build
|
3
.gitignore
vendored
@ -11,3 +11,6 @@ build*/
|
||||
# Temp files
|
||||
*.swp
|
||||
*~
|
||||
|
||||
# Node modules
|
||||
**/node_modules
|
||||
|
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[submodule "doxy/doxygen2jsdoc"]
|
||||
path = doxy/doxygen2jsdoc
|
||||
url = https://github.com/intel-iot-devkit/doxygen2jsdoc
|
||||
[submodule "doxy/doxyport"]
|
||||
path = doxy/doxyport
|
||||
url = https://github.com/intel-iot-devkit/doxyport
|
137
.travis.yml
@ -1,48 +1,91 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
language: cpp
|
||||
env:
|
||||
global:
|
||||
- MRAA_ROOT=/tmp/mraa
|
||||
- MRAA_BUILD=$MRAA_ROOT/build
|
||||
- UPM_ROOT=$TRAVIS_BUILD_DIR
|
||||
- UPM_BUILD=$UPM_ROOT/build
|
||||
- JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
matrix:
|
||||
- NODE010=true
|
||||
- NODE012=true
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
install:
|
||||
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-dev/swig
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y --force-yes -qq swig3.0 git
|
||||
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||
- sudo update-java-alternatives -s java-8-oracle
|
||||
before_script:
|
||||
# Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
|
||||
- if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; fi
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; fi
|
||||
# Handle 0.10 NODE_ROOT_DIR differently than other versions
|
||||
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
|
||||
script:
|
||||
# Build/install MRAA
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
|
||||
- mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=ON -DFIRMATA=ON -DENABLEEXAMPLES=OFF $MRAA_ROOT
|
||||
- sudo make install
|
||||
- sudo ldconfig
|
||||
# Build/install UPM
|
||||
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DBUILDTESTS=ON .. && sudo make install && sudo ldconfig && ctest --output-on-failure -E examplenames_js
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- george-edison55-precise-backports
|
||||
packages:
|
||||
- cmake
|
||||
- cmake-data
|
||||
- g++-4.8
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo wget -q https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TARGET=android
|
||||
include:
|
||||
- &run-with-clang-minimal
|
||||
stage: Clang 3.8 - minimal with unit tests
|
||||
env:
|
||||
- TARGET=minimal
|
||||
- CMAKE_BUILD_TYPE=Debug
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-with-clang-minimal
|
||||
env:
|
||||
- TARGET=minimal
|
||||
- CMAKE_BUILD_TYPE=Release
|
||||
- &run-with-clang
|
||||
stage: Clang 3.8
|
||||
env: TARGET=python
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-clang
|
||||
env: TARGET=java
|
||||
- &run-with-gcc-5
|
||||
stage: Gcc 5
|
||||
env: TARGET=python
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=gcc-5 CXX=g++-5
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-gcc-5
|
||||
env: TARGET=java
|
||||
- &run-with-gcc-6
|
||||
stage: Gcc 6
|
||||
env: TARGET=python
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=gcc-6 CXX=g++-6
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node4
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node5
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=node6
|
||||
- <<: *run-with-gcc-6
|
||||
env: TARGET=java
|
||||
- &run-additional-jobs
|
||||
stage: Additional Jobs
|
||||
env: TARGET=doc
|
||||
before_script: docker-compose pull ${TARGET}
|
||||
script:
|
||||
- export CC=clang-3.8 CXX=clang++-3.8
|
||||
- docker-compose run ${TARGET}
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=android
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=cordova
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=examples
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=sonar-scan
|
||||
- <<: *run-additional-jobs
|
||||
env: TARGET=npm
|
||||
|
310
CMakeLists.txt
@ -8,10 +8,8 @@ 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 (BUILDEXAMPLES "Build C/C++ example binaries" OFF)
|
||||
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
option (BUILDCORDOVA "Build cordova bindings" OFF)
|
||||
option (BUILDEXAMPLES "Build C/C++/JAVA examples" OFF)
|
||||
option (NPM "Generate NPM/GYP tarballs" OFF)
|
||||
option (BUILDTESTS "Generate check-ups for upm" OFF)
|
||||
option (WERROR "Make all warnings into errors." ON)
|
||||
@ -91,12 +89,19 @@ endfunction ()
|
||||
|
||||
# Compiler flags common to both C and CXX
|
||||
# Enable -Wall
|
||||
set (C_CXX_WARNING_FLAGS -Wall
|
||||
-Wno-strict-aliasing
|
||||
-Wno-deprecated-declarations # Temp fix for MRAA deprecated methods
|
||||
)
|
||||
|
||||
# GCC-6 added -Wmisleading-indentation to -Wall, skip these for now
|
||||
set (C_CXX_WARNING_FLAGS -Wall -Wno-misleading-indentation -Wno-strict-aliasing)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6")
|
||||
list (APPEND C_CXX_WARNING_FLAGS -Wno-misleading-indentation)
|
||||
endif ()
|
||||
|
||||
# Warnings as errors?
|
||||
if (WERROR)
|
||||
set (C_CXX_WARNING_FLAGS "-Werror ${C_CXX_WARNING_FLAGS}")
|
||||
list (APPEND C_CXX_WARNING_FLAGS -Werror)
|
||||
message (STATUS "Warnings as errors enabled (-Werror), disable with -DWERROR=off")
|
||||
endif (WERROR)
|
||||
|
||||
@ -105,6 +110,7 @@ endif (WERROR)
|
||||
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
|
||||
@ -112,15 +118,29 @@ upm_add_compile_flags(C ${C_CXX_WARNING_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 1.1.1)
|
||||
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)
|
||||
@ -131,14 +151,42 @@ pkg_check_modules (MODBUS libmodbus>=3.1.2)
|
||||
# Check for OPENZWAVE
|
||||
pkg_check_modules (OPENZWAVE libopenzwave)
|
||||
|
||||
# Check for TinyB
|
||||
pkg_check_modules (TINYB tinyb>=0.5.1)
|
||||
# And get full path to the tinyb library
|
||||
find_library(TINYB_LIBRARY NAMES tinyb HINTS ${TINYB_LIBDIR})
|
||||
|
||||
# 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)
|
||||
@ -187,7 +235,7 @@ include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
# If git_describe fails, use a dirty version
|
||||
if (${VERSION} MATCHES -NOTFOUND)
|
||||
set (VERSION "v1.0.1-dirty")
|
||||
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 ()
|
||||
@ -210,16 +258,6 @@ 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}")
|
||||
|
||||
#-march=native for ARM when not defined/forced
|
||||
if (DETECTED_ARCH MATCHES "arm.*" AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||
endif()
|
||||
|
||||
# enable c++11 standards support unconditionally
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||
@ -254,173 +292,143 @@ else()
|
||||
set (C_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
# The doc target depends on each sensor target
|
||||
# The doc target depends on the C/C++ source and all libraries
|
||||
#
|
||||
# doc
|
||||
# ├──> src
|
||||
# ├──> include
|
||||
# ├──> libupm_sensor0
|
||||
# ├──> libupm_sensor1
|
||||
# ├──> libupm_sensor2
|
||||
# ├──> ...
|
||||
# └──> libupm_sensor_n
|
||||
#
|
||||
# The pydoc target builds documentation with sphinx via inspection by loading
|
||||
# each python module. Those modules must include the CXX documentation via
|
||||
# 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
|
||||
# ├──> libupm_sensor0
|
||||
# └──> doxy2swig
|
||||
#
|
||||
# The doxy2swig target is dependent upon the doc target IF BUILDDOC=ON,
|
||||
# otherwise doxy2swig uses an empty file. Doxy2swig also depends on each
|
||||
# sensor target
|
||||
#
|
||||
# doxy2swig
|
||||
# ├──> BUILDDOC=ON───> doc
|
||||
# └──> libupm_sensor0
|
||||
# └──> BUILDDOC=ON───> doc
|
||||
#
|
||||
# The jsdoc target builds js documentation via yuidoc and only requires
|
||||
# the doc target
|
||||
#
|
||||
# jsdoc ─> doc
|
||||
#
|
||||
if (BUILDDOC)
|
||||
function (CreateDocumentationTargets)
|
||||
# Add a target to generate API documentation with Doxygen
|
||||
find_package (Doxygen REQUIRED)
|
||||
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()
|
||||
add_custom_target (doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
COMMAND tar -czf html/xml.tar.gz -C xml .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
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()
|
||||
|
||||
# Check if Sphinx is installed and add target to generate API documentationa
|
||||
# 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)
|
||||
find_package (Sphinx REQUIRED)
|
||||
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_target (pydoc ALL
|
||||
COMMAND rm -r -f ${CMAKE_BINARY_DIR}/pyupm && mkdir -p ${CMAKE_BINARY_DIR}/pyupm
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/pyupm \;
|
||||
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/pyupm
|
||||
# TODO: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND ${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
|
||||
# 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
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
)
|
||||
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 REQUIRED)
|
||||
file(GLOB_RECURSE JSDOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/doxy/node doxy/node/*)
|
||||
foreach(JSDOC_FILE ${JSDOC_FILES})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
|
||||
endforeach()
|
||||
add_custom_target(jsdoc ALL
|
||||
COMMAND ${NODEJS_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
|
||||
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
|
||||
COMMAND ${NODEJS_EXECUTABLE} tolower -i html/node
|
||||
DEPENDS doc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Yuidoc" VERBATIM
|
||||
)
|
||||
endif(BUILDSWIGNODE)
|
||||
endif (BUILDDOC)
|
||||
|
||||
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")
|
||||
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 ()
|
||||
set (TARGET_ARCH ${DETECTED_ARCH})
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Yuidoc. Node.js API doc will not be generated")
|
||||
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_PACKAGE_VERSION ${VERSION})
|
||||
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()
|
||||
endif(BUILDSWIGNODE)
|
||||
endfunction()
|
||||
|
||||
# UPM common headers
|
||||
set (UPM_COMMON_HEADER_DIRS
|
||||
${CMAKE_HOME_DIRECTORY}/include
|
||||
${CMAKE_HOME_DIRECTORY}/include/fti)
|
||||
set (UPM_COMMON_HEADER_DIRS ${CMAKE_HOME_DIRECTORY}/include)
|
||||
|
||||
# Generate a build-only C++ header to add functionality to SWIG'ed modules
|
||||
configure_file (${PROJECT_SOURCE_DIR}/cmake/modules/version.hpp.in ${PROJECT_BINARY_DIR}/src/version.hpp @ONLY)
|
||||
|
||||
# UPM source
|
||||
add_subdirectory (src)
|
||||
if(BUILDEXAMPLES)
|
||||
add_subdirectory (examples/c)
|
||||
if(BUILDCPP)
|
||||
add_subdirectory (examples/c++)
|
||||
endif(BUILDCPP)
|
||||
endif()
|
||||
|
||||
if(BUILDJAVAEXAMPLES)
|
||||
add_subdirectory (examples/java)
|
||||
endif()
|
||||
# UPM examples
|
||||
add_subdirectory (examples)
|
||||
|
||||
# Python interp is previously found if BUILDTESTS=ON
|
||||
if (BUILDTESTS)
|
||||
@ -428,6 +436,12 @@ if (BUILDTESTS)
|
||||
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
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
COMPONENT ${CMAKE_PROJECT_NAME}-dev
|
||||
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
|
||||
|
44
CONTRIBUTING
Normal file
@ -0,0 +1,44 @@
|
||||
# Contributing to Eclipse UPM
|
||||
|
||||
Thanks for your interest in this project.
|
||||
|
||||
## Project description
|
||||
|
||||
The Eclipse 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 Eclipse MRAA APIs.
|
||||
|
||||
* https://projects.eclipse.org/projects/iot.upm
|
||||
|
||||
## Developer resources
|
||||
|
||||
Information regarding source code management, builds, coding standards, and
|
||||
more.
|
||||
|
||||
* https://projects.eclipse.org/projects/iot.upm/developer
|
||||
|
||||
The project maintains the following source code repositories
|
||||
|
||||
|
||||
## Eclipse Contributor Agreement
|
||||
|
||||
Before your contribution can be accepted by the project team contributors must
|
||||
electronically sign the Eclipse Contributor Agreement (ECA).
|
||||
|
||||
* http://www.eclipse.org/legal/ECA.php
|
||||
|
||||
Commits that are provided by non-committers must have a Signed-off-by field in
|
||||
the footer indicating that the author is aware of the terms by which the
|
||||
contribution has been provided to the project. The non-committer must
|
||||
additionally have an Eclipse Foundation account and must have a signed Eclipse
|
||||
Contributor Agreement (ECA) on file.
|
||||
|
||||
For more information, please see the Eclipse Committer Handbook:
|
||||
https://www.eclipse.org/projects/handbook/#resources-commit
|
||||
|
||||
## Contact
|
||||
|
||||
Contact the project developers via the project's "dev" list.
|
||||
|
||||
*
|
3
LICENSE
@ -1,4 +1,5 @@
|
||||
Copyright © 2014-2015 Intel Corporation
|
||||
The MIT License (MIT)
|
||||
Copyright © 2014-2019 Intel Corporation and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
106
README.md
@ -1,112 +1,114 @@
|
||||
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
|
||||
<p align="center">
|
||||
<img src="https://github.com/eclipse/upm/blob/master/docs/icons/upm_logo.png" height="150px" width="auto" algt="UPM Logo"/>
|
||||
</p>
|
||||
|
||||
Eclipse UPM Sensor and Actuator Repository
|
||||
==============
|
||||
|
||||
The UPM repository provides software drivers for a wide variety of commonly
|
||||
used sensors and actuators. These software drivers interact with the
|
||||
The Eclipse 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.
|
||||
sensors, through calls to [Eclipse MRAA](https://github.com/eclipse/mraa) APIs.
|
||||
|
||||
Programmers can access the interfaces for each sensor by including the sensor’s
|
||||
Programmers can access the interfaces for each sensor by including the sensor's
|
||||
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.
|
||||
As of UPM 2.0, sensor initialization can also be done, in most cases, via
|
||||
overloaded constructors that accept string identifiers.
|
||||
|
||||
C++ interfaces have been defined for the following sensor/actuator types, but
|
||||
they are subject to change:
|
||||
We endorse additions that implement the generic C and C++ interfaces provided
|
||||
with the libraries. With the 2.0 release, UPM introduces the following sensor
|
||||
interfaces:
|
||||
```
|
||||
iAcceleration, iAngle, iButton, iClock, iCollision, iDistance,
|
||||
iDistanceInterrupter, iEC, iElectromagnet, iEmg, iGas, iGps, iGyroscope,
|
||||
iHallEffect, iHeartRate, iHumidity, iLight, iLineFinder, iMagnetometer,
|
||||
iMoisture, iMotion, iOrp, iPH, iPressure, iProximity, iTemperature, iVDiv,
|
||||
iWater.
|
||||
```
|
||||
The developer community is invited to propose new interfaces for actuator types.
|
||||
|
||||
* Light controller
|
||||
* Light sensor
|
||||
* Temperature sensor
|
||||
* Humidity sensor
|
||||
* Pressure sensor
|
||||
* Gas sensor
|
||||
* Analog to digital converter
|
||||
|
||||
The developer community is encouraged to help expand the list of supported
|
||||
sensors and actuators and provide feedback on interface design.
|
||||
The UPM project is joining the Eclipse Foundation as an Eclipse IoT project.
|
||||
You can read more about this [here](https://projects.eclipse.org/proposals/eclipse-upm).
|
||||
|
||||
### 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_I2C_BUS,
|
||||
upm::MMA7660 *accel = new upm::MMA7660(MMA7660_DEFAULT_I2C_BUS,
|
||||
MMA7660_DEFAULT_I2C_ADDR);
|
||||
|
||||
// place device in standby mode so we can write registers
|
||||
accel->setModeStandby();
|
||||
|
||||
// enable 64 samples per second
|
||||
accel->setSampleRate(upm::MMA7660::AUTOSLEEP_64);
|
||||
|
||||
accel->setSampleRate(MMA7660_AUTOSLEEP_64);
|
||||
|
||||
// place device into active mode
|
||||
accel->setModeActive();
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
int x, y, z;
|
||||
|
||||
accel->getRawValues(&x, &y, &z);
|
||||
cout << "Raw values: x = " << x
|
||||
<< " y = " << y
|
||||
<< " z = " << z
|
||||
<< endl;
|
||||
|
||||
float ax, ay, az;
|
||||
|
||||
|
||||
accel->getAcceleration(&ax, &ay, &az);
|
||||
cout << "Acceleration: x = " << ax
|
||||
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).
|
||||
Browse through the list of all [examples](https://github.com/eclipse/upm/tree/master/examples).
|
||||
|
||||
Multi-sensor samples for the starter and specialized kits can be found in the
|
||||
Multi-sensor samples for 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 and More
|
||||
|
||||
### IDE Integration
|
||||
The UPM project includes support for multiple industrial-grade sensors, actuators, radios,
|
||||
protocols and standards in use today. It is also highly integrated with the Eclipse IDE
|
||||
through the help of the Foundation's partners.
|
||||
Learn more about [tools](https://software.intel.com/en-us/tools-by-segment/systems-iot).
|
||||
|
||||
If you would like to create projects and run the UPM samples using an Intel recommended IDE,
|
||||
please refer to the Intel Developer Zone IDE page.
|
||||
### Installing UPM
|
||||
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="docs/icons/allides.png"/></a>
|
||||
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).
|
||||
|
||||
[](https://travis-ci.org/intel-iot-devkit/upm)
|
||||
[](https://sonarcloud.io/dashboard?id=upm-master)
|
||||
|
||||
### Making your own UPM module
|
||||
|
||||
Porting [link](docs/porting.md) has more information on making new UPM modules.
|
||||
|
||||
There is also an example available gfor max31855 [sensor](docs/max31855.md).
|
||||
|
||||
Guide on creating Java [bindings](docs/creating_java_bindings.md).
|
||||
|
||||
### Naming conventions and rules for new UPM contributions
|
||||
### 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.
|
||||
|
||||
Also, please read the guidelines for contributions [to UPM](docs/contributions.md).
|
||||
|
||||
Don't forget to check the documentation [section](docs/documentation.md).
|
||||
Next, review the project's [contribution guide](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.
|
||||
as a contributor. Signing-off your commits and accepting the ECA is mandatory
|
||||
for making new contributions to this project.
|
||||
|
||||
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
|
||||
==============
|
||||
@ -122,8 +124,6 @@ our API in a way that will break backwards compatibility. If you find yourself
|
||||
unable to compile code that was working fine before a library update, make sure
|
||||
you check the [API changes](docs/apichanges.md) section first.
|
||||
|
||||
**NOTE** - Our **C++ header files** changed extension from *.h* to *.hpp*!
|
||||
|
||||
### Changelog
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
# 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)
|
@ -1,66 +1,66 @@
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
# 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})
|
||||
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"
|
||||
)
|
||||
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})
|
||||
# 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 "include/node/node.h" "include/src/node.h"
|
||||
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
|
||||
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}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args (Nodejs DEFAULT_MSG
|
||||
NODEJS_EXECUTABLE
|
||||
NODEJS_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
if (NODEJS_EXECUTABLE)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
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)
|
||||
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}")
|
||||
@ -85,13 +85,15 @@ if (NODEJS_EXECUTABLE)
|
||||
set (V8_VERSION_MINOR "28")
|
||||
set (V8_VERSION_PATCH "72")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
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})
|
||||
message (STATUS "Node version is ${NODE_VERSION_STRING}")
|
||||
message (STATUS "Node using v8 ${V8_VERSION_STRING}")
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
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 ()
|
||||
|
71
cmake/modules/FindNpm.cmake
Normal 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)
|
@ -17,14 +17,16 @@ find_package_handle_standard_args (Sphinx DEFAULT_MSG
|
||||
SPHINX_API_EXECUTABLE
|
||||
)
|
||||
|
||||
# Get Sphinx version
|
||||
# Get Sphinx Version
|
||||
if (SPHINX_EXECUTABLE)
|
||||
execute_process(COMMAND ${SPHINX_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE SPHINX_VERSION)
|
||||
if(SPHINX_VERSION)
|
||||
string(REGEX MATCH "([0-9]\\.[0-9]\\.[0-9])" SPHINX_VERSION_STR ${SPHINX_VERSION})
|
||||
message (STATUS "Sphinx version is ${SPHINX_VERSION_STR}")
|
||||
endif()
|
||||
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)
|
||||
|
20
cmake/modules/FindUpmCordovaGenerator.cmake
Normal 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)
|
@ -1,136 +0,0 @@
|
||||
# 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()
|
@ -1,4 +0,0 @@
|
||||
#include "version.h"
|
||||
|
||||
const char* gVERSION = "@VERSION@";
|
||||
const char* gVERSION_SHORT = "@VERSION_SHORT@";
|
6
cmake/modules/version.hpp.in
Normal file
@ -0,0 +1,6 @@
|
||||
#include <string>
|
||||
|
||||
inline std::string getVersion()
|
||||
{
|
||||
return "@upm_VERSION_STRING@";
|
||||
}
|
122
docker-compose.yaml
Normal file
@ -0,0 +1,122 @@
|
||||
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"
|
||||
|
||||
npm:
|
||||
extends: all
|
||||
environment:
|
||||
- NPM=ON
|
||||
- BUILDDOC=OFF
|
||||
command: bash -c "./scripts/run-cmake.sh && make -Cbuild -j8 npmpkg"
|
||||
|
||||
sonar-scan:
|
||||
extends: base
|
||||
image: inteliotdevkit/upm-sonar
|
||||
environment:
|
||||
- BUILDTESTS=OFF
|
||||
- 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
|
@ -4,6 +4,239 @@ API Changes {#apichanges}
|
||||
Here's a list of other API changes made to the library that break source/binary
|
||||
compatibility between releases:
|
||||
|
||||
# v2.0.0
|
||||
* Sensors implementing the old interfaces (bme280, bmpx8x, si7005, si1132,
|
||||
max44009, lp8860, ds1808lc, hlg150h) have been updated to use the new ones,
|
||||
hence some function names and parameters will be different.
|
||||
* Removed deprecated basic grove classes from project, see API changes for
|
||||
v1.1.0 and prior for a complete list
|
||||
|
||||
# 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.
|
||||
@ -11,27 +244,35 @@ compatibility between releases:
|
||||
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.
|
||||
|
164
docs/building.md
@ -34,7 +34,12 @@ 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.
|
||||
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:
|
||||
@ -64,10 +69,6 @@ Building with an older version of swig (swig 2.0+) requires the disabling of jav
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDSWIGNODE=OFF
|
||||
~~~~~~~~~~~~~
|
||||
Generating python3 modules instead of python2.7
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDPYTHON3=ON
|
||||
~~~~~~~~~~~~~
|
||||
Disabling python module building
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDSWIGPYTHON=OFF
|
||||
@ -80,14 +81,10 @@ Building documentation
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDDOC=ON
|
||||
~~~~~~~~~~~~~
|
||||
Build C++ example binaries
|
||||
Build C/C++/JAVA examples
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDEXAMPLES=ON
|
||||
~~~~~~~~~~~~~
|
||||
Build Java examples
|
||||
~~~~~~~~~~~~~
|
||||
-DBUILDJAVAEXAMPLES=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
|
||||
@ -99,32 +96,35 @@ 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 make the lcd module you would:
|
||||
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 name is i2clcd. Therefore the python
|
||||
module target name will be prefixed by _pyupm_. Just do the following to build
|
||||
only that module. Modules not using the UPM cmake macros may have different
|
||||
naming.
|
||||
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_i2clcd
|
||||
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-i2clcd) and then add /usr/include/upm to the
|
||||
library (in this case libupm-lcd) and then add /usr/include/upm to the
|
||||
loader path:
|
||||
|
||||
~~~~~~~~~~~~
|
||||
g++ test.cxx -lupm-i2clcd -I/usr/include/upm
|
||||
g++ test.cxx -lupm-lcd -I/usr/include/upm
|
||||
~~~~~~~~~~~~
|
||||
|
||||
You can also use pkg-config to return the information to you, which is
|
||||
@ -132,5 +132,131 @@ considered the correct way if including UPM in a build system like cmake or
|
||||
autotools on linux.
|
||||
|
||||
~~~~~~~~~~~
|
||||
pkg-config --cflags --libs upm-i2clcd
|
||||
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"
|
||||
```
|
||||
|
@ -4,6 +4,106 @@ Changelog {#changelog}
|
||||
Here's a list summarizing some of the key undergoing changes to our library
|
||||
from earlier versions:
|
||||
|
||||
### v2.0.0
|
||||
|
||||
* Reworked existing interfaces and extended the list to include iAcceleration,
|
||||
iAngle, iButton, iClock, iCollision, iDistance, iDistanceInterrupter, iEC,
|
||||
iElectromagnet, iEmg, iGas, iGps, iGyroscope, iHallEffect, iHeartRate, iHumidity,
|
||||
iLight, iLineFinder, iMagnetometer, iMoisture, iMotion, iOrp, iPH, iPressure,
|
||||
iProximity, iTemperature, iVDiv, iWater
|
||||
* Provided overloaded string based constructors for a good number of sensors,
|
||||
allowing initialization from external frameworks without type knowledge
|
||||
* Removed deprecated basic grove classes from project
|
||||
* Replaced 6 unsafe occurrences of sprintf() usage
|
||||
* Cleaned-up build system around target arch detection and cpack usage, added
|
||||
detection and resolution of tinyb library when used as a dependency
|
||||
* New sensors: 2jciebu01_ble, 2jciebu01_usb
|
||||
|
||||
### 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)
|
||||
|
@ -1,96 +1,104 @@
|
||||
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/.
|
||||
In order to contribute to the project:
|
||||
- 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.
|
||||
- Commits must be named `<file/module>: Some decent description`.
|
||||
- Each commit must have a sign-off line by everyone who authored or reviewed
|
||||
them.
|
||||
- Your new module must have an example that builds against your UPM library.
|
||||
- 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
|
||||
the UPM repository. Below is the comment block needed at the top each source
|
||||
file:
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Author: <your full name>
|
||||
* Author: <your full name>
|
||||
* Copyright (c) <year> <copyright holder>
|
||||
*
|
||||
* Author: <contributing author full name - if applicable>
|
||||
* 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:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
Code signing
|
||||
Eclipse Contributor Agreement
|
||||
============
|
||||
|
||||
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:
|
||||
Your contribution cannot be accepted unless you have a signed [ECA - Eclipse Foundation Contributor Agreement](http://www.eclipse.org/legal/ECA.php) in place.
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
Here is the checklist for contributions to be considered _acceptable_:
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
1. [Create an account at Eclipse](https://dev.eclipse.org/site_login/createaccount.php).
|
||||
2. Add your GitHub user name in your account settings.
|
||||
3. [Log into the project's portal](https://projects.eclipse.org/) and sign the ["Eclipse ECA"](https://projects.eclipse.org/user/sign/cla).
|
||||
4. Ensure that you [_sign-off_](https://wiki.eclipse.org/Development_Resources/Contributing_via_Git#Signing_off_on_a_commit) your Git commits.
|
||||
5. Ensure that you use the _same_ email address as your Eclipse account in commits.
|
||||
6. Include the appropriate copyright notice and license at the top of each file.
|
||||
|
||||
(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
|
||||
Your signing of the ECA will be verified by a webservice called 'ip-validation'
|
||||
that checks the email address that signed-off on your commits has signed the
|
||||
ECA. **Note**: This service is case-sensitive, so ensure the email that signed
|
||||
the ECA and that signed-off on your commits is the same, down to the case.
|
||||
|
||||
(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
|
||||
Creating a new sensor library using the sensortemplate
|
||||
=======================================
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
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.
|
||||
|
||||
(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
|
||||
```shell
|
||||
#!/bin/bash
|
||||
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
function make_new_sensor {
|
||||
export SensorName=$1
|
||||
# Get a lowercase version of the string
|
||||
export sensorname=${SensorName,,}
|
||||
|
||||
using your real name (sorry, no pseudonyms or anonymous contributions.)
|
||||
Unsigned commits will not be accepted.
|
||||
# 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).
|
||||
|
@ -12,89 +12,87 @@ Creating Java Bindings Guide
|
||||
* [Implementing callbacks in Java](#implementing-callbacks-in-java)
|
||||
|
||||
|
||||
##Overview
|
||||
## 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
|
||||
## 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
|
||||
## Recommendations for the native API
|
||||
|
||||
###Pointers
|
||||
### 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:
|
||||
#### 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);
|
||||
/*
|
||||
* 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();
|
||||
/*
|
||||
* 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);
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis in the given variables.
|
||||
*/
|
||||
void getAccel(int *accelX, int *accelY, int *accelZ);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
int *getAccel();
|
||||
/*
|
||||
* 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);
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *light, int *air);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
int getLight();
|
||||
int getAir();
|
||||
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);
|
||||
/*
|
||||
* Function returns the light intensity and air pollution
|
||||
*/
|
||||
void getData(int *temp, int *humid);
|
||||
```
|
||||
|
||||
__Replaced by:__
|
||||
__Replaced by:__
|
||||
```c++
|
||||
void getData();
|
||||
int getTemp();
|
||||
int getHumid();
|
||||
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].
|
||||
@ -103,8 +101,8 @@ __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:
|
||||
### 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++
|
||||
@ -126,18 +124,18 @@ The exception.i library file provides support for creating language independent
|
||||
|
||||
|
||||
```c++
|
||||
// Language independent exception handler
|
||||
%include exception.i
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
%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.
|
||||
@ -155,19 +153,19 @@ The upm_exception.i interface file is included in the upm.i file, therefor SWIG
|
||||
* std::exception
|
||||
|
||||
|
||||
####Java specific:
|
||||
#### 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;
|
||||
}
|
||||
}
|
||||
%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).
|
||||
@ -179,110 +177,99 @@ 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;
|
||||
}
|
||||
}
|
||||
%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 ();
|
||||
void function throws IOException ();
|
||||
```
|
||||
|
||||
##Caveats & Challenges
|
||||
## Caveats & Challenges
|
||||
|
||||
###Wrapping C arrays with Java arrays
|
||||
### 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
|
||||
### 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.
|
||||
*/
|
||||
/*
|
||||
* Function returns the acceleration on the three
|
||||
* axis as elements of a 3-element array.
|
||||
*/
|
||||
|
||||
int *getAccel();
|
||||
int *getAccel();
|
||||
```
|
||||
|
||||
__SWIG:__
|
||||
__SWIG:__
|
||||
```c++
|
||||
%typemap(jni) int* "jintArray"
|
||||
%typemap(jstype) int* "int[]"
|
||||
%typemap(jtype) int* "int[]"
|
||||
%typemap(jni) int* "jintArray"
|
||||
%typemap(jstype) int* "int[]"
|
||||
%typemap(jtype) int* "int[]"
|
||||
|
||||
%typemap(javaout) int* {
|
||||
return $jnicall;
|
||||
}
|
||||
%typemap(javaout) int* {
|
||||
return $jnicall;
|
||||
}
|
||||
|
||||
%typemap(out) int *getAccel {
|
||||
$result = JCALL1(NewIntArray, jenv, 3);
|
||||
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
|
||||
}
|
||||
%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
|
||||
### 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);
|
||||
void func(uint8_t *buffer, int length);
|
||||
```
|
||||
|
||||
__SWIG:__
|
||||
__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(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);
|
||||
}
|
||||
%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.
|
||||
### 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.
|
||||
|
||||
SWIGJAVA is a symbol that is always defined by SWIG when using Java. We enclose the _installISR\(jobject runnable\)_ method in a _\#if defined(SWIGJAVA)_ check, to ensure the code only exists when creating a wrapper for Java.
|
||||
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++
|
||||
#if defined(SWIGJAVA)
|
||||
void A110X::installISR(jobject runnable)
|
||||
{
|
||||
installISR(mraa_java_isr_callback, runnable);
|
||||
}
|
||||
#endif
|
||||
JAVA_ADD_INSTALLISR(upm::A110X)
|
||||
```
|
||||
|
||||
We hide the underlying method, _installISR\(void \(\*isr\)\(void \*\), void \*arg\)_ , and expose only the _installISR\(jobject runnable\)_ to SWIG, through the use of the SWIGJAVA symbol. When SWIGJAVA is defined, we change the access modifier of the underlying method to private.
|
||||
Will expand to the following SWIG wrapper code:
|
||||
|
||||
```c++
|
||||
public:
|
||||
#if defined(SWIGJAVA)
|
||||
void installISR(jobject runnable);
|
||||
#else
|
||||
void installISR(void (*isr)(void *), void *arg);
|
||||
#endif
|
||||
private:
|
||||
#if defined(SWIGJAVA)
|
||||
void installISR(void (*isr)(void *), void *arg);
|
||||
#endif
|
||||
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:
|
||||
@ -290,13 +277,13 @@ To use callback in java, we create a ISR class, which implements the Java Runnab
|
||||
```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);
|
||||
@ -313,41 +300,3 @@ class A110XISR implements Runnable {
|
||||
}
|
||||
}
|
||||
```
|
||||
####Issues with java callbacks and workarounds
|
||||
|
||||
__SWIGJAVA not defined at compile time__
|
||||
|
||||
Consider the following files:
|
||||
* example.h - Header file for our source file
|
||||
* example.cxx - Source file containing the class Example, for which we build java bindings
|
||||
* example.i - The SWIG interface, that includes the example.h header file
|
||||
|
||||
The build process of a java module using SWIG is split into two steps:
|
||||
|
||||
1. Generating the intermediate files, from the SWIG interface file. This will produce the java class file (Example.java), the JNI file (exampleJNI.java) and wrapper file (example_wrap.cxx). The source file (example.cxx) is not needed in the first step.
|
||||
|
||||
```
|
||||
swig -c++ -java example.i
|
||||
```
|
||||
|
||||
2. Generating the shared library from the C++ sources and wrapper file
|
||||
```
|
||||
g++ -fPIC -c example.cxx example_wrap.cxx -I/usr/lib/jvm/java-1.8.0/include -I/usr/lib/jvm/java-1.8.0/include/linux
|
||||
g++ -shared example_wrap.o sensor.o -o libexample.so
|
||||
```
|
||||
|
||||
|
||||
SWIGJAVA is always defined when SWIG parses the interface file, meaning it will be defined when it parses the header file (example.h) that is included in the interface file (example.i).
|
||||
SWIG also adds the "#define SWIGJAVA" directive in the wrapper file (example_wrap.cxx).
|
||||
However, in generating the shared library the SWIGJAVA symbol is only defined in the example_wrap.cxx file, because of the added "#define SWIGJAVA" directive. But we have also used the "#if defined(SWIGJAVA)" check in the source file (example.cxx), and thus need to define SWIGJAVA for it too. If we define the SWIGJAVA symbol as a compile flag, when compiling the source code to object code, the SWIGJAVA compile flag and #define SWIGJAVA" directive will clash and give a double definition warning (only a warning).
|
||||
|
||||
In this example it is simple to compile the two source codes separately, one with the compile flag, the other without, and then create the shared library (libexample.so).
|
||||
But in a big automatic build like the java upm libraries, this may prove too hard or too complicated to do. A workaround to this would be to define a custom symbol (e.q. JAVACALLBACK in the upm library) and also test for it. In short, replace:
|
||||
```c++
|
||||
#if defined(SWIGJAVA)
|
||||
```
|
||||
by
|
||||
```c++
|
||||
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
|
||||
```
|
||||
|
||||
|
@ -4,98 +4,138 @@ 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
|
||||
- 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 even in comments.
|
||||
- Stick to <80 chars per line where possible.
|
||||
- No text is allowed on the same line as the start or end of a comment /** */.
|
||||
|
||||
####The sensor block
|
||||
We currently document our libraries in the following way:
|
||||
|
||||
This is added just before the class declaration in your header(.h) file and has
|
||||
mandatory fields. For single sensor libraries, this block will actually
|
||||
follow immediately after the library block. If you have multiple physical
|
||||
sensors, add this to every one.
|
||||
Here's an example (disregard the "@verbatim" tags in your actual code):
|
||||
* **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.
|
||||
|
||||
```
|
||||
@verbatim
|
||||
/**
|
||||
* @library <lib-name>
|
||||
* @sensor <chip-id>
|
||||
* @comname <component-name>
|
||||
* @altname <alt-name>
|
||||
* @altid <alt-id>
|
||||
* @type <component-category>
|
||||
* @man <component-manufacturer>
|
||||
* @web <component-weblinks>
|
||||
* @con <connection-type>
|
||||
* @kit <component-kit>
|
||||
*
|
||||
* @brief Short class/sensor description
|
||||
*
|
||||
* Then add a longer
|
||||
* description here.
|
||||
*
|
||||
* @image html <component-img.jpeg>
|
||||
* @snippet <example-name.cxx> Interesting
|
||||
*/
|
||||
@endverbatim
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `<lib-name>` When adding to an existing library this needs to match that
|
||||
library's "@defgroup", otherwise this is a new library name, generally the
|
||||
same as chip id. *Mandatory*
|
||||
- `<chip-id>` Usually the chip number used by the sensor. When this is not
|
||||
available or relevant, use a unique descriptor that makes sense. Must match
|
||||
class name. *Mandatory*
|
||||
- `<component-name>` A short name for your sensor, try to avoid including the
|
||||
manufacturer's name here. *Mandatory*
|
||||
- `<alt-name>` Alternative names that your sensor driver might have. This may
|
||||
include manufacturer's name. *Optional*
|
||||
- `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional*
|
||||
- `<component-category>` Mention one or more categories the sensor fits in. Can
|
||||
be 'other'. *Mandatory*
|
||||
- `<component-manufacturer>` Sensor manufacturer. Can be 'generic'. *Mandatory*
|
||||
- `<component-weblinks>` Links to vendors or data-sheets. *Optional*
|
||||
- `<connection-type>` Specifies how does the sensor connect to the board
|
||||
*Mandatory*
|
||||
- `<component-kit>` Specifies if the sensor is part of a kit. *Optional*
|
||||
#### Mandatory fields:
|
||||
|
||||
Existing groups that can be used for the manufacturer, connection, category and
|
||||
kit tags are found in the *src/groups.md* file.
|
||||
For the library:
|
||||
|
||||
Optionally, a small representative image can be placed in the "docs/images"
|
||||
subfolder and linked with the "@image" tag.
|
||||
**Please do not use existing, copyrighted images with your sensors!**
|
||||
- `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.
|
||||
|
||||
The example should have an 'Interesting' section which will be highlighted as
|
||||
a code sample in doxygen. Everything in between such tags will show up in the
|
||||
class documentation when "@snippet" is added at the end of a class docstring.
|
||||
Tags use this format (in "example-name.cxx"):
|
||||
For the sensor classes:
|
||||
|
||||
```
|
||||
@verbatim
|
||||
//! [Interesting]
|
||||
- `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.
|
||||
|
||||
...example code here...
|
||||
#### Optional and customizable fields
|
||||
|
||||
//! [Interesting]
|
||||
@endverbatim
|
||||
```
|
||||
- `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.
|
||||
|
||||
For more examples take a look at the existing headers in our github repository.
|
||||
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.
|
||||
|
||||
####The library block
|
||||
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:
|
||||
You should end up with something like this (disregard the "@verbatim" tags in
|
||||
your actual code):
|
||||
|
||||
```
|
||||
@verbatim
|
||||
@ -110,8 +150,43 @@ You should end up with something like this:
|
||||
@endverbatim
|
||||
```
|
||||
|
||||
In "@defgroup" use the same `<lib-name>` used in the sensor block. Multiple
|
||||
sensors can be added to the same library this way.
|
||||
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
docs/guidelines.md
Normal 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. |
|
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 14 KiB |
BIN
docs/icons/upm_logo.png
Normal file
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 5.1 KiB |
@ -1,361 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution-NonCommercial-ShareAlike 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(g) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined above) for the purposes of this
|
||||
License.
|
||||
c. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
d. "License Elements" means the following high-level license attributes
|
||||
as selected by Licensor and indicated in the title of this License:
|
||||
Attribution, Noncommercial, ShareAlike.
|
||||
e. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
f. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
g. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
h. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
i. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
j. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved, including but not limited to the
|
||||
rights described in Section 4(e).
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(d), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(d), as requested.
|
||||
b. You may Distribute or Publicly Perform an Adaptation only under: (i)
|
||||
the terms of this License; (ii) a later version of this License with
|
||||
the same License Elements as this License; (iii) a Creative Commons
|
||||
jurisdiction license (either this or a later license version) that
|
||||
contains the same License Elements as this License (e.g.,
|
||||
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License").
|
||||
You must include a copy of, or the URI, for Applicable License with
|
||||
every copy of each Adaptation You Distribute or Publicly Perform. You
|
||||
may not offer or impose any terms on the Adaptation that restrict the
|
||||
terms of the Applicable License or the ability of the recipient of the
|
||||
Adaptation to exercise the rights granted to that recipient under the
|
||||
terms of the Applicable License. You must keep intact all notices that
|
||||
refer to the Applicable License and to the disclaimer of warranties
|
||||
with every copy of the Work as included in the Adaptation You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Adaptation, You may not impose any effective technological
|
||||
measures on the Adaptation that restrict the ability of a recipient of
|
||||
the Adaptation from You to exercise the rights granted to that
|
||||
recipient under the terms of the Applicable License. This Section 4(b)
|
||||
applies to the Adaptation as incorporated in a Collection, but this
|
||||
does not require the Collection apart from the Adaptation itself to be
|
||||
made subject to the terms of the Applicable License.
|
||||
c. You may not exercise any of the rights granted to You in Section 3
|
||||
above in any manner that is primarily intended for or directed toward
|
||||
commercial advantage or private monetary compensation. The exchange of
|
||||
the Work for other copyrighted works by means of digital file-sharing
|
||||
or otherwise shall not be considered to be intended for or directed
|
||||
toward commercial advantage or private monetary compensation, provided
|
||||
there is no payment of any monetary compensation in con-nection with
|
||||
the exchange of copyrighted works.
|
||||
d. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
|
||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||
"French translation of the Work by Original Author," or "Screenplay
|
||||
based on original Work by Original Author"). The credit required by
|
||||
this Section 4(d) may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of a Adaptation or Collection, at
|
||||
a minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only
|
||||
use the credit required by this Section for the purpose of attribution
|
||||
in the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||
use of the Work, without the separate, express prior written
|
||||
permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor reserves
|
||||
the exclusive right to collect such royalties for any exercise by
|
||||
You of the rights granted under this License if Your exercise of
|
||||
such rights is for a purpose or use which is otherwise than
|
||||
noncommercial as permitted under Section 4(c) and otherwise waives
|
||||
the right to collect royalties through any statutory or compulsory
|
||||
licensing scheme; and,
|
||||
iii. Voluntary License Schemes. The Licensor reserves the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License that is for a
|
||||
purpose or use which is otherwise than noncommercial as permitted
|
||||
under Section 4(c).
|
||||
f. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE
|
||||
FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS
|
||||
AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
|
||||
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
|
||||
LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
|
||||
WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of this License.
|
||||
|
||||
Creative Commons may be contacted at https://creativecommons.org/.
|
||||
|
BIN
docs/images/es9257.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 97 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 90 KiB |
BIN
docs/images/ims.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
docs/images/kxtj3.png
Executable file
After Width: | Height: | Size: 52 KiB |
BIN
docs/images/lidarlitev3.jpg
Normal file
After Width: | Height: | Size: 156 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
BIN
docs/images/max30100.png
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
docs/images/p9813.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/images/rf22.jpg
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
docs/images/sensortemplate.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
docs/images/tca9548a.jpg
Normal file
After Width: | Height: | Size: 616 KiB |
98
docs/installing.md
Normal file
@ -0,0 +1,98 @@
|
||||
Installing UPM {#installing}
|
||||
============
|
||||
|
||||
UPM packages are provided for some of the major supported distributions, making
|
||||
it very easy to install UPM and its dependencies without having to go through a
|
||||
full build.
|
||||
|
||||
### Poky Linux
|
||||
|
||||
Yocto Project based Poky Linux builds are provided for Intel Galileo, Intel
|
||||
Edison and Minnowboard. These are the official images released with the Intel
|
||||
IoT Developer Kit and can found [here](https://iotdk.intel.com/images/3.5/).
|
||||
|
||||
To update to the latest stable UPM version:
|
||||
|
||||
```bash
|
||||
echo "src intel-iotdk https://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586/" > /etc/opkg/intel-iotdk.conf
|
||||
opkg update
|
||||
opkg upgrade mraa upm
|
||||
```
|
||||
|
||||
If you would like to try the development version use `intelgalactic-dev`
|
||||
instead.
|
||||
|
||||
### WindRiver Pulsar Linux
|
||||
|
||||
WR Pulsar uses SmartPM for software updates. Updating to the latest UPM version
|
||||
requires:
|
||||
|
||||
```bash
|
||||
smart channel -y --add upm_mraa_channel type=rpm-md name="MRAA/UPM" baseurl=http://iotdk.intel.com/repos/pulsar/8/x64
|
||||
smart update
|
||||
smart install -y mraa upm
|
||||
```
|
||||
|
||||
For Pulsar 7 use the following baseurl instead: `baseurl=http://iotdk.intel.com/repos/pulsar/7/x64`
|
||||
|
||||
Wind River Linux 7 uses 01.org repositories and will have a default update
|
||||
channel that includes MRAA & UPM. Thus you only have to update and install.
|
||||
|
||||
### Ubuntu Desktop/Server
|
||||
|
||||
MRAA and UPM are available through a Personal Package Archive (PPA) on Ubuntu
|
||||
that can be found [here](https://launchpad.net/~mraa/+archive/ubuntu/mraa).
|
||||
|
||||
To install:
|
||||
|
||||
```bash
|
||||
sudo add-apt-repository ppa:mraa/mraa
|
||||
sudo apt-get update
|
||||
sudo apt-get install libupm-dev libupm-java python-upm python3-upm node-upm upm-examples
|
||||
```
|
||||
|
||||
Running UPM applications on Ubuntu systems requires elevated permissions
|
||||
(e.g. run with `sudo`).
|
||||
|
||||
### Fedora Linux
|
||||
|
||||
MRAA and UPM are available through the default package repositories on Fedora and can be
|
||||
installed in the standard method using dnf.
|
||||
|
||||
To install:
|
||||
|
||||
```bash
|
||||
sudo dnf install upm
|
||||
sudo dnf install paython3-upm nodejs-upm upm-examples
|
||||
```
|
||||
|
||||
### Installing for Red Hat Enterprise Linux, CentOS and Other Linux Distributions
|
||||
|
||||
The UPM project does not currently distribute official binaries for RHEL
|
||||
or CentOS so developers will have to compile the project from sources as
|
||||
described [here](./building.md).
|
||||
|
||||
For testing and development purposes it may be possible to share and install
|
||||
.deb and .rpm packages across similar Linux builds.
|
||||
|
||||
### Node.js bindings only (NPM)
|
||||
|
||||
This option allows compiling MRAA/UPM on any system with npm and node-gyp.
|
||||
|
||||
The UPM modules have a hard dependency on MRAA, thus you will have to install
|
||||
it first. Also, make sure Node can find MRAA by updating the `NODE_PATH`
|
||||
variable if necessary. A global installation is preferred:
|
||||
|
||||
`npm install mraa -g`
|
||||
|
||||
After this, to install a UPM module using npm simply type:
|
||||
|
||||
`npm install jsupm_<module-name> -g`
|
||||
|
||||
In order to initialize the platform, require MRAA *before* you load a UPM
|
||||
module in your code:
|
||||
|
||||
```js
|
||||
require('mraa');
|
||||
var lib = require('jsupm_<module-name>');
|
||||
```
|
@ -7,6 +7,9 @@ such sensors and known workarounds if they exist.
|
||||
|
||||
#### Grove Sensors
|
||||
|
||||
* **RN2903** Click 2 version. This device will not work using the
|
||||
Edison UART on the Arduino breakout. It does work on Edison using a
|
||||
USB->serial interface.
|
||||
* **Grove LCD RGB Backlit** (JHD1313M1) requires 5V and should be used with an
|
||||
external power supply connected to the board to function properly. Although
|
||||
some high powered USB ports might be enough, in most cases you will encounter
|
||||
@ -50,11 +53,11 @@ such sensors and known workarounds if they exist.
|
||||
* **Grove BLE** (HM-11) does not return data on the Intel Galileo board due to
|
||||
known UART limitation.
|
||||
* **Grove Hall Sensor** (A11X) if the base shield is set to 3V on Intel Edison,
|
||||
it will trigger continous callbacks when the sensor is not reading anything.
|
||||
it will trigger continuous callbacks when the sensor is not reading anything.
|
||||
* **Grove RTC** (DS1307) is not compatible with the Intel Edison Arduino board
|
||||
but will work with the Mini-breakout.
|
||||
* **Grove Tempture & Humidity (High-Accuracy & Mini) Sensor** (TH02) only works
|
||||
with the Intel Edison Arduino board when powered from the 3.3V rail.
|
||||
* **Grove Temperature & Humidity (High-Accuracy & Mini) Sensor** (TH02) only
|
||||
works with the Intel Edison Arduino board when powered from the 3.3V rail.
|
||||
|
||||
#### Adafruit Sensors
|
||||
|
||||
@ -75,6 +78,8 @@ This affects the **DS18B20**, **DS2413** and **DFREC** drivers.
|
||||
|
||||
#### Other Sensors
|
||||
|
||||
* **HTU21D** is unstable on the Intel Edison with the Arduino breakout and
|
||||
will throw an error when it can't complete an update call.
|
||||
* **MLX90614** is not compatible with the Intel Galileo due to the inability
|
||||
to change the I2C bus speed to 100 KHz.
|
||||
* **MICSV89** is not compatible with the Intel Galileo due to the inability to
|
||||
@ -89,10 +94,9 @@ This affects the **DS18B20**, **DS2413** and **DFREC** drivers.
|
||||
|
||||
Some *I2C* sensors add too much capacitance to the SDA line of the Intel Edison
|
||||
Arduino breakout board, thus the signal sticks to a logic 1. When this happens,
|
||||
other sensors connected to the I2C bus are unusable. While there is no generic
|
||||
solution for this limitation, in most cases the sensor works on the Intel
|
||||
Edison Mini-breakout. When this board is not an option, the sensor can be
|
||||
sometimes replaced with the same model from a different vendor.
|
||||
other sensors connected to the I2C bus also become unusable. In order to solve
|
||||
this problem, an I2C repeater that isolates the capacitance on the bus, such as
|
||||
the PCA9517 can be used.
|
||||
|
||||
The Intel Edison *SPI* bus can corrupt data being sent across when certain
|
||||
sensors are connected to it, if using an old image. This has been resolved with
|
||||
|
@ -14,8 +14,7 @@ First thing to do is to create a tree structure like this in upm/src/max31855:
|
||||
|
||||
* max31855.cxx
|
||||
* max31855.hpp
|
||||
* jsupm_max31855.i
|
||||
* pyupm_max31855.i
|
||||
* max31855.i
|
||||
* CMakeLists.txt
|
||||
|
||||
And then an example file to use & test our lib with in upm/examples/max31855.cxx.
|
||||
|
@ -25,6 +25,4 @@ sensor can inherit your class if they only have minor changes.
|
||||
|
||||
### Doubt
|
||||
|
||||
If ever, give either of us a ping via email:
|
||||
mihai.tudor.panu@intel.com or brendan.le.foll@intel.com
|
||||
and we'll try suggest decent names for your module.
|
||||
If ever, open a new issue and ask for naming help from the project's community.
|
||||
|
@ -59,7 +59,6 @@ the UPM build system.
|
||||
The last step is when you're happy with your module and it works send us a pull
|
||||
request! We'd love to include your sensor in our repository.
|
||||
|
||||
If you don't like github you can also send mihai.tudor.panu@intel.com a git
|
||||
formatted patch of your sensor. More details are on @ref contributions and on
|
||||
More details on @ref contributions and on
|
||||
https://help.github.com/articles/creating-a-pull-request
|
||||
|
||||
|
@ -129,8 +129,6 @@ ABBREVIATE_BRIEF = "The $name class" \
|
||||
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
|
||||
DETAILS_AT_TOP = YES
|
||||
|
||||
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
|
||||
# inherited members of a class in the documentation of that class as if those
|
||||
# members were ordinary class members. Constructors, destructors and assignment
|
||||
@ -156,7 +154,7 @@ FULL_PATH_NAMES = YES
|
||||
# will be relative from the directory where doxygen is started.
|
||||
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
|
||||
|
||||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
|
||||
# path mentioned in the documentation of a class, which tells the reader which
|
||||
@ -704,7 +702,7 @@ CITE_BIB_FILES =
|
||||
# messages are off.
|
||||
# The default value is: NO.
|
||||
|
||||
QUIET = NO
|
||||
QUIET = YES
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
|
||||
@ -862,7 +860,8 @@ EXCLUDE_SYMLINKS = NO
|
||||
# bmi160 driver contains code provided by bosch. This source contains
|
||||
# tags which are picked up by doxygen (namely \mainpage) and
|
||||
# incorrectly get added to docs.
|
||||
EXCLUDE_PATTERNS = bosch_*
|
||||
EXCLUDE_PATTERNS = bosch_* \
|
||||
sensortemplate*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@ -1861,18 +1860,6 @@ GENERATE_XML = YES
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
|
||||
# listings (including syntax highlighting and cross-referencing information) to
|
||||
# the XML output. Note that enabling this will significantly increase the size
|
||||
|
@ -129,8 +129,6 @@ ABBREVIATE_BRIEF = "The $name class" \
|
||||
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
|
||||
DETAILS_AT_TOP = YES
|
||||
|
||||
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
|
||||
# inherited members of a class in the documentation of that class as if those
|
||||
# members were ordinary class members. Constructors, destructors and assignment
|
||||
@ -704,7 +702,7 @@ CITE_BIB_FILES =
|
||||
# messages are off.
|
||||
# The default value is: NO.
|
||||
|
||||
QUIET = NO
|
||||
QUIET = YES
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
|
||||
@ -1818,18 +1816,6 @@ GENERATE_XML = YES
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
|
||||
# listings (including syntax highlighting and cross-referencing information) to
|
||||
# the XML output. Note that enabling this will significantly increase the size
|
||||
|
@ -15,7 +15,7 @@ sensor in order to reduce load when doing multiple reads to sensor data.
|
||||
### Example
|
||||
|
||||
A sensor/actuator is expected to work as such (here is the servo ES08A API):
|
||||
@snippet es08a.cxx Interesting
|
||||
@snippet servo-es08a.cxx Interesting
|
||||
|
||||
However implementation and API design is completely up to the developer, some
|
||||
enumerable sensors for example may provide much clever instantiation. Displays
|
||||
|
@ -34,13 +34,6 @@ var lib = require('jsupm_<module-name>');
|
||||
### Supported Sensors
|
||||
The full list is available on [Intel® IoT Developer Zone](https://software.intel.com/en-us/iot/hardware/sensors).
|
||||
|
||||
### IDE Integration
|
||||
Intel® XDK IoT Edition is the recommended IDE for Node.js development. Visit
|
||||
the Intel® Developer Zone [IDE page](https://software.intel.com/iot/software/ide)
|
||||
for more information on how to get started.
|
||||
|
||||

|
||||
|
||||
### Building UPM
|
||||
See building documentation [here](https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md).
|
||||
|
||||
|
1
doxy/doxygen2jsdoc
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 67cad692720982ac3cbd99bf1c3421edc69b08f9
|
1
doxy/doxyport
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit db3e1a6eb8677d3166d90d82c3068689803ce547
|
@ -23,15 +23,6 @@ repository.
|
||||
|
||||
Individual sensor usage examples for Python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
|
||||
|
||||
``IDE Compatibility``
|
||||
################
|
||||
|
||||
While there is no official IDE provided with our Python libraries, we do recommend the web-based IDE Wyliodrin. It can be used with multiple programming
|
||||
languages, including Python. More information can be found on the Intel Developer Zone IDE page.
|
||||
|
||||
.. image:: ../docs/icons/wyliodrin.png
|
||||
:target: https://software.intel.com/iot/software/ide
|
||||
|
||||
``Making your own UPM Module``
|
||||
##############################
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Author: Heidi Pan <heidi.pan@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var xml2js = require('./xml2js')
|
||||
, fs = require('fs')
|
||||
, Promise = require('bluebird')
|
||||
, opts = require('commander')
|
||||
, _ = require('lodash')
|
||||
, mkdirp = require('mkdirp');
|
||||
|
||||
|
||||
// parse command line arguments
|
||||
_.extend(opts, { addOptions: function(module) { return module.addOptions(opts); } });
|
||||
opts
|
||||
.option('-m, --module [module]', 'module name for which to build documentation', 'mraa')
|
||||
.option('-f, --formats [formats]', 'format for js comments', 'yuidoc,ternjs')
|
||||
.option('-o, --outdir [directory]', 'top directory to build documentation', __dirname + '/jsdoc')
|
||||
.addOptions(xml2js)
|
||||
.parse(process.argv);
|
||||
|
||||
|
||||
// use promise-style programming rather than spaghetti callbacks
|
||||
Promise.promisifyAll(fs);
|
||||
Promise.promisifyAll(mkdirp);
|
||||
|
||||
|
||||
// main
|
||||
xml2js.parse().then(function(specjs) {
|
||||
var formats = opts.formats.split(',');
|
||||
Promise.all(_.map(formats, function(format) {
|
||||
var generateDocs = require(__dirname + '/generators/' + format + '/generator');
|
||||
var dir = opts.outdir + '/' + format + '/' + specjs.MODULE;
|
||||
return mkdirp.mkdirpAsync(dir).then(function() {
|
||||
return fs.writeFileAsync(dir + '/doc.js', generateDocs(specjs));
|
||||
});
|
||||
}));
|
||||
});
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"templates": {
|
||||
"default": {
|
||||
"outputSourceFiles": false
|
||||
}
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Author: Heidi Pan <heidi.pan@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
// generate JSDoc-style documentation
|
||||
function generateDocs(specjs) {
|
||||
var docs = GENERATE_MODULE(specjs.MODULE);
|
||||
docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec);
|
||||
}, docs);
|
||||
docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) {
|
||||
return memo += GENERATE_ENUM(enumName, enumSpec);
|
||||
}, docs);
|
||||
docs = _.reduce(specjs.CLASSES, function(memo, classSpec, parentClass) {
|
||||
return _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec, parentClass);
|
||||
}, memo);
|
||||
}, docs);
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// comment wrapper around entire spec
|
||||
function GENERATE_DOC(text) {
|
||||
return '/**\n' + text + ' */\n';
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(module) {
|
||||
return GENERATE_DOC('@module ' + module + '\n');
|
||||
}
|
||||
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ '@instance\n'
|
||||
+ (parent ? ('@memberof ' + parent + '\n') : '')
|
||||
+ _.reduce(spec.params, function(memo, paramSpec, paramName) {
|
||||
return '@param {' + paramSpec.type + '} ' + paramName + ' ' + paramSpec.description + '\n';
|
||||
}, '')
|
||||
+ ( !_.isEmpty(spec.return) ? ('@return {' + spec.return.type + '} ' + spec.return.description + '\n') : ''));
|
||||
}
|
||||
|
||||
|
||||
// generate enum spec
|
||||
function GENERATE_ENUM(name, spec) {
|
||||
return GENERATE_DOC(spec.description + '\n\n'
|
||||
+ '@var ' + name + '\n'
|
||||
+ '@type Enum(' + spec.type + ')\n'
|
||||
+ '@instance\n');
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
// generate link spec
|
||||
function GENERATE_LINK(text) {
|
||||
return '{@link ' + text + '}';
|
||||
}
|
||||
|
||||
|
||||
module.exports = generateDocs;
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Author: Heidi Pan <heidi.pan@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
// generate json for ternjs input
|
||||
function generateDocs(specjs) {
|
||||
GENERATE_TYPE = (function(enums) {
|
||||
return function(type) {
|
||||
return (_.contains(enums, type) ? ('Enum ' + type) : type);
|
||||
}
|
||||
})(_.keys(specjs.ENUMS_BY_GROUP));
|
||||
var docs = { '!name': specjs.MODULE + 'library' };
|
||||
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
|
||||
_.each(specjs.ENUMS, function(enumSpec, enumName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
_.each(specjs.METHODS, function(methodSpec, methodName) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
|
||||
if (_.isEmpty(specjs.CLASSGROUPS)) {
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
|
||||
} else {
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
_.extend(docs, GENERATE_MODULE(groupName));
|
||||
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
|
||||
});
|
||||
}
|
||||
return JSON.stringify(docs, null, 2);
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(module) {
|
||||
var docs = {};
|
||||
docs[module] = {};
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate the spec for the given list of classes
|
||||
function GENERATE_CLASSES(classes) {
|
||||
var docs = {};
|
||||
_.each(classes, function(classSpec, parentClass) {
|
||||
var constructor = classSpec.methods[parentClass];
|
||||
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
|
||||
if (_.has(docs, parentClass)) {
|
||||
_.each(classSpec.enums, function(enumSpec, enumName) {
|
||||
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
|
||||
});
|
||||
docs[parentClass].prototype = {};
|
||||
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
|
||||
});
|
||||
_.each(classSpec.variables, function(variableSpec, variableName) {
|
||||
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
|
||||
});
|
||||
}
|
||||
});
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// generate method spec
|
||||
function GENERATE_METHOD(name, spec) {
|
||||
var doc = {};
|
||||
doc[name] = {
|
||||
'!type': 'fn(' + GENERATE_PARAMS(spec.params) + ')' + GENERATE_RETURN(spec.return),
|
||||
'!doc': spec.description
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
// generate parameter signatures for method
|
||||
function GENERATE_PARAMS(spec) {
|
||||
return _.map(spec, function(paramSpec, paramName) {
|
||||
return paramName + ': ' + paramSpec.type;
|
||||
}).join(', ');
|
||||
}
|
||||
|
||||
|
||||
// generate return signature for method
|
||||
function GENERATE_RETURN(spec) {
|
||||
return (_.isEmpty(spec) ? '' : (' -> ' + spec.type));
|
||||
}
|
||||
|
||||
|
||||
// generate enum spec
|
||||
function GENERATE_ENUM(name, spec) {
|
||||
var doc = {};
|
||||
doc[name] = 'Enum ' + spec.type ;
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
// generate variable spec
|
||||
function GENERATE_VARIABLE(name, spec) {
|
||||
var doc = {};
|
||||
doc[name]= spec.type ;
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
module.exports = generateDocs;
|
144
doxy/node/generators/yuidoc/generator.js
vendored
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Author: Heidi Pan <heidi.pan@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
// generate YuiDocs-style documentation
|
||||
function generateDocs(specjs) {
|
||||
var docs = GENERATE_MODULE(specjs.MODULE, '');
|
||||
GENERATE_TYPE = (function(enums) {
|
||||
return function(type) {
|
||||
return (_.contains(enums, type) ? ('Enum ' + type) : type);
|
||||
}
|
||||
})(_.keys(specjs.ENUMS_BY_GROUP));
|
||||
docs = _.reduce(specjs.METHODS, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec);
|
||||
}, docs);
|
||||
docs = _.reduce(specjs.ENUMS, function(memo, enumSpec, enumName) {
|
||||
return memo += GENERATE_ENUM(enumName, enumSpec);
|
||||
}, docs);
|
||||
if (_.isEmpty(specjs.CLASSGROUPS)) {
|
||||
docs += GENERATE_CLASSES(specjs.CLASSES);
|
||||
} else {
|
||||
docs += GENERATE_MODULE('common', '');
|
||||
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
|
||||
});
|
||||
// TODO: figure out why yuidoc won't associate the class with the right module if module definitions are interspersed
|
||||
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
|
||||
docs += GENERATE_MODULE(groupName, groupSpec.description);
|
||||
});
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
// comment wrapper around entire spec
|
||||
function GENERATE_DOC(text) {
|
||||
return '/**\n' + text + ' */\n';
|
||||
}
|
||||
|
||||
|
||||
// generate module spec
|
||||
function GENERATE_MODULE(name, description) {
|
||||
return GENERATE_DOC(description + '\n'
|
||||
+ '@module ' + name + '\n');
|
||||
}
|
||||
|
||||
|
||||
// generate spec for the given list of classes
|
||||
function GENERATE_CLASSES(classes, parent) {
|
||||
return _.reduce(classes, function(memo, classSpec, className) {
|
||||
return memo
|
||||
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
|
||||
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
|
||||
return memo += GENERATE_METHOD(methodName, methodSpec, className);
|
||||
}, '')
|
||||
+ _.reduce(classSpec.variables, function(memo, variableSpec, variableName) {
|
||||
return memo += GENERATE_VAR(variableName, variableSpec, className);
|
||||
}, '')
|
||||
+ _.reduce(classSpec.enums, function(memo, enumSpec, enumName) {
|
||||
return memo += GENERATE_ENUM(enumName, enumSpec, className);
|
||||
}, '');
|
||||
}, '');
|
||||
}
|
||||
|
||||
|
||||
// generate class spec
|
||||
function GENERATE_CLASS(name, description, namespace, parent) {
|
||||
return GENERATE_DOC(description + '\n'
|
||||
+ '@class ' + name + '\n'
|
||||
+ (namespace ? ('@module ' + namespace + '\n') : '')
|
||||
/*
|
||||
TODO: leave out until figure out what swig does with inheritance
|
||||
+ (parent ? ('@extends ' + parent + '\n') : '')
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// generate method spec with parent module/class
|
||||
function GENERATE_METHOD(name, spec, parent) {
|
||||
name = name.replace(/!+$/, '');
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@method ' + name + '\n'
|
||||
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')
|
||||
+ _.reduce(spec.params, function(memo, paramSpec, paramName) {
|
||||
return memo + '@param {' + GENERATE_TYPE(paramSpec.type) + '} ' + paramName + ' ' + paramSpec.description + '\n';
|
||||
}, '')
|
||||
+ ( !_.isEmpty(spec.return) ? ('@return {' + GENERATE_TYPE(spec.return.type) + '} ' + spec.return.description + '\n') : ''));
|
||||
}
|
||||
|
||||
|
||||
// generate enum spec
|
||||
function GENERATE_ENUM(name, spec, parent) {
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@property ' + name + '\n'
|
||||
+ '@type Enum ' + spec.type + '\n'
|
||||
+ '@for ' + (parent ? parent : 'common') + '\n');
|
||||
}
|
||||
|
||||
|
||||
// generate variable specs
|
||||
function GENERATE_VAR(name, spec, parent) {
|
||||
return GENERATE_DOC(spec.description + '\n'
|
||||
+ '@property ' + name + '\n'
|
||||
+ '@type ' + spec.type + '\n'
|
||||
+ '@for ' + parent + '\n');
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
// generate link spec
|
||||
function GENERATE_LINK(text) {
|
||||
return '{{#crossLink "' + text + '"}}{{/crossLink}}';
|
||||
}
|
||||
|
||||
|
||||
module.exports = generateDocs;
|
@ -18,7 +18,7 @@
|
||||
<p>
|
||||
The UPM API is a high level sensor library for IoT devices using MRAA. See examples <a href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.
|
||||
Back to <a href="http://iotdk.intel.com/docs/master/upm/node/"> index </a> page.
|
||||
<br><em>SparkFun sensor images provided under <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>CC BY-NC-SA-3.0</a>.</em>
|
||||
<br><em>SparkFun sensor images provided under <a href=https://creativecommons.org/licenses/by/2.0/>CC BY 2.0</a>.</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -36,19 +36,6 @@
|
||||
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
|
||||
|
||||
</div>
|
||||
<div class="section" id="ide">
|
||||
<h3><tt class="docutils literal"><span class="pre">IDE Compatibility</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
href="#ide"
|
||||
title="Permalink to this headline">*</a></h3>
|
||||
|
||||
|
||||
<p>Intel® XDK IoT Edition is the recommended IDE for Node.js development.
|
||||
Visit the Intel® Developer Zone IDE page for more information on how to get
|
||||
started.<br>
|
||||
<a href="https://software.intel.com/iot/software/ide"><img src="../docs/icons/xdk.png"/></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section" id="building-upm">
|
||||
<h3><tt class="docutils literal"><span class="pre">Building</span>
|
||||
<span class="pre">UPM</span></tt><a class="headerlink"
|
||||
|
@ -1,45 +0,0 @@
|
||||
document
|
||||
= _ ignore* _ "<doxygen " _ attr:attr* _ ">" body:elements _ "</doxygen>" _ { return body; }
|
||||
|
||||
|
||||
elements
|
||||
= element*
|
||||
|
||||
element
|
||||
= _ "<" startTag:id _ attr:attr* _ ">" _ children:elements _ "</" endTag:id ">" _ {
|
||||
if (startTag != endTag) {
|
||||
throw new Error("Expected </" + startTag + "> but </" + endTag + "> found.");
|
||||
}
|
||||
return {name: startTag, attr: attr, children: children }
|
||||
}
|
||||
/ "<" tag:id _ attr:attr* _ "/>" _ {
|
||||
return {name: tag, attr: attr }
|
||||
}
|
||||
/ _ text:text _ { return text }
|
||||
|
||||
ignore
|
||||
= "<?xml" _ attr* _ "?>" { return }
|
||||
|
||||
attr
|
||||
= name:id _ "=" _ value:string { return { name:name, value:value } }
|
||||
|
||||
string
|
||||
= '"' '"' _ { return ""; }
|
||||
/ "'" "'" _ { return ""; }
|
||||
/ '"' text:quoted '"' _ { return text; }
|
||||
/ "'" text:quoted "'" _ { return text; }
|
||||
|
||||
quoted
|
||||
= chars:[^<>'" \t\n\r]+ { return chars.join(""); }
|
||||
|
||||
text
|
||||
= chars:[^<> \t\n\r]+ { return chars.join(""); }
|
||||
|
||||
id
|
||||
= chars:[^<>/'"=? \t\n\r]+ { return chars.join(""); }
|
||||
|
||||
_ "whitespace"
|
||||
= whitespace*
|
||||
|
||||
whitespace
|
||||
= [ \t\n\r]
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Author: Dina M Suehiro <dina.m.suehiro@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var opts = require('commander'), // for command line args
|
||||
fs = require('fs'), // for file system access
|
||||
path = require('path'); // for file path parsing
|
||||
|
||||
// parse command line arguments
|
||||
opts
|
||||
.option('-i, --inputdir [directory]', 'product documents directory', __dirname + '/docs/yuidoc/upm')
|
||||
.parse(process.argv);
|
||||
|
||||
// Set to true for console output
|
||||
var debug = true;
|
||||
|
||||
// Global arrays tracking the files that have been renamed
|
||||
var originalFiles = [];
|
||||
var renamedFiles = [];
|
||||
|
||||
// Filter to get html files from different directories
|
||||
var rootFiles = getHtmlFilenames(opts.inputdir);
|
||||
var classesFiles = getHtmlFilenames(opts.inputdir + "/classes");
|
||||
var modulesFiles = getHtmlFilenames(opts.inputdir + "/modules");
|
||||
|
||||
// Rename files in the classes directory to have lower-cased file names.
|
||||
renameFiles(classesFiles);
|
||||
|
||||
classesFiles = getHtmlFilenames(opts.inputdir + "/classes");
|
||||
|
||||
// Go through the html files and update links to reflect the file names that we changed.
|
||||
renameLinks(rootFiles);
|
||||
renameLinks(classesFiles);
|
||||
renameLinks(modulesFiles);
|
||||
|
||||
// Helper function that returns paths to the html files in the specified directory
|
||||
function getHtmlFilenames (directory)
|
||||
{
|
||||
return fs.readdirSync(directory).map(function (file) {
|
||||
return path.join(directory, file);
|
||||
}).filter(function (file) {
|
||||
return fs.statSync(file).isFile();
|
||||
}).filter(function (file) {
|
||||
return path.extname(file).toLowerCase() == ".html";
|
||||
});
|
||||
}
|
||||
|
||||
// Goes through the files and renames them to be lower-cased and tracks them the
|
||||
// renamed files in the originalFiles[] and renamedFiles[] arrays.
|
||||
function renameFiles(files)
|
||||
{
|
||||
files.forEach(function (file)
|
||||
{
|
||||
var originalName = path.basename(file);
|
||||
var newFileName = originalName.toLowerCase();
|
||||
var directory = path.dirname(file);
|
||||
if (originalName != newFileName)
|
||||
{
|
||||
fs.renameSync(file, directory + "/" + newFileName); //, function(err)
|
||||
|
||||
if (debug)
|
||||
console.log('Renamed: %s --> %s', originalName, newFileName);
|
||||
|
||||
originalFiles.push(originalName);
|
||||
renamedFiles.push(newFileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Helper function goes through the specified files and does a file/replace of the
|
||||
// originalFiles to the renamedFiles so that the .html links match what has been renamed.
|
||||
function renameLinks (files)
|
||||
{
|
||||
if (originalFiles.length <= 0)
|
||||
{
|
||||
if (debug)
|
||||
console.log("No links to rename.");
|
||||
return;
|
||||
}
|
||||
|
||||
files.forEach(function (file)
|
||||
{
|
||||
// Read the file
|
||||
data = fs.readFileSync(file, 'ascii');
|
||||
|
||||
// Find/replace the file names that were renamed
|
||||
for (var i = 0; i < originalFiles.length; i++)
|
||||
{
|
||||
var findString = '/' + originalFiles[i] + '\"';
|
||||
var replaceString = '/' + renamedFiles[i] + '\"';
|
||||
|
||||
data = data.replace(findString, replaceString);
|
||||
}
|
||||
|
||||
// Write back
|
||||
fs.writeFile(file, data, 'ascii', function (err) {
|
||||
if (err)
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (debug)
|
||||
console.log('Renamed links in: %s', file);
|
||||
});
|
||||
}
|
@ -1,935 +0,0 @@
|
||||
/*
|
||||
* Author: Heidi Pan <heidi.pan@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// dependencies
|
||||
var peg = require('pegjs')
|
||||
, fs = require('fs')
|
||||
, path = require('path')
|
||||
, Promise = require('bluebird')
|
||||
, _ = require('lodash')
|
||||
, util = require('util');
|
||||
|
||||
|
||||
// use promise-style programming rather than spaghetti callbacks
|
||||
Promise.promisifyAll(fs);
|
||||
|
||||
|
||||
var xml2js = {
|
||||
|
||||
// js-format specs
|
||||
// MODULE: <module name>
|
||||
// ENUMS: {
|
||||
// <enum name>: {
|
||||
// type: <enum type>,
|
||||
// description: <enum description>
|
||||
// }, ...
|
||||
// }
|
||||
// ENUMS_BY_GROUP: {
|
||||
// <enum type>: {
|
||||
// description: <enum group description>
|
||||
// members: [ <enum name>, ... ]
|
||||
// }, ...
|
||||
// }
|
||||
// METHODS: {
|
||||
// <method name>: {
|
||||
// description: <method description>,
|
||||
// params: {
|
||||
// <param name>: {
|
||||
// type: <param type>,
|
||||
// description: <param description >
|
||||
// }, ...
|
||||
// },
|
||||
// return: {
|
||||
// type: <return type>,
|
||||
// description: <return description>
|
||||
// }
|
||||
// }, ...
|
||||
// }
|
||||
// CLASSES: {
|
||||
// <class name>: {
|
||||
// description: <class description>,
|
||||
// parent: <parent class name>,
|
||||
// group: <group name>,
|
||||
// methods: { ... },
|
||||
// variables: {
|
||||
// <variable name>: {
|
||||
// type: <variable type>,
|
||||
// description: <variable description>
|
||||
// }
|
||||
// },
|
||||
// enums: { ... },
|
||||
// enums_by_group: { ... }
|
||||
// }, ...
|
||||
// }
|
||||
// CLASSGROUPS: {
|
||||
// <group name>: {
|
||||
// description: <group description>,
|
||||
// classes: [ <class name>, ... ],
|
||||
// enums: { ... },
|
||||
// enums_by_group: { ... }
|
||||
// }, ...
|
||||
// }
|
||||
MODULE: '',
|
||||
ENUMS: {},
|
||||
ENUMS_BY_GROUP: {},
|
||||
METHODS: {},
|
||||
CLASSES: {},
|
||||
CLASSGROUPS: {},
|
||||
|
||||
|
||||
// baseline c -> js type mapping
|
||||
TYPEMAPS: {
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(int|short|long|float|double|size_t|u?int\\d{1,2}_t)?$': 'Number',
|
||||
'^bool$': 'Boolean',
|
||||
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String', // TODO: verify that swig does this mapping
|
||||
'^void\\s*\\(\\s*\\*\\s*\\)\\s*\\(\\s*void\\s*\\*\\)\\s*$': 'Function'
|
||||
},
|
||||
|
||||
|
||||
// custom c -> js type mapping for pointers
|
||||
// ARRAY_TYPEMAPS: {
|
||||
// <pointer data type>: {
|
||||
// arrayType: <swig generated array type that will replace pointers of data type>,
|
||||
// classes: [ <class that contains arrayType>, ... ]
|
||||
// }, ...
|
||||
// }
|
||||
// POINTER_TYPEMAPS: {
|
||||
// <class that contains pointerType>: {
|
||||
// <c pointer data type>: <js swig generated pointer type that will replace pointers of data type>, ...
|
||||
// }, ...
|
||||
// }
|
||||
ARRAY_TYPEMAPS: {},
|
||||
POINTER_TYPEMAPS: {},
|
||||
|
||||
|
||||
// add command line options for this module
|
||||
addOptions: function(opts) {
|
||||
xml2js.opts = opts;
|
||||
return opts
|
||||
.option('-i, --inputdir [directory]', 'directory for xml files', __dirname + '/xml/mraa')
|
||||
.option('-c, --custom [file]', 'json for customizations')
|
||||
.option('-t, --typemaps [directory]', 'directory for custom pointer type maps')
|
||||
.option('-g, --imagedir [directory]', 'directory to link to where the images will be kept', '')
|
||||
.option('-s, --strict', 'leave out methods/variables if unknown type')
|
||||
},
|
||||
|
||||
|
||||
// parse doxygen xml -> js-format specs
|
||||
// TODO: figure out whether we need to document any protected methods/variables
|
||||
parse: function() {
|
||||
var XML_GRAMMAR_SPEC = 'grammars/xml.peg';
|
||||
var NAMESPACE_SPEC = xml2js.opts.inputdir + '/namespace' + xml2js.opts.module + '.xml';
|
||||
var CLASS_SPEC = function(c) { return xml2js.opts.inputdir + '/' + c + '.xml'; }
|
||||
var TYPES_SPEC = xml2js.opts.inputdir + '/types_8h.xml';
|
||||
xml2js.MODULE = xml2js.opts.module;
|
||||
return Promise.join(createXmlParser(XML_GRAMMAR_SPEC),
|
||||
xml2js.opts.typemaps ? initCustomPointerTypemaps(xml2js.opts.typemaps) : Promise.resolve(),
|
||||
fs.readFileAsync(NAMESPACE_SPEC, 'utf8'),
|
||||
fs.existsSync(TYPES_SPEC) ? fs.readFileAsync(TYPES_SPEC, 'utf8') : Promise.resolve(null),
|
||||
function(xmlparser, ignore, xml, xml_types) {
|
||||
if (xml_types != null) {
|
||||
_.extend(xml2js.ENUMS, getEnums(xmlparser.parse(xml_types)[0], false));
|
||||
_.extend(xml2js.ENUMS_BY_GROUP, getEnums(xmlparser.parse(xml_types)[0], true));
|
||||
}
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
_.extend(xml2js.ENUMS, getEnums(spec_c, false));
|
||||
_.extend(xml2js.ENUMS_BY_GROUP, getEnums(spec_c, true));
|
||||
_.extend(xml2js.METHODS, getMethods(spec_c));
|
||||
_.each(getSubclassNames(spec_c), function(className) { xml2js.CLASSES[className] = {} });
|
||||
var parseClasses = _.map(getSubclasses(spec_c), function(c) {
|
||||
return fs.readFileAsync(CLASS_SPEC(c), 'utf8').then(function(xml) {
|
||||
try {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
var className = getName(spec_c);
|
||||
_.extend(xml2js.CLASSES[className], {
|
||||
description: getDescription(spec_c),
|
||||
parent: getParent(spec_c, className),
|
||||
enums: getEnums(spec_c, false, className),
|
||||
enums_by_group: getEnums(spec_c, true, className),
|
||||
variables: getVariables(spec_c, className),
|
||||
methods: getMethods(spec_c, className)
|
||||
});
|
||||
} catch(e) {
|
||||
console.log(e.toString() + ': class ' + className + ' was not parsed correctly.');
|
||||
}
|
||||
});
|
||||
});
|
||||
var parseGroups = fs.readdirAsync(xml2js.opts.inputdir).then(function(files) {
|
||||
var groupxmlfiles = _.filter(files, function(fn) {
|
||||
return ((path.extname(fn) == '.xml') && (path.basename(fn).search(/^group/) != -1));
|
||||
});
|
||||
return Promise.all(_.map(groupxmlfiles, function(fn) {
|
||||
return fs.readFileAsync(xml2js.opts.inputdir + '/' + fn, 'utf8').then(function(xml) {
|
||||
var spec_c = xmlparser.parse(xml)[0];
|
||||
if (_.isEmpty(getSubmodules(spec_c))) {
|
||||
var group = getName(spec_c);
|
||||
var classes = getSubclassNames(spec_c);
|
||||
xml2js.CLASSGROUPS[group] = {
|
||||
description: getDescription(spec_c),
|
||||
classes: classes
|
||||
};
|
||||
_.each(classes, function(c) {
|
||||
if (_.has(xml2js.CLASSES, c)) {
|
||||
xml2js.CLASSES[c].group = group;
|
||||
} else {
|
||||
console.log('Warning: Group ' + group + ' has unknown class ' + c);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
return Promise.all(parseClasses.concat(parseGroups));
|
||||
}).then(function() {
|
||||
if (!_.isEmpty(xml2js.CLASSGROUPS)) {
|
||||
// try to categorize ungrouped classes, if any
|
||||
var grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
var ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
_.each(ungrouped, function(c) {
|
||||
_.each(findUsage(c), function(group) {
|
||||
xml2js.CLASSGROUPS[group].classes.push(c);
|
||||
});
|
||||
});
|
||||
grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
|
||||
ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
|
||||
// try to categorize ungrouped enums, if any
|
||||
_.each(xml2js.ENUMS_BY_GROUP, function(enumGroupSpec, enumGroupName) {
|
||||
_.each(findUsage(enumGroupName, true), function(c) {
|
||||
xml2js.CLASSES[c].enums_by_group[enumGroupName] = enumGroupSpec;
|
||||
_.each(enumGroupSpec.members, function(enumName) {
|
||||
xml2js.CLASSES[c].enums[enumName] = xml2js.ENUMS[enumName];
|
||||
delete xml2js.ENUMS[enumName];
|
||||
});
|
||||
delete xml2js.ENUMS_BY_GROUP[enumGroupName];
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function() {
|
||||
if (xml2js.opts.custom && fs.existsSync(xml2js.opts.custom)) {
|
||||
return fs.readFileAsync(xml2js.opts.custom, 'utf8').then(function(custom) {
|
||||
try {
|
||||
customizeMethods(JSON.parse(custom));
|
||||
} catch(e) {
|
||||
console.log('invalid custom.json, ignored. ' + e.toString());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log(xml2js.opts.custom ? ('Error: No such customization file exists: ' + xml2js.opts.custom) : 'No customizations given.');
|
||||
}
|
||||
}).then(function() {
|
||||
generateCustomPointerClasses();
|
||||
validateMethods();
|
||||
validateVars();
|
||||
return _.pick(xml2js, 'MODULE', 'ENUMS', 'ENUMS_BY_GROUP', 'METHODS', 'CLASSES', 'CLASSGROUPS');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// create an xml parser
|
||||
function createXmlParser(XML_GRAMMAR_SPEC) {
|
||||
return fs.readFileAsync(XML_GRAMMAR_SPEC, 'utf8').then(function(xmlgrammar) {
|
||||
return peg.buildParser(xmlgrammar);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// configure c->js typemaps from custom swig directives
|
||||
// TODO: many built in assumptions based on current upm file structures & .i customizations
|
||||
function initCustomPointerTypemaps(typemapsdir) {
|
||||
return fs.readdirAsync(typemapsdir).then(function(dirs) {
|
||||
return Promise.all(_.map(dirs, function(dir) {
|
||||
// get all js*.i directives from class-specific subdirectories, to be parsed below for %typemaps directives
|
||||
return fs.readdirAsync(typemapsdir + '/' + dir).then(function(files) {
|
||||
var directive = _.find(files, function(fn) {
|
||||
return ((path.extname(fn) == '.i') && (path.basename(fn).search(/^js/) != -1));
|
||||
});
|
||||
var data = {};
|
||||
if (directive) {
|
||||
data[dir] = typemapsdir + '/' + dir + '/' + directive;
|
||||
}
|
||||
return data;
|
||||
}).catch(function(e) {
|
||||
// get all .i directives from top level directory, and parse for %array_class directives
|
||||
if (e.code == 'ENOTDIR') {
|
||||
var fn = dir;
|
||||
if (path.extname(fn) == '.i') {
|
||||
return fs.readFileAsync(typemapsdir + '/' + fn, 'utf8').then(function(directives) {
|
||||
var arraytypes = _.filter(directives.split(/\n/), function(line) {
|
||||
return (line.search(/^%array_class/) != -1);
|
||||
});
|
||||
_.each(arraytypes, function(arraytype) {
|
||||
var parsed = arraytype.match(/%array_class\(([A-Za-z0-9_]+)[\s]*,[\s]*([A-Za-z0-9_]+)\)/);
|
||||
if (parsed) {
|
||||
var from = parsed[1];
|
||||
var to = parsed[2];
|
||||
xml2js.ARRAY_TYPEMAPS[from] = { arrayType: to, classes: [] };
|
||||
} else {
|
||||
console.log('Incorrectly parsed array_class from ' + fn + ': ' + arraytype);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}));
|
||||
}).then(function(__directivesFiles) {
|
||||
// parse for %typemaps & %pointer_functions directives
|
||||
var _directivesFiles = _.filter(__directivesFiles, function(data) { return !_.isEmpty(data); });
|
||||
var directivesFiles = _.object(_.map(_directivesFiles, _.keys), _.flatten(_.map(_directivesFiles, _.values)));
|
||||
return Promise.all(_.map(directivesFiles, function(directivesFn, className) {
|
||||
return fs.readFileAsync(directivesFn, 'utf8').then(function(directives) {
|
||||
var typemaps = _.filter(directives.split(/\n/), function(line) {
|
||||
return (line.search(/^%typemap/) != -1);
|
||||
});
|
||||
_.each(typemaps, function(typemap) {
|
||||
var parsed = typemap.match(/%typemap\((in|out)\)[\s]+([A-Za-z0-9_]+[\s]*[\*])/);
|
||||
if (parsed) {
|
||||
var dir = parsed[1]; // TODO: ignored for now
|
||||
var type = normalizePointer(parsed[2]);
|
||||
var datatype = getPointerDataType(type);
|
||||
if (_.has(xml2js.ARRAY_TYPEMAPS, datatype)) {
|
||||
xml2js.ARRAY_TYPEMAPS[datatype].classes.push(className);
|
||||
} else {
|
||||
console.log('Ignored typemap from ' + directivesFn + ': ' + typemap.replace('{', '') + ' (no %array_class directive found for ' + datatype + ')');
|
||||
}
|
||||
} else {
|
||||
console.log('Ignored typemap from ' + directivesFn + ': ' + typemap.replace('{', '') + ' (only considering in/out typemaps of pointer types)');
|
||||
}
|
||||
});
|
||||
var ptrfns = _.filter(directives.split(/\n/), function(line) {
|
||||
return (line.search(/^%pointer_functions/) != -1);
|
||||
});
|
||||
_.each(ptrfns, function(ptrfn) {
|
||||
var parsed = ptrfn.match(/%pointer_functions\(([A-Za-z0-9_]+)[\s]*,[\s]*([A-Za-z0-9_]+)\)/);
|
||||
if (parsed) {
|
||||
var from = parsed[1];
|
||||
var to = parsed[2];
|
||||
if (!_.has(xml2js.POINTER_TYPEMAPS, className)) {
|
||||
xml2js.POINTER_TYPEMAPS[className] = {};
|
||||
}
|
||||
xml2js.POINTER_TYPEMAPS[className][from] = to;
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// generate class specs for custom pointer types
|
||||
function generateCustomPointerClasses() {
|
||||
var arrayTypes = _.pluck(_.values(xml2js.ARRAY_TYPEMAPS), 'arrayType');
|
||||
var pointerTypes = _.uniq(_.flatten(_.map(_.values(xml2js.POINTER_TYPEMAPS), _.values)));
|
||||
_.each(arrayTypes, function(arrayType) {
|
||||
var dataType = _.findKey(xml2js.ARRAY_TYPEMAPS, function(to) { return to.arrayType == arrayType; });
|
||||
xml2js.CLASSES[arrayType] = {
|
||||
description: 'Array of type ' + dataType + '.',
|
||||
enums: {},
|
||||
enums_by_group: {},
|
||||
variables: {},
|
||||
methods: {}
|
||||
};
|
||||
xml2js.CLASSES[arrayType].methods[arrayType] = {
|
||||
description: 'Instantiates the array.',
|
||||
params: {
|
||||
nelements: {
|
||||
type: 'Number',
|
||||
description: 'number of elements in the array'
|
||||
}
|
||||
},
|
||||
return: {}
|
||||
};
|
||||
xml2js.CLASSES[arrayType].methods.getitem = {
|
||||
description: 'Access a particular element in the array.',
|
||||
params: {
|
||||
index: {
|
||||
type: 'Number',
|
||||
description: 'index of array to read from'
|
||||
},
|
||||
},
|
||||
return: {
|
||||
type: getType(dataType),
|
||||
description: 'the value of the element found at the given index of the array'
|
||||
}
|
||||
};
|
||||
xml2js.CLASSES[arrayType].methods.setitem = {
|
||||
description: 'Modify a particular element in the array.',
|
||||
params: {
|
||||
index: {
|
||||
type: 'Number',
|
||||
description: 'index of array to write to'
|
||||
},
|
||||
value: {
|
||||
type: getType(dataType),
|
||||
description: 'the value to set the element found at the given index of the array'
|
||||
}
|
||||
},
|
||||
return: {}
|
||||
};
|
||||
});
|
||||
var pointerDataTypeMap = _.reduce(_.map(_.values(xml2js.POINTER_TYPEMAPS), _.invert), function(memo, typemap) {
|
||||
return _.extend(memo, typemap);
|
||||
}, {});
|
||||
_.each(pointerTypes, function(pointerType) {
|
||||
var dataType = pointerDataTypeMap[pointerType];
|
||||
xml2js.CLASSES[pointerType] = {
|
||||
description: 'Proxy object to data of type ' + dataType + '.',
|
||||
enums: {},
|
||||
enums_by_group: {},
|
||||
variables: {},
|
||||
methods: {}
|
||||
};
|
||||
xml2js.CLASSES[pointerType].methods[pointerType] = {
|
||||
description: 'Instantiates the proxy object.',
|
||||
params: {},
|
||||
return: {}
|
||||
};
|
||||
xml2js.CLASSES[pointerType].methods.value = {
|
||||
description: 'Get the value of the object.',
|
||||
params: {},
|
||||
return: {
|
||||
type: getType(dataType),
|
||||
description: 'the value of the object'
|
||||
}
|
||||
};
|
||||
xml2js.CLASSES[pointerType].methods.assign = {
|
||||
description: 'Set the value of the object.',
|
||||
params: {
|
||||
value: {
|
||||
type: getType(dataType),
|
||||
description: 'the value to set the object to'
|
||||
}
|
||||
},
|
||||
return: {}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// search for usage of a type
|
||||
function findUsage(type, classOnly) {
|
||||
var filterClasses = function(fn) { return _.without(_.map(xml2js.CLASSES, fn), undefined); };
|
||||
var usesType = function(classSpec, className) {
|
||||
var methodsOfType = (_.find(classSpec.methods, function(methodSpec, methodName) {
|
||||
return ((!_.isEmpty(methodSpec.return) && methodSpec.return.type == type) ||
|
||||
(_.contains(_.pluck(methodSpec.params, 'type'), type)));
|
||||
}) != undefined);
|
||||
var variablesOfType = _.contains(_.pluck(classSpec.variable, 'type'), type);
|
||||
return ((methodsOfType || variablesOfType) ? className : undefined);
|
||||
};
|
||||
var extendsType = function(classSpec, className) {
|
||||
return ((classSpec.parent == type) ? className : undefined);
|
||||
};
|
||||
var classes = _.union(filterClasses(usesType), filterClasses(extendsType));
|
||||
if (classOnly) {
|
||||
return classes;
|
||||
} else {
|
||||
return _.without(_.uniq(_.pluck(_.pick(xml2js.CLASSES, classes), 'group')), undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// override autogenerated methods with custom configuration
|
||||
function customizeMethods(custom) {
|
||||
_.each(custom, function(classMethods, className) {
|
||||
_.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
|
||||
return isValidMethodSpec(methodSpec, className + '.' + methodName);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// make sure methods have valid types, otherwise warn (& don't include if strict)
|
||||
function validateMethods() {
|
||||
xml2js.METHODS = _.pick(xml2js.METHODS, function(methodSpec, methodName) {
|
||||
return hasValidTypes(methodSpec, methodName);
|
||||
});
|
||||
_.each(xml2js.CLASSES, function(classSpec, className) {
|
||||
var valid = _.pick(classSpec.methods, function(methodSpec, methodName) {
|
||||
return hasValidTypes(methodSpec, className + '.' + methodName, className);
|
||||
});
|
||||
if (xml2js.opts.strict) {
|
||||
xml2js.CLASSES[className].methods = valid;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// make sure variables have valid types, otherwise warn (& don't include if strict)
|
||||
function validateVars() {
|
||||
_.each(xml2js.CLASSES, function(classSpec, className) {
|
||||
var valid = _.pick(classSpec.variables, function(varSpec, varName) {
|
||||
return ofValidType(varSpec, className + '.' + varName, className);
|
||||
});
|
||||
if (xml2js.opts.strict) {
|
||||
xml2js.CLASSES[className].variables = valid;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// verify that the json spec is well formatted
|
||||
function isValidMethodSpec(methodSpec, methodName) {
|
||||
var valid = true;
|
||||
var printIgnoredMethodOnce = _.once(function() { console.log(methodName + ' from ' + path.basename(xml2js.opts.custom) + ' is omitted from JS documentation.'); });
|
||||
function checkRule(rule, errMsg) {
|
||||
if (!rule) {
|
||||
printIgnoredMethodOnce();
|
||||
console.log(' ' + errMsg);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
checkRule(_.has(methodSpec, 'description'), 'no description given');
|
||||
checkRule(_.has(methodSpec, 'params'), 'no params given (specify "params": {} for no params)');
|
||||
_.each(methodSpec.params, function(paramSpec, paramName) {
|
||||
checkRule(_.has(paramSpec, 'type'), 'no type given for param ' + paramName);
|
||||
checkRule(_.has(paramSpec, 'description'), 'no description given for param ' + paramName);
|
||||
});
|
||||
checkRule(_.has(methodSpec, 'return'), 'no return given (specify "return": {} for no return value)');
|
||||
checkRule(_.has(methodSpec.return, 'type'), 'no type given for return value');
|
||||
checkRule(_.has(methodSpec.return, 'description'), 'no description given for return value');
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
// get enum specifications
|
||||
function getEnums(spec_c, bygroup, parent) {
|
||||
var spec_js = {};
|
||||
var enumGroups = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
|
||||
var kind = getAttr(section, 'kind');
|
||||
return ((kind == 'enum') || (kind == 'public-type'));
|
||||
});
|
||||
if (enumGroups) {
|
||||
_.each(enumGroups.children, function(enumGroup) {
|
||||
var enumGroupName = getText(getChild(enumGroup, 'name'), 'name');
|
||||
var enumGroupDescription = getText(getChild(enumGroup, 'detaileddescription'), 'description');
|
||||
var enumGroupVals = getChildren(enumGroup, 'enumvalue');
|
||||
if (bygroup) {
|
||||
spec_js[enumGroupName] = {
|
||||
description: enumGroupDescription,
|
||||
members: []
|
||||
};
|
||||
}
|
||||
_.each(enumGroupVals, function(e) {
|
||||
// TODO: get prefix as option
|
||||
var enumName = getText(getChild(e, 'name'), 'name').replace(/^MRAA_/, '');
|
||||
var enumDescription = getText(getChild(e, 'detaileddescription'), 'description');
|
||||
if (!bygroup) {
|
||||
spec_js[enumName] = {
|
||||
type: enumGroupName,
|
||||
description: enumDescription
|
||||
};
|
||||
} else {
|
||||
spec_js[enumGroupName].members.push(enumName);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return spec_js;
|
||||
}
|
||||
|
||||
|
||||
// get the name for the module/group/class
|
||||
function getName(spec_c) {
|
||||
return getText(getChild(spec_c, 'compoundname'), 'name').replace(xml2js.opts.module + '::', '');
|
||||
}
|
||||
|
||||
|
||||
// get the description for the module/group/class
|
||||
function getDescription(spec_c) {
|
||||
return getText(getChild(spec_c, 'detaileddescription'), 'description');
|
||||
}
|
||||
|
||||
|
||||
// get the classes (xml file names) for the given module
|
||||
function getSubclasses(spec_c) {
|
||||
return _.map(getChildren(spec_c, 'innerclass'), function(innerclass) {
|
||||
return getAttr(innerclass, 'refid');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get the classes (class names) for the given module
|
||||
function getSubclassNames(spec_c) {
|
||||
return _.map(getChildren(spec_c, 'innerclass'), function(innerclass) {
|
||||
return getText(innerclass).replace(xml2js.opts.module + '::', '');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get the submodules (xml file names) for the given module
|
||||
function getSubmodules(spec_c) {
|
||||
return _.map(getChildren(spec_c, 'innergroup'), function(innergroup) {
|
||||
return getAttr(innergroup, 'refid');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get parent class, if any
|
||||
function getParent(spec_c, className) {
|
||||
var parent = getChild(spec_c, 'basecompoundref');
|
||||
if (parent) {
|
||||
parent = getText(parent);
|
||||
if (!_.has(xml2js.CLASSES, parent)) {
|
||||
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
function hasParams(paramsSpec) {
|
||||
return !(_.isEmpty(paramsSpec) ||
|
||||
((_.size(paramsSpec) == 1) && getText(getChild(paramsSpec[0], 'type')) == 'void'));
|
||||
}
|
||||
|
||||
|
||||
// get method specifications for top-level module or a given class
|
||||
// TODO: overloaded functions
|
||||
// TODO: functions w/ invalid parameter(s)/return
|
||||
function getMethods(spec_c, parent) {
|
||||
var spec_js = {};
|
||||
var methods = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
|
||||
var kind = getAttr(section, 'kind');
|
||||
return ((kind == 'public-func') || (kind == 'func'));
|
||||
});
|
||||
if (methods) {
|
||||
_.each(methods.children, function(method) {
|
||||
var methodName = getText(getChild(method, 'name'), 'name');
|
||||
if (methodName[0] != '~') { // filter out destructors
|
||||
try {
|
||||
var description = getChild(method, 'detaileddescription');
|
||||
var methodDescription = getText(description, 'description');
|
||||
var paramsSpec = getChildren(method, 'param');
|
||||
var params = {};
|
||||
if (hasParams(paramsSpec)) {
|
||||
params = getParams(paramsSpec, getParamsDetails(description), methodName, parent);
|
||||
}
|
||||
var returnSpec = getChild(method, 'type');
|
||||
var retval = {};
|
||||
if (!_.isEmpty(returnSpec)) {
|
||||
retval = getReturn(returnSpec, getReturnDetails(description), methodName, parent);
|
||||
}
|
||||
methodName = getUniqueMethodName(methodName, spec_js, parent);
|
||||
spec_js[methodName] = {
|
||||
description: methodDescription,
|
||||
params: params,
|
||||
return: retval
|
||||
};
|
||||
} catch(e) {
|
||||
console.log((parent ? (parent + '.') : '') + methodName + ' is omitted from JS documentation.');
|
||||
console.log(' ' + e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return spec_js;
|
||||
}
|
||||
|
||||
|
||||
// get a unique string to represent the name of an overloaded method
|
||||
function getUniqueMethodName(methodName, module, parent) {
|
||||
if (methodName in module) {
|
||||
do {
|
||||
methodName += '!';
|
||||
} while (methodName in module);
|
||||
}
|
||||
return methodName;
|
||||
}
|
||||
|
||||
|
||||
// get variable specifications for a class
|
||||
function getVariables(spec_c, parent) {
|
||||
var spec_js = {};
|
||||
var vars = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
|
||||
var kind = getAttr(section, 'kind');
|
||||
return (kind == 'public-attrib');
|
||||
});
|
||||
if (vars) {
|
||||
_.each(_.filter(vars.children, function(variable) {
|
||||
return (getAttr(variable, 'kind') == 'variable');
|
||||
}), function(variable) {
|
||||
var varName = getText(getChild(variable, 'name'), 'name');
|
||||
var varType = getType(getText(getChild(variable, 'type')), parent);
|
||||
var varDescription = getText(getChild(variable, 'detaileddescription'));
|
||||
spec_js[varName] = {
|
||||
type: varType,
|
||||
description: varDescription
|
||||
}
|
||||
});
|
||||
}
|
||||
return spec_js;
|
||||
}
|
||||
|
||||
|
||||
// get return value specs of a method
|
||||
function getReturn(spec_c, details, method, parent) {
|
||||
var retType = getType(getText(spec_c, 'type'), parent);
|
||||
var retDescription = (details ? getText(details, 'description') : '');
|
||||
return ((retType == 'void') ? {} : {
|
||||
type: retType,
|
||||
description: retDescription
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get paramater specs of a method
|
||||
function getParams(spec_c, details, method, parent) {
|
||||
var spec_js = {};
|
||||
_.each(spec_c, function(param) {
|
||||
try {
|
||||
var paramType = getType(getText(getChild(param, 'type'), 'type'), parent);
|
||||
var paramName = getText(getChild(param, 'declname'), 'name');
|
||||
spec_js[paramName] = { type: paramType };
|
||||
} catch(e) {
|
||||
if (paramType == '...') {
|
||||
spec_js['arguments'] = { type: paramType };
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
_.each(details, function(param) {
|
||||
var getParamName = function(p) { return getText(getChild(getChild(p, 'parameternamelist'), 'parametername'), 'name'); }
|
||||
var paramName = getParamName(param);
|
||||
var paramDescription = getText(getChild(param, 'parameterdescription'), 'description');
|
||||
if (_.has(spec_js, paramName)) {
|
||||
spec_js[paramName].description = paramDescription;
|
||||
} else {
|
||||
var msg = ' has documentation for an unknown parameter: ' + paramName + '. ';
|
||||
var suggestions = _.difference(_.keys(spec_js), _.map(details, getParamName));
|
||||
var msgAddendum = (!_.isEmpty(suggestions) ? ('Did you mean ' + suggestions.join(', or ') + '?') : '');
|
||||
console.log('Warning: ' + (parent ? (parent + '.') : '') + method + msg + msgAddendum);
|
||||
}
|
||||
});
|
||||
return spec_js;
|
||||
}
|
||||
|
||||
|
||||
// get the equivalent javascript type from the given c type
|
||||
function getType(type_c, parent) {
|
||||
var type_js = type_c;
|
||||
_.find(xml2js.TYPEMAPS, function(to, from) {
|
||||
var pattern = new RegExp(from, 'i');
|
||||
if (type_c.search(pattern) == 0) {
|
||||
type_js = to;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (isPointer(type_js)) {
|
||||
var dataType = getPointerDataType(type_js);
|
||||
var className = parent.toLowerCase();
|
||||
if (_.has(xml2js.ARRAY_TYPEMAPS, dataType) && _.contains(xml2js.ARRAY_TYPEMAPS[dataType].classes, className)) {
|
||||
type_js = xml2js.ARRAY_TYPEMAPS[dataType].arrayType;
|
||||
} else if (_.has(xml2js.POINTER_TYPEMAPS, className) && _.has(xml2js.POINTER_TYPEMAPS[className], dataType)) {
|
||||
type_js = xml2js.POINTER_TYPEMAPS[className][dataType];
|
||||
} else if (_.has(xml2js.CLASSES, dataType)) { // TODO: verify that swig does this mapping
|
||||
type_js = dataType;
|
||||
} else {
|
||||
type_js = dataType + ' *'
|
||||
}
|
||||
}
|
||||
return type_js;
|
||||
}
|
||||
|
||||
|
||||
// verify that all types associated with the method are valid
|
||||
function hasValidTypes(methodSpec, methodName, parent) {
|
||||
var valid = true;
|
||||
var msg = (xml2js.opts.strict ? ' is omitted from JS documentation.' : ' has invalid type(s).');
|
||||
var printIgnoredMethodOnce = _.once(function() { console.log(methodName + msg); });
|
||||
_.each(methodSpec.params, function(paramSpec, paramName) {
|
||||
if (!isValidType(paramSpec.type, parent)) {
|
||||
valid = false;
|
||||
printIgnoredMethodOnce();
|
||||
console.log(' Error: parameter ' + paramName + ' has invalid type ' + typeToString(paramSpec.type));
|
||||
}
|
||||
});
|
||||
if (!_.isEmpty(methodSpec.return) && !isValidType(methodSpec.return.type, parent)) {
|
||||
valid = false;
|
||||
printIgnoredMethodOnce();
|
||||
console.log(' Error: returns invalid type ' + typeToString(methodSpec.return.type));
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
// verify that type of variable is valid
|
||||
function ofValidType(varSpec, varName, parent) {
|
||||
if (isValidType(varSpec.type, parent)) {
|
||||
return true;
|
||||
} else {
|
||||
var msgAddendum = (xml2js.opts.strict ? ' Omitted from JS documentation.' : '');
|
||||
console.log('Error: ' + varName + ' is of invalid type ' + typeToString(varSpec.type) + '.' + msgAddendum);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// verify whether the given type is valid JS
|
||||
function isValidType(type, parent) {
|
||||
return (_.contains(_.values(xml2js.TYPEMAPS), type) ||
|
||||
_.has(xml2js.CLASSES, type) ||
|
||||
_.has(xml2js.ENUMS_BY_GROUP, type) ||
|
||||
_.contains(['Buffer', 'Function', 'mraa_result_t'], type) ||
|
||||
_.has((parent ? xml2js.CLASSES[parent].enums_by_group : []), type) ||
|
||||
isValidPointerType(type, parent));
|
||||
}
|
||||
|
||||
|
||||
function isValidPointerType(type, parent) {
|
||||
var className = parent.toLowerCase();
|
||||
var arrayTypemap = _.find(xml2js.ARRAY_TYPEMAPS, function(to) { return to.arrayType == type; });
|
||||
var valid = ((arrayTypemap && _.contains(arrayTypemap.classes, className)) ||
|
||||
(_.has(xml2js.POINTER_TYPEMAPS, className) && (_.contains(_.values(xml2js.POINTER_TYPEMAPS[className]), type))));
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
// determines whether a type looks like a c pointer
|
||||
function isPointer(type) {
|
||||
return (type.search(/\w+\s*(\*|&)$/) != -1);
|
||||
}
|
||||
|
||||
|
||||
// remove extraneous whitespace from pointer types as canonical representation
|
||||
function normalizePointer(ptr) {
|
||||
return ptr.replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
|
||||
// get the data type of a pointer (e.g. int is the data type of int*)
|
||||
function getPointerDataType(ptr) {
|
||||
return ptr.replace(/\s*(\*|&)$/, '');
|
||||
}
|
||||
|
||||
|
||||
// print more human friendly type for error messages
|
||||
function typeToString(type) {
|
||||
return type.replace('*', '*');
|
||||
}
|
||||
|
||||
|
||||
// get the detailed description of a method's parameters
|
||||
function getParamsDetails(spec_c) {
|
||||
var paras = getChildren(spec_c, 'para');
|
||||
var details = _.find(_.map(paras, function(para) {
|
||||
return getChild(para, 'parameterlist');
|
||||
}), function(obj) { return (obj != undefined); });
|
||||
return (details ? details.children : undefined);
|
||||
}
|
||||
|
||||
|
||||
// get the detailed description of a method's return value
|
||||
function getReturnDetails(spec_c) {
|
||||
var paras = getChildren(spec_c, 'para');
|
||||
return _.find(_.map(paras, function(para) {
|
||||
return getChild(para, 'simplesect');
|
||||
}), function(obj) { return ((obj != undefined) && (getAttr(obj, 'kind') == 'return')); });
|
||||
}
|
||||
|
||||
|
||||
// get (and flatten) the text of the given object
|
||||
function getText(obj, why) {
|
||||
// TODO: links ignored for now, patched for types for
|
||||
var GENERATE_LINK = function(x) { return x + ' '; }
|
||||
return _.reduce(obj.children, function(text, elem) {
|
||||
if (_.isString(elem)) {
|
||||
return text += elem.trim() + ' ';
|
||||
} else if (_.isPlainObject(elem)) {
|
||||
switch(elem.name) {
|
||||
case 'para':
|
||||
return text += getText(elem, why) + ' \n';
|
||||
case 'ref':
|
||||
return text += GENERATE_LINK(getText(elem, why));
|
||||
case 'parameterlist':
|
||||
case 'simplesect':
|
||||
return text; // to be handled elsewhere
|
||||
case 'programlisting':
|
||||
case 'htmlonly':
|
||||
return text; // ignored
|
||||
// TODO: html doesn't seem to work for yuidoc, using markdown for now
|
||||
case 'itemizedlist':
|
||||
return text += '\n' + getText(elem, why) + ' \n \n';
|
||||
case 'listitem':
|
||||
return text += '+ ' + getText(elem, why) + '\n';
|
||||
case 'bold':
|
||||
return text += '__' + getText(elem, why).trim() + '__ ';
|
||||
case 'ulink':
|
||||
return text += '[' + getText(elem, why).trim() + '](' + getAttr(elem, 'url').trim() + ') ';
|
||||
case 'image':
|
||||
// TODO: copy images over; hard coded for now
|
||||
var fn = getAttr(elem, 'name');
|
||||
return text += ' \n \n ';
|
||||
case 'linebreak':
|
||||
return text += ' \n';
|
||||
case 'ndash':
|
||||
return text += '– ';
|
||||
default:
|
||||
// TODO: incomplete list of doxygen xsd implemented
|
||||
console.warn('NYI Unknown Object Type: ' + elem.name);
|
||||
return text;
|
||||
//throw new Error('NYI Unknown Object Type: ' + elem.name);
|
||||
}
|
||||
} else {
|
||||
throw new Error('NYI Unknown Type: ' + (typeof elem));
|
||||
}
|
||||
}, '').trim();
|
||||
}
|
||||
|
||||
|
||||
// get the value of attribute with the given name of the given object
|
||||
function getAttr(obj, name) {
|
||||
return _.find(obj.attr, function(item) {
|
||||
return item.name == name;
|
||||
}).value;
|
||||
}
|
||||
|
||||
|
||||
// get the child object with the given name of the given object
|
||||
function getChild(obj, name) {
|
||||
return _.find(obj.children, function(child) {
|
||||
return child.name == name;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get all children objects with the given name of the given object
|
||||
function getChildren(obj, name) {
|
||||
return _.filter(obj.children, function(child) {
|
||||
return child.name == name;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// debug helper: print untruncated object
|
||||
function printObj(obj) {
|
||||
console.log(util.inspect(obj, false, null));
|
||||
}
|
||||
|
||||
|
||||
module.exports = xml2js;
|
@ -1,72 +1,84 @@
|
||||
# Mapping examples across provided languages
|
||||
a110x.cxx A110XSample.java a110x.js a110x.py
|
||||
a110x-intr.cxx A110X_intrSample.java a110x-intr.js a110x-intr.py
|
||||
adc121c021.cxx ADC121C021Sample.java adc121c021.js adc121c021.py
|
||||
adxl345.cxx Adxl345Sample.java adxl345.js adxl345.py
|
||||
biss0001.cxx BISS0001Sample.java biss0001.js biss0001.py
|
||||
bmpx8x.cxx BMPX8XSample.java bmpx8x.js bmpx8x.py
|
||||
button.cxx ButtonSample.java button.js button.py
|
||||
buzzer.cxx BuzzerSample.java buzzer.js buzzer.py
|
||||
cjq4435.cxx CJQ4435Sample.java cjq4435.js cjq4435.py
|
||||
ds1307.cxx DS1307Sample.java ds1307.js ds1307.py
|
||||
enc03r.cxx ENC03RSample.java enc03r.js enc03r.py
|
||||
es08a.cxx ES08ASample.java es08a.js es08a.py
|
||||
groveehr.cxx GroveEHRSample.java groveehr.js groveehr.py
|
||||
groveledbar.cxx GroveLEDBar.java groveledbar.js groveledbar.py
|
||||
groveled.cxx GroveLEDSample.java groveled.js groveled.py
|
||||
grovelinefinder.cxx GroveLineFinderSample.java grovelinefinder.js grovelinefinder.py
|
||||
grovemoisture.cxx GroveMoistureSample.java grovemoisture.js grovemoisture.py
|
||||
grovescam.cxx GROVESCAMSample.java grovescam.js grovescam.py
|
||||
grovewfs.cxx GroveWFSSample.java grovewfs.js grovewfs.py
|
||||
guvas12d.cxx GUVAS12DSample.java guvas12d.js guvas12d.py
|
||||
h3lis331dl.cxx H3LIS331DLSample.java h3lis331dl.js h3lis331dl.py
|
||||
hcsr04.cxx HCSR04Sample.java hcsr04.js hcsr04.py
|
||||
hm11.cxx HM11Sample.java hm11.js hm11.py
|
||||
hmc5883l.cxx Hmc5883lSample.java hmc5883l.js hmc5883l.py
|
||||
htu21d.cxx HTU21DSample.java htu21d.js htu21d.py
|
||||
itg3200.cxx Itg3200Sample.java itg3200.js itg3200.py
|
||||
jhd1313m1-lcd.cxx Jhd1313m1_lcdSample.java jhd1313m1-lcd.js jhd1313m1-lcd.py
|
||||
joystick12.cxx Joystick12Sample.java joystick12.js joystick12.py
|
||||
lcm1602-i2c.cxx Lcm1602_i2cSample.java lcm1602-i2c.js lcm1602-i2c.py
|
||||
ldt0028.cxx LDT0028Sample.java ldt0028.js ldt0028.py
|
||||
light.cxx LightSample.java light.js light.py
|
||||
lol.cxx LoLSample.java lol.js lol.py
|
||||
lsm303.cxx LSM303Sample.java lsm303.js lsm303.py
|
||||
m24lr64e.cxx M24LR64ESample.java m24lr64e.js m24lr64e.py
|
||||
max44000.cxx MAX44000Sample.java max44000.js max44000.py
|
||||
mic.cxx MicrophoneSample.java mic.js mic.py
|
||||
mma7455.cxx MMA7455Sample.java mma7455.js mma7455.py
|
||||
mma7660.cxx MMA7660Sample.java mma7660.js mma7660.py
|
||||
mpl3115a2.cxx MPL3115A2Sample.java mpl3115a2.js mpl3115a2.py
|
||||
mpr121.cxx MPR121Sample.java mpr121.js mpr121.py
|
||||
mpu9150.cxx MPU9150Sample.java mpu9150.js mpu9150.py
|
||||
mq2.cxx MQ2Sample.java mq2.js mq2.py
|
||||
mq303a.cxx MQ303ASample.java mq303a.js mq303a.py
|
||||
mq5.cxx MQ5Sample.java mq5.js mq5.py
|
||||
nrf24l01-receiver.cxx NRF24L01_receiverSample.java nrf24l01-receiver.js nrf24l01-receiver.py
|
||||
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java nrf24l01-transmitter.js nrf24l01-transmitter.py
|
||||
nunchuck.cxx NUNCHUCKSample.java nunchuck.js nunchuck.py
|
||||
otp538u.cxx OTP538USample.java otp538u.js otp538u.py
|
||||
ppd42ns.cxx PPD42NSSample.java ppd42ns.js ppd42ns.py
|
||||
pulsensor.cxx PulsensorSample.java pulsensor.js pulsensor.py
|
||||
relay.cxx RelaySample.java relay.js relay.py
|
||||
rfr359f.cxx RFR359FSample.java rfr359f.js rfr359f.py
|
||||
rotary.cxx RotarySample.java rotary.js rotary.py
|
||||
rotaryencoder.cxx RotaryEncoderSample.java rotaryencoder.js rotaryencoder.py
|
||||
rpr220.cxx RPR220Sample.java rpr220.js rpr220.py
|
||||
rpr220-intr.cxx RPR220_intrSample.java rpr220-intr.js rpr220-intr.py
|
||||
slide.cxx SlideSample.java slide.js slide.py
|
||||
speaker.cxx SpeakerSample.java speaker.js speaker.py
|
||||
ssd1308-oled.cxx SSD1308_oledSample.java ssd1308-oled.js ssd1308-oled.py
|
||||
ssd1327-oled.cxx SSD1327_oledSample.java ssd1327-oled.js ssd1327-oled.py
|
||||
st7735.cxx ST7735Sample.java st7735.js st7735.py
|
||||
stepmotor.cxx StepMotorSample.java stepmotor.js stepmotor.py
|
||||
tm1637.cxx TM1637Sample.java tm1637.js tm1637.py
|
||||
tp401.cxx TP401Sample.java tp401.js tp401.py
|
||||
tsl2561.cxx TSL2561Sample.java tsl2561.js tsl2561.py
|
||||
ttp223.cxx TTP223Sample.java ttp223.js ttp223.py
|
||||
uln200xa.cxx ULN200XASample.java uln200xa.js uln200xa.py
|
||||
vdiv.cxx VDivSample.java vdiv.js vdiv.py
|
||||
water.cxx WaterSample.java water.js water.py
|
||||
wt5001.cxx WT5001Sample.java wt5001.js wt5001.py
|
||||
yg1006.cxx YG1006Sample.java yg1006.js yg1006.py
|
||||
a110x.cxx A110X_Example.java a110x.js a110x.py
|
||||
a110x-intr.cxx A110X_intr_Example.java a110x-intr.js a110x-intr.py
|
||||
adc121c021.cxx ADC121C021_Example.java adc121c021.js adc121c021.py
|
||||
adxl345.cxx Adxl345_Example.java adxl345.js adxl345.py
|
||||
bh1749.cxx BH1749_Example.java bh1749.js bh1749.py
|
||||
bh1750.cxx BH1750_Example.java bh1750.js bh1750.py
|
||||
bh1792.cxx BH1792_Example.java bh1792.js bh1792.py
|
||||
biss0001.cxx BISS0001_Example.java biss0001.js biss0001.py
|
||||
bmpx8x.cxx BMPX8X_Example.java bmpx8x.js bmpx8x.py
|
||||
bno055.cxx BNO055_Example.java bno055.js bno055.py
|
||||
button.cxx Button_Example.java button.js button.py
|
||||
buzzer.cxx Buzzer_Example.java buzzer.js buzzer.py
|
||||
cjq4435.cxx CJQ4435_Example.java cjq4435.js cjq4435.py
|
||||
ds1307.cxx DS1307_Example.java ds1307.js ds1307.py
|
||||
enc03r.cxx ENC03R_Example.java enc03r.js enc03r.py
|
||||
servo-es08a.cxx ES08A_Example.java es08a.js es08a.py
|
||||
groveehr.cxx GroveEHR_Example.java groveehr.js groveehr.py
|
||||
my9221-groveledbar.cxx GroveLEDBar_Example.java groveledbar.js groveledbar.py
|
||||
grove-groveled.cxx GroveLED_Example.java groveled.js groveled.py
|
||||
grovelinefinder.cxx GroveLineFinder_Example.java grovelinefinder.js grovelinefinder.py
|
||||
grovemoisture.cxx GroveMoisture_Example.java grovemoisture.js grovemoisture.py
|
||||
grovescam.cxx GROVESCAM_Example.java grovescam.js grovescam.py
|
||||
grovewfs.cxx GroveWFS_Example.java grovewfs.js grovewfs.py
|
||||
guvas12d.cxx GUVAS12D_Example.java guvas12d.js guvas12d.py
|
||||
h3lis331dl.cxx H3LIS331DL_Example.java h3lis331dl.js h3lis331dl.py
|
||||
hcsr04.cxx HCSR04_Example.java hcsr04.js hcsr04.py
|
||||
hm11.cxx HM11_Example.java hm11.js hm11.py
|
||||
hmc5883l.cxx Hmc5883l_Example.java hmc5883l.js hmc5883l.py
|
||||
htu21d.cxx HTU21D_Example.java htu21d.js htu21d.py
|
||||
ims.cxx IMS_Example.java ims.js ims.py
|
||||
itg3200.cxx Itg3200_Example.java itg3200.js itg3200.py
|
||||
jhd1313m1-lcd.cxx Jhd1313m1_lcd_Example.java jhd1313m1-lcd.js jhd1313m1-lcd.py
|
||||
joystick12.cxx Joystick12_Example.java joystick12.js joystick12.py
|
||||
lcm1602-i2c.cxx Lcm1602_i2c_Example.java lcm1602-i2c.js lcm1602-i2c.py
|
||||
ldt0028.cxx LDT0028_Example.java ldt0028.js ldt0028.py
|
||||
light.cxx Light_Example.java light.js light.py
|
||||
lol.cxx LoL_Example.java lol.js lol.py
|
||||
lsm303dlh.cxx LSM303DLH_Example.java lsm303dlh.js lsm303dlh.py
|
||||
m24lr64e.cxx M24LR64E_Example.java m24lr64e.js m24lr64e.py
|
||||
max44000.cxx MAX44000_Example.java max44000.js max44000.py
|
||||
mic.cxx Microphone_Example.java mic.js mic.py
|
||||
mma7455.cxx MMA7455_Example.java mma7455.js mma7455.py
|
||||
mma7660.cxx MMA7660_Example.java mma7660.js mma7660.py
|
||||
mpl3115a2.cxx MPL3115A2_Example.java mpl3115a2.js mpl3115a2.py
|
||||
mpr121.cxx MPR121_Example.java mpr121.js mpr121.py
|
||||
mpu9150.cxx MPU9150_Example.java mpu9150.js mpu9150.py
|
||||
gas-mq2.cxx MQ2_Example.java mq2.js mq2.py
|
||||
mq303a.cxx MQ303A_Example.java mq303a.js mq303a.py
|
||||
gas-mq5.cxx MQ5_Example.java mq5.js mq5.py
|
||||
nrf24l01-receiver.cxx NRF24L01_receiver_Example.java nrf24l01-receiver.js nrf24l01-receiver.py
|
||||
nrf24l01-transmitter.cxx NRF24L01_transmitter_Example.java nrf24l01-transmitter.js nrf24l01-transmitter.py
|
||||
nunchuck.cxx NUNCHUCK_Example.java nunchuck.js nunchuck.py
|
||||
otp538u.cxx OTP538U_Example.java otp538u.js otp538u.py
|
||||
ppd42ns.cxx PPD42NS_Example.java ppd42ns.js ppd42ns.py
|
||||
pulsensor.cxx Pulsensor_Example.java pulsensor.js pulsensor.py
|
||||
relay.cxx Relay_Example.java relay.js relay.py
|
||||
rfr359f.cxx RFR359F_Example.java rfr359f.js rfr359f.py
|
||||
rotary.cxx Rotary_Example.java rotary.js rotary.py
|
||||
rotaryencoder.cxx RotaryEncoder_Example.java rotaryencoder.js rotaryencoder.py
|
||||
rpr220.cxx RPR220_Example.java rpr220.js rpr220.py
|
||||
rpr220-intr.cxx RPR220_intr_Example.java rpr220-intr.js rpr220-intr.py
|
||||
slide.cxx Slide_Example.java slide.js slide.py
|
||||
speaker.cxx Speaker_Example.java speaker.js speaker.py
|
||||
lcd-ssd1308-oled.cxx SSD1308_oled_Example.java ssd1308-oled.js ssd1308-oled.py
|
||||
lcd-ssd1327-oled.cxx SSD1327_oled_Example.java ssd1327-oled.js ssd1327-oled.py
|
||||
st7735.cxx ST7735_Example.java st7735.js st7735.py
|
||||
stepmotor.cxx StepMotor_Example.java stepmotor.js stepmotor.py
|
||||
tm1637.cxx TM1637_Example.java tm1637.js tm1637.py
|
||||
gas-tp401.cxx TP401_Example.java tp401.js tp401.py
|
||||
tsl2561.cxx TSL2561_Example.java tsl2561.js tsl2561.py
|
||||
ttp223.cxx TTP223_Example.java ttp223.js ttp223.py
|
||||
uln200xa.cxx ULN200XA_Example.java uln200xa.js uln200xa.py
|
||||
vdiv.cxx VDiv_Example.java vdiv.js vdiv.py
|
||||
water.cxx Water_Example.java water.js water.py
|
||||
wt5001.cxx WT5001_Example.java wt5001.js wt5001.py
|
||||
yg1006.cxx YG1006_Example.java yg1006.js yg1006.py
|
||||
sensortemplate.cxx SensorTemplate_Example.java sensortemplate.js sensortemplate.py
|
||||
p9813.cxx P9813_Example.java p9813.js p9813.py
|
||||
tcs37727.cxx tcs37727.py
|
||||
tmp006.cxx tmp006.py
|
||||
mma8x5x.cxx mma8x5x.py
|
||||
mag3110.cxx mag3110.py
|
||||
hdc1000.cxx hdc1000.py
|
||||
|
132
examples/CMakeLists.txt
Normal file
@ -0,0 +1,132 @@
|
||||
# Add an example executable target for the provided source file which depends
|
||||
# on a UPM library target. Strings after the first '-' are ignored.
|
||||
#
|
||||
# Usage:
|
||||
# add_example(source_file TARGETS <target0> <target1> <targetn> SUFFIX <target_suffix>)
|
||||
#
|
||||
# Parameters:
|
||||
# source_file - C/C++ source file. Filename must follow a specific format:
|
||||
# <library>-[additional].c(xx)
|
||||
# library: Name of UPM library required by example
|
||||
# -additional: Any other string used to identify the example
|
||||
# TARGETS - Additional dependency target/s required to BUILD/RUN this example. If TARGETS is
|
||||
# set, these are in addition to the dependency library provided by the example filename.
|
||||
# SUFFIX - Provide a means to differentiate between C/C++ dependency targets and
|
||||
# example names. Leave empty for CXX examples. Use '-c' for c targets.
|
||||
# SUFFIX Example file Dependency target Example binary
|
||||
# ------ ------------ ----------------- --------------
|
||||
# "-c" foo.c foo-c foo-example-c
|
||||
# foo.cxx foo foo-example-cxx
|
||||
#
|
||||
# Parent scope variable:
|
||||
# example_src_list - Any example target which is successfully created by
|
||||
# add_example will be removed from the parent scope variable
|
||||
# example_src_list (if it exists). This provides a means to handle
|
||||
# special case examples BEFORE handling all files in example_src_list.
|
||||
#
|
||||
# Examples:
|
||||
# # Creates sensorfoo-example-cxx, depends on target: sensorfoo
|
||||
# add_example(sensorfoo.cxx)
|
||||
#
|
||||
# # Creates sensorfoo-example-c, depends on target: sensorfoo-c
|
||||
# add_example(sensorfoo.c SUFFIX "-c")
|
||||
#
|
||||
# # Creates sensorfoo-bar-example-c, depends on target: sensorfoo-c
|
||||
# add_example(sensorfoo-bar.c SUFFIX "-c")
|
||||
#
|
||||
# # Creates testfoobar-cxx, depends on targets: blib, blah
|
||||
# add_example(testfoobar.c TARGETS blib blah)
|
||||
#
|
||||
# Examples:
|
||||
# a110x.c Requires libupmc-a110x
|
||||
# lcm1602-i2c.c Requires libupmc-lcm1602
|
||||
# bmp280-bme280.c Requires libupmc-bmp280
|
||||
# lcd-eboled.cxx Requires libupm-lcd
|
||||
#
|
||||
#
|
||||
function (add_example example_src)
|
||||
set (oneValueArgs SUFFIX)
|
||||
set (multiValueArgs TARGETS)
|
||||
# Parse function parameters
|
||||
cmake_parse_arguments(add_example "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Attempt to remove this example source file from a list of example
|
||||
# sources. This allows for handling special case examples.
|
||||
list (REMOVE_ITEM example_src_list ${example_src})
|
||||
set (example_src_list ${example_src_list} PARENT_SCOPE)
|
||||
|
||||
# Get the base filename from the full filename
|
||||
# For file /some/path/to/sensorfoo-bar.c, example_name = sensorfoo-bar
|
||||
get_filename_component(example_name ${example_src} NAME_WE)
|
||||
|
||||
# Parse out <library>
|
||||
# Example: sensorfoo-bar.c, library = sensorfoo
|
||||
string (REPLACE "-" ";" split_name ${example_name})
|
||||
list (GET split_name 0 library_name)
|
||||
|
||||
# Parse dependency target name from example_src filename (add on suffix)
|
||||
# For sensorfoo, lib_target_names = sensorfoo-c
|
||||
set (lib_target_names "${library_name}${add_example_SUFFIX}")
|
||||
|
||||
# If TARGETS is provided, add additional dependency targets
|
||||
if (add_example_TARGETS)
|
||||
list (APPEND lib_target_names "${add_example_TARGETS}")
|
||||
endif ()
|
||||
|
||||
# Unfortunately, c++ and c library targets are not named the same. If
|
||||
# no suffix is provided, assume C++ and add a suffix of -cxx to the
|
||||
# example target name
|
||||
# library example target
|
||||
# c: sensorfoo-c sensorfoo-bar-example-c
|
||||
# cxx: sensorfoo sensorfoo-bar-example-cxx
|
||||
if (NOT add_example_SUFFIX)
|
||||
set(add_example_SUFFIX "-cxx")
|
||||
endif ()
|
||||
|
||||
# Create the target name for this example: mylibrary-bar-example-c
|
||||
set (this_target_name "${example_name}-example${add_example_SUFFIX}")
|
||||
|
||||
# If a dependency target does NOT exist, print a warning and skip
|
||||
foreach(_dep_target ${lib_target_names})
|
||||
if (NOT TARGET ${_dep_target})
|
||||
message(STATUS "Example ${example_src} is missing a required CMake target (${_dep_target}), skipping...")
|
||||
return()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Create an executable target for this example
|
||||
add_executable (${this_target_name} ${example_src})
|
||||
|
||||
# Add each dependency to the library target
|
||||
foreach(_dep_target ${lib_target_names})
|
||||
target_link_libraries(${this_target_name} ${_dep_target} ${CMAKE_THREAD_LIBS_INIT} utilities-c)
|
||||
endforeach ()
|
||||
endfunction (add_example example_src)
|
||||
|
||||
# Add subdirectories if BUILDEXAMPLES=on
|
||||
if(BUILDEXAMPLES)
|
||||
# Add C examples
|
||||
add_subdirectory (c)
|
||||
|
||||
# Add C++ examples?
|
||||
if (BUILDCPP)
|
||||
add_subdirectory (c++)
|
||||
endif ()
|
||||
|
||||
# Add java examples?
|
||||
if(BUILDSWIGJAVA)
|
||||
add_subdirectory (java)
|
||||
endif()
|
||||
|
||||
# Add all examples as an install component (if building examples)
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/upm
|
||||
COMPONENT ${CMAKE_PROJECT_NAME}-examples
|
||||
FILES_MATCHING
|
||||
PATTERN "*.c"
|
||||
PATTERN "*.cxx"
|
||||
PATTERN "*.hpp"
|
||||
PATTERN "*.java"
|
||||
PATTERN "*.js"
|
||||
PATTERN "*.py")
|
||||
endif()
|
528
examples/c++/2jciebu01_ble.cxx
Normal file
@ -0,0 +1,528 @@
|
||||
/*
|
||||
* Author: Hiroyuki Mino <omronsupportupm@omron.com>
|
||||
* Copyright (c) 2019 Omron Electronic Components - Americas
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* omron sensor headers */
|
||||
#include "2jciebu01_ble.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
#define PREVIOUS_MENU_CHOICE 8
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
|
||||
|
||||
upm::OM2JCIEBU_BLE::om2jciebuData_t om2jciebuSensorData;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if(signum == SIGABRT) {
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
}
|
||||
if(signum == SIGINT) {
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getSensorData(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t parameterChoice = 0;
|
||||
int displayDelay = 0;
|
||||
uint16_t sensorParamData = 0;
|
||||
uint32_t pressureData = 0;
|
||||
bool seconds_validate = false;
|
||||
|
||||
p_om2jcieble->getDiscoveredServices(OM2JCIEBU_BLE::ALL_PARAM);
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_BLE::ALL_PARAM && parameterChoice <= OM2JCIEBU_BLE::ECO2) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) {
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 to 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_BLE::ALL_PARAM:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("**********************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::TEMP, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::HUMIDITY, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("***************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::PRESSURE, &pressureData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("********************************************************************\r\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::NOISE:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::NOISE, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("*************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::ETVOC:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ETVOC, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** eTVOC Attribute Values ***************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("*******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ECO2:
|
||||
if(p_om2jcieble->getSensorData(OM2JCIEBU_BLE::ECO2, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieble->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void getAdvSensorData(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t parameterChoice = 0, sensorParamData = 0;
|
||||
int displayDelay = 0;
|
||||
uint32_t pressureData = 0;
|
||||
bool seconds_validate = false;
|
||||
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_BLE::ALL_PARAM && parameterChoice <= OM2JCIEBU_BLE::ECO2) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) {
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 and 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_BLE::ALL_PARAM:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("*********************************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::TEMP, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("**************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::HUMIDITY, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("********************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("***************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::PRESSURE, &pressureData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("*********************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::NOISE:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::NOISE, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("*************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_BLE::ETVOC:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ETVOC, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("**************** Advertisement eTVOC Attribute Values ******************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("************************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ECO2:
|
||||
if(p_om2jcieble->getAdvSensorData(OM2JCIEBU_BLE::ECO2, &sensorParamData) == OM2JCIEBU_BLE::SUCCESS) {
|
||||
printf("************** Advertisement eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieble->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void configureLEDSetting(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
int led_choice = 0;
|
||||
unsigned short int red_scale = 0, green_scale = 0, blue_scale = 0;
|
||||
bool red_scale_validate = false, green_scale_validate = false, blue_scale_validate = false;
|
||||
printf("************** Sensor LED Configuration ***************\r\n");
|
||||
printf("Please select a operation for LED\r\n");
|
||||
printf("0) Normally OFF\r\n");
|
||||
printf("1) Normally ON\r\n");
|
||||
printf("2) Temperature value scales\r\n");
|
||||
printf("3) Relative humidity value scales\r\n");
|
||||
printf("4) Ambient light value scales\r\n");
|
||||
printf("5) Barometric pressure value scales\r\n");
|
||||
printf("6) Sound noise value scales\r\n");
|
||||
printf("7) eTVOC value scales\r\n");
|
||||
printf("8) SI vale scales\r\n");
|
||||
printf("9) PGA value scales\r\n");
|
||||
printf("**********************************************************\r\n");
|
||||
while(!(std::cin >> led_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
if(led_choice == OM2JCIEBU_BLE::NORMALLY_ON) {
|
||||
printf("Please select a LED color scale\r\n");
|
||||
printf("Please enter Red Color scale (scale range 0 to 255)\r\n");
|
||||
while(!red_scale_validate) {
|
||||
cin >> red_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (red_scale >= 0 && red_scale <= 255)) {
|
||||
red_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an red color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Green Color scale(scale range 0 to 255)\r\n");
|
||||
while(!green_scale_validate) {
|
||||
cin >> green_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (green_scale >= 0 && green_scale <= 255)) {
|
||||
green_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an green color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Blue Color scale(scale range 0 to 255)\r\n");
|
||||
while(!blue_scale_validate) {
|
||||
cin >> blue_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (blue_scale >= 0 && blue_scale <= 255)) {
|
||||
blue_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an blue color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NORMALLY_ON, red_scale, green_scale, blue_scale);
|
||||
} else {
|
||||
switch(led_choice) {
|
||||
case OM2JCIEBU_BLE::NORMALLY_OFF:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NORMALLY_OFF, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::TEMP_SACLE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::TEMP_SACLE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::HUMIDITY_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::HUMIDITY_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::AMBIENT_LIGHT_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::AMBIENT_LIGHT_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PRESSURE_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::PRESSURE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::NOISE_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::NOISE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ETVOC_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::ETVOC_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::SI_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::SI_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::PGA_SCALE:
|
||||
p_om2jcieble->configureSensorLedState(OM2JCIEBU_BLE::PGA_SCALE, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Wrong LED scale choice please try again" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void configureAdvInterval(OM2JCIEBU_BLE *p_om2jcieble)
|
||||
{
|
||||
if(p_om2jcieble == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t millisecond = 0;
|
||||
bool milisecond_validate = false;
|
||||
int advertising_mode = 0;
|
||||
printf("************** Sensor Advertise Configuration ***************\r\n");
|
||||
printf("Please enter time interval (in Milliseconds), for changing Advertise interval, between 100 to 10240 milliseconds\r\n");
|
||||
while(!milisecond_validate) {
|
||||
cin >> millisecond;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (millisecond >= 100 && millisecond <= 10240)) {
|
||||
milisecond_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an millisecond between 100 and 10240!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please select an Advertise mode with the selected Advertise interval \r\n");
|
||||
printf("1) Sensor data\r\n");
|
||||
printf("2) Calculation data\r\n");
|
||||
printf("3) Sensor data and Calculation data\r\n");
|
||||
printf("4) Sensor flag and Calculation flag\r\n");
|
||||
printf("5) Serial number\r\n");
|
||||
while(!(std::cin >> advertising_mode)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(advertising_mode) {
|
||||
case OM2JCIEBU_BLE::SENSOR_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_SENSOR_DATA:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::ACCELERATION_SENSOR_FLAG:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::ACCELERATION_SENSOR_FLAG);
|
||||
break;
|
||||
case OM2JCIEBU_BLE::SERIAL_NUMBER:
|
||||
p_om2jcieble->configureSensorAdvSetting(millisecond, OM2JCIEBU_BLE::SERIAL_NUMBER);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice\n";
|
||||
}
|
||||
printf("**************************************************************\r\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int operation_choice = 0;
|
||||
if(argc <= 1) {
|
||||
std::cout << "usage ./a.out xx:xx:xx:xx:xx:xx" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
signal(SIGABRT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
upm::OM2JCIEBU_BLE om2jciebu_ble(argv[1]);
|
||||
while(true) {
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
std::cout << "Please choose one option for Omron sensor operation" << std::endl;
|
||||
std::cout << "1) Display Advertisement Sensor attriutes" << std::endl;
|
||||
std::cout << "2) Display Sensor attriutes" << std::endl;
|
||||
std::cout << "3) Configure LED setting " << std::endl;
|
||||
std::cout << "4) Configure advertise setting" << std::endl;
|
||||
std::cout << "5) Exit" << std::endl;
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
while(!(std::cin >> operation_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
switch(operation_choice) {
|
||||
case 1:
|
||||
getAdvSensorData(&om2jciebu_ble);
|
||||
break;
|
||||
case 2:
|
||||
getSensorData(&om2jciebu_ble);
|
||||
break;
|
||||
case 3:
|
||||
configureLEDSetting(&om2jciebu_ble);
|
||||
break;
|
||||
case 4:
|
||||
configureAdvInterval(&om2jciebu_ble);
|
||||
break;
|
||||
case 5:
|
||||
std::cout << "Application Exited" << std::endl;
|
||||
om2jciebu_ble.removeBleDevice();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
403
examples/c++/2jciebu01_usb.cxx
Normal file
@ -0,0 +1,403 @@
|
||||
/*
|
||||
* Author: Hiroyuki Mino <omronsupportupm@omron.com>
|
||||
* Copyright (c) 2019 Omron Electronic Components - Americas
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* standard headers */
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* omron sensor headers */
|
||||
#include "2jciebu01_usb.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
volatile sig_atomic_t flag = 1;
|
||||
#define PREVIOUS_MENU_CHOICE 10
|
||||
|
||||
upm::OM2JCIEBU_UART::om2jciebuData_t om2jciebuSensorData;
|
||||
|
||||
void
|
||||
sig_handler(int signum)
|
||||
{
|
||||
if(signum == SIGABRT) { //check for Abort signal
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
}
|
||||
if(signum == SIGINT) { //check for Interrupt signal
|
||||
std::cout << "Exiting..." << std::endl;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getSensorData(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
uint16_t parameterChoice = 0;
|
||||
int displayDelay = 0;
|
||||
bool seconds_validate = false;
|
||||
uint16_t sensorParamData = 0;
|
||||
uint32_t pressureData = 0;
|
||||
|
||||
while(true) {
|
||||
printf("************************************************************\r\n");
|
||||
printf("Please select sensor attribute for display\r\n");
|
||||
printf("0) All parameter\r\n");
|
||||
printf("1) Temperature data\r\n");
|
||||
printf("2) Relative humidity data\r\n");
|
||||
printf("3) Ambient light data\r\n");
|
||||
printf("4) Barometric pressure data\r\n");
|
||||
printf("5) Sound noise data\r\n");
|
||||
printf("6) eTVOC data\r\n");
|
||||
printf("7) eCO2 data\r\n");
|
||||
printf("8) Discomfort index data\r\n");
|
||||
printf("9) Heat stroke data\r\n");
|
||||
printf("10) Return to main menu\r\n");
|
||||
printf("Note :: Press Ctrl+C for sensor attribute display menu\r\n");
|
||||
printf("************************************************************\r\n");
|
||||
while(!(std::cin >> parameterChoice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
if(parameterChoice >= OM2JCIEBU_UART::ALL_PARAM && parameterChoice <= OM2JCIEBU_UART::HEAT_STROKE) {
|
||||
flag = 1;
|
||||
printf("Please enter time interval (in Seconds), for display sensor data\r\n");
|
||||
while(!seconds_validate) { //validate user input values
|
||||
cin >> displayDelay;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (displayDelay >= 1 && displayDelay <= 10)) {
|
||||
seconds_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an second between 1 to 10!" << endl;
|
||||
}
|
||||
}
|
||||
while(flag) {
|
||||
switch(parameterChoice) {
|
||||
case OM2JCIEBU_UART::ALL_PARAM:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ALL_PARAM, &om2jciebuSensorData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Sensor Attribute Values ***************\r\n");
|
||||
printf("Sequence Number :: %d \r\n", om2jciebuSensorData.sequence_number);
|
||||
printf("Temperature :: %d degC\r\n", om2jciebuSensorData.temperature);
|
||||
printf("Relative humidity :: %d RH\r\n", om2jciebuSensorData.relative_humidity);
|
||||
printf("Ambient light :: %d lx\r\n", om2jciebuSensorData.ambient_light);
|
||||
printf("Barometric pressure :: %d hPa\r\n", om2jciebuSensorData.pressure);
|
||||
printf("Sound noise :: %d dB\r\n", om2jciebuSensorData.noise);
|
||||
printf("eTVOC :: %d ppb\r\n", om2jciebuSensorData.eTVOC);
|
||||
printf("eCO2 :: %d ppm\r\n", om2jciebuSensorData.eCO2);
|
||||
printf("Discomfort index :: %d \r\n", om2jciebuSensorData.discomfort_index);
|
||||
printf("Heat stroke :: %d degC\r\n", om2jciebuSensorData.heat_stroke);
|
||||
printf("**********************************************************\r\n");
|
||||
memset(&om2jciebuSensorData, 0, sizeof(om2jciebuSensorData));
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::TEMP:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::TEMP, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Temperature Attribute Values ***************\r\n");
|
||||
printf("Temperature :: %d degC\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::HUMIDITY:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::HUMIDITY, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Relative humidity Attribute Values ***************\r\n");
|
||||
printf("Relative humidity :: %d RH\r\n", sensorParamData);
|
||||
printf("******************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::AMBIENT_LIGHT:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::AMBIENT_LIGHT, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Ambient light Attribute Values ***************\r\n");
|
||||
printf("Ambient light :: %d lx\r\n", sensorParamData);
|
||||
printf("**************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::PRESSURE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::PRESSURE, &pressureData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Barometric pressure Attribute Values ***************\r\n");
|
||||
printf("Barometric pressure :: %d hPa\r\n", pressureData);
|
||||
printf("********************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_UART::NOISE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::NOISE, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** Sound noise Attribute Values ***************\r\n");
|
||||
printf("Sound noise :: %d dB\r\n", sensorParamData);
|
||||
printf("************************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case OM2JCIEBU_UART::ETVOC:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ETVOC, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eTVOC Attribute Values ***************\r\n");
|
||||
printf("eTVOC :: %d ppb\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::ECO2:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::ECO2, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("eCO2 :: %d ppm\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::DISCOMFORT_INDEX:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::DISCOMFORT_INDEX, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("Discomfort index :: %d \r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
case OM2JCIEBU_UART::HEAT_STROKE:
|
||||
if(p_om2jcieuart->getSensorData(OM2JCIEBU_UART::HEAT_STROKE, &sensorParamData) == OM2JCIEBU_UART::SUCCESS) {
|
||||
printf("************** eCO2 Attribute Values ***************\r\n");
|
||||
printf("Heat stroke :: %d degC\r\n\r\n", sensorParamData);
|
||||
printf("******************************************************\r\n");
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
printf("\r\n");
|
||||
p_om2jcieuart->delay(displayDelay);
|
||||
}
|
||||
} else if(parameterChoice == PREVIOUS_MENU_CHOICE) {
|
||||
break;
|
||||
} else {
|
||||
printf("Invalid choice\r\n");
|
||||
}
|
||||
seconds_validate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void configureLEDSetting(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
int led_choice = 0;
|
||||
bool red_scale_validate = false, green_scale_validate = false, blue_scale_validate = false;
|
||||
unsigned short int red_scale = 0, green_scale = 0, blue_scale = 0;
|
||||
printf("************** Sensor LED Configuration ***************\r\n");
|
||||
printf("Please select a operation for LED\r\n");
|
||||
printf("0) Normally OFF\r\n");
|
||||
printf("1) Normally ON\r\n");
|
||||
printf("2) Temperature value scales\r\n");
|
||||
printf("3) Relative humidity value scales\r\n");
|
||||
printf("4) Ambient light value scales\r\n");
|
||||
printf("5) Barometric pressure value scales\r\n");
|
||||
printf("6) Sound noise value scales\r\n");
|
||||
printf("7) eTVOC value scales\r\n");
|
||||
printf("8) SI vale scales\r\n");
|
||||
printf("9) PGA value scales\r\n");
|
||||
printf("**********************************************************\r\n");
|
||||
while(!(std::cin >> led_choice)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
|
||||
if(led_choice == OM2JCIEBU_UART::NORMALLY_ON) {
|
||||
printf("Please Select a LED color scale\r\n");
|
||||
printf("Please enter Red Color scale (scale range 0 to 255)\r\n");
|
||||
while(!red_scale_validate) {
|
||||
cin >> red_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (red_scale >= 0 && red_scale <= 255)) {
|
||||
red_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an red color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Green Color scale(scale range 0 to 255)\r\n");
|
||||
while(!green_scale_validate) {
|
||||
cin >> green_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (green_scale >= 0 && green_scale <= 255)) {
|
||||
green_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an green color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please enter Blue Color scale(scale range 0 to 255)\r\n");
|
||||
while(!blue_scale_validate) {
|
||||
cin >> blue_scale;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (blue_scale >= 0 && blue_scale <= 255)) {
|
||||
blue_scale_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an blue color scale between 0 and 255!" << endl;
|
||||
}
|
||||
}
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NORMALLY_ON, red_scale, green_scale, blue_scale);
|
||||
} else {
|
||||
switch(led_choice) {
|
||||
case OM2JCIEBU_UART::NORMALLY_OFF:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NORMALLY_OFF, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::TEMP_SACLE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::TEMP_SACLE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::HUMIDITY_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::HUMIDITY_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::AMBIENT_LIGHT_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::AMBIENT_LIGHT_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::PRESSURE_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::PRESSURE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::NOISE_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::NOISE_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ETVOC_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::ETVOC_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::SI_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::SI_SCALE, 0, 0, 0);
|
||||
break;
|
||||
case OM2JCIEBU_UART::PGA_SCALE:
|
||||
p_om2jcieuart->configureSensorLedState(OM2JCIEBU_UART::PGA_SCALE, 0, 0, 0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Wrong LED scale choice please try again" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void configureAdvInterval(OM2JCIEBU_UART *p_om2jcieuart)
|
||||
{
|
||||
if(p_om2jcieuart == NULL) {
|
||||
std::cout << "Null pointer received..." << std::endl;
|
||||
return;
|
||||
}
|
||||
bool millisecond_validate = false;
|
||||
uint16_t millisecond = 0;
|
||||
int advertising_mode = 0;
|
||||
printf("************** Sensor Advertise Configuration ***************\r\n");
|
||||
printf("Please enter time interval (in Milliseconds), for changing Advertise interval, between 100 to 10240 milliseconds\r\n");
|
||||
while(!millisecond_validate) {//validate millisecond
|
||||
cin >> millisecond;
|
||||
if(!cin.fail() && (cin.peek() == EOF || cin.peek() == '\n') && (millisecond >= 100 && millisecond <= 10240)) {
|
||||
millisecond_validate = true;
|
||||
} else {
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
cout << "Error, enter an milisecond between 100 and 10240!" << endl;
|
||||
}
|
||||
}
|
||||
printf("Please select an Advertise mode with the selected Advertise interval \r\n");
|
||||
printf("1) Sensor data\r\n");
|
||||
printf("2) Calculation data\r\n");
|
||||
printf("3) Sensor data and Calculation data\r\n");
|
||||
printf("4) Sensor flag and Calculation flag\r\n");
|
||||
printf("5) Serial number\r\n");
|
||||
while(!(std::cin >> advertising_mode)) {
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(advertising_mode) {
|
||||
case OM2JCIEBU_UART::SENSOR_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_SENSOR_DATA:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_SENSOR_DATA);
|
||||
break;
|
||||
case OM2JCIEBU_UART::ACCELERATION_SENSOR_FLAG:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::ACCELERATION_SENSOR_FLAG);
|
||||
break;
|
||||
case OM2JCIEBU_UART::SERIAL_NUMBER:
|
||||
p_om2jcieuart->configureSensorAdvSetting(millisecond, OM2JCIEBU_UART::SERIAL_NUMBER);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice\n";
|
||||
}
|
||||
printf("**************************************************************\r\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int operation_choice = 0;
|
||||
if(argc <= 1) {
|
||||
std::cout << "usage ./a.out /dev/ttyUSB*" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
signal(SIGABRT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
upm::OM2JCIEBU_UART om2jciebu_uart(argv[1], 115200);
|
||||
om2jciebu_uart.setMode(8, mraa::UART_PARITY_NONE, 1);
|
||||
om2jciebu_uart.setFlowControl(false, false);
|
||||
while(true) {
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
std::cout << "Please choose one option for Omron sensor operation" << std::endl;
|
||||
std::cout << "1) Display Sensor attriutes" << std::endl;
|
||||
std::cout << "2) Configure LED setting " << std::endl;
|
||||
std::cout << "3) Configure advertise setting" << std::endl;
|
||||
std::cout << "4) Exit" << std::endl;
|
||||
std::cout << "*************************************************************" << std::endl;
|
||||
while(!(std::cin >> operation_choice)) { //validate operation choice from user input
|
||||
std::cin.clear(); //clear bad input flag
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //discard input
|
||||
std::cout << "Invalid input; please re-enter.\n";
|
||||
}
|
||||
switch(operation_choice) {
|
||||
case 1:
|
||||
getSensorData(&om2jciebu_uart);
|
||||
break;
|
||||
case 2:
|
||||
configureLEDSetting(&om2jciebu_uart);
|
||||
break;
|
||||
case 3:
|
||||
configureAdvInterval(&om2jciebu_uart);
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Application Exited" << std::endl;
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
std::cout << "Invalid choice" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,366 +1,14 @@
|
||||
# Selectively disable certain warnings for the examples
|
||||
# nrf examples flag -Wtautological-compare
|
||||
set (CXX_DISABLED_WARNINGS -Wno-tautological-compare)
|
||||
# Create an list of all C++ source files in this directory
|
||||
file (GLOB example_src_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cxx")
|
||||
|
||||
# Extract module name from non-standard example name
|
||||
macro(get_module_name example_name module_name)
|
||||
string(LENGTH ${example_name} length)
|
||||
string(FIND ${example_name} "-" index)
|
||||
if (${index} GREATER 1)
|
||||
string(SUBSTRING ${example_name} 0 ${index} substr)
|
||||
set(${module_name} ${substr})
|
||||
elseif (${example_name} MATCHES "^grove")
|
||||
set (${module_name} "grove")
|
||||
elseif ((${example_name} MATCHES "^mq" AND ${length} EQUAL 3) OR ${example_name} STREQUAL "tp401")
|
||||
set (${module_name} "gas")
|
||||
else()
|
||||
set(${module_name} ${example_name})
|
||||
endif()
|
||||
endmacro()
|
||||
# - Handle special cases here --------------------------------------------------
|
||||
|
||||
# Set source file, include and linker settings for an example
|
||||
# If example cannot be built, example_bin is cleared
|
||||
macro(add_custom_example example_bin example_src example_module_list)
|
||||
set(found_all_modules TRUE)
|
||||
foreach (module ${example_module_list})
|
||||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
if (MODULE_LIST)
|
||||
list(FIND MODULE_LIST ${module} index)
|
||||
if (${index} EQUAL -1)
|
||||
set(found_all_modules FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
if (found_all_modules)
|
||||
add_executable (${example_bin} ${example_src})
|
||||
target_link_libraries (${example_bin} ${CMAKE_THREAD_LIBS_INIT})
|
||||
# Test temperature interface for 2 sensor libraries
|
||||
add_example(iTemperature_sample.cxx TARGETS interfaces lm35 abp)
|
||||
# Test light interface for 3 sensor libraries
|
||||
add_example(iLight_sample.cxx TARGETS interfaces apds9002 bh1750 max44009)
|
||||
|
||||
# Disable warnings from CXX_DISABLED_WARNINGS
|
||||
foreach(flag ${CXX_DISABLED_WARNINGS})
|
||||
compiler_flag_supported(CXX is_supported ${flag})
|
||||
if (is_supported)
|
||||
target_compile_options(${example_bin} PRIVATE "${flag}")
|
||||
endif(is_supported)
|
||||
endforeach(flag ${CXX_DISABLED_WARNINGS})
|
||||
|
||||
foreach (module ${example_module_list})
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module}")
|
||||
include_directories (${module_dir})
|
||||
if (${module} STREQUAL "lcd")
|
||||
set(module "i2clcd")
|
||||
endif()
|
||||
target_link_libraries (${example_bin} ${module})
|
||||
endforeach()
|
||||
else()
|
||||
message (WARNING "Ignored ${example_bin}")
|
||||
set (example_bin "")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Add specified example by name
|
||||
# Note special case for grove based examples
|
||||
macro(add_example example_name)
|
||||
set(example_src "${example_name}.cxx")
|
||||
set(example_bin "${example_name}-example-cxx")
|
||||
get_module_name(${example_name} module_name)
|
||||
set(module_dir "${PROJECT_SOURCE_DIR}/src/${module_name}")
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_src}"
|
||||
AND EXISTS ${module_dir}
|
||||
AND IS_DIRECTORY ${module_dir})
|
||||
add_custom_example(${example_bin} ${example_src} ${module_name})
|
||||
if ((NOT ${example_bin} STREQUAL "") AND (${module_name} STREQUAL "grove"))
|
||||
set(grove_module_path "${PROJECT_SOURCE_DIR}/src/${example_name}")
|
||||
if (EXISTS ${grove_module_path})
|
||||
include_directories(${grove_module_path})
|
||||
target_link_libraries (${example_bin} ${example_name})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message (WARNING "Ignored ${example_bin}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
|
||||
|
||||
# UPM c include directories
|
||||
include_directories (${PROJECT_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/src/utilities)
|
||||
|
||||
# Set the mraa include and link directories prior to adding examples
|
||||
include_directories (${MRAA_INCLUDE_DIRS})
|
||||
link_directories (${MRAA_LIBDIR})
|
||||
|
||||
# If your sample source file matches the name of the module it tests, add it here
|
||||
# Exceptions are as follows:
|
||||
# string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)
|
||||
# mq? will use module gas
|
||||
# grove* will use module grove
|
||||
add_example (hmc5883l)
|
||||
add_example (led)
|
||||
add_example (groveled)
|
||||
add_example (relay)
|
||||
add_example (groverelay)
|
||||
add_example (light)
|
||||
add_example (grovelight)
|
||||
add_example (temperature)
|
||||
add_example (grovetemp)
|
||||
add_example (button)
|
||||
add_example (grovebutton)
|
||||
add_example (rotary)
|
||||
add_example (groverotary)
|
||||
add_example (slide)
|
||||
add_example (groveslide)
|
||||
add_example (buzzer)
|
||||
add_example (nrf24l01-transmitter)
|
||||
add_example (nrf24l01-receiver)
|
||||
add_example (nrf24l01-broadcast)
|
||||
add_example (hcsr04)
|
||||
add_example (max44000)
|
||||
add_example (mma7455)
|
||||
add_example (st7735)
|
||||
add_example (max31855)
|
||||
add_example (bmpx8x)
|
||||
add_example (stepmotor)
|
||||
add_example (pulsensor)
|
||||
add_example (mic)
|
||||
add_example (mpu9150)
|
||||
add_example (maxds3231m)
|
||||
add_example (max31723)
|
||||
add_example (max5487)
|
||||
add_example (nrf8001-broadcast)
|
||||
add_example (nrf8001-helloworld)
|
||||
add_example (lpd8806)
|
||||
add_example (mlx90614)
|
||||
add_example (ecs1030)
|
||||
add_example (mq2)
|
||||
add_example (mq3)
|
||||
add_example (mq4)
|
||||
add_example (mq5)
|
||||
add_example (mq6)
|
||||
add_example (mq7)
|
||||
add_example (mq8)
|
||||
add_example (mq9)
|
||||
add_example (tp401)
|
||||
add_example (tcs3414cs)
|
||||
add_example (th02)
|
||||
add_example (ttp223)
|
||||
add_example (lsm303)
|
||||
add_example (joystick12)
|
||||
add_example (lol)
|
||||
add_example (tsl2561)
|
||||
add_example (htu21d)
|
||||
add_example (mpl3115a2)
|
||||
add_example (ldt0028)
|
||||
add_example (am2315)
|
||||
add_example (itg3200)
|
||||
add_example (enc03r)
|
||||
add_example (adc121c021)
|
||||
add_example (ds1307)
|
||||
add_example (a110x)
|
||||
add_example (gp2y0a)
|
||||
add_example (moisture)
|
||||
add_example (grovemoisture)
|
||||
add_example (ehr)
|
||||
add_example (groveehr)
|
||||
add_example (ta12200)
|
||||
add_example (grovelinefinder)
|
||||
add_example (linefinder)
|
||||
add_example (vdiv)
|
||||
add_example (grovevdiv)
|
||||
add_example (water)
|
||||
add_example (grovewater)
|
||||
add_example (guvas12d)
|
||||
add_example (mpr121)
|
||||
add_example (yg1006)
|
||||
add_example (wt5001)
|
||||
add_example (ppd42ns)
|
||||
add_example (mq303a)
|
||||
add_example (speaker)
|
||||
add_example (grovespeaker)
|
||||
add_example (rfr359f)
|
||||
add_example (biss0001)
|
||||
add_example (rotaryencoder)
|
||||
add_example (adxl345)
|
||||
add_example (rpr220)
|
||||
add_example (rpr220-intr)
|
||||
add_example (mma7660)
|
||||
add_example (cjq4435)
|
||||
add_example (adxl335)
|
||||
add_example (hmtrp)
|
||||
add_example (nunchuck)
|
||||
add_example (otp538u)
|
||||
add_example (collision)
|
||||
add_example (grovecollision)
|
||||
add_example (electromagnet)
|
||||
add_example (groveelectromagnet)
|
||||
add_example (emg)
|
||||
add_example (groveemg)
|
||||
add_example (o2)
|
||||
add_example (groveo2)
|
||||
add_example (gsr)
|
||||
add_example (grovegsr)
|
||||
add_example (ina132)
|
||||
add_example (l298)
|
||||
add_example (l298-stepper)
|
||||
add_example (at42qt1070)
|
||||
add_example (grovemd)
|
||||
add_example (md)
|
||||
add_example (grovemd-stepper)
|
||||
add_example (md-stepper)
|
||||
add_example (pca9685)
|
||||
add_example (eldriver)
|
||||
add_example (groveeldriver)
|
||||
add_example (adafruitss)
|
||||
add_example (adafruitms1438)
|
||||
add_example (adafruitms1438-stepper)
|
||||
add_example (hx711)
|
||||
add_example (flex)
|
||||
add_example (a110x-intr)
|
||||
add_example (mhz16)
|
||||
add_example (apds9002)
|
||||
add_example (waterlevel)
|
||||
add_example (tm1637)
|
||||
add_example (zfm20)
|
||||
add_example (zfm20-register)
|
||||
add_example (uln200xa)
|
||||
add_example (grovewfs)
|
||||
add_example (wfs)
|
||||
add_example (isd1820)
|
||||
add_example (sx6119)
|
||||
add_example (si114x)
|
||||
add_example (maxsonarez)
|
||||
add_example (hm11)
|
||||
add_example (ht9170)
|
||||
add_example (h3lis331dl)
|
||||
add_example (ad8232)
|
||||
add_example (grovescam)
|
||||
add_example (scam)
|
||||
add_example (m24lr64e)
|
||||
add_example (rgbringcoder)
|
||||
add_example (hp20x)
|
||||
add_example (pn532)
|
||||
add_example (pn532-writeurl)
|
||||
add_example (lsm9ds0)
|
||||
add_example (loudness)
|
||||
add_example (mg811)
|
||||
add_example (wheelencoder)
|
||||
add_example (sm130)
|
||||
add_example (gprs)
|
||||
add_example (grovegprs)
|
||||
add_example (lm35)
|
||||
add_example (micsv89)
|
||||
add_example (xbee)
|
||||
add_example (urm37)
|
||||
add_example (urm37-uart)
|
||||
add_example (adxrs610)
|
||||
add_example (bma220)
|
||||
add_example (dfrph)
|
||||
add_example (mcp9808)
|
||||
add_example (groveultrasonic)
|
||||
add_example (ultrasonic)
|
||||
add_example (sx1276-lora)
|
||||
add_example (sx1276-fsk)
|
||||
add_example (ili9341)
|
||||
add_example (nlgpio16)
|
||||
add_example (ads1x15)
|
||||
if (MODBUS_FOUND)
|
||||
include_directories(${MODBUS_INCLUDE_DIRS})
|
||||
add_example (t3311)
|
||||
add_example (hwxpxx)
|
||||
add_example (h803x)
|
||||
endif()
|
||||
add_example (hdxxvxta)
|
||||
add_example (rhusb)
|
||||
add_example (apds9930)
|
||||
add_example (kxcjk1013)
|
||||
add_example (ssd1351)
|
||||
add_example (ds1808lc)
|
||||
add_example (hlg150h)
|
||||
add_example (lp8860)
|
||||
add_example (max44009)
|
||||
add_example (si1132)
|
||||
add_example (si7005)
|
||||
add_example (t6713)
|
||||
add_example (cwlsxxa)
|
||||
add_example (teams)
|
||||
add_example (apa102)
|
||||
add_example (tex00)
|
||||
add_example (bmi160)
|
||||
add_example (smartdrive)
|
||||
if (HAVE_FIRMATA)
|
||||
add_example (curieimu)
|
||||
endif ()
|
||||
if (BACNET_FOUND)
|
||||
include_directories(${BACNET_INCLUDE_DIRS})
|
||||
# we need access to bacnetmstp headers too
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
|
||||
add_example (e50hx)
|
||||
add_example (t8100)
|
||||
add_example (tb7300)
|
||||
endif()
|
||||
if (JPEG_FOUND)
|
||||
add_example (vcap)
|
||||
endif (JPEG_FOUND)
|
||||
add_example (ds2413)
|
||||
add_example (ds18b20)
|
||||
add_example (bmp280)
|
||||
add_example (bno055)
|
||||
add_example (l3gd20)
|
||||
add_example (l3gd20-i2c)
|
||||
add_example (bmx055)
|
||||
add_example (ms5611)
|
||||
add_example (nmea_gps)
|
||||
add_example (mma7361)
|
||||
add_example (bh1750)
|
||||
add_example (hka5)
|
||||
add_example (dfrorp)
|
||||
add_example (dfrec)
|
||||
add_example (sht1x)
|
||||
add_example (ms5803)
|
||||
|
||||
# These are special cases where you specify example binary, source file and module(s)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src)
|
||||
add_custom_example (groveled-multi-example-cxx groveled-multi.cxx grove)
|
||||
add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcd)
|
||||
add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcd)
|
||||
add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx lcd)
|
||||
add_custom_example (es08a-example-cxx es08a.cxx servo)
|
||||
add_custom_example (ssd1306-oled-example-cxx ssd1306-oled.cxx lcd)
|
||||
add_custom_example (ssd1308-oled-example-cxx ssd1308-oled.cxx lcd)
|
||||
add_custom_example (ssd1327-oled-example-cxx ssd1327-oled.cxx lcd)
|
||||
add_custom_example (sainsmartks-example-cxx sainsmartks.cxx lcd)
|
||||
add_custom_example (eboled-example-cxx eboled.cxx lcd)
|
||||
add_custom_example (mpu60x0-example-cxx mpu60x0.cxx mpu9150)
|
||||
add_custom_example (ak8975-example-cxx ak8975.cxx mpu9150)
|
||||
add_custom_example (mpu9250-example-cxx mpu9250.cxx mpu9150)
|
||||
add_custom_example (groveledbar-example-cxx groveledbar.cxx my9221)
|
||||
add_custom_example (grovecircularled-example-cxx grovecircularled.cxx my9221)
|
||||
add_custom_example (temperature-sensor-example-cxx temperature-sensor.cxx "si7005;bmpx8x;bmp280")
|
||||
add_custom_example (humidity-sensor-example-cxx humidity-sensor.cxx "si7005;bmp280")
|
||||
add_custom_example (pressure-sensor-example-cxx pressure-sensor.cxx "bmpx8x;bmp280")
|
||||
add_custom_example (co2-sensor-example-cxx co2-sensor.cxx "t6713")
|
||||
add_custom_example (adc-example-cxx adc-sensor.cxx "ads1x15")
|
||||
add_custom_example (light-sensor-example-cxx light-sensor.cxx "si1132;max44009")
|
||||
add_custom_example (light-controller-example-cxx light-controller.cxx "lp8860;ds1808lc;hlg150h")
|
||||
add_custom_example (bme280-example-cxx bme280.cxx bmp280)
|
||||
add_custom_example (bma250e-example-cxx bma250e.cxx bmx055)
|
||||
add_custom_example (bmg160-example-cxx bmg160.cxx bmx055)
|
||||
add_custom_example (bmm150-example-cxx bmm150.cxx bmx055)
|
||||
add_custom_example (bmc150-example-cxx bmc150.cxx bmx055)
|
||||
add_custom_example (bmi055-example-cxx bmi055.cxx bmx055)
|
||||
if (OPENZWAVE_FOUND)
|
||||
include_directories(${OPENZWAVE_INCLUDE_DIRS})
|
||||
|
||||
add_custom_example (ozwdump-example-cxx ozwdump.cxx ozw)
|
||||
add_custom_example (aeotecss6-example-cxx aeotecss6.cxx ozw)
|
||||
add_custom_example (aeotecsdg2-example-cxx aeotecsdg2.cxx ozw)
|
||||
add_custom_example (aeotecdw2e-example-cxx aeotecdw2e.cxx ozw)
|
||||
add_custom_example (aeotecdsb09104-example-cxx aeotecdsb09104.cxx ozw)
|
||||
add_custom_example (tzemt400-example-cxx tzemt400.cxx ozw)
|
||||
endif()
|
||||
add_custom_example (nmea_gps_i2c_example-cxx nmea_gps_i2c.cxx nmea_gps)
|
||||
# - Create an executable for all other src files in this directory -------------
|
||||
foreach (_example_src ${example_src_list})
|
||||
add_example(${_example_src})
|
||||
endforeach ()
|
||||
|
@ -2,75 +2,65 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "a110x.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
// Our pulse counter
|
||||
volatile unsigned int counter = 0;
|
||||
|
||||
// Our interrupt handler
|
||||
void hallISR(void *arg)
|
||||
void
|
||||
hallISR(void* arg)
|
||||
{
|
||||
counter++;
|
||||
counter++;
|
||||
}
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm::A110X* hall = new upm::A110X(2);
|
||||
|
||||
// This example uses a user-supplied interrupt handler to count
|
||||
// pulses that occur when a magnetic field of the correct polarity
|
||||
// is detected. This could be used to measure the rotations per
|
||||
// minute (RPM) of a rotor for example.
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm::A110X hall(2);
|
||||
|
||||
hall->installISR(hallISR, NULL);
|
||||
// This example uses a user-supplied interrupt handler to count
|
||||
// pulses that occur when a magnetic field of the correct polarity
|
||||
// is detected. This could be used to measure the rotations per
|
||||
// minute (RPM) of a rotor for example.
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "Pulses detected: " << counter << endl;
|
||||
hall.installISR(hallISR, NULL);
|
||||
|
||||
sleep(1);
|
||||
while (shouldRun) {
|
||||
cout << "Pulses detected: " << counter << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete hall;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,66 +2,53 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "a110x.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm::A110X* hall = new upm::A110X(2);
|
||||
|
||||
// check every second for the presence of a magnetic field (south
|
||||
// polarity)
|
||||
while (shouldRun)
|
||||
{
|
||||
bool val = hall->magnetDetected();
|
||||
if (val)
|
||||
cout << "Magnet (south polarity) detected." << endl;
|
||||
else
|
||||
cout << "No magnet detected." << endl;
|
||||
//! [Interesting]
|
||||
// Instantiate an A110X sensor on digital pin D2
|
||||
upm::A110X hall(2);
|
||||
|
||||
sleep(1);
|
||||
// check every second for the presence of a magnetic field (south
|
||||
// polarity)
|
||||
while (shouldRun) {
|
||||
bool val = hall.magnetDetected();
|
||||
if (val)
|
||||
cout << "Magnet (south polarity) detected." << endl;
|
||||
else
|
||||
cout << "No magnet detected." << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete hall;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
49
examples/c++/abp.cxx
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Author: Abhishek Malik <abhishek.malik@intel.com>
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "abp.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate an ABP sensor on i2c bus 0
|
||||
upm::ABP abp(0, ABP_DEFAULT_ADDRESS);
|
||||
while (shouldRun) {
|
||||
abp.update();
|
||||
cout << "Retrieved pressure: " << abp.getPressure() << endl;
|
||||
cout << "Retrieved Temperature: " << abp.getTemperature() << endl;
|
||||
|
||||
upm_delay(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -2,64 +2,52 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "ad8232.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Ad8232 sensor on digital pins 10 (LO+), 11 (LO-)
|
||||
// and an analog pin, 0 (OUTPUT)
|
||||
upm::AD8232 *ad8232 = new upm::AD8232(10, 11, 0);
|
||||
|
||||
// Output the raw numbers from the ADC, for plotting elsewhere.
|
||||
// A return of 0 indicates a Lead Off (LO) condition.
|
||||
// In theory, this data could be fed to software like Processing
|
||||
// (https://www.processing.org/) to plot the data just like an
|
||||
// EKG you would see in a hospital.
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << ad8232->value() << endl;
|
||||
usleep(1000);
|
||||
//! [Interesting]
|
||||
// Instantiate a Ad8232 sensor on digital pins 10 (LO+), 11 (LO-)
|
||||
// and an analog pin, 0 (OUTPUT)
|
||||
upm::AD8232 ad8232(10, 11, 0);
|
||||
|
||||
// Output the raw numbers from the ADC, for plotting elsewhere.
|
||||
// A return of 0 indicates a Lead Off (LO) condition.
|
||||
// In theory, this data could be fed to software like Processing
|
||||
// (https://www.processing.org/) to plot the data just like an
|
||||
// EKG you would see in a hospital.
|
||||
while (shouldRun) {
|
||||
cout << ad8232.value() << endl;
|
||||
upm_delay_us(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete ad8232;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,81 +2,63 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "adafruitms1438.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an Adafruit MS 1438 on I2C bus 0
|
||||
//! [Interesting]
|
||||
// Instantiate an Adafruit MS 1438 on I2C bus 0
|
||||
|
||||
upm::AdafruitMS1438 *ms =
|
||||
new upm::AdafruitMS1438(ADAFRUITMS1438_I2C_BUS,
|
||||
ADAFRUITMS1438_DEFAULT_I2C_ADDR);
|
||||
upm::AdafruitMS1438 ms(ADAFRUITMS1438_I2C_BUS, ADAFRUITMS1438_DEFAULT_I2C_ADDR);
|
||||
|
||||
// Setup for use with a stepper motor connected to the M1 & M2 ports
|
||||
// Setup for use with a stepper motor connected to the M1 & M2 ports
|
||||
|
||||
// set a PWM period of 50Hz
|
||||
// set a PWM period of 50Hz
|
||||
|
||||
// disable first, to be safe
|
||||
ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
// disable first, to be safe
|
||||
ms.disableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
|
||||
// configure for a NEMA-17, 200 steps per revolution
|
||||
ms->stepConfig(AdafruitMS1438::STEPMOTOR_M12, 200);
|
||||
// configure for a NEMA-17, 200 steps per revolution
|
||||
ms.stepConfig(AdafruitMS1438::STEPMOTOR_M12, 200);
|
||||
|
||||
// set speed at 10 RPM's
|
||||
ms->setStepperSpeed(AdafruitMS1438::STEPMOTOR_M12, 10);
|
||||
ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12,
|
||||
AdafruitMS1438::DIR_CW);
|
||||
// set speed at 10 RPM's
|
||||
ms.setStepperSpeed(AdafruitMS1438::STEPMOTOR_M12, 10);
|
||||
ms.setStepperDirection(AdafruitMS1438::STEPMOTOR_M12, AdafruitMS1438::DIR_CW);
|
||||
|
||||
// enable
|
||||
cout << "Enabling..." << endl;
|
||||
ms->enableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
// enable
|
||||
cout << "Enabling..." << endl;
|
||||
ms.enableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
|
||||
cout << "Rotating 1 full revolution at 10 RPM speed." << endl;
|
||||
ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 200);
|
||||
cout << "Rotating 1 full revolution at 10 RPM speed." << endl;
|
||||
ms.stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 200);
|
||||
|
||||
cout << "Sleeping for 2 seconds..." << endl;
|
||||
sleep(2);
|
||||
cout << "Rotating 1/2 revolution in opposite direction at 10 RPM speed."
|
||||
<< endl;
|
||||
cout << "Sleeping for 2 seconds..." << endl;
|
||||
upm_delay(2);
|
||||
cout << "Rotating 1/2 revolution in opposite direction at 10 RPM speed." << endl;
|
||||
|
||||
ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12,
|
||||
AdafruitMS1438::DIR_CCW);
|
||||
ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 100);
|
||||
ms.setStepperDirection(AdafruitMS1438::STEPMOTOR_M12, AdafruitMS1438::DIR_CCW);
|
||||
ms.stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 100);
|
||||
|
||||
cout << "Disabling..." << endl;
|
||||
ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
cout << "Disabling..." << endl;
|
||||
ms.disableStepper(AdafruitMS1438::STEPMOTOR_M12);
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
delete ms;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,74 +2,58 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "adafruitms1438.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
// Instantiate an Adafruit MS 1438 on I2C bus 0
|
||||
//! [Interesting]
|
||||
// Instantiate an Adafruit MS 1438 on I2C bus 0
|
||||
|
||||
upm::AdafruitMS1438 *ms =
|
||||
new upm::AdafruitMS1438(ADAFRUITMS1438_I2C_BUS,
|
||||
ADAFRUITMS1438_DEFAULT_I2C_ADDR);
|
||||
upm::AdafruitMS1438 ms(ADAFRUITMS1438_I2C_BUS, ADAFRUITMS1438_DEFAULT_I2C_ADDR);
|
||||
|
||||
// Setup for use with a DC motor connected to the M3 port
|
||||
// Setup for use with a DC motor connected to the M3 port
|
||||
|
||||
// set a PWM period of 50Hz
|
||||
ms->setPWMPeriod(50);
|
||||
// set a PWM period of 50Hz
|
||||
ms.setPWMPeriod(50);
|
||||
|
||||
// disable first, to be safe
|
||||
ms->disableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
// disable first, to be safe
|
||||
ms.disableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
|
||||
// set speed at 50%
|
||||
ms->setMotorSpeed(AdafruitMS1438::MOTOR_M3, 50);
|
||||
ms->setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CW);
|
||||
// set speed at 50%
|
||||
ms.setMotorSpeed(AdafruitMS1438::MOTOR_M3, 50);
|
||||
ms.setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CW);
|
||||
|
||||
cout << "Spin M3 at half speed for 3 seconds, then reverse for 3 seconds."
|
||||
<< endl;
|
||||
cout << "Spin M3 at half speed for 3 seconds, then reverse for 3 seconds." << endl;
|
||||
|
||||
ms->enableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
ms.enableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
|
||||
sleep(3);
|
||||
upm_delay(3);
|
||||
|
||||
cout << "Reversing M3" << endl;
|
||||
ms->setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CCW);
|
||||
cout << "Reversing M3" << endl;
|
||||
ms.setMotorDirection(AdafruitMS1438::MOTOR_M3, AdafruitMS1438::DIR_CCW);
|
||||
|
||||
sleep(3);
|
||||
upm_delay(3);
|
||||
|
||||
cout << "Stopping M3" << endl;
|
||||
ms->disableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
cout << "Stopping M3" << endl;
|
||||
ms.disableMotor(AdafruitMS1438::MOTOR_M3);
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
delete ms;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,76 +2,64 @@
|
||||
* Author: Stan Gifford <stan@gifford.id.au>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Description
|
||||
* Demo program for Adafruit 16 channel servo shield/controller
|
||||
* Physical setup for tests is a single servo attached to one channel.
|
||||
* Note - when 3 or more GWS servos attached results unpredictable.
|
||||
* Adafruit do recommend a Cap be installed on the board which should alleviate the issue.
|
||||
* Adafruit do recommend a Cap be installed on the board which should alleviate
|
||||
* the issue.
|
||||
* I (and Adafruit) are unable to give any Capacitor sizing data.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "adafruitss.hpp"
|
||||
#include <unistd.h>
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int
|
||||
main()
|
||||
{
|
||||
int n;
|
||||
|
||||
int n;
|
||||
//! [Interesting]
|
||||
upm::adafruitss servos(6, 0x40);
|
||||
|
||||
//! [Interesting]
|
||||
upm::adafruitss* servos = new upm::adafruitss(6,0x40);
|
||||
for (;;) {
|
||||
cout << "Setting all to 0" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos.servo(n, 1, 0); // GWS Mini Servo = Type 1.
|
||||
upm_delay_us(1000000); // Wait 1 second
|
||||
|
||||
for (;;)
|
||||
{
|
||||
cout << "Setting all to 0" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos->servo(n, 1, 0); // GWS Mini Servo = Type 1.
|
||||
usleep(1000000); // Wait 1 second
|
||||
cout << "Setting all to 45" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos.servo(n, 1, 45);
|
||||
upm_delay_us(1000000); // Wait 1 second
|
||||
|
||||
cout << "Setting all to 45" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos->servo(n, 1, 45);
|
||||
usleep(1000000); // Wait 1 second
|
||||
cout << "Setting all to 90" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos.servo(n, 1, 90);
|
||||
upm_delay_us(1000000); // Wait 1 second
|
||||
|
||||
cout << "Setting all to 90" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos->servo(n, 1, 90);
|
||||
usleep(1000000); // Wait 1 second
|
||||
cout << "Setting all to 135" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos.servo(n, 1, 135);
|
||||
upm_delay_us(1000000); // Wait 1 second
|
||||
|
||||
cout << "Setting all to 135" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos->servo(n, 1, 135);
|
||||
usleep(1000000); // Wait 1 second
|
||||
|
||||
cout << "Setting all to 180" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos->servo(n, 1, 160);
|
||||
usleep(2000000); // Wait 1 second
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
cout << "Setting all to 180" << endl;
|
||||
for (n = 0; n < 16; n++)
|
||||
servos.servo(n, 1, 160);
|
||||
upm_delay_us(2000000); // Wait 1 second
|
||||
}
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "ads1015.hpp"
|
||||
#include "mraa/gpio.hpp"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
#define EDISON_GPIO_SI7005_CS 20
|
||||
|
||||
|
||||
//! [Interesting]
|
||||
// Simple example of using IADC to determine
|
||||
// which sensor is present and return its name.
|
||||
// IADC is then used to get readings from sensor
|
||||
|
||||
|
||||
upm::IADC* getADC()
|
||||
{
|
||||
upm::IADC* adc = NULL;
|
||||
try {
|
||||
adc = new upm::ADS1015(EDISON_I2C_BUS);
|
||||
mraa::Gpio gpio(EDISON_GPIO_SI7005_CS);
|
||||
gpio.dir(mraa::DIR_OUT_HIGH);
|
||||
return adc;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "ADS1015: " << e.what() << std::endl;
|
||||
}
|
||||
return adc;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
upm::IADC* adc = getADC();
|
||||
if (adc == NULL) {
|
||||
std::cout << "ADC not detected" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "ADC " << adc->getModuleName() << " detected. " ;
|
||||
std::cout << adc->getNumInputs() << " inputs available" << std::endl;
|
||||
while (true) {
|
||||
for (unsigned int i=0; i<adc->getNumInputs(); ++i) {
|
||||
std::cout << "Input " << i;
|
||||
try {
|
||||
float voltage = adc->getVoltage(i);
|
||||
std::cout << ": Voltage = " << voltage << "V" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
delete adc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|
@ -2,65 +2,51 @@
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "adc121c021.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int shouldRun = true;
|
||||
|
||||
void sig_handler(int signo)
|
||||
void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate an ADC121C021 on I2C bus 0
|
||||
//! [Interesting]
|
||||
// Instantiate an ADC121C021 on I2C bus 0
|
||||
|
||||
upm::ADC121C021 *adc = new upm::ADC121C021(ADC121C021_I2C_BUS,
|
||||
ADC121C021_DEFAULT_I2C_ADDR);
|
||||
upm::ADC121C021 adc(ADC121C021_I2C_BUS, ADC121C021_DEFAULT_I2C_ADDR);
|
||||
|
||||
// An analog sensor, such as a Grove light sensor,
|
||||
// must be attached to the adc
|
||||
// Prints the value and corresponding voltage every 50 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
uint16_t val = adc->value();
|
||||
cout << "ADC value: " << val << " Volts = "
|
||||
<< adc->valueToVolts(val) << endl;
|
||||
usleep(50000);
|
||||
// An analog sensor, such as a Grove light sensor,
|
||||
// must be attached to the adc
|
||||
// Prints the value and corresponding voltage every 50 milliseconds
|
||||
while (shouldRun) {
|
||||
uint16_t val = adc.value();
|
||||
cout << "ADC value: " << val << " Volts = " << adc.valueToVolts(val) << endl;
|
||||
upm_delay_us(50000);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete adc;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,9 +12,12 @@
|
||||
// This example code runs on an Intel Edison and uses mraa to acquire data
|
||||
// from an ADIS16448. This data is then scaled and printed onto the terminal.
|
||||
//
|
||||
// This software has been tested to connect to an ADIS16448 through a level shifter
|
||||
// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through
|
||||
// the level shifter and the ADIS16448 is also being powered by the Intel Edison.
|
||||
// This software has been tested to connect to an ADIS16448 through a level
|
||||
// shifter
|
||||
// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired
|
||||
// through
|
||||
// the level shifter and the ADIS16448 is also being powered by the Intel
|
||||
// Edison.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@ -36,31 +39,29 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
#include "adis16448.h"
|
||||
#include "adis16448.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
//! [Interesting]
|
||||
upm::ADIS16448* imu = new upm::ADIS16448(0,3); //upm::ADIS16448(SPI,RST)
|
||||
while (true) {
|
||||
//! [Interesting]
|
||||
upm::ADIS16448 imu(0, 3); // upm::ADIS16448(SPI,RST)
|
||||
|
||||
//Read the specified register, scale it, and display it on the screen
|
||||
std::cout << "XGYRO_OUT:" << imu->gyroScale(imu->regRead(XGYRO_OUT)) << std::endl;
|
||||
std::cout << "YGYRO_OUT:" << imu->gyroScale(imu->regRead(YGYRO_OUT)) << std::endl;
|
||||
std::cout << "ZGYRO_OUT:" << imu->gyroScale(imu->regRead(ZGYRO_OUT)) << std::endl;
|
||||
// Read the specified register, scale it, and display it on the screen
|
||||
std::cout << "XGYRO_OUT:" << imu.gyroScale(imu.regRead(XGYRO_OUT)) << std::endl;
|
||||
std::cout << "YGYRO_OUT:" << imu.gyroScale(imu.regRead(YGYRO_OUT)) << std::endl;
|
||||
std::cout << "ZGYRO_OUT:" << imu.gyroScale(imu.regRead(ZGYRO_OUT)) << std::endl;
|
||||
std::cout << " " << std::endl;
|
||||
std::cout << "XACCL_OUT:" << imu->accelScale(imu->regRead(XACCL_OUT)) << std::endl;
|
||||
std::cout << "YACCL_OUT:" << imu->accelScale(imu->regRead(YACCL_OUT)) << std::endl;
|
||||
std::cout << "ZACCL_OUT:" << imu->accelScale(imu->regRead(ZACCL_OUT)) << std::endl;
|
||||
std::cout << "XACCL_OUT:" << imu.accelScale(imu.regRead(XACCL_OUT)) << std::endl;
|
||||
std::cout << "YACCL_OUT:" << imu.accelScale(imu.regRead(YACCL_OUT)) << std::endl;
|
||||
std::cout << "ZACCL_OUT:" << imu.accelScale(imu.regRead(ZACCL_OUT)) << std::endl;
|
||||
std::cout << " " << std::endl;
|
||||
//! [Interesting]
|
||||
sleep(1);
|
||||
//! [Interesting]
|
||||
upm_delay(1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
54
examples/c++/ads1x15-adc-sensor.cxx
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the The MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ads1015.hpp"
|
||||
#include "mraa/gpio.hpp"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
#define EDISON_I2C_BUS 1
|
||||
#define FT4222_I2C_BUS 0
|
||||
#define EDISON_GPIO_SI7005_CS 20
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
/* Create an instance of the ADS1015 sensor */
|
||||
upm::ADS1015 adc(EDISON_I2C_BUS);
|
||||
mraa::Gpio gpio(EDISON_GPIO_SI7005_CS);
|
||||
gpio.dir(mraa::DIR_OUT_HIGH);
|
||||
|
||||
// if (adc == NULL) {
|
||||
// std::cout << "ADC not detected" << std::endl;
|
||||
// return 1;
|
||||
// }
|
||||
std::cout << "ADC " << adc.getModuleName() << " detected. ";
|
||||
std::cout << adc.getNumInputs() << " inputs available" << std::endl;
|
||||
while (true) {
|
||||
for (unsigned int i = 0; i < adc.getNumInputs(); ++i) {
|
||||
std::cout << "Input " << i;
|
||||
try {
|
||||
float voltage = adc.getVoltage(i);
|
||||
std::cout << ": Voltage = " << voltage << "V" << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! [Interesting]
|