eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 613 forks source link

Up Squared - Nodejs on Ubuntu: How to compile? #871

Closed lenhuy closed 6 years ago

lenhuy commented 6 years ago
  1. Test.js var m = require('mraa'); console.log("MRAA version: " + m.getVersion()); var digitalPin = new m.Gpio(12);

  2. node Test.js

MRAA version: v1.9.0 Test.js:3 var digitalPin = new m.Gpio(12); ^ Error: Illegal arguments for construction of _exports_Gpio

  1. sudo node Test.js

module.js:328 throw err; ^

Error: Cannot find module 'mraa'

Propanu commented 6 years ago

Use sudo -E node Test.js, or modify your sudoers file to keep NODE_PATH.

lenhuy commented 6 years ago
  1. sudo -E node Test.js Got the same error same "node Test.js"

MRAA version: v1.9.0 Test.js:3 var digitalPin = new m.Gpio(12); ^ Error: Illegal arguments for construction of _exports_Gpio

  1. How do I modify sudoers file to keep NODE_PATH?
alext-mkrs commented 6 years ago

@lenhuy, you can find many tutorials/guides on configuring sudo using your favorite search engine, as this is a standard Linux tool. It's strange that sudo -E didn't work. Please post the contents of your system syslog/journal around the time you run this, mraa should be logging more details there.

Propanu commented 6 years ago

Are you using the Ubuntu image provided by Emutex for the UP2, or just plain vanilla Ubuntu? The latter won't give you access to the GPIO pins as it doesn't have the required kernel driver.

lenhuy commented 6 years ago

I'm using the Ubuntu deskop version 16.04.1 LTS 64 bit https://www.ubuntu.com/download/desktop. How do I install the required kernel driver to gain access to the GPIO?

Propanu commented 6 years ago

You can find instructions on how to patch the kernel here: https://wiki.up-community.org/Ubuntu

lenhuy commented 6 years ago

Thank you. I'd would like to use GrovePi board for the Up Squared, which packets that I need to install for node JS on Ubuntu?

Grove Pi board https://www.seeedstudio.com/UP%26sup2%3B-Grove-IoT-Development-Kit-p-2994.html

lenhuy commented 6 years ago

I got it working now. Need the line below to interface with Grove Sensors. mraa.addSubplatform(mraa.GROVEPI, "0 ")