{"action":"closed","issue":{"url":"https://api.github.com/repos/Samsung/iotjs/issues/272","labels_url":"https://api.github.com/repos/Samsung/iotjs/issues/272/labels{/name}","comments_url":"https://api.github.com/repos/Samsung/iotjs/issues/272/comments","events_url":"https://api.github.com/repos/Samsung/iotjs/issues/272/events","html_url":"https://github.com/Samsung/iotjs/issues/272","id":112536525,"number":272,"title":"Implement GPIO by libmraa, which can directly operate the board pins in Edison Board and others","user":{"login":"jiangzidong","id":15059452,"avatar_url":"https://avatars.githubusercontent.com/u/15059452?v=3","gravatar_id":"","url":"https://api.github.com/users/jiangzidong","html_url":"https://github.com/jiangzidong","followers_url":"https://api.github.com/users/jiangzidong/followers","following_url":"https://api.github.com/users/jiangzidong/following{/other_user}","gists_url":"https://api.github.com/users/jiangzidong/gists{/gist_id}","starred_url":"https://api.github.com/users/jiangzidong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiangzidong/subscriptions","organizations_url":"https://api.github.com/users/jiangzidong/orgs","repos_url":"https://api.github.com/users/jiangzidong/repos","events_url":"https://api.github.com/users/jiangzidong/events{/privacy}","received_events_url":"https://api.github.com/users/jiangzidong/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-21T08:34:00Z","updated_at":"2015-10-28T22:49:16Z","closed_at":"2015-10-28T22:49:16Z","body":"IoTjs is designed for iot device, so the GPIO is one of the main features. Now the linux gpio has a general impl, which directly operate the gpios in kernel. While the mapping between kernel's gpio and physical gpio in board is difficult and varies with different embedded board, so we propose to import mraa into IoTjs and let mraa handle the mapping work. (https://github.com/intel-iot-devkit/mraa)\r\n\r\nThe codes are in https://github.com/jiangzidong/iotjs/tree/mraa_enable.\r\n**Should I just directly create a pull request, and let's discuss there?** or stay in this issue? I think PR is easy to review the code.\r\n\r\n1, We add a file : iotjs_module_gpio-linux-mraa.inl.h, which is parallel with iotjs_module_gpio-linux-general.inl.h. **The GPIO API is not changed**. Users can choose suitable implementation by the building option. \r\n```\r\n./tools/build.py --mraa\r\n```\r\n2, Gpio-linux-mraa implement export, unexport, setpin, readpin, writepin with mraa api. Then the users can operate board gpio pin directly. For example, to turn on the LED in Edison Arduino Board.\r\n```javascript\r\nvar gpio = require(\"gpio\");\r\ngpio.initialize(init_done);\r\nfunction init_done() {\r\n  print(\"init done!\");\r\n  gpio.setPin(13, \"out\", set_done);// the led is in the board pin 13\r\n}\r\nfunction set_done() {\r\n  print(\"set done!\");\r\n   gpio.writePin(13, 1);\r\n}\r\n```\r\nif the users operate the kernel gpio to turn on the led, they may need to refer the handbook and handle more than 5 gpios. see example in http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide.\r\n\r\n3, The libmraa is a **dinamic** libraries and is included in the official Edison/Galileo image. We add mraa as a submodule, and only build it for link. So the final `iotjs` doesn't have any mraa codes. It can run in the linux env with libmraa, such as Edison board. Building iotjs for Edison is easy. i686 version can run directly in Edison. In the host PC(no matter 32bit or 64bit), `./tools/build.py --mraa --target-arch=i686`, then copy the binary `iotjs` into Edison board.\r\n"}}