Open venturanc opened 7 years ago
It's a messy situation because of typescript, but I think this should work:
npm link
ant-cycling-power
install it with npm link ant-plus
Check the README.md
in ant-cycling-power
for details on Typescript stuff.
In my case, I link all three modules:
~/.../waterrower-ble/node_modules$ ls -la
lrwxrwxrwx 1 root root 56 Jan 22 20:15 ant-cycling-power -> ../../../../../../usr/lib/node_modules/ant-cycling-power
lrwxrwxrwx 1 brunofr brunofr 47 Oct 18 19:37 ant-plus -> ../../../../../../usr/lib/node_modules/ant-plus
drwxrwxr-x 2 brunofr brunofr 4096 Oct 18 19:36 .bin
drwxrwxr-x 2 brunofr brunofr 4096 Oct 18 19:34 bindings
lrwxrwxrwx 1 root root 56 Jan 22 20:15 ble-cycling-power -> ../../../../../../usr/lib/node_modules/ble-cycling-power
drwxrwxr-x 5 brunofr brunofr 4096 Oct 18 19:34 bleno
[...]
Hope this helps. I should really fix it so that it build out of the box, but the ant-plus
stuff is messy.
Thanks for trying to help. I am still running into a few errors.
I have the links to the 3 modules working in waterrower-ble
~/waterrower-ble/node_modules $ ls -al total 84 drwxr-xr-x 21 pi pi 4096 Feb 17 15:27 . drwxr-xr-x 4 pi pi 4096 Feb 17 15:21 .. lrwxrwxrwx 1 pi pi 52 Feb 17 15:21 ant-cycling-power -> ../../.npm-global/lib/node_modules/ant-cycling-power lrwxrwxrwx 1 pi pi 43 Feb 17 15:02 ant-plus -> ../../.npm-global/lib/node_modules/ant-plus drwxr-xr-x 2 pi pi 4096 Feb 13 22:49 .bin drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 bindings lrwxrwxrwx 1 pi pi 52 Feb 17 15:27 ble-cycling-power -> ../../.npm-global/lib/node_modules/ble-cycling-power drwxr-xr-x 5 pi pi 4096 Feb 13 22:48 bleno drwxr-xr-x 6 pi pi 4096 Feb 13 22:51 bluetooth-hci-socket drwxr-xr-x 3 pi pi 4096 Feb 13 22:48 bplist-parser drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 commander drwxr-xr-x 3 pi pi 4096 Feb 13 22:48 debug drwxr-xr-x 3 pi pi 4096 Feb 13 22:48 define-properties drwxr-xr-x 4 pi pi 4096 Feb 13 22:48 es6-promise drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 foreach drwxr-xr-x 3 pi pi 4096 Feb 13 22:48 function-bind drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 graceful-readlink drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 ms drwxr-xr-x 4 pi pi 4096 Feb 13 22:48 nan drwxr-xr-x 4 pi pi 4096 Feb 13 22:48 object.assign drwxr-xr-x 3 pi pi 4096 Feb 13 22:48 object-keys drwxr-xr-x 2 pi pi 4096 Feb 13 22:48 q drwxr-xr-x 7 pi pi 4096 Feb 13 22:52 serialport drwxr-xr-x 8 pi pi 4096 Feb 13 22:51 usb
I can check my installed modules with node:
~/ant-plus $ npm list -g --depth=0 /home/pi/.npm-global/lib ├── ant-cycling-power@0.1.0 ├── ant-plus@0.0.9 ├── ble-cycling-power@0.0.1 ├── typescript@2.1.6 └── typings@2.1.0
But I don't think I got ant-plus installed correctly because when I try to run waterrower-ble, I'm still getting errors related to ant-plus:
~/waterrower-ble $ DEBUG=usb,ble,ant node main.js --test ble [BLE] {"heart_rate":0,"watts":0,"rev_count":0} +0ms module.js:341 throw err; ^
Error: Cannot find module './build/ant'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.
when I was installing ant-cycling-power, I wasn't able to do the steps: $ cd ant-cycling-power $ typings install
which gives error:
~/ant-cycling-power $ /home/pi/.npm-global/bin/typings install typings WARN enoent Path "/home/pi/ant-cycling-power/typings.json" is missing
└── (No dependencies)
but I noticed that in the ant-plus folder, there is a typings.json file, and I tried the typings install command there, but got an access error,
pi@raspberrypi2:~ $ cd /home/pi/ant-plus/ pi@raspberrypi2:~/ant-plus $ /home/pi/.npm-global/bin/typings install typings WARN deprecated 11/21/2016: "registry:dt/node#6.0.0+20160608055420" is deprecated (updated, replaced or removed) typings ERR! message EACCES: permission denied, open '/home/pi/ant-plus/typings/globals/node/typings.json' typings ERR! typings ERR! cwd /home/pi/ant-plus typings ERR! system Linux 4.4.48-v7+ typings ERR! command "/usr/bin/nodejs" "/home/pi/.npm-global/bin/typings" "install" typings ERR! node -v v5.12.0 typings ERR! typings -v 2.1.0 typings ERR! code EACCES typings ERR! typings ERR! If you need help, you may report this error at: typings ERR! https://github.com/typings/typings/issues
So, I ended up doing a sudo typings install in the ant-plus folder and that appeared successful (but probably is going to give me other permissions problems down the line, I am guessing.
sudo /home/pi/.npm-global/bin/typings install typings WARN deprecated 11/21/2016: "registry:dt/node#6.0.0+20160608055420" is deprecated (updated, replaced or removed)
└── node (global)
Then I linked ant-plus while in the ant-cycling-power folder also, but I'm still getting the same error when trying to run waterrower-ble with what appears to be an ant-plus error for the ant-plus module within the ant-cycling-power node_modules folder. And still relating to a missing ".build/ant" module.
At this point, I think the next step may be to wipe the Pi OS and try again from scratch, unless you have any other ideas about the missing .build/ant module.
ok, so looking back at the error messages and in the folder, i noticed that the node_modules/ant-plus/ folder didn't have a build folder inside of it, while the ant-plus folder in my home directory did. I copied the ant-plus/build folder into the .../lib/node_modules/ant-cycling-power
ls -al /home/pi/.npm-global/lib/node_modules/ant-cycling-power/node_modules/ant-plus/ total 32 drwxr-xr-x 3 pi pi 4096 Feb 17 15:19 . drwxr-xr-x 5 pi pi 4096 Feb 17 15:19 .. -rw-r--r-- 1 pi pi 653 Feb 17 15:18 ant-plus.js -rw-r--r-- 1 pi pi 1086 Feb 17 15:18 LICENSE -rw-r--r-- 1 pi pi 5794 Feb 17 15:19 package.json -rw-r--r-- 1 pi pi 3383 Feb 17 15:18 README.md drwxr-xr-x 2 pi pi 4096 Feb 17 15:19 src
~/ant-plus $ cp -avr build /home/pi/.npm-global/lib/node_modules/ant-cycling-power/node_modules/ant-plus/
And now, no more error message when running: ~/waterrower-ble $ DEBUG=usb,ble,ant node main.js --test
And, with my Wahoo app, I can see both the waterrower BLE power profile with the power and cadence, and an Ant+ power device with the same power and cadence!! Super pumped. Thank you so much for your hard work and help. Hopefully anyone else in my same situation after following your directions will be able to copy the build folder and get their setup working!
Fantastic insight! Thank you for chasing this and documenting your process. It looks like npm
might be behaving different across versions. I really need to see how to fix this Typescript / npm problem and possibly produce a full OS + app image that can be written directly onto an SD card.
currently i am here: `pi@carcam:~/ant-cycling-power $ sudo node test.js Event: 1 Power: 336w Cadence: 80rpm /home/pi/ant-cycling-power/power-meter.js:62 data = data.concat(Ant.Messages.intToLEHexArray(this.power_accumulated, 2)); ^
TypeError: Cannot read property 'intToLEHexArray' of undefined
at PowerMeter.broadcast (/home/pi/ant-cycling-power/power-meter.js:62:34)
at a (/home/pi/ant-cycling-power/test.js:7:6)
at Object.
and i stuck, can can anybody help a bit?
ah saw the post a above and get it working :)
i like to send data from a table, so i have the real power on the screen. My elliptical trainer have a display where i can access + and - buttons. The power table is written in the manual:
Level | RPM 20 30 40 50 60 70 80 90 100 110 120 130
------------------------------------------------------
6 15 31 52 75 105 135 166 202 231 275 289
7 16 35 58 85 118 152 185 226 260 305 332
8 18 39 65 96 131 169 208 249 289 333 375
etc.... So when i choose a start level of 6 i know the wattage on the given table data. When i change to 7 or 8 with buttons +/- it should be possible to transfer the data to the pi and change the values are send. This would be a great success for thousands of people, because they can ride and walk, row, or what ever they want with real power data. I put 100$ in the pot for the maker of that! :+1: What do you think
Tried to get the new version with ant+ installed/working and I'm getting the following error. I also tried installing olympum/ant-plus separately, and ant-cycling-power and running the test.js, and getting the same error.
Anyone have any tips based on this error message?
$ ~/waterrower-ble $ DEBUG=usb,ble,ant node main.js --test ble [BLE] {"heart_rate":0,"watts":0,"rev_count":0} +0ms module.js:341 throw err; ^
Error: Cannot find module './build/ant' at Function.Module._resolveFilename (module.js:339:15) at Function.Module._load (module.js:290:25) at Module.require (module.js:367:17) at require (internal/module.js:20:19) at Object. (/home/pi/waterrower-ble/node_modules/ant-plus/ant-plus.js:2:11)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I can only find this "build" folder in the ant-plus directory and it doesn't seem to have anything called "ant":
~/waterrower-ble/node_modules/ant-plus/node_modules/usb/build
$ ls action_after_build.target.mk config.gypi libusb.target.mk Release binding.Makefile libusb.Makefile Makefileusb_bindings.target.mk
Thanks for any help/tips.