[
  {
    "path": ".gitignore",
    "content": ".settings.xml\n.DS_Store\nbonescript.log\n*~\nnode_modules\n.coveralls.yml\n"
  },
  {
    "path": ".travis.yml",
    "content": "sudo: required\nlanguage: node_js\nnode_js:\n   - \"6\"\n   - \"8\"\n   - \"10\"\nafter_script:\n  - npm run-script coveralls\nnotifications:\n  irc:\n    - \"chat.freenode.net#beagle-bonescript\"\n  webhooks:\n    urls:\n      - https://webhooks.gitter.im/e/800e4efb92aa7f8eda15\n    on_success: change  # options: [always|never|change] default: always\n    on_failure: always  # options: [always|never|change] default: always\n    on_start: false     # default: false\n\n\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2011 Jason Kridner <jdk@ti.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "PREFIX:=/usr/local\nnpm_options:=--unsafe-perm=true --progress=false --loglevel=error\nNODE_PATH:=$(DESTDIR)$(PREFIX)/lib/node_modules\nNODEJS:=nodejs\nNPM:=npm\n\nver=$(shell nodejs -pe \"require('./package.json').version\")\nnpm_version=$(shell $(NPM) --version)\nnode_version=$(shell $(NODEJS) --version)\nbs_path=./build/lib/node_modules/bonescript\n\nall:\n\tmkdir -p $(bs_path)\n\techo $(ver) > $(bs_path)/bonescript.version\n\techo $(node_version) > $(bs_path)/bonescript.node_version\n\techo $(npm_version) > $(bs_path)/bonescript.npm_version\n\tTERM=dumb $(NPM) install -g $(npm_options) --prefix ./build\n\tcp -dr --preserve=mode,timestamp etc/* ./build/etc/\n\nclean:\n\trm -rf build\n\ntest:\n\n\ninstall:\n\tinstall -m 0755 -d $(DESTDIR)$(PREFIX)\n\tcp -dr --preserve=mode,timestamp ./build/* $(DESTDIR)$(PREFIX)/\n\tsystemctl stop bonescript-autorun.service || true\n\tsystemctl stop bonescript.service || true\n\tsystemctl stop bonescript.socket || true\n\tinstall -m 0755 -d $(DESTDIR)/lib/systemd/system\n\tinstall -m 0644 systemd/bonescript.socket $(DESTDIR)/lib/systemd/system/\n\tinstall -m 0644 systemd/bonescript.service $(DESTDIR)/lib/systemd/system/\n\tinstall -m 0644 systemd/bonescript-autorun.service $(DESTDIR)/lib/systemd/system/\n\tsystemctl enable bonescript.socket || true\n\tsystemctl enable bonescript.service || true\n\tsystemctl enable bonescript-autorun.service || true\n\n.PHONY: clean test install\n"
  },
  {
    "path": "README.md",
    "content": "BoneScript\n==========\n\n[![Join the chat at https://gitter.im/jadonk/bonescript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jadonk/bonescript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n[![Build Status](https://travis-ci.org/jadonk/bonescript.svg?branch=0.5.x)](https://travis-ci.org/jadonk/bonescript)\n[![Coverage Status](https://img.shields.io/coveralls/jadonk/bonescript.svg)](https://coveralls.io/r/jadonk/bonescript)\n\nBoneScript is a node.js library for physical computing on embedded Linux,\nstarting with support for BeagleBone.\n\nInformation on the language is available at http://nodejs.org.\n\nTo check the version and to see if BoneScript is in your path, try running:\n````sh\nnode -pe \"require('bonescript').getPlatform().bonescript\"\n````\n\nAdditional documentation is available at http://beagleboard.org/bonescript.\n\nThe concept is to use Arduino-like functions written in JavaScript to\nsimplify learning how to do physical computing tasks under embedded Linux\nand to further provide support for rapidly creating GUIs for your embedded\napplications through the use of HTML5/JavaScript web pages.\n\n\nGlobal Installation\n-------------------\nBoneScript comes installed on your BeagleBone. To update to the latest revision, use 'npm'\non a recent BeagleBoard.org Debian image from https://beagleboard.org/latest-images\nand perform:\n````sh\nTERM=none sudo npm cache clear\nTERM=none sudo npm install -g --prefix /usr/local --unsafe-perm bonescript\nsudo shutdown -r now\n````\n\nTesting on other distributions is limited.\n\nThere are some additional installation steps that can be performed, but are typically\ninstalled by other mechanisms on the BeagleBoard.org Debian images. These setup\nbackground services (bone101 webserver with bonescript RPC and bonescript autorun\nservice) as well as configure environment variables for these services and other\nglobally run scripts.\n````sh\nsudo cp bonescript/etc/default/node /etc/default/node\nsudo cp bonescript/etc/profile.d/node.sh /etc/profile.d/node.sh\nsudo cp bonescript/systemd/\\* /lib/systemd/system\nsudo systemctl enable bonescript.socket\nsudo systemctl enable bonescript-autorun.service\n````\n\nLaunching applications persistently\n-----------------------------------\nTo have your applications launch on startup, simply drop them into the\n/var/lib/cloud9/autorun folder.  Moving them out of that folder will kill\nthe processes.  You are expected to only drop in already bug-free apps into\nthis folder as there isn't a good way to perform debug on them.\n\nNote on code state\n==================\nThere's still a lot of development going on, so be sure to check back on a \nfrequent basis.  Many of the fancier peripherals aren't yet supported\nexcept through performing file I/O.\n\nDirectory layout\n----------------\n* index.js: Main BoneScript source code\n* autorun.js: Node.JS app to run apps dropped in the autorun folder\n* package.json: NPM.JS package descriptor\n* server.js: BoneScript web server to serve up remote procedure calls\n* dts: Devicetree templates\n* etc: Configuration files to be placed in target distro\n* src: Library source code\n* systemd: Configuration files for systemd to start services\n* test: To-be-automated test code\n\nTemplate\n========\nFor a BoneScript application, you must currently manually 'require' the\nbonescript library.  Functions are then referenced through the object\nprovided back from require.\n\nI started out trying to provide Arduino-like setup/loop functions, but the\nidea really isn't a good match for JavaScript.  Using JavaScript's native\nflow works best, but the familiar functions are enough to give you a boost\nin your physical computing productivity.\n\nHere's an example:\n\n````javascript\nvar b = require('bonescript');\n\nb.pinMode('P8_12', b.INPUT);\nb.pinMode('P8_13', b.OUTPUT);\n\nsetInterval(copyInputToOutput, 100);\n\nfunction copyInputToOutput() {\n    b.digitalRead('P8_12', writeToOutput);\n    function writeToOutput(x) {\n        b.digitalWrite('P8_13', x.value);\n    }\n}\n````\n\nThe 'P8\\_12' and 'P8\\_13' are pin names on the board and the above example\nwould copy the input value at P8\\_12 to the output P8\\_13 every 100 ms.\n\n\nAPI\n===\nWhen a callback is provided, the functions will behave asynchronously.\nWithout a callback provided, the functions will synchronize and complete\nbefore returning.\n\nSystem\n------\n* getPlatform([callback]) -> platform\n* getEeproms([callback]) -> eeproms\n* echo(data, [callback]) -> data\n* readTextFile(filename, [callback]) -> data\n* writeTextFile(filename, data, [callback])\n* setDate(date, [callback])\n\nDigital and Analog I/O\n----------------------\n* analogRead(pin, [callback]) -> value\n* analogWrite(pin, value, [freq], [callback])\n* attachInterrupt(pin, handler, mode, [callback])\n* detachInterrupt(pin, [callback])\n* digitalRead(pin, [calback]) -> value\n* digitalWrite(pin, value, [callback])\n* pinMode(pin, direction, [mux], [pullup], [slew], [callback])\n* getPinMode(pin, [callback]) -> pinMode\n* shiftOut(dataPin, clockPin, bitOrder, val, [callback])\n\nSerial\n------\nUses https://github.com/voodootikigod/node-serialport\n* serialOpen(port, options, [callback])\n* serialWrite(port, data, [callback])\n* serialParsers is serialport.parsers\n\nI2C\n---\nUses https://github.com/korevec/node-i2c\n* i2cOpen(port, address, options, [callback])\n* i2cScan(port, [callback])\n* i2cWriteByte(port, byte, [callback])\n* i2cWriteBytes(port, command, bytes, [callback])\n* i2cReadByte(port, [callback])\n* i2cReadBytes(port, command, length, [callback])\n* i2cStream(port, command, length, [callback])\n\nRobot Control\n-------------\n__new in 0.7.0__ Runs on BeagleBone Blue; or BeagleBone Black or BeagleBone Black Wireless with BeagleBoard.org Robotics Cape\n* rcInitialize([callback])\n* rcState([state], [callback]) -> state\n* rcLED(led, [value], [callback]) -> value\n* rcOn(event, [callback])\n* rcMotor(motor, value, [callback])\n* rcServo(option, value, [callback])\n* rcBMP([option], [callback]) -> value\n* rcIMU([option], [callback]) -> value\n* rcEncoder(encoder, [value], [callback]) -> value\n\nBits/Bytes, Math, Trigonometry and Random Numbers\n-------------------------------------------------\n* lowByte(value)\n* highByte(value)\n* bitRead(value, bitnum)\n* bitWrite(value, bitnum, bitdata) \n* bitSet(value, bitnum) \n* bitClear(value, bitnum) \n* bit(bitnum)\n* min(x, y)\n* max(x, y)\n* abs(x)\n* constrain(x, a, b)\n* map(value, fromLow, fromHigh, toLow, toHigh)\n* pow(x, y)\n* sqrt(x)\n* sin(radians)\n* cos(radians)\n* tan(radians)\n* randomSeed(x)\n* random([min], max)\n\n\nNote on performance\n===================\nThis code is totally unoptimized.  The list of possible optimizations that run\nthrough my head is staggering.  The good news is that I think it can all be\ndone without impacting the API, primarily thanks to the introspection\ncapabilities of JavaScript.\n\nEventually, this is planned to enable real-time usage, directly from\nJavaScript.  The plan is to attact the ability to use this programming environment\nin real-time on several fronts:\n* Enabling multiple loops and analyzing them to determine if they can be off-\n  loaded to a PRU.  This will be the primary mechanism for providing real-time\n  servicing of the IOs.\n* Providing higher-order services that utilize the standard peripherals for\n  their intended use:\n  - Serial drivers for I2C, SPI, UARTs, etc.\n  - analogWrite for PWMs using hardware PWMs, timers, kernel GPIO drivers, etc.\n* Adding real-time patches to the kernel\n\n\nThe JavaScript language provides some features that I think are really cool\nfor doing embedded programming and node.js does some things to help enable\nthat.  The primary one is that the I/O functions are all asynchronous.  For\nembedded systems, this is especially useful for performing low-latency tasks\nthat respond to events in the system.  What makes JavaScript so much easier\nthan other languages for doing this is that it keeps the full context around\nthe handler, so you don't have to worry about it.\n\nWhat's New\n==========\n\n0.7.4 key updates\n-----------------\n* Enabled BeagleBone AI GPIO functions (digitalRead/digitalWrite/getPinMode)\n\n0.7.3 key updates\n-----------------\nBig speed-up on loading by lazy-loading infrequently used modules\n\n0.7.2 key updates\n-----------------\n* https://github.com/beagleboard/bonescript/issues/52\n* https://github.com/beagleboard/bonescript/issues/53\n\n0.7.1 key updates\n-----------------\nVery minor update on a function scope\n\n0.7.0 key updates\n-----------------\nMost of these fixes came from a [Google Summer of Code 2018 project](https://github.com/vaishnav98/bone101/wiki/BeagleBoard-GSoC'18:-Fixing-Bugs-in-BoneScript-and-Improving-BeagleBone-User-Interface)\n* Fixes in PWM output during analogWrite updates\n* Added function calls for Robot Control library support on BeagleBone Blue or Robotics Cape\n* Added support for node-style callbacks with error and data separated (optional)\n\nPlans\n=====\n* SPI support\n* PRU support\n* Handling array of pins in pinMode and getPinMode\n* Saving off created dtbo and writing configuration to cape EEPROM\n\n"
  },
  {
    "path": "autorun.js",
    "content": "var b = require('bonescript');\n\nvar directory = (process.env.AUTORUN_DIR) ? process.env.AUTORUN_DIR : '/var/lib/cloud9/autorun';\n\nb.autorun(directory);"
  },
  {
    "path": "dts/bs_template.dts",
    "content": "// Copyright 2013\n// Charles Steinkuehler <charles@steinkuehler.net>\n// Copyright 2014\n// Jason Kridner <jdk@ti.com>\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n/dts-v1/;\n/plugin/;\n\n/ {\n    compatible = \"ti,beaglebone\", \"ti,beaglebone-black\";\n\n    /* identification */\n    part-number = \"cape-bonescript\";\n    version = \"00A0\";\n\n    /* state the resources this cape uses */\n    exclusive-use =\n\n/*      \"P8.1\",     GND     */\n/*      \"P8.2\",     GND     */\n/*      \"P8.3\",     emmc    */\n/*      \"P8.4\",     emmc    */\n/*      \"P8.5\",     emmc    */\n/*      \"P8.6\",     emmc    */\n        \"P8.7\",\n        \"P8.8\",\n        \"P8.9\",\n        \"P8.10\",\n        \"P8.11\",\n        \"P8.12\",\n        \"P8.13\",\n        \"P8.14\",\n        \"P8.15\",\n        \"P8.16\",\n        \"P8.17\",\n        \"P8.18\",\n        \"P8.19\",\n/*      \"P8.20\",    emmc    */\n/*      \"P8.21\",    emmc    */\n/*      \"P8.22\",    emmc    */\n/*      \"P8.23\",    emmc    */\n/*      \"P8.24\",    emmc    */\n/*      \"P8.25\",    emmc    */\n        \"P8.26\",\n/*      \"P8.27\",    hdmi    */\n/*      \"P8.28\",    hdmi    */\n/*      \"P8.29\",    hdmi    */\n/*      \"P8.30\",    hdmi    */\n/*      \"P8.31\",    hdmi    */\n/*      \"P8.32\",    hdmi    */\n/*      \"P8.33\",    hdmi    */\n/*      \"P8.34\",    hdmi    */\n/*      \"P8.35\",    hdmi    */\n/*      \"P8.36\",    hdmi    */\n/*      \"P8.37\",    hdmi    */\n/*      \"P8.38\",    hdmi    */\n/*      \"P8.39\",    hdmi    */\n/*      \"P8.40\",    hdmi    */\n/*      \"P8.41\",    hdmi    */\n/*      \"P8.42\",    hdmi    */\n/*      \"P8.43\",    hdmi    */\n/*      \"P8.44\",    hdmi    */\n/*      \"P8.45\",    hdmi    */\n/*      \"P8.46\",    hdmi    */\n\n/*      \"P9.1\",     GND     */\n/*      \"P9.2\",     GND     */\n/*      \"P9.3\",     3.3V    */\n/*      \"P9.4\",     3.3V    */\n/*      \"P9.5\",     VDD_5V  */\n/*      \"P9.6\",     VDD_5V  */\n/*      \"P9.7\",     SYS_5V  */\n/*      \"P9.8\",     SYS_5V  */\n/*      \"P9.9\",     PWR_BUT */\n/*      \"P9.10\",    RESETn  */\n        \"P9.11\",\n        \"P9.12\",\n        \"P9.13\",\n        \"P9.14\",\n        \"P9.15\",\n        \"P9.16\",\n        \"P9.17\",\n        \"P9.18\",\n/*      \"P9.19\",    I2C     */\n/*      \"P9.20\",    I2C     */\n        \"P9.21\",\n        \"P9.22\",\n        \"P9.23\",\n        \"P9.24\",\n/*      \"P9.25\",    Audio   */\n        \"P9.26\",\n        \"P9.27\",\n/*      \"P9.28\",    Audio   */\n/*      \"P9.29\",    Audio   */\n        \"P9.30\",\n/*      \"P9.31\",    Audio   */\n/*      \"P9.32\",    VADC    */\n/*      \"P9.33\",    AIN4    */\n/*      \"P9.34\",    AGND    */\n/*      \"P9.35\",    AIN6    */\n/*      \"P9.36\",    AIN5    */\n/*      \"P9.37\",    AIN2    */\n/*      \"P9.38\",    AIN3    */\n/*      \"P9.39\",    AIN0    */\n/*      \"P9.40\",    AIN1    */\n        \"P9.41\",\n        \"P9.41.1\",\n        \"P9.42\",\n        \"P9.42.1\",\n/*      \"P9.43\",    GND     */\n/*      \"P9.44\",    GND     */\n/*      \"P9.45\",    GND     */\n/*      \"P9.46\",    GND     */\n\n        \"uart1\",\n        \"uart2\",\n        \"uart4\",\n//      \"uart5\",    /* Conflicts with HDMI  */\n\n        \"ehrpwm0A\",\n        \"ehrpwm0B\",\n        \"ehrpwm1A\",\n        \"ehrpwm1B\",\n        \"ehrpwm2A\",\n        \"ehrpwm2B\",\n\n//        \"epwmss0\",\n//        \"ehrpwm0\",\n//        \"ecap0\",\n//        \"epwmss1\",\n//        \"ehrpwm1\",\n//        \"epwmss2\",\n//        \"ehrpwm2\",\n//        \"ecap2\",\n\n        \"i2c1\",\n        \"spi1\",\n        \"spi0\",\n        \"dcan0\",\n        \"dcan1\",\n\n        \"pru0\",\n        \"pru1\",\n        \"pruss\";\n\n    fragment@0 {\n        target = <&am33xx_pinmux>;\n        __overlay__ {\n\n            /************************/\n            /* P8 Header            */\n            /************************/\n\n            /* P8_01                GND     */\n            /* P8_02                GND     */\n            /* P8_03 (ZCZ ball R9 ) emmc    */\n            /* P8_04 (ZCZ ball T9 ) emmc    */\n            /* P8_05 (ZCZ ball R8 ) emmc    */\n            /* P8_06 (ZCZ ball T8 ) emmc    */\n\n            /* P8_07 (ZCZ ball R7 ) */\n            P8_07_default_pin: pinmux_P8_07_default_pin {\n                pinctrl-single,pins = <0x090  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_07_gpio_pin: pinmux_P8_07_gpio_pin {\n                pinctrl-single,pins = <0x090  0x2F>; };     /* Mode 7, RxActive */\n            P8_07_gpio_pu_pin: pinmux_P8_07_gpio_pu_pin {\n                pinctrl-single,pins = <0x090  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_07_gpio_pd_pin: pinmux_P8_07_gpio_pd_pin {\n                pinctrl-single,pins = <0x090  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_07_timer_pin: pinmux_P8_07_timer_pin {\n                pinctrl-single,pins = <0x090  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n\n            /* P8_08 (ZCZ ball T7 ) */\n            P8_08_default_pin: pinmux_P8_08_default_pin {\n                pinctrl-single,pins = <0x094  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_08_gpio_pin: pinmux_P8_08_gpio_pin {\n                pinctrl-single,pins = <0x094  0x2F>; };     /* Mode 7, RxActive */\n            P8_08_gpio_pu_pin: pinmux_P8_08_gpio_pu_pin {\n                pinctrl-single,pins = <0x094  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_08_gpio_pd_pin: pinmux_P8_08_gpio_pd_pin {\n                pinctrl-single,pins = <0x094  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_08_timer_pin: pinmux_P8_08_timer_pin {\n                pinctrl-single,pins = <0x094  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n\n            /* P8_09 (ZCZ ball T6 ) */\n            P8_09_default_pin: pinmux_P8_09_default_pin {\n                pinctrl-single,pins = <0x09c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_09_gpio_pin: pinmux_P8_09_gpio_pin {\n                pinctrl-single,pins = <0x09c  0x2F>; };     /* Mode 7, RxActive */\n            P8_09_gpio_pu_pin: pinmux_P8_09_gpio_pu_pin {\n                pinctrl-single,pins = <0x09c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_09_gpio_pd_pin: pinmux_P8_09_gpio_pd_pin {\n                pinctrl-single,pins = <0x09c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_09_timer_pin: pinmux_P8_09_timer_pin {\n                pinctrl-single,pins = <0x09c  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n\n            /* P8_10 (ZCZ ball U6 ) */\n            P8_10_default_pin: pinmux_P8_10_default_pin {\n                pinctrl-single,pins = <0x098  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_10_gpio_pin: pinmux_P8_10_gpio_pin {\n                pinctrl-single,pins = <0x098  0x2F>; };     /* Mode 7, RxActive */\n            P8_10_gpio_pu_pin: pinmux_P8_10_gpio_pu_pin {\n                pinctrl-single,pins = <0x098  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_10_gpio_pd_pin: pinmux_P8_10_gpio_pd_pin {\n                pinctrl-single,pins = <0x098  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_10_timer_pin: pinmux_P8_10_timer_pin {\n                pinctrl-single,pins = <0x098  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n\n            /* P8_11 (ZCZ ball R12) */\n            P8_11_default_pin: pinmux_P8_11_default_pin {\n                pinctrl-single,pins = <0x034  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_11_gpio_pin: pinmux_P8_11_gpio_pin {\n                pinctrl-single,pins = <0x034  0x2F>; };     /* Mode 7, RxActive */\n            P8_11_gpio_pu_pin: pinmux_P8_11_gpio_pu_pin {\n                pinctrl-single,pins = <0x034  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_11_gpio_pd_pin: pinmux_P8_11_gpio_pd_pin {\n                pinctrl-single,pins = <0x034  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_11_pruout_pin: pinmux_P8_11_pruout_pin {\n                pinctrl-single,pins = <0x034  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n            P8_11_qep_pin: pinmux_P8_11_qep_pin {\n                pinctrl-single,pins = <0x034  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_12 (ZCZ ball T12) */\n            P8_12_default_pin: pinmux_P8_12_default_pin {\n                pinctrl-single,pins = <0x030  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_12_gpio_pin: pinmux_P8_12_gpio_pin {\n                pinctrl-single,pins = <0x030  0x2F>; };     /* Mode 7, RxActive */\n            P8_12_gpio_pu_pin: pinmux_P8_12_gpio_pu_pin {\n                pinctrl-single,pins = <0x030  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_12_gpio_pd_pin: pinmux_P8_12_gpio_pd_pin {\n                pinctrl-single,pins = <0x030  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_12_pruout_pin: pinmux_P8_12_pruout_pin {\n                pinctrl-single,pins = <0x030  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n            P8_12_qep_pin: pinmux_P8_12_qep_pin {\n                pinctrl-single,pins = <0x030  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_13 (ZCZ ball T10) */\n            P8_13_default_pin: pinmux_P8_13_default_pin {\n                pinctrl-single,pins = <0x024  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_13_gpio_pin: pinmux_P8_13_gpio_pin {\n                pinctrl-single,pins = <0x024  0x2F>; };     /* Mode 7, RxActive */\n            P8_13_gpio_pu_pin: pinmux_P8_13_gpio_pu_pin {\n                pinctrl-single,pins = <0x024  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_13_gpio_pd_pin: pinmux_P8_13_gpio_pd_pin {\n                pinctrl-single,pins = <0x024  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_13_pwm_pin: pinmux_P8_13_pwm_pin {\n                pinctrl-single,pins = <0x024  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_14 (ZCZ ball T11) */\n            P8_14_default_pin: pinmux_P8_14_default_pin {\n                pinctrl-single,pins = <0x028  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_14_gpio_pin: pinmux_P8_14_gpio_pin {\n                pinctrl-single,pins = <0x028  0x2F>; };     /* Mode 7, RxActive */\n            P8_14_gpio_pu_pin: pinmux_P8_14_gpio_pu_pin {\n                pinctrl-single,pins = <0x028  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_14_gpio_pd_pin: pinmux_P8_14_gpio_pd_pin {\n                pinctrl-single,pins = <0x028  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_14_pwm_pin: pinmux_P8_14_pwm_pin {\n                pinctrl-single,pins = <0x028  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_15 (ZCZ ball U13) */\n            P8_15_default_pin: pinmux_P8_15_default_pin {\n                pinctrl-single,pins = <0x03c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_15_gpio_pin: pinmux_P8_15_gpio_pin {\n                pinctrl-single,pins = <0x03c  0x2F>; };     /* Mode 7, RxActive */\n            P8_15_gpio_pu_pin: pinmux_P8_15_gpio_pu_pin {\n                pinctrl-single,pins = <0x03c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_15_gpio_pd_pin: pinmux_P8_15_gpio_pd_pin {\n                pinctrl-single,pins = <0x03c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_15_pruin_pin: pinmux_P8_15_pruin_pin {\n                pinctrl-single,pins = <0x03c  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n            P8_15_qep_pin: pinmux_P8_15_qep_pin {\n                pinctrl-single,pins = <0x03c  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_16 (ZCZ ball V13) */\n            P8_16_default_pin: pinmux_P8_16_default_pin {\n                pinctrl-single,pins = <0x038  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_16_gpio_pin: pinmux_P8_16_gpio_pin {\n                pinctrl-single,pins = <0x038  0x2F>; };     /* Mode 7, RxActive */\n            P8_16_gpio_pu_pin: pinmux_P8_16_gpio_pu_pin {\n                pinctrl-single,pins = <0x038  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_16_gpio_pd_pin: pinmux_P8_16_gpio_pd_pin {\n                pinctrl-single,pins = <0x038  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_16_pruin_pin: pinmux_P8_16_pruin_pin {\n                pinctrl-single,pins = <0x038  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n            P8_16_qep_pin: pinmux_P8_16_qep_pin {\n                pinctrl-single,pins = <0x038  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_17 (ZCZ ball U12) */\n            P8_17_default_pin: pinmux_P8_17_default_pin {\n                pinctrl-single,pins = <0x02c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_17_gpio_pin: pinmux_P8_17_gpio_pin {\n                pinctrl-single,pins = <0x02c  0x2F>; };     /* Mode 7, RxActive */\n            P8_17_gpio_pu_pin: pinmux_P8_17_gpio_pu_pin {\n                pinctrl-single,pins = <0x02c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_17_gpio_pd_pin: pinmux_P8_17_gpio_pd_pin {\n                pinctrl-single,pins = <0x02c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_17_pwm_pin: pinmux_P8_17_pwm_pin {\n                pinctrl-single,pins = <0x02c  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_18 (ZCZ ball V12) */\n            P8_18_default_pin: pinmux_P8_18_default_pin {\n                pinctrl-single,pins = <0x08c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_18_gpio_pin: pinmux_P8_18_gpio_pin {\n                pinctrl-single,pins = <0x08c  0x2F>; };     /* Mode 7, RxActive */\n            P8_18_gpio_pu_pin: pinmux_P8_18_gpio_pu_pin {\n                pinctrl-single,pins = <0x08c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_18_gpio_pd_pin: pinmux_P8_18_gpio_pd_pin {\n                pinctrl-single,pins = <0x08c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n\n            /* P8_19 (ZCZ ball U10) */\n            P8_19_default_pin: pinmux_P8_19_default_pin {\n                pinctrl-single,pins = <0x020  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_19_gpio_pin: pinmux_P8_19_gpio_pin {\n                pinctrl-single,pins = <0x020  0x2F>; };     /* Mode 7, RxActive */\n            P8_19_gpio_pu_pin: pinmux_P8_19_gpio_pu_pin {\n                pinctrl-single,pins = <0x020  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_19_gpio_pd_pin: pinmux_P8_19_gpio_pd_pin {\n                pinctrl-single,pins = <0x020  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P8_19_pwm_pin: pinmux_P8_19_pwm_pin {\n                pinctrl-single,pins = <0x020  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P8_20 (ZCZ ball V9 ) emmc    */\n            /* P8_21 (ZCZ ball U9 ) emmc    */\n            /* P8_22 (ZCZ ball V8 ) emmc    */\n            /* P8_23 (ZCZ ball U8 ) emmc    */\n            /* P8_24 (ZCZ ball V7 ) emmc    */\n            /* P8_25 (ZCZ ball U7 ) emmc    */\n\n            /* P8_26 (ZCZ ball V6 ) */\n            P8_26_default_pin: pinmux_P8_26_default_pin {\n                pinctrl-single,pins = <0x07c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_26_gpio_pin: pinmux_P8_26_gpio_pin {\n                pinctrl-single,pins = <0x07c  0x2F>; };     /* Mode 7, RxActive */\n            P8_26_gpio_pu_pin: pinmux_P8_26_gpio_pu_pin {\n                pinctrl-single,pins = <0x07c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P8_26_gpio_pd_pin: pinmux_P8_26_gpio_pd_pin {\n                pinctrl-single,pins = <0x07c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n\n            /* P8_27 (ZCZ ball U5 ) hdmi    */\n            /* P8_28 (ZCZ ball V5 ) hdmi    */\n            /* P8_29 (ZCZ ball R5 ) hdmi    */\n            /* P8_30 (ZCZ ball R6 ) hdmi    */\n            /* P8_31 (ZCZ ball V4 ) hdmi    */\n            /* P8_32 (ZCZ ball T5 ) hdmi    */\n            /* P8_33 (ZCZ ball V3 ) hdmi    */\n            /* P8_34 (ZCZ ball U4 ) hdmi    */\n            /* P8_35 (ZCZ ball V2 ) hdmi    */\n            /* P8_36 (ZCZ ball U3 ) hdmi    */\n            /* P8_37 (ZCZ ball U1 ) hdmi    */\n            /* P8_38 (ZCZ ball U2 ) hdmi    */\n            /* P8_39 (ZCZ ball T3 ) hdmi    */\n            /* P8_40 (ZCZ ball T4 ) hdmi    */\n            /* P8_41 (ZCZ ball T1 ) hdmi    */\n            /* P8_42 (ZCZ ball T2 ) hdmi    */\n            /* P8_43 (ZCZ ball R3 ) hdmi    */\n            /* P8_44 (ZCZ ball R4 ) hdmi    */\n            /* P8_45 (ZCZ ball R1 ) hdmi    */\n            /* P8_46 (ZCZ ball R2 ) hdmi    */\n\n\n            /************************/\n            /* P9 Header            */\n            /************************/\n\n            /* P9_01                GND     */\n            /* P9_02                GND     */\n            /* P9_03                3.3V    */\n            /* P9_04                3.3V    */\n            /* P9_05                VDD_5V  */\n            /* P9_06                VDD_5V  */\n            /* P9_07                SYS_5V  */\n            /* P9_08                SYS_5V  */\n            /* P9_09                PWR_BUT */\n            /* P9_10 (ZCZ ball A10) RESETn  */\n\n            /* P9_11 (ZCZ ball T17) */\n            P9_11_default_pin: pinmux_P9_11_default_pin {\n                pinctrl-single,pins = <0x070  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_11_gpio_pin: pinmux_P9_11_gpio_pin {\n                pinctrl-single,pins = <0x070  0x2F>; };     /* Mode 7, RxActive */\n            P9_11_gpio_pu_pin: pinmux_P9_11_gpio_pu_pin {\n                pinctrl-single,pins = <0x070  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_11_gpio_pd_pin: pinmux_P9_11_gpio_pd_pin {\n                pinctrl-single,pins = <0x070  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_11_uart_pin: pinmux_P9_11_uart_pin {\n                pinctrl-single,pins = <0x070  0x36>; };     /* Mode 6, Pull-Up, RxActive */\n\n            /* P9_12 (ZCZ ball U18) */\n            P9_12_default_pin: pinmux_P9_12_default_pin {\n                pinctrl-single,pins = <0x078  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_12_gpio_pin: pinmux_P9_12_gpio_pin {\n                pinctrl-single,pins = <0x078  0x2F>; };     /* Mode 7, RxActive */\n            P9_12_gpio_pu_pin: pinmux_P9_12_gpio_pu_pin {\n                pinctrl-single,pins = <0x078  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_12_gpio_pd_pin: pinmux_P9_12_gpio_pd_pin {\n                pinctrl-single,pins = <0x078  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n\n            /* P9_13 (ZCZ ball U17) */\n            P9_13_default_pin: pinmux_P9_13_default_pin {\n                pinctrl-single,pins = <0x074  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_13_gpio_pin: pinmux_P9_13_gpio_pin {\n                pinctrl-single,pins = <0x074  0x2F>; };     /* Mode 7, RxActive */\n            P9_13_gpio_pu_pin: pinmux_P9_13_gpio_pu_pin {\n                pinctrl-single,pins = <0x074  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_13_gpio_pd_pin: pinmux_P9_13_gpio_pd_pin {\n                pinctrl-single,pins = <0x074  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_13_uart_pin: pinmux_P9_13_uart_pin {\n                pinctrl-single,pins = <0x074  0x36>; };     /* Mode 6, Pull-Up, RxActive */\n\n            /* P9_14 (ZCZ ball U14) */\n            P9_14_default_pin: pinmux_P9_14_default_pin {\n                pinctrl-single,pins = <0x048  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_14_gpio_pin: pinmux_P9_14_gpio_pin {\n                pinctrl-single,pins = <0x048  0x2F>; };     /* Mode 7, RxActive */\n            P9_14_gpio_pu_pin: pinmux_P9_14_gpio_pu_pin {\n                pinctrl-single,pins = <0x048  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_14_gpio_pd_pin: pinmux_P9_14_gpio_pd_pin {\n                pinctrl-single,pins = <0x048  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_14_pwm_pin: pinmux_P9_14_pwm_pin {\n                pinctrl-single,pins = <0x048  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_15 (ZCZ ball R13) */\n            P9_15_default_pin: pinmux_P9_15_default_pin {\n                pinctrl-single,pins = <0x040  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_15_gpio_pin: pinmux_P9_15_gpio_pin {\n                pinctrl-single,pins = <0x040  0x2F>; };     /* Mode 7, RxActive */\n            P9_15_gpio_pu_pin: pinmux_P9_15_gpio_pu_pin {\n                pinctrl-single,pins = <0x040  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_15_gpio_pd_pin: pinmux_P9_15_gpio_pd_pin {\n                pinctrl-single,pins = <0x040  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_15_pwm_pin: pinmux_P9_15_pwm_pin {\n                pinctrl-single,pins = <0x040  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_16 (ZCZ ball T14) */\n            P9_16_default_pin: pinmux_P9_16_default_pin {\n                pinctrl-single,pins = <0x04c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_16_gpio_pin: pinmux_P9_16_gpio_pin {\n                pinctrl-single,pins = <0x04c  0x2F>; };     /* Mode 7, RxActive */\n            P9_16_gpio_pu_pin: pinmux_P9_16_gpio_pu_pin {\n                pinctrl-single,pins = <0x04c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_16_gpio_pd_pin: pinmux_P9_16_gpio_pd_pin {\n                pinctrl-single,pins = <0x04c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_16_pwm_pin: pinmux_P9_16_pwm_pin {\n                pinctrl-single,pins = <0x04c  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_17 (ZCZ ball A16) */\n            P9_17_default_pin: pinmux_P9_17_default_pin {\n                pinctrl-single,pins = <0x15c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_17_gpio_pin: pinmux_P9_17_gpio_pin {\n                pinctrl-single,pins = <0x15c  0x2F>; };     /* Mode 7, RxActive */\n            P9_17_gpio_pu_pin: pinmux_P9_17_gpio_pu_pin {\n                pinctrl-single,pins = <0x15c  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_17_gpio_pd_pin: pinmux_P9_17_gpio_pd_pin {\n                pinctrl-single,pins = <0x15c  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_17_spi_pin: pinmux_P9_17_spi_pin {\n                pinctrl-single,pins = <0x15c  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_17_i2c_pin: pinmux_P9_17_i2c_pin {\n                pinctrl-single,pins = <0x15c  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_17_pwm_pin: pinmux_P9_17_pwm_pin {\n                pinctrl-single,pins = <0x15c  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n\n            /* P9_18 (ZCZ ball B16) */\n            P9_18_default_pin: pinmux_P9_18_default_pin {\n                pinctrl-single,pins = <0x158  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_18_gpio_pin: pinmux_P9_18_gpio_pin {\n                pinctrl-single,pins = <0x158  0x2F>; };     /* Mode 7, RxActive */\n            P9_18_gpio_pu_pin: pinmux_P9_18_gpio_pu_pin {\n                pinctrl-single,pins = <0x158  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_18_gpio_pd_pin: pinmux_P9_18_gpio_pd_pin {\n                pinctrl-single,pins = <0x158  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_18_spi_pin: pinmux_P9_18_spi_pin {\n                pinctrl-single,pins = <0x158  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_18_i2c_pin: pinmux_P9_18_i2c_pin {\n                pinctrl-single,pins = <0x158  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_18_pwm_pin: pinmux_P9_18_pwm_pin {\n                pinctrl-single,pins = <0x158  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n\n            // Leave the cape I2C EEPROM bus alone\n            /* P9_19 (ZCZ ball D17) I2C     */\n            /* P9_20 (ZCZ ball D18) I2C     */\n\n            /* P9_21 (ZCZ ball B17) */\n            P9_21_default_pin: pinmux_P9_21_default_pin {\n                pinctrl-single,pins = <0x154  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_21_gpio_pin: pinmux_P9_21_gpio_pin {\n                pinctrl-single,pins = <0x154  0x2F>; };     /* Mode 7, RxActive */\n            P9_21_gpio_pu_pin: pinmux_P9_21_gpio_pu_pin {\n                pinctrl-single,pins = <0x154  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_21_gpio_pd_pin: pinmux_P9_21_gpio_pd_pin {\n                pinctrl-single,pins = <0x154  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_21_spi_pin: pinmux_P9_21_spi_pin {\n                pinctrl-single,pins = <0x154  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_21_uart_pin: pinmux_P9_21_uart_pin {\n                pinctrl-single,pins = <0x154  0x31>; };     /* Mode 1, Pull-Up, RxActive */\n            P9_21_i2c_pin: pinmux_P9_21_i2c_pin {\n                pinctrl-single,pins = <0x154  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_21_pwm_pin: pinmux_P9_21_pwm_pin {\n                pinctrl-single,pins = <0x154  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n\n            /* P9_22 (ZCZ ball A17) */\n            P9_22_default_pin: pinmux_P9_22_default_pin {\n                pinctrl-single,pins = <0x150  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_22_gpio_pin: pinmux_P9_22_gpio_pin {\n                pinctrl-single,pins = <0x150  0x2F>; };     /* Mode 7, RxActive */\n            P9_22_gpio_pu_pin: pinmux_P9_22_gpio_pu_pin {\n                pinctrl-single,pins = <0x150  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_22_gpio_pd_pin: pinmux_P9_22_gpio_pd_pin {\n                pinctrl-single,pins = <0x150  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_22_spi_pin: pinmux_P9_22_spi_pin {\n                pinctrl-single,pins = <0x150  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_22_uart_pin: pinmux_P9_22_uart_pin {\n                pinctrl-single,pins = <0x150  0x31>; };     /* Mode 1, Pull-Up, RxActive */\n            P9_22_i2c_pin: pinmux_P9_22_i2c_pin {\n                pinctrl-single,pins = <0x150  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_22_pwm_pin: pinmux_P9_22_pwm_pin {\n                pinctrl-single,pins = <0x150  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n\n            /* P9_23 (ZCZ ball V14) */\n            P9_23_default_pin: pinmux_P9_23_default_pin {\n                pinctrl-single,pins = <0x044  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_23_gpio_pin: pinmux_P9_23_gpio_pin {\n                pinctrl-single,pins = <0x044  0x2F>; };     /* Mode 7, RxActive */\n            P9_23_gpio_pu_pin: pinmux_P9_23_gpio_pu_pin {\n                pinctrl-single,pins = <0x044  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_23_gpio_pd_pin: pinmux_P9_23_gpio_pd_pin {\n                pinctrl-single,pins = <0x044  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_23_pwm_pin: pinmux_P9_23_pwm_pin {\n                pinctrl-single,pins = <0x044  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_24 (ZCZ ball D15) */\n            P9_24_default_pin: pinmux_P9_24_default_pin {\n                pinctrl-single,pins = <0x184  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_24_gpio_pin: pinmux_P9_24_gpio_pin {\n                pinctrl-single,pins = <0x184  0x2F>; };     /* Mode 7, RxActive */\n            P9_24_gpio_pu_pin: pinmux_P9_24_gpio_pu_pin {\n                pinctrl-single,pins = <0x184  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_24_gpio_pd_pin: pinmux_P9_24_gpio_pd_pin {\n                pinctrl-single,pins = <0x184  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_24_uart_pin: pinmux_P9_24_uart_pin {\n                pinctrl-single,pins = <0x184  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_24_can_pin: pinmux_P9_24_can_pin {\n                pinctrl-single,pins = <0x184  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_24_i2c_pin: pinmux_P9_24_i2c_pin {\n                pinctrl-single,pins = <0x184  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n            P9_24_pruin_pin: pinmux_P9_24_pruin_pin {\n                pinctrl-single,pins = <0x184  0x36>; };     /* Mode 6, Pull-Up, RxActive */\n\n            /* P9_25 (ZCZ ball A14) Audio   */\n\n            /* P9_26 (ZCZ ball D16) */\n            P9_26_default_pin: pinmux_P9_26_default_pin {\n                pinctrl-single,pins = <0x180  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_26_gpio_pin: pinmux_P9_26_gpio_pin {\n                pinctrl-single,pins = <0x180  0x2F>; };     /* Mode 7, RxActive */\n            P9_26_gpio_pu_pin: pinmux_P9_26_gpio_pu_pin {\n                pinctrl-single,pins = <0x180  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_26_gpio_pd_pin: pinmux_P9_26_gpio_pd_pin {\n                pinctrl-single,pins = <0x180  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_26_uart_pin: pinmux_P9_26_uart_pin {\n                pinctrl-single,pins = <0x180  0x30>; };     /* Mode 0, Pull-Up, RxActive */\n            P9_26_can_pin: pinmux_P9_26_can_pin {\n                pinctrl-single,pins = <0x180  0x32>; };     /* Mode 2, Pull-Up, RxActive */\n            P9_26_i2c_pin: pinmux_P9_26_i2c_pin {\n                pinctrl-single,pins = <0x180  0x33>; };     /* Mode 3, Pull-Up, RxActive */\n            P9_26_pruin_pin: pinmux_P9_26_pruin_pin {\n                pinctrl-single,pins = <0x180  0x36>; };     /* Mode 6, Pull-Up, RxActive */\n\n            /* P9_27 (ZCZ ball C13) */\n            P9_27_default_pin: pinmux_P9_27_default_pin {\n                pinctrl-single,pins = <0x1a4  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_27_gpio_pin: pinmux_P9_27_gpio_pin {\n                pinctrl-single,pins = <0x1a4  0x2F>; };     /* Mode 7, RxActive */\n            P9_27_gpio_pu_pin: pinmux_P9_27_gpio_pu_pin {\n                pinctrl-single,pins = <0x1a4  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_27_gpio_pd_pin: pinmux_P9_27_gpio_pd_pin {\n                pinctrl-single,pins = <0x1a4  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_27_qep_pin: pinmux_P9_27_qep_pin {\n                pinctrl-single,pins = <0x1a4  0x21>; };     /* Mode 1, Pull-Down, RxActive */\n            P9_27_pruout_pin: pinmux_P9_27_pruout_pin {\n                pinctrl-single,pins = <0x1a4  0x25>; };     /* Mode 5, Pull-Down, RxActive */\n            P9_27_pruin_pin: pinmux_P9_27_pruin_pin {\n                pinctrl-single,pins = <0x1a4  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_28 (ZCZ ball C12) Audio   */\n            /* P9_29 (ZCZ ball B13) Audio   */\n\n            /* P9_30 (ZCZ ball D12) */\n            P9_30_default_pin: pinmux_P9_30_default_pin {\n                pinctrl-single,pins = <0x198  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_30_gpio_pin: pinmux_P9_30_gpio_pin {\n                pinctrl-single,pins = <0x198  0x2F>; };     /* Mode 7, RxActive */\n            P9_30_gpio_pu_pin: pinmux_P9_30_gpio_pu_pin {\n                pinctrl-single,pins = <0x198  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_30_gpio_pd_pin: pinmux_P9_30_gpio_pd_pin {\n                pinctrl-single,pins = <0x198  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_30_pwm_pin: pinmux_P9_30_pwm_pin {\n                pinctrl-single,pins = <0x198  0x21>; };     /* Mode 1, Pull-Down, RxActive */\n            P9_30_spi_pin: pinmux_P9_30_spi_pin {\n                pinctrl-single,pins = <0x198  0x23>; };     /* Mode 3, Pull-Down, RxActive */\n            P9_30_pruout_pin: pinmux_P9_30_pruout_pin {\n                pinctrl-single,pins = <0x198  0x25>; };     /* Mode 5, Pull-Down, RxActive */\n            P9_30_pruin_pin: pinmux_P9_30_pruin_pin {\n                pinctrl-single,pins = <0x198  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_31 (ZCZ ball A13) Audio   */\n\n            /* P9_32                VADC    */\n            /* P9_33 (ZCZ ball C8 ) AIN4    */\n            /* P9_34                AGND    */\n            /* P9_35 (ZCZ ball A8 ) AIN6    */\n            /* P9_36 (ZCZ ball B8 ) AIN5    */\n            /* P9_37 (ZCZ ball B7 ) AIN2    */\n            /* P9_38 (ZCZ ball A7 ) AIN3    */\n            /* P9_39 (ZCZ ball B6 ) AIN0    */\n            /* P9_40 (ZCZ ball C7 ) AIN1    */\n\n            /* P9_41 (ZCZ ball D14) */\n            P9_41_default_pin: pinmux_P9_41_default_pin {\n                pinctrl-single,pins = <0x1b4  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_41_gpio_pin: pinmux_P9_41_gpio_pin {\n                pinctrl-single,pins = <0x1b4  0x2F>; };     /* Mode 7, RxActive */\n            P9_41_gpio_pu_pin: pinmux_P9_41_gpio_pu_pin {\n                pinctrl-single,pins = <0x1b4  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_41_gpio_pd_pin: pinmux_P9_41_gpio_pd_pin {\n                pinctrl-single,pins = <0x1b4  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_41_timer_pin: pinmux_P9_41_timer_pin {\n                pinctrl-single,pins = <0x1b4  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n            P9_41_pruin_pin: pinmux_P9_41_pruin_pin {\n                pinctrl-single,pins = <0x1b4  0x25>; };     /* Mode 5, Pull-Down, RxActive */\n\n            /* P9_41.1              */\n            /* P9_91 (ZCZ ball D13) */\n            P9_91_default_pin: pinmux_P9_91_default_pin {\n                pinctrl-single,pins = <0x1a8  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_91_gpio_pin: pinmux_P9_91_gpio_pin {\n                pinctrl-single,pins = <0x1a8  0x2F>; };     /* Mode 7, RxActive */\n            P9_91_gpio_pu_pin: pinmux_P9_91_gpio_pu_pin {\n                pinctrl-single,pins = <0x1a8  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_91_gpio_pd_pin: pinmux_P9_91_gpio_pd_pin {\n                pinctrl-single,pins = <0x1a8  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_91_qep_pin: pinmux_P9_91_qep_pin {\n                pinctrl-single,pins = <0x1a8  0x21>; };     /* Mode 1, Pull-Down, RxActive */\n            P9_91_pruout_pin: pinmux_P9_91_pruout_pin {\n                pinctrl-single,pins = <0x1a8  0x25>; };     /* Mode 5, Pull-Down, RxActive */\n            P9_91_pruin_pin: pinmux_P9_91_pruin_pin {\n                pinctrl-single,pins = <0x1a8  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_42 (ZCZ ball C18) */\n            P9_42_default_pin: pinmux_P9_42_default_pin {\n                pinctrl-single,pins = <0x164  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_42_gpio_pin: pinmux_P9_42_gpio_pin {\n                pinctrl-single,pins = <0x164  0x2F>; };     /* Mode 7, RxActive */\n            P9_42_gpio_pu_pin: pinmux_P9_42_gpio_pu_pin {\n                pinctrl-single,pins = <0x164  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_42_gpio_pd_pin: pinmux_P9_42_gpio_pd_pin {\n                pinctrl-single,pins = <0x164  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_42_pwm_pin: pinmux_P9_42_pwm_pin {\n                pinctrl-single,pins = <0x164  0x20>; };     /* Mode 0, Pull-Down, RxActive */\n            P9_42_uart_pin: pinmux_P9_42_uart_pin {\n                pinctrl-single,pins = <0x164  0x21>; };     /* Mode 1, Pull-Down, RxActive */\n            P9_42_spics_pin: pinmux_P9_42_spics_pin {\n                pinctrl-single,pins = <0x164  0x22>; };     /* Mode 2, Pull-Down, RxActive */\n            P9_42_spiclk_pin: pinmux_P9_42_spiclk_pin {\n                pinctrl-single,pins = <0x164  0x24>; };     /* Mode 4, Pull-Down, RxActive */\n\n            /* P9_42.1              */\n            /* P9_92 (ZCZ ball B12) */\n            P9_92_default_pin: pinmux_P9_92_default_pin {\n                pinctrl-single,pins = <0x1a0  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_92_gpio_pin: pinmux_P9_92_gpio_pin {\n                pinctrl-single,pins = <0x1a0  0x2F>; };     /* Mode 7, RxActive */\n            P9_92_gpio_pu_pin: pinmux_P9_92_gpio_pu_pin {\n                pinctrl-single,pins = <0x1a0  0x37>; };     /* Mode 7, Pull-Up, RxActive */\n            P9_92_gpio_pd_pin: pinmux_P9_92_gpio_pd_pin {\n                pinctrl-single,pins = <0x1a0  0x27>; };     /* Mode 7, Pull-Down, RxActive */\n            P9_92_qep_pin: pinmux_P9_92_qep_pin {\n                pinctrl-single,pins = <0x1a0  0x21>; };     /* Mode 1, Pull-Down, RxActive */\n            P9_92_pruout_pin: pinmux_P9_92_pruout_pin {\n                pinctrl-single,pins = <0x1a0  0x25>; };     /* Mode 5, Pull-Down, RxActive */\n            P9_92_pruin_pin: pinmux_P9_92_pruin_pin {\n                pinctrl-single,pins = <0x1a0  0x26>; };     /* Mode 6, Pull-Down, RxActive */\n\n            /* P9_43                GND     */\n            /* P9_44                GND     */\n            /* P9_45                GND     */\n            /* P9_46                GND     */\n\n        };\n    };\n\n\n    /************************/\n    /* Pin Multiplexing     */\n    /************************/\n\n    fragment@1 {\n        target = <&ocp>;\n        __overlay__ {\n\n            /************************/\n            /* P8 Header            */\n            /************************/\n\n            P8_07_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"timer\";\n                pinctrl-0 = <&P8_07_default_pin>;\n                pinctrl-1 = <&P8_07_gpio_pin>;\n                pinctrl-2 = <&P8_07_gpio_pu_pin>;\n                pinctrl-3 = <&P8_07_gpio_pd_pin>;\n                pinctrl-4 = <&P8_07_timer_pin>;\n            };\n\n            P8_08_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"timer\";\n                pinctrl-0 = <&P8_08_default_pin>;\n                pinctrl-1 = <&P8_08_gpio_pin>;\n                pinctrl-2 = <&P8_08_gpio_pu_pin>;\n                pinctrl-3 = <&P8_08_gpio_pd_pin>;\n                pinctrl-4 = <&P8_08_timer_pin>;\n            };\n\n            P8_09_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"timer\";\n                pinctrl-0 = <&P8_09_default_pin>;\n                pinctrl-1 = <&P8_09_gpio_pin>;\n                pinctrl-2 = <&P8_09_gpio_pu_pin>;\n                pinctrl-3 = <&P8_09_gpio_pd_pin>;\n                pinctrl-4 = <&P8_09_timer_pin>;\n            };\n\n            P8_10_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"timer\";\n                pinctrl-0 = <&P8_10_default_pin>;\n                pinctrl-1 = <&P8_10_gpio_pin>;\n                pinctrl-2 = <&P8_10_gpio_pu_pin>;\n                pinctrl-3 = <&P8_10_gpio_pd_pin>;\n                pinctrl-4 = <&P8_10_timer_pin>;\n            };\n\n            P8_11_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pruout\", \"qep\";\n                pinctrl-0 = <&P8_11_default_pin>;\n                pinctrl-1 = <&P8_11_gpio_pin>;\n                pinctrl-2 = <&P8_11_gpio_pu_pin>;\n                pinctrl-3 = <&P8_11_gpio_pd_pin>;\n                pinctrl-4 = <&P8_11_pruout_pin>;\n                pinctrl-5 = <&P8_11_qep_pin>;\n            };\n\n            P8_12_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pruout\", \"qep\";\n                pinctrl-0 = <&P8_12_default_pin>;\n                pinctrl-1 = <&P8_12_gpio_pin>;\n                pinctrl-2 = <&P8_12_gpio_pu_pin>;\n                pinctrl-3 = <&P8_12_gpio_pd_pin>;\n                pinctrl-4 = <&P8_12_pruout_pin>;\n                pinctrl-5 = <&P8_12_qep_pin>;\n            };\n\n            P8_13_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P8_13_default_pin>;\n                pinctrl-1 = <&P8_13_gpio_pin>;\n                pinctrl-2 = <&P8_13_gpio_pu_pin>;\n                pinctrl-3 = <&P8_13_gpio_pd_pin>;\n                pinctrl-4 = <&P8_13_pwm_pin>;\n            };\n\n            P8_14_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P8_14_default_pin>;\n                pinctrl-1 = <&P8_14_gpio_pin>;\n                pinctrl-2 = <&P8_14_gpio_pu_pin>;\n                pinctrl-3 = <&P8_14_gpio_pd_pin>;\n                pinctrl-4 = <&P8_14_pwm_pin>;\n            };\n\n            P8_15_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pruin\", \"qep\";\n                pinctrl-0 = <&P8_15_default_pin>;\n                pinctrl-1 = <&P8_15_gpio_pin>;\n                pinctrl-2 = <&P8_15_gpio_pu_pin>;\n                pinctrl-3 = <&P8_15_gpio_pd_pin>;\n                pinctrl-4 = <&P8_15_pruin_pin>;\n                pinctrl-5 = <&P8_15_qep_pin>;\n            };\n\n            P8_16_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pruin\", \"qep\";\n                pinctrl-0 = <&P8_16_default_pin>;\n                pinctrl-1 = <&P8_16_gpio_pin>;\n                pinctrl-2 = <&P8_16_gpio_pu_pin>;\n                pinctrl-3 = <&P8_16_gpio_pd_pin>;\n                pinctrl-4 = <&P8_16_pruin_pin>;\n                pinctrl-5 = <&P8_16_qep_pin>;\n            };\n\n            P8_17_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P8_17_default_pin>;\n                pinctrl-1 = <&P8_17_gpio_pin>;\n                pinctrl-2 = <&P8_17_gpio_pu_pin>;\n                pinctrl-3 = <&P8_17_gpio_pd_pin>;\n                pinctrl-4 = <&P8_17_pwm_pin>;\n            };\n\n            P8_18_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\";\n                pinctrl-0 = <&P8_18_default_pin>;\n                pinctrl-1 = <&P8_18_gpio_pin>;\n                pinctrl-2 = <&P8_18_gpio_pu_pin>;\n                pinctrl-3 = <&P8_18_gpio_pd_pin>;\n            };\n\n            P8_19_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P8_19_default_pin>;\n                pinctrl-1 = <&P8_19_gpio_pin>;\n                pinctrl-2 = <&P8_19_gpio_pu_pin>;\n                pinctrl-3 = <&P8_19_gpio_pd_pin>;\n                pinctrl-4 = <&P8_19_pwm_pin>;\n            };\n\n            P8_26_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\";\n                pinctrl-0 = <&P8_26_default_pin>;\n                pinctrl-1 = <&P8_26_gpio_pin>;\n                pinctrl-2 = <&P8_26_gpio_pu_pin>;\n                pinctrl-3 = <&P8_26_gpio_pd_pin>;\n            };\n\n\n            /************************/\n            /* P9 Header            */\n            /************************/\n\n            P9_11_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"uart\";\n                pinctrl-0 = <&P9_11_default_pin>;\n                pinctrl-1 = <&P9_11_gpio_pin>;\n                pinctrl-2 = <&P9_11_gpio_pu_pin>;\n                pinctrl-3 = <&P9_11_gpio_pd_pin>;\n                pinctrl-4 = <&P9_11_uart_pin>;\n            };\n\n            P9_12_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\";\n                pinctrl-0 = <&P9_12_default_pin>;\n                pinctrl-1 = <&P9_12_gpio_pin>;\n                pinctrl-2 = <&P9_12_gpio_pu_pin>;\n                pinctrl-3 = <&P9_12_gpio_pd_pin>;\n            };\n\n            P9_13_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"uart\";\n                pinctrl-0 = <&P9_13_default_pin>;\n                pinctrl-1 = <&P9_13_gpio_pin>;\n                pinctrl-2 = <&P9_13_gpio_pu_pin>;\n                pinctrl-3 = <&P9_13_gpio_pd_pin>;\n                pinctrl-4 = <&P9_13_uart_pin>;\n            };\n\n            P9_14_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P9_14_default_pin>;\n                pinctrl-1 = <&P9_14_gpio_pin>;\n                pinctrl-2 = <&P9_14_gpio_pu_pin>;\n                pinctrl-3 = <&P9_14_gpio_pd_pin>;\n                pinctrl-4 = <&P9_14_pwm_pin>;\n            };\n\n            P9_15_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P9_15_default_pin>;\n                pinctrl-1 = <&P9_15_gpio_pin>;\n                pinctrl-2 = <&P9_15_gpio_pu_pin>;\n                pinctrl-3 = <&P9_15_gpio_pd_pin>;\n                pinctrl-4 = <&P9_15_pwm_pin>;\n            };\n\n            P9_16_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P9_16_default_pin>;\n                pinctrl-1 = <&P9_16_gpio_pin>;\n                pinctrl-2 = <&P9_16_gpio_pu_pin>;\n                pinctrl-3 = <&P9_16_gpio_pd_pin>;\n                pinctrl-4 = <&P9_16_pwm_pin>;\n            };\n\n            P9_17_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"spi\", \"i2c\", \"pwm\";\n                pinctrl-0 = <&P9_17_default_pin>;\n                pinctrl-1 = <&P9_17_gpio_pin>;\n                pinctrl-2 = <&P9_17_gpio_pu_pin>;\n                pinctrl-3 = <&P9_17_gpio_pd_pin>;\n                pinctrl-4 = <&P9_17_spi_pin>;\n                pinctrl-5 = <&P9_17_i2c_pin>;\n                pinctrl-6 = <&P9_17_pwm_pin>;\n            };\n\n            P9_18_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"spi\", \"i2c\", \"pwm\";\n                pinctrl-0 = <&P9_18_default_pin>;\n                pinctrl-1 = <&P9_18_gpio_pin>;\n                pinctrl-2 = <&P9_18_gpio_pu_pin>;\n                pinctrl-3 = <&P9_18_gpio_pd_pin>;\n                pinctrl-4 = <&P9_18_spi_pin>;\n                pinctrl-5 = <&P9_18_i2c_pin>;\n                pinctrl-6 = <&P9_18_pwm_pin>;\n            };\n\n            // I2C Pins\n            // P9_19_pinmux\n            // P9_20_pinmux\n\n            P9_21_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"spi\", \"uart\", \"i2c\", \"pwm\";\n                pinctrl-0 = <&P9_21_default_pin>;\n                pinctrl-1 = <&P9_21_gpio_pin>;\n                pinctrl-2 = <&P9_21_gpio_pu_pin>;\n                pinctrl-3 = <&P9_21_gpio_pd_pin>;\n                pinctrl-4 = <&P9_21_spi_pin>;\n                pinctrl-5 = <&P9_21_uart_pin>;\n                pinctrl-6 = <&P9_21_i2c_pin>;\n                pinctrl-7 = <&P9_21_pwm_pin>;\n            };\n\n            P9_22_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"spi\", \"uart\", \"i2c\", \"pwm\";\n                pinctrl-0 = <&P9_22_default_pin>;\n                pinctrl-1 = <&P9_22_gpio_pin>;\n                pinctrl-2 = <&P9_22_gpio_pu_pin>;\n                pinctrl-3 = <&P9_22_gpio_pd_pin>;\n                pinctrl-4 = <&P9_22_spi_pin>;\n                pinctrl-5 = <&P9_22_uart_pin>;\n                pinctrl-6 = <&P9_22_i2c_pin>;\n                pinctrl-7 = <&P9_22_pwm_pin>;\n            };\n\n            P9_23_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\";\n                pinctrl-0 = <&P9_23_default_pin>;\n                pinctrl-1 = <&P9_23_gpio_pin>;\n                pinctrl-2 = <&P9_23_gpio_pu_pin>;\n                pinctrl-3 = <&P9_23_gpio_pd_pin>;\n                pinctrl-4 = <&P9_23_pwm_pin>;\n            };\n\n            P9_24_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"uart\", \"can\", \"i2c\", \"pruin\";\n                pinctrl-0 = <&P9_24_default_pin>;\n                pinctrl-1 = <&P9_24_gpio_pin>;\n                pinctrl-2 = <&P9_24_gpio_pu_pin>;\n                pinctrl-3 = <&P9_24_gpio_pd_pin>;\n                pinctrl-4 = <&P9_24_uart_pin>;\n                pinctrl-5 = <&P9_24_can_pin>;\n                pinctrl-6 = <&P9_24_i2c_pin>;\n                pinctrl-7 = <&P9_24_pruin_pin>;\n            };\n\n\n            // Audio pin\n            // P9_25_pinmux\n\n            P9_26_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"uart\", \"can\", \"i2c\", \"pruin\";\n                pinctrl-0 = <&P9_26_default_pin>;\n                pinctrl-1 = <&P9_26_gpio_pin>;\n                pinctrl-2 = <&P9_26_gpio_pu_pin>;\n                pinctrl-3 = <&P9_26_gpio_pd_pin>;\n                pinctrl-4 = <&P9_26_uart_pin>;\n                pinctrl-5 = <&P9_26_can_pin>;\n                pinctrl-6 = <&P9_26_i2c_pin>;\n                pinctrl-7 = <&P9_26_pruin_pin>;\n            };\n\n            P9_27_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"qep\", \"pruout\", \"pruin\";\n                pinctrl-0 = <&P9_27_default_pin>;\n                pinctrl-1 = <&P9_27_gpio_pin>;\n                pinctrl-2 = <&P9_27_gpio_pu_pin>;\n                pinctrl-3 = <&P9_27_gpio_pd_pin>;\n                pinctrl-4 = <&P9_27_qep_pin>;\n                pinctrl-5 = <&P9_27_pruout_pin>;\n                pinctrl-6 = <&P9_27_pruin_pin>;\n            };\n\n            // Audio pins\n            // P9_28_pinmux\n            // P9_29_pinmux\n\n            P9_30_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\", \"spi\", \"pruout\", \"pruin\";\n                pinctrl-0 = <&P9_30_default_pin>;\n                pinctrl-1 = <&P9_30_gpio_pin>;\n                pinctrl-2 = <&P9_30_gpio_pu_pin>;\n                pinctrl-3 = <&P9_30_gpio_pd_pin>;\n                pinctrl-4 = <&P9_30_pwm_pin>;\n                pinctrl-5 = <&P9_30_spi_pin>;\n                pinctrl-6 = <&P9_30_pruout_pin>;\n                pinctrl-7 = <&P9_30_pruin_pin>;\n            };\n\n            // Audio pin\n            // P9_31_pinmux\n\n            P9_41_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"timer\", \"pruin\";\n                pinctrl-0 = <&P9_41_default_pin>;\n                pinctrl-1 = <&P9_41_gpio_pin>;\n                pinctrl-2 = <&P9_41_gpio_pu_pin>;\n                pinctrl-3 = <&P9_41_gpio_pd_pin>;\n                pinctrl-4 = <&P9_41_timer_pin>;\n                pinctrl-5 = <&P9_41_pruin_pin>;\n            };\n\n            P9_91_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"qep\", \"pruout\", \"pruin\";\n                pinctrl-0 = <&P9_91_default_pin>;\n                pinctrl-1 = <&P9_91_gpio_pin>;\n                pinctrl-2 = <&P9_91_gpio_pu_pin>;\n                pinctrl-3 = <&P9_91_gpio_pd_pin>;\n                pinctrl-4 = <&P9_91_qep_pin>;\n                pinctrl-5 = <&P9_91_pruout_pin>;\n                pinctrl-6 = <&P9_91_pruin_pin>;\n            };\n\n            P9_42_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"pwm\", \"uart\", \"spics\", \"spiclk\";\n                pinctrl-0 = <&P9_42_default_pin>;\n                pinctrl-1 = <&P9_42_gpio_pin>;\n                pinctrl-2 = <&P9_42_gpio_pu_pin>;\n                pinctrl-3 = <&P9_42_gpio_pd_pin>;\n                pinctrl-4 = <&P9_42_pwm_pin>;\n                pinctrl-5 = <&P9_42_uart_pin>;\n                pinctrl-6 = <&P9_42_spics_pin>;\n                pinctrl-7 = <&P9_42_spiclk_pin>;\n            };\n\n            P9_92_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\", \"gpio\", \"gpio_pu\", \"gpio_pd\", \"qep\", \"pruout\", \"pruin\";\n                pinctrl-0 = <&P9_92_default_pin>;\n                pinctrl-1 = <&P9_92_gpio_pin>;\n                pinctrl-2 = <&P9_92_gpio_pu_pin>;\n                pinctrl-3 = <&P9_92_gpio_pd_pin>;\n                pinctrl-4 = <&P9_92_qep_pin>;\n                pinctrl-5 = <&P9_92_pruout_pin>;\n                pinctrl-6 = <&P9_92_pruin_pin>;\n            };\n        };\n    };\n    \n    fragment@2 {\n        target = <&ocp>;\n        __overlay__ {\n\n            // !!!WARNING!!!\n            // gpio-of-helper &gpio pointers are off-by-one vs. the hardware:\n            //   hardware GPIO bank 0 = &gpio1\n            cape-universal {\n                compatible = \"gpio-of-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\";\n                pinctrl-0 = <>;\n\n                P8_07 {\n                    gpio-name = \"P8_07\";\n                    gpio = <&gpio3 2 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_08 {\n                    gpio-name = \"P8_08\";\n                    gpio = <&gpio3 3 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_09 {\n                    gpio-name = \"P8_09\";\n                    gpio = <&gpio3 5 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_10 {\n                    gpio-name = \"P8_10\";\n                    gpio = <&gpio3 4 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_11 {\n                    gpio-name = \"P8_11\";\n                    gpio = <&gpio2 13 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_12 {\n                    gpio-name = \"P8_12\";\n                    gpio = <&gpio2 12 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_13 {\n                    gpio-name = \"P8_13\";\n                    gpio = <&gpio1 23 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_14 {\n                    gpio-name = \"P8_14\";\n                    gpio = <&gpio1 26 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_15 {\n                    gpio-name = \"P8_15\";\n                    gpio = <&gpio2 15 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_16 {\n                    gpio-name = \"P8_16\";\n                    gpio = <&gpio2 14 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_17 {\n                    gpio-name = \"P8_17\";\n                    gpio = <&gpio1 27 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_18 {\n                    gpio-name = \"P8_18\";\n                    gpio = <&gpio3 1 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_19 {\n                    gpio-name = \"P8_19\";\n                    gpio = <&gpio1 22 0>;\n                    input;\n                    dir-changeable;\n                };\n                P8_26 {\n                    gpio-name = \"P8_26\";\n                    gpio = <&gpio2 29 0>;\n                    input;\n                    dir-changeable;\n                };\n\n\n                P9_11 {\n                    gpio-name = \"P9_11\";\n                    gpio = <&gpio1 30 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_12 {\n                    gpio-name = \"P9_12\";\n                    gpio = <&gpio2 28 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_13 {\n                    gpio-name = \"P9_13\";\n                    gpio = <&gpio1 31 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_14 {\n                    gpio-name = \"P9_14\";\n                    gpio = <&gpio2 18 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_15 {\n                    gpio-name = \"P9_15\";\n                    gpio = <&gpio2 16 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_16 {\n                    gpio-name = \"P9_16\";\n                    gpio = <&gpio2 19 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_17 {\n                    gpio-name = \"P9_17\";\n                    gpio = <&gpio1 5 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_18 {\n                    gpio-name = \"P9_18\";\n                    gpio = <&gpio1 4 0>;\n                    input;\n                    dir-changeable;\n                };\n\n                // I2C pins\n                // P9_19\n                // P9_20\n\n                P9_21 {\n                    gpio-name = \"P9_21\";\n                    gpio = <&gpio1 3 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_22 {\n                    gpio-name = \"P9_22\";\n                    gpio = <&gpio1 2 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_23 {\n                    gpio-name = \"P9_23\";\n                    gpio = <&gpio2 17 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_24 {\n                    gpio-name = \"P9_24\";\n                    gpio = <&gpio1 15 0>;\n                    input;\n                    dir-changeable;\n                };\n\n                // Audio pin\n                // P9_25\n\n                P9_26 {\n                    gpio-name = \"P9_26\";\n                    gpio = <&gpio1 14 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_27 {\n                    gpio-name = \"P9_27\";\n                    gpio = <&gpio4 19 0>;\n                    input;\n                    dir-changeable;\n                };\n\n                // Audio pins\n                // P9_28\n                // P9_29\n\n                P9_30 {\n                    gpio-name = \"P9_30\";\n                    gpio = <&gpio4 16 0>;\n                    input;\n                    dir-changeable;\n                };\n\n                // Audio pin\n                // P9_31\n\n                P9_41 {\n                    gpio-name = \"P9_41\";\n                    gpio = <&gpio1 20 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_91 {\n                    gpio-name = \"P9_91\";\n                    gpio = <&gpio4 20 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_42 {\n                    gpio-name = \"P9_42\";\n                    gpio = <&gpio1 7 0>;\n                    input;\n                    dir-changeable;\n                };\n                P9_92 {\n                    gpio-name = \"P9_92\";\n                    gpio = <&gpio4 18 0>;\n                    input;\n                    dir-changeable;\n                };\n            };\n        };\n    };\n\n\n\n    /************************/\n    /* UARTs                */\n    /************************/\n\n    fragment@10 {\n        target = <&uart2>;  /* really uart1 */\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@11 {\n        target = <&uart3>;  /* really uart2 */\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@12 {\n        target = <&uart5>;  /* really uart4 */\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n//    /* UART 5 only available on LCD/HDMI pins */\n//    fragment@13 {\n//        target = <&uart6>;  /* really uart5 */\n//        __overlay__ {\n//            status = \"okay\";\n//            pinctrl-names = \"default\";\n//            pinctrl-0 = <>; \n//        };\n//    };\n\n    /************************/\n    /* Timers / PWM         */\n    /************************/\n\n    fragment@20 {\n        target = <&epwmss0>;\n        __overlay__ {\n            status = \"okay\";\n        };\n    };\n\n    fragment@21 {\n        target = <&ehrpwm0>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@22 {\n        target = <&ecap0>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@23 {\n        target = <&epwmss1>;\n        __overlay__ {\n            status = \"okay\";\n        };\n    };\n\n    fragment@24 {\n        target = <&ehrpwm1>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@25 {\n        target = <&epwmss2>;\n        __overlay__ {\n            status = \"okay\";\n        };\n    };\n\n    fragment@26 {\n        target = <&ehrpwm2>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    fragment@27 {\n        target = <&ecap2>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n        };\n    };\n\n    /************************/\n    /* I2C / SPI            */\n    /************************/\n\n\n    fragment@30 {\n        target = <&i2c1>;   /* i2c1 is numbered correctly */\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n\n            /* this is the configuration part */\n            clock-frequency = <100000>;\n\n            #address-cells = <1>;\n            #size-cells = <0>;\n\n            /* add any i2c devices on the bus here */\n\n            // commented out example of a touchscreen (taken from BB-BONE-LCD7-01-00A4) */\n            // maxtouch@4a {\n            //  compatible = \"mXT224\";\n            //  reg = <0x4a>;\n            //  interrupt-parent = <&gpio4>;\n            //  interrupts = <19 0x0>;\n            //  atmel,irq-gpio = <&gpio4 19 0>;\n            // };\n        };\n    };\n\n    fragment@31 {\n        target = <&spi0>;   /* spi0 is numbered correctly */\n        __overlay__ {\n            #address-cells = <1>;\n            #size-cells = <0>;\n\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n\n            spi0channel@0 {\n                #address-cells = <1>;\n                #size-cells = <0>;\n\n                compatible = \"spidev\";\n\n                reg = <0>;\n                spi-max-frequency = <16000000>;\n                spi-cpha;\n            };\n\n\n            spi0channel@1 {\n                #address-cells = <1>;\n                #size-cells = <0>;\n\n                compatible = \"spidev\";\n\n                reg = <1>;\n                spi-max-frequency = <16000000>;\n            };\n        };\n    };\n\n    fragment@32 {\n        target = <&spi1>;   /* spi1 is numbered correctly */\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>; \n\n            #address-cells = <1>;\n            #size-cells = <0>;\n\n            spi1channel@0 {\n                #address-cells = <1>;\n                #size-cells = <0>;\n\n                compatible = \"spidev\";\n\n                reg = <0>;\n                spi-max-frequency = <16000000>;\n                spi-cpha;\n            };\n\n            spi1channel@1 {\n                #address-cells = <1>;\n                #size-cells = <0>;\n\n                compatible = \"spidev\";\n\n                reg = <1>;\n                spi-max-frequency = <16000000>;\n            };\n        };\n    };\n\n    fragment@33 {\n        target = <&dcan0>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>;\n        };\n    };\n\n    fragment@34 {\n        target = <&dcan1>;\n        __overlay__ {\n            status = \"okay\";\n            pinctrl-names = \"default\";\n            pinctrl-0 = <>;\n        };\n    };\n\n\n    /************************/\n    /* PRUSS                */\n    /************************/\n\n    fragment@40 {\n        target = <&pruss>;\n        __overlay__ {\n            status = \"okay\";\n        };\n    };\n\n};\n"
  },
  {
    "path": "dts/bspm_template.dts",
    "content": "/*\n * This is a template-generated file from BoneScript\n */\n\n/dts-v1/;\n/plugin/;\n\n/{\n    compatible = \"ti,beaglebone\", \"ti,beaglebone-black\";\n    part_number = \"BS_PINMODE_!PIN_KEY!_!DATA!\";\n\n    exclusive-use =\n        \"!PIN_DOT_KEY!\",\n        \"!PIN_FUNCTION!\";\n\n    fragment@0 {\n        target = <&am33xx_pinmux>;\n        __overlay__ {\n            bs_pinmode_!PIN_KEY!_!DATA!: pinmux_bs_pinmode_!PIN_KEY!_!DATA! {\n                pinctrl-single,pins = <!PIN_OFFSET! !DATA!>;\n            };\n        };\n    };\n\n    fragment@1 {\n        target = <&ocp>;\n        __overlay__ {\n            bs_pinmode_!PIN_KEY!_!DATA!_pinmux {\n                compatible = \"bone-pinmux-helper\";\n                status = \"okay\";\n                pinctrl-names = \"default\";\n                pinctrl-0 = <&bs_pinmode_!PIN_KEY!_!DATA!>;\n            };\n        };\n    };\n};\n"
  },
  {
    "path": "dts/bspwm_template.dts",
    "content": "/*\n * Copyright (C) 2013 CircuitCo\n * Copyright (C) 2013 Texas Instruments\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License version 2 as\n * published by the Free Software Foundation.\n *\n * This is a template-generated file from BoneScript\n */\n/dts-v1/;\n/plugin/;\n\n/ {\n\tcompatible = \"ti,beaglebone\", \"ti,beaglebone-black\";\n\n\t/* identification */\n\tpart-number = \"BS_PWM_!PIN_KEY!_!DATA!\";\n\n\t/* state the resources this cape uses */\n\texclusive-use =\n\t\t/* the pin header uses */\n\t\t\"!PIN_DOT_KEY!\",\n\t\t/* the hardware IP uses */\n\t\t\"!PIN_FUNCTION!\";\n\n\tfragment@0 {\n\t\ttarget = <&am33xx_pinmux>;\n\t\t__overlay__ {\n\t\t\tbs_pwm_!PIN_KEY!_!DATA!: pinmux_bs_pwm_!PIN_KEY!_!DATA! {\n\t\t\t\tpinctrl-single,pins = <!PIN_OFFSET! !DATA!>;\n\t\t\t};\n\t\t};\n\t};\n\n\tfragment@1 {\n\t\ttarget = <&ocp>;\n\t\t__overlay__ {\n\t\t\tbs_pwm_test_!PIN_KEY! {\n\t\t\t\tcompatible\t= \"pwm_test\";\n\t\t\t\tpwms \t\t= <&!PWM_MODULE! !PWM_INDEX! !DUTY_CYCLE! 1>;\n\t\t\t\tpwm-names \t= \"PWM_!PIN_KEY!\";\n\n\t\t\t\tpinctrl-names\t= \"default\";\n\t\t\t\tpinctrl-0\t= <&bs_pwm_!PIN_KEY!_!DATA!>;\n\n\t\t\t\tenabled\t\t= <1>;\n\t\t\t\tduty\t\t= <0>;\n\t\t\t\tstatus \t\t= \"okay\";\n\t\t\t};\n\t\t};\n\t};\n};\n"
  },
  {
    "path": "etc/avahi/services/bone101.service",
    "content": "<?xml version=\\\"1.0\\\" standalone='no'?><!--*-nxml-*-->\n<!DOCTYPE service-group SYSTEM \\\"avahi-service.dtd\\\">\n<!-- See avahi.service(5) for more information about this configuration file -->\n<service-group>\n  <name replace-wildcards=\\\"yes\\\">BeagleBone 101 Getting Started for %h</name>\n  <service>\n    <type>_http._tcp</type>\n    <port>80</port>\n  </service>\n</service-group>\n"
  },
  {
    "path": "etc/default/cloud9",
    "content": "NODE_PATH=/usr/lib/node_modules\nHOME=/root\nPORT=3000\n"
  },
  {
    "path": "etc/default/node",
    "content": "NODE_PATH=/usr/lib/node_modules\nSERVER_DIR=/usr/share/bone101\n"
  },
  {
    "path": "etc/profile.d/node.sh",
    "content": "#!/bin/sh\nexport NODE_PATH=/usr/lib/node_modules\n"
  },
  {
    "path": "lint-config.json",
    "content": "{\n    \"indent_size\": 4,\n    \"indent_char\": \" \",\n    \"indent_with_tabs\": false,\n    \"eol\": \"\\n\",\n    \"end_with_newline\": false,\n    \"indent_level\": 0,\n    \"preserve_newlines\": true,\n    \"max_preserve_newlines\": 10,\n    \"space_in_paren\": false,\n    \"space_in_empty_paren\": false,\n    \"jslint_happy\": true,\n    \"space_after_anon_function\": false,\n    \"brace_style\": \"collapse\",\n    \"unindent_chained_methods\": false,\n    \"break_chained_methods\": false,\n    \"keep_array_indentation\": false,\n    \"unescape_strings\": false,\n    \"wrap_line_length\": 0,\n    \"e4x\": false,\n    \"comma_first\": false,\n    \"operator_position\": \"before-newline\"\n}\n"
  },
  {
    "path": "main.js",
    "content": "module.exports = process.env.BONESCRIPT_COV ?\n    require('./src-cov/index') :\n    require('./src/index');"
  },
  {
    "path": "package.json",
    "content": "{\n  \"author\": {\n    \"name\": \"Jason Kridner\",\n    \"email\": \"jkridner@beagleboard.org\",\n    \"url\": \"http://jkridner.wordpress.com\"\n  },\n  \"name\": \"bonescript\",\n  \"description\": \"Physical computing library for embedded Linux\",\n  \"keywords\": [\n    \"embedded\",\n    \"linux\",\n    \"beagleboard\",\n    \"beaglebone\",\n    \"physical\",\n    \"gpio\",\n    \"arduino\"\n  ],\n  \"version\": \"0.7.4-beta1\",\n  \"homepage\": \"http://beagleboard.org/bonescript\",\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/jadonk/bonescript\"\n  },\n  \"main\": \"main\",\n  \"types\": \"./src/index.d.ts\",\n  \"engines\": {\n    \"node\": \">= 6.0.0\"\n  },\n  \"dependencies\": {\n    \"chokidar\": \"2.0.3\",\n    \"express\": \"4.13.4\",\n    \"socket.io\": \"1.4.5\",\n    \"systemd\": \"0.3.1\",\n    \"winston\": \"2.1.1\",\n    \"@types/verror\": \"latest\",\n    \"shelljs\": \"0.8.2\"\n  },\n  \"optionalDependencies\": {\n    \"serialport\": \"6.0.5\",\n    \"@types/serialport\": \"latest\",\n    \"i2c\": \"0.2.3\",\n    \"epoll\": \"0.1.18\",\n    \"pi-spi\": \"1.0.2\",\n    \"roboticscape\": \"0.0.8\",\n    \"ffi\": \"2.2.0\"\n  },\n  \"devDependencies\": {\n    \"coveralls\": \"~3.0.1\",\n    \"js-beautify\": \"^1.7.5\",\n    \"jscoverage\": \"~0.6.0\",\n    \"nodeunit\": \"^0.11.2\",\n    \"socket.io-client\": \"1.4.5\"\n  },\n  \"scripts\": {\n    \"start\": \"node server.js\",\n    \"test\": \"NODE_PATH=.. nodeunit test\",\n    \"beautify\": \"NODE_PATH=.. js-beautify --config lint-config.json -r -f *.js src/*.js test/*.js\",\n    \"coveralls\": \"NODE_PATH=.. jscoverage src && NODE_PATH=.. BONESCRIPT_COV=1 nodeunit --reporter=lcov test | coveralls\"\n  }\n}\n"
  },
  {
    "path": "server.js",
    "content": "var b = require('bonescript');\nvar util = require('util');\nvar fs = require('fs');\nvar configFile = '/etc/default/bonescript';\nvar server;\n//read the configuration from configFile\nfs.readFile(configFile, {\n    encoding: 'ascii'\n}, function read(err, data) {\n    if (err) {\n        server = b.serverStart(); //start server with default settings\n    } else {\n        data = JSON.parse(data); //start server with saved config\n        server = b.serverStart(data.port, data.directory, {\n            data: data.passphrase,\n            hash: data.hash\n        });\n    }\n    onServerStart();\n});\n\nfunction onServerStart() {\n    server.on('server$listening', serverListening);\n    server.on('server$error', serverError);\n    server.on('server$connection', serverConnection);\n}\n\nfunction serverListening() {\n    if (debug) winston.debug('Server listening');\n}\n\nfunction serverError(error) {\n    if (debug) winston.debug('Server error: ' + JSON.stringify(error));\n}\n\nfunction serverConnection(connection) {\n    if (debug) winston.debug('Server connection: ' + connection);\n}"
  },
  {
    "path": "src/autorun.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\n//\n//\nvar fs = require('fs');\nvar child_process = require('child_process');\nvar events = require('events');\nvar my = require('./my');\nvar winston = my.require('winston');\nvar chokidar = my.require('chokidar');\n\nvar debug = process.env.DEBUG ? true : false;\nvar apps = {};\nvar watchers = [];\nvar emitter = new events.EventEmitter();\n\nvar autorun = function (dir) {\n    var ar = dir || '/var/lib/cloud9/autorun';\n\n    winston.info('Starting bonescript autorun service');\n\n    fs.exists(ar, arExists);\n\n    function arExists(exists) {\n        if (!exists) fs.mkdir(ar, arWatch);\n        else fs.readdir(ar, arFound);\n    }\n\n    function arFound(err, files) {\n        if (err) {\n            winston.err('Error reading directory: ' + err);\n            arWatch();\n            return;\n        }\n        var i = 0;\n        arTestNext();\n\n        function arTestNext() {\n            if (i == files.length) {\n                arWatch();\n                return;\n            }\n            if (debug) winston.debug(\"arTestNext: files[\" + i + \"] = \" + ar + '/' + files[i]);\n            appStart(ar + '/' + files[i]);\n            i++;\n            arTestNext();\n        }\n    }\n\n    function appStart(file) {\n        if (apps[file]) {\n            if (debug) winston.debug(\"already started: \" + file);\n            return;\n        }\n        appTest();\n\n        function appTest() {\n            fs.exists(file, appExists);\n        }\n\n        function appExists(exists) {\n            function onStdout(data) {\n                winston.info('stdout (' + file + '): ' + data);\n            }\n\n            function onStderr(data) {\n                winston.info('stderr (' + file + '):' + data);\n            }\n\n            if (exists) {\n                if (typeof apps[file] != 'undefined') {\n                    winston.info('already running: ' + file);\n                    return;\n                }\n\n                if (file.match(/\\.js$/)) {\n                    winston.info('start: ' + file);\n                    apps[file] = child_process.spawn(process.argv[0], [file]);\n                    apps[file].on('close', appClosed);\n                    apps[file].stdout.on('data', onStdout);\n                    apps[file].stderr.on('data', onStderr);\n                } else if (file.match(/\\.py$/)) {\n                    winston.info('start: ' + file);\n                    apps[file] = child_process.spawn('/usr/bin/python', [file]);\n                    apps[file].on('close', appClosed);\n                    apps[file].stdout.on('data', onStdout);\n                    apps[file].stderr.on('data', onStderr);\n                } else if (file.match(/\\.sh$/)) {\n                    winston.info('start: ' + file);\n                    apps[file] = child_process.spawn('/bin/bash', [file]);\n                    apps[file].on('close', appClosed);\n                    apps[file].stdout.on('data', onStdout);\n                    apps[file].stderr.on('data', onStderr);\n                } else if (file.match(/\\.ino$/)) {\n                    winston.info('start: ' + file);\n                    apps[file] = child_process.spawn('/usr/bin/make', [\n                        \"-f\",\n                        \"/var/lib/cloud9/extras/Userspace-Arduino/Makefile\",\n                        \"TARGET=\" + file.replace(/\\.ino$/, ''),\n                        \"LOCAL_INO_SRCS=\" + file,\n                        \"LOCAL_C_SRCS=\",\n                        \"LOCAL_CPP_SRCS=\",\n                        \"LOCAL_PDE_SRCS=\",\n                        \"LOCAL_AS_SRCS=\",\n                        \"COMMON_DEPS=\"\n                    ], {\n                        'cwd': ar\n                    });\n                    apps[file].on('close', appClosed);\n                    apps[file].stdout.on('data', onStdout);\n                    apps[file].stderr.on('data', onStderr);\n                }\n                emitter.emit('start', file);\n            }\n        }\n\n        function appClosed(code, signal) {\n            winston.info(\"closed: \" + file);\n            delete apps[file];\n            emitter.emit('closed', file);\n            //setTimeout(appTest, 1000);\n        }\n    }\n\n    function arWatch() {\n        if (debug) winston.debug(\"arWatch: \" + ar);\n        var w = chokidar.watch(ar, {\n            persistent: true\n        });\n        w.on('add', arAdd);\n        w.on('change', arChange);\n        w.on('unlink', appStop);\n        watchers.push(w);\n    }\n\n    function arAdd(filename) {\n        winston.info('add: ' + filename);\n        appStart(filename);\n    }\n\n    function arChange(filename) {\n        winston.info('change: ' + filename);\n        appStop(filename);\n        appStart(filename);\n    }\n\n    function appStop(file) {\n        if (debug) {\n            for (var x in apps) {\n                winston.debug('running: ' + x);\n            }\n        }\n        if (typeof apps[file] != 'undefined') {\n            emitter.emit('stop', file);\n            winston.info('stop: ' + file + ' (pid: ' + apps[file].pid + ')');\n            apps[file].kill('SIGTERM');\n        } else {\n            winston.info('already stopped: ' + file);\n        }\n    }\n\n    return ({\n        getApps: function () {\n            return (apps);\n        },\n        getEmitter: function () {\n            return (emitter);\n        },\n        stop: function () {\n            for (var app in apps) {\n                appStop(app);\n            }\n            for (var w in watchers) {\n                watchers[w].close();\n            }\n        }\n    });\n};\n\nmodule.exports = {\n    autorun: autorun\n};"
  },
  {
    "path": "src/bone.js",
    "content": "// Database of pins\n// pinIndex is an array whose elements describe each pin.  The order is\n//    USR LEDs, P8 header pins, then P9 header\n// pins is an object whose keys are the pinIndex keys, e.g. P9_14.\n// uarts and i2c are objects describing the serial ports and i2c buses.\n\n\n\nvar pinIndex = [{\n        \"name\": \"USR0\",\n        \"gpio\": 53,\n        \"led\": \"beaglebone:green:usr0\",\n        \"mux\": \"gpmc_a5\",\n        \"key\": \"USR0\",\n        \"muxRegOffset\": \"0x054\",\n        \"options\": [\n            \"gpmc_a5\",\n            \"gmii2_txd0\",\n            \"rgmii2_td0\",\n            \"rmii2_txd0\",\n            \"gpmc_a21\",\n            \"pr1_mii1_rxd3\",\n            \"eqep1b_in\",\n            \"gpio1_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V15\",\n            \"BSM\": \"P13\"\n        },\n        \"ai\": {\n            \"gpio\": 81,\n            \"ball\": {\n                \"abc\": [\n                    \"AF6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1528\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d13\",\n                \"vin1b_d2\",\n                \"\",\n                \"\",\n                \"vout3_d10\",\n                \"gpmc_a25\",\n                \"\",\n                \"\",\n                \"\",\n                \"kbd_row7\",\n                \"pr1_edc_sync1_out\",\n                \"\",\n                \"pr1_pru0_gpi10\",\n                \"pr1_pru0_gpo10\",\n                \"gpio3_17\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"USR1\",\n        \"gpio\": 54,\n        \"led\": \"beaglebone:green:usr1\",\n        \"mux\": \"gpmc_a6\",\n        \"key\": \"USR1\",\n        \"muxRegOffset\": \"0x058\",\n        \"options\": [\n            \"gpmc_a6\",\n            \"gmii2_txclk\",\n            \"rgmii2_tclk\",\n            \"mmc2_dat4\",\n            \"gpmc_a22\",\n            \"pr1_mii1_rxd2\",\n            \"eqep1_index\",\n            \"gpio1_22\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U15\",\n            \"BSM\": \"T14\"\n        },\n        \"ai\": {\n            \"gpio\": 133,\n            \"ball\": {\n                \"abc\": [\n                    \"J11\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16C0\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr3\",\n                \"mcasp6_axr3\",\n                \"\",\n                \"uart6_rtsn\",\n                \"\",\n                \"\",\n                \"vout2_d3\",\n                \"\",\n                \"vin4a_d3\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio5_5\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"USR2\",\n        \"gpio\": 55,\n        \"led\": \"beaglebone:green:usr2\",\n        \"mux\": \"gpmc_a7\",\n        \"key\": \"USR2\",\n        \"muxRegOffset\": \"0x05c\",\n        \"options\": [\n            \"gpmc_a7\",\n            \"gmii2_rxclk\",\n            \"rgmii2_rclk\",\n            \"mmc2_dat5\",\n            \"gpmc_a23\",\n            \"pr1_mii1_rxd1\",\n            \"eqep1_strobe\",\n            \"gpio1_23\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T15\",\n            \"BSM\": \"R14\"\n        },\n        \"ai\": {\n            \"gpio\": 79,\n            \"ball\": {\n                \"abc\": [\n                    \"AG5\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1520\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d11\",\n                \"vin1b_d4\",\n                \"\",\n                \"\",\n                \"vout3_d12\",\n                \"gpmc_a23\",\n                \"\",\n                \"\",\n                \"\",\n                \"kbd_row5\",\n                \"pr1_edc_latch1_in\",\n                \"\",\n                \"pr1_pru0_gpi8\",\n                \"pr1_pru0_gpo8\",\n                \"gpio3_15\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"USR3\",\n        \"gpio\": 56,\n        \"led\": \"beaglebone:green:usr3\",\n        \"mux\": \"gpmc_a8\",\n        \"key\": \"USR3\",\n        \"muxRegOffset\": \"0x060\",\n        \"options\": [\n            \"gpmc_a8\",\n            \"gmii2_rxd3\",\n            \"rgmii2_rd3\",\n            \"mmc2_dat6\",\n            \"gpmc_a24\",\n            \"pr1_mii1_rxd0\",\n            \"mcasp0_aclkx\",\n            \"gpio1_24\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V16\",\n            \"BSM\": \"P14\"\n        },\n        \"ai\": {\n            \"gpio\": 78,\n            \"ball\": {\n                \"abc\": [\n                    \"AG3\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x151C\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d10\",\n                \"vin1b_d5\",\n                \"\",\n                \"\",\n                \"vout3_d13\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"kbd_row4\",\n                \"pr1_edc_latch0_in\",\n                \"\",\n                \"pr1_pru0_gpi7\",\n                \"pr1_pru0_gpo7\",\n                \"gpio3_14\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"USR4\",\n        \"led\": \"beaglebone:green:usr4\",\n        \"key\": \"USR4\",\n        \"ai\": {\n            \"gpio\": 71,\n            \"ball\": {\n                \"abc\": [\n                    \"AH6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1500\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d3\",\n                \"\",\n                \"\",\n                \"vout3_d4\",\n                \"vout3_d20\",\n                \"uart8_rtsn\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"eCAP1_in_PWM1_out\",\n                \"\",\n                \"pr1_pru0_gpi0\",\n                \"pr1_pru0_gpo0\",\n                \"gpio3_7\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"DGND\",\n        \"key\": [\n            \"P8_1\",\n            \"P8_2\",\n            \"P9_1\",\n            \"P9_2\",\n            \"P9_43\",\n            \"P9_44\",\n            \"P9_45\",\n            \"P9_46\",\n            \"P1_15\",\n            \"P1_16\",\n            \"P1_22\",\n            \"P2_15\",\n            \"P2_21\",\n            \"E1_1\",\n            \"E2_1\",\n            \"E3_1\",\n            \"E4_1\",\n            \"S1_1_1\",\n            \"S1_2_1\",\n            \"UT0_1\",\n            \"UT1_1\",\n            \"UT5_1\",\n            \"DSM2_2\",\n            \"I2C_1\",\n            \"GPS_2\",\n            \"GPS_6\",\n            \"GP0_1\",\n            \"GP1_1\"\n        ]\n    },\n    {\n        \"name\": \"GPIO1_6\",\n        \"gpio\": 38,\n        \"mux\": \"gpmc_ad6\",\n        \"eeprom\": 26,\n        \"key\": \"P8_3\",\n        \"universalName\": [\n            \"ocp:P8_03_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x018\",\n        \"options\": [\n            \"gpmc_ad6\",\n            \"mmc1_dat6\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_6\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R9\",\n            \"BSM\": \"P4\"\n        },\n        \"ai\": {\n            \"gpio\": 24,\n            \"ball\": {\n                \"abc\": [\n                    \"AB8\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x179C\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat6\",\n                \"spi4_d0\",\n                \"uart10_ctsn\",\n                \"\",\n                \"vin2b_de1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_hsync0\",\n                \"ehrpwm3_tripzone_input\",\n                \"pr2_mii1_rxd1\",\n                \"pr2_pru0_gpi10\",\n                \"pr2_pru0_gpo10\",\n                \"gpio1_24\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_7\",\n        \"gpio\": 39,\n        \"mux\": \"gpmc_ad7\",\n        \"eeprom\": 27,\n        \"key\": \"P8_4\",\n        \"universalName\": [\n            \"ocp:P8_04_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x01c\",\n        \"options\": [\n            \"gpmc_ad7\",\n            \"mmc1_dat7\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_7\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T9\",\n            \"BSM\": \"R4\"\n        },\n        \"ai\": {\n            \"gpio\": 25,\n            \"ball\": {\n                \"abc\": [\n                    \"AB5\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x17A0\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat7\",\n                \"spi4_cs0\",\n                \"uart10_rtsn\",\n                \"\",\n                \"vin2b_clk1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_vsync0\",\n                \"eCAP3_in_PWM3_out\",\n                \"pr2_mii1_rxd0\",\n                \"pr2_pru0_gpi11\",\n                \"pr2_pru0_gpo11\",\n                \"gpio1_25\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_2\",\n        \"gpio\": 34,\n        \"mux\": \"gpmc_ad2\",\n        \"eeprom\": 22,\n        \"key\": \"P8_5\",\n        \"universalName\": [\n            \"ocp:P8_05_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x008\",\n        \"options\": [\n            \"gpmc_ad2\",\n            \"mmc1_dat2\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_2\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R8\",\n            \"BSM\": \"R1\"\n        },\n        \"ai\": {\n            \"gpio\": 193,\n            \"ball\": {\n                \"abc\": [\n                    \"AC9\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x178C\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat2\",\n                \"spi3_cs0\",\n                \"uart5_ctsn\",\n                \"\",\n                \"vin2b_d3\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d3\",\n                \"eQEP3_index\",\n                \"pr2_mii_mr1_clk\",\n                \"pr2_pru0_gpi6\",\n                \"pr2_pru0_gpo6\",\n                \"gpio7_1\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_3\",\n        \"gpio\": 35,\n        \"mux\": \"gpmc_ad3\",\n        \"eeprom\": 23,\n        \"key\": \"P8_6\",\n        \"universalName\": [\n            \"ocp:P8_06_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x00c\",\n        \"options\": [\n            \"gpmc_ad3\",\n            \"mmc1_dat3\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_3\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T8\",\n            \"BSM\": \"T3\"\n        },\n        \"ai\": {\n            \"gpio\": 194,\n            \"ball\": {\n                \"abc\": [\n                    \"AC3\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1790\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat3\",\n                \"spi3_cs1\",\n                \"uart5_rtsn\",\n                \"\",\n                \"vin2b_d2\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d2\",\n                \"eQEP3_strobe\",\n                \"pr2_mii1_rxdv\",\n                \"pr2_pru0_gpi7\",\n                \"pr2_pru0_gpo7\",\n                \"gpio7_2\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"TIMER4\",\n        \"gpio\": 66,\n        \"mux\": \"gpmc_advn_ale\",\n        \"eeprom\": 41,\n        \"key\": [\n            \"P8_7\",\n            \"RED\",\n            \"GP1_5\"\n        ],\n        \"led\": [\n            null,\n            \"red\",\n            \"red\"\n        ],\n        \"universalName\": [\n            \"ocp:P8_07_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x090\",\n        \"options\": [\n            \"gpmc_advn_ale\",\n            \"NA\",\n            \"timer4\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_2\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R7\",\n            \"BSM\": \"M1\"\n        },\n        \"ai\": {\n            \"gpio\": 165,\n            \"ball\": {\n                \"abc\": [\n                    \"G14\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16EC\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr14\",\n                \"mcasp7_aclkx\",\n                \"mcasp7_aclkr\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d9\",\n                \"\",\n                \"\",\n                \"timer11\",\n                \"pr2_mii0_rxdv\",\n                \"pr2_pru1_gpi16\",\n                \"pr2_pru1_gpo16\",\n                \"gpio6_5\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"TIMER7\",\n        \"gpio\": 67,\n        \"mux\": \"gpmc_oen_ren\",\n        \"eeprom\": 44,\n        \"key\": [\n            \"P8_8\",\n            \"GREEN\",\n            \"GP1_6\"\n        ],\n        \"led\": [\n            null,\n            \"green\",\n            \"green\"\n        ],\n        \"universalName\": [\n            \"ocp:P8_08_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x094\",\n        \"options\": [\n            \"gpmc_oen_ren\",\n            \"NA\",\n            \"timer7\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_3\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T7\",\n            \"BSM\": \"N1\"\n        },\n        \"ai\": {\n            \"gpio\": 166,\n            \"ball\": {\n                \"abc\": [\n                    \"F14\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16F0\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr15\",\n                \"mcasp7_fsx\",\n                \"mcasp7_fsr\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d8\",\n                \"\",\n                \"\",\n                \"timer12\",\n                \"pr2_mii0_rxd3\",\n                \"pr2_pru0_gpi20\",\n                \"pr2_pru0_gpo20\",\n                \"gpio6_6\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"TIMER5\",\n        \"gpio\": 69,\n        \"mux\": \"gpmc_ben0_cle\",\n        \"eeprom\": 42,\n        \"key\": [\n            \"P8_9\",\n            \"PAUSE\"\n        ],\n        \"universalName\": [\n            \"ocp:P8_09_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x09c\",\n        \"options\": [\n            \"gpmc_ben0_cle\",\n            \"NA\",\n            \"timer5\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_5\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T6\",\n            \"BSM\": \"N3\"\n        },\n        \"ai\": {\n            \"gpio\": 178,\n            \"ball\": {\n                \"abc\": [\n                    \"E17\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1698\",\n                \"\"\n            ],\n            \"options\": [\n                \"xref_clk1\",\n                \"mcasp2_axr9\",\n                \"mcasp1_axr5\",\n                \"mcasp2_ahclkx\",\n                \"mcasp6_ahclkx\",\n                \"\",\n                \"\",\n                \"vin6a_clk0\",\n                \"\",\n                \"\",\n                \"timer14\",\n                \"pr2_mii1_crs\",\n                \"pr2_pru1_gpi6\",\n                \"pr2_pru1_gpo6\",\n                \"gpio6_18\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"TIMER6\",\n        \"gpio\": 68,\n        \"mux\": \"gpmc_wen\",\n        \"eeprom\": 43,\n        \"key\": [\n            \"P8_10\",\n            \"MODE\"\n        ],\n        \"muxRegOffset\": \"0x098\",\n        \"options\": [\n            \"gpmc_wen\",\n            \"NA\",\n            \"timer6\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_4\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U6\",\n            \"BSM\": \"N2\"\n        },\n        \"ai\": {\n            \"gpio\": 164,\n            \"ball\": {\n                \"abc\": [\n                    \"A13\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16E8\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr13\",\n                \"mcasp7_axr1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d10\",\n                \"\",\n                \"\",\n                \"timer10\",\n                \"pr2_mii_mr0_clk\",\n                \"pr2_pru1_gpi15\",\n                \"pr2_pru1_gpo15\",\n                \"gpio6_4\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_13\",\n        \"gpio\": 45,\n        \"mux\": \"gpmc_ad13\",\n        \"eeprom\": 29,\n        \"key\": [\n            \"P8_11\",\n            \"E3_4\",\n            \"P2_33\"\n        ],\n        \"muxRegOffset\": \"0x034\",\n        \"options\": [\n            \"gpmc_ad13\",\n            \"lcd_data18\",\n            \"mmc1_dat5\",\n            \"mmc2_dat1\",\n            \"eqep2B_in\",\n            \"pr1_mii0_txd\",\n            \"pr1_pru0_pru_r30_15\",\n            \"gpio1_13\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R12\",\n            \"BSM\": \"R6\"\n        },\n        \"ai\": {\n            \"gpio\": 75,\n            \"ball\": {\n                \"abc\": [\n                    \"AH4\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1510\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d7\",\n                \"\",\n                \"\",\n                \"vout3_d0\",\n                \"vout3_d16\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"eQEP2B_in\",\n                \"\",\n                \"pr1_pru0_gpi4\",\n                \"pr1_pru0_gpo4\",\n                \"gpio3_11\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_12\",\n        \"gpio\": 44,\n        \"mux\": \"gpmc_ad12\",\n        \"eeprom\": 28,\n        \"key\": [\n            \"P8_12\",\n            \"E3_3\",\n            \"P2_24\"\n        ],\n        \"muxRegOffset\": \"0x030\",\n        \"options\": [\n            \"gpmc_ad12\",\n            \"lcd_data19\",\n            \"mmc1_dat4\",\n            \"mmc2_dat0\",\n            \"eqep2a_in\",\n            \"pr1_mii0_txd2\",\n            \"pr1_pru0_pru_r30_14\",\n            \"gpio1_12\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T12\",\n            \"BSM\": \"P6\"\n        },\n        \"ai\": {\n            \"gpio\": 74,\n            \"ball\": {\n                \"abc\": [\n                    \"AG6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x150C\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d6\",\n                \"\",\n                \"\",\n                \"vout3_d1\",\n                \"vout3_d17\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"eQEP2A_in\",\n                \"\",\n                \"pr1_pru0_gpi3\",\n                \"pr1_pru0_gpo3\",\n                \"gpio3_10\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"EHRPWM2B\",\n        \"gpio\": 23,\n        \"mux\": \"gpmc_ad9\",\n        \"eeprom\": 15,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm2\",\n            \"sysfs\": 6,\n            \"index\": 1,\n            \"muxmode\": 4,\n            \"path\": \"ehrpwm.2:1\",\n            \"name\": \"EHRPWM2B\",\n            \"chip\": \"48304000\",\n            \"addr\": \"48304200\"\n        },\n        \"key\": [\n            \"P8_13\",\n            \"P2_3\"\n        ],\n        \"universalName\": [\n            \"ocp:P8_13_pinmux\",\n            \"ocp:P2_03_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x024\",\n        \"options\": [\n            \"gpmc_ad9\",\n            \"lcd_data22\",\n            \"mmc1_dat1\",\n            \"mmc2_dat5\",\n            \"ehrpwm2B\",\n            \"pr1_mii0_col\",\n            \"NA\",\n            \"gpio0_23\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T10\",\n            \"BSM\": \"P5\"\n        },\n        \"ai\": {\n            \"gpio\": 107,\n            \"ball\": {\n                \"abc\": [\n                    \"D3\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1590\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d10\",\n                \"\",\n                \"\",\n                \"mdio_mclk\",\n                \"vout2_d13\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"kbd_col7\",\n                \"ehrpwm2B\",\n                \"pr1_mdio_mdclk\",\n                \"pr1_pru1_gpi7\",\n                \"pr1_pru1_gpo7\",\n                \"gpio4_11\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO0_26\",\n        \"gpio\": 26,\n        \"mux\": \"gpmc_ad10\",\n        \"eeprom\": 16,\n        \"key\": [\n            \"P8_14\",\n            \"BAT100\",\n            \"P1_34\"\n        ],\n        \"led\": [\n            null,\n            \"bat100\",\n            null\n        ],\n        \"muxRegOffset\": \"0x028\",\n        \"options\": [\n            \"gpmc_ad10\",\n            \"lcd_data21\",\n            \"mmc1_dat2\",\n            \"mmc2_dat6\",\n            \"ehrpwm2_tripzone_input\",\n            \"pr1_mii0_txen\",\n            \"NA\",\n            \"gpio0_26\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T11\",\n            \"BSM\": \"R5\"\n        },\n        \"ai\": {\n            \"gpio\": 109,\n            \"ball\": {\n                \"abc\": [\n                    \"D5\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1598\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d12\",\n                \"\",\n                \"\",\n                \"rgmii1_txc\",\n                \"vout2_d11\",\n                \"\",\n                \"\",\n                \"\",\n                \"mii1_rxclk\",\n                \"kbd_col8\",\n                \"eCAP2_in_PWM2_out\",\n                \"pr1_mii1_txd1\",\n                \"pr1_pru1_gpi9\",\n                \"pr1_pru1_gpo9\",\n                \"gpio4_13\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_15\",\n        \"gpio\": 47,\n        \"mux\": \"gpmc_ad15\",\n        \"eeprom\": 31,\n        \"key\": [\n            \"P8_15\",\n            \"E4_4\",\n            \"P2_18\"\n        ],\n        \"muxRegOffset\": \"0x03c\",\n        \"options\": [\n            \"gpmc_ad15\",\n            \"lcd_data16\",\n            \"mmc1_dat7\",\n            \"mmc2_dat3\",\n            \"eqep2_strobe\",\n            \"pr1_ecap0_ecap_capin_apwm_o\",\n            \"pr1_pru0_pru_r31_15\",\n            \"gpio1_15\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U13\",\n            \"BSM\": \"P7\"\n        },\n        \"ai\": {\n            \"gpio\": 99,\n            \"ball\": {\n                \"abc\": [\n                    \"D1\",\n                    \"A3\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1570\",\n                \"0x15B4\"\n            ],\n            \"options\": [\n                \"vin2a_d2\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d21\",\n                \"emu12\",\n                \"\",\n                \"\",\n                \"uart10_rxd\",\n                \"kbd_row6\",\n                \"eCAP1_in_PWM1_out\",\n                \"pr1_ecap0_ecap_capin_apwm_o\",\n                \"pr1_edio_data_in7\",\n                \"pr1_edio_data_out7\",\n                \"gpio4_3\",\n                \"Driver off\",\n                \"vin2a_d19\",\n                \"\",\n                \"vin2b_d4\",\n                \"rgmii1_rxctl\",\n                \"vout2_d4\",\n                \"\",\n                \"vin3a_d11\",\n                \"\",\n                \"mii1_txer\",\n                \"\",\n                \"ehrpwm3_tripzone_input\",\n                \"pr1_mii1_rxd0\",\n                \"pr1_pru1_gpi16\",\n                \"pr1_pru1_gpo16\",\n                \"gpio4_27\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_14\",\n        \"gpio\": 46,\n        \"mux\": \"gpmc_ad14\",\n        \"eeprom\": 30,\n        \"key\": [\n            \"P8_16\",\n            \"E4_3\",\n            \"P2_22\"\n        ],\n        \"muxRegOffset\": \"0x038\",\n        \"options\": [\n            \"gpmc_ad14\",\n            \"lcd_data17\",\n            \"mmc1_dat6\",\n            \"mmc2_dat2\",\n            \"eqep2_index\",\n            \"pr1_mii0_txd0\",\n            \"pr1_pru0_pru_r31_14\",\n            \"gpio1_14\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V13\",\n            \"BSM\": \"T6\"\n        },\n        \"ai\": {\n            \"gpio\": 125,\n            \"ball\": {\n                \"abc\": [\n                    \"B4\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15BC\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d21\",\n                \"\",\n                \"vin2b_d2\",\n                \"rgmii1_rxd2\",\n                \"vout2_d2\",\n                \"vin3a_fld0\",\n                \"vin3a_d13\",\n                \"\",\n                \"mii1_col\",\n                \"\",\n                \"\",\n                \"pr1_mii1_rxlink\",\n                \"pr1_pru1_gpi18\",\n                \"pr1_pru1_gpo18\",\n                \"gpio4_29\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO0_27\",\n        \"gpio\": 27,\n        \"mux\": \"gpmc_ad11\",\n        \"eeprom\": 17,\n        \"key\": [\n            \"P8_17\",\n            \"BAT25\",\n            \"P2_19\"\n        ],\n        \"led\": [\n            null,\n            \"bat25\",\n            null\n        ],\n        \"muxRegOffset\": \"0x02c\",\n        \"options\": [\n            \"gpmc_ad11\",\n            \"lcd_data20\",\n            \"mmc1_dat3\",\n            \"mmc2_dat7\",\n            \"ehrpwm0_synco\",\n            \"pr1_mii0_txd3\",\n            \"NA\",\n            \"gpio0_27\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U12\",\n            \"BSM\": \"T5\"\n        },\n        \"ai\": {\n            \"gpio\": 242,\n            \"ball\": {\n                \"abc\": [\n                    \"A7\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1624\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d18\",\n                \"\",\n                \"emu4\",\n                \"vin4a_d2\",\n                \"vin3a_d2\",\n                \"obs11\",\n                \"obs27\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in2\",\n                \"pr2_edio_data_out2\",\n                \"pr2_pru0_gpi15\",\n                \"pr2_pru0_gpo15\",\n                \"gpio8_18\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_1\",\n        \"gpio\": 65,\n        \"mux\": \"gpmc_clk\",\n        \"eeprom\": 40,\n        \"key\": [\n            \"P8_18\",\n            \"P2_17\"\n        ],\n        \"muxRegOffset\": \"0x08c\",\n        \"options\": [\n            \"gpmc_clk\",\n            \"lcd_memory_clk_mux\",\n            \"NA\",\n            \"mmc2_clk\",\n            \"NA\",\n            \"NA\",\n            \"mcasp0_fsr\",\n            \"gpio2_1\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V12\",\n            \"BSM\": \"T7\"\n        },\n        \"ai\": {\n            \"gpio\": 105,\n            \"ball\": {\n                \"abc\": [\n                    \"F5\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1588\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d8\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d15\",\n                \"emu18\",\n                \"\",\n                \"\",\n                \"mii1_rxd3\",\n                \"kbd_col5\",\n                \"eQEP2_strobe\",\n                \"pr1_mii1_txd3\",\n                \"pr1_pru1_gpi5\",\n                \"pr1_pru1_gpo5\",\n                \"gpio4_9\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"EHRPWM2A\",\n        \"gpio\": 22,\n        \"mux\": \"gpmc_ad8\",\n        \"eeprom\": 14,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm2\",\n            \"sysfs\": 5,\n            \"index\": 0,\n            \"muxmode\": 4,\n            \"path\": \"ehrpwm.2:0\",\n            \"name\": \"EHRPWM2A\",\n            \"chip\": \"48304000\",\n            \"addr\": \"48304200\"\n        },\n        \"key\": \"P8_19\",\n        \"muxRegOffset\": \"0x020\",\n        \"options\": [\n            \"gpmc_ad8\",\n            \"lcd_data23\",\n            \"mmc1_dat0\",\n            \"mmc2_dat4\",\n            \"ehrpwm2A\",\n            \"pr1_mii_mt0_clk\",\n            \"NA\",\n            \"gpio0_22\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U10\",\n            \"BSM\": \"T4\"\n        },\n        \"ai\": {\n            \"gpio\": 106,\n            \"ball\": {\n                \"abc\": [\n                    \"E6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x158C\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d9\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d14\",\n                \"emu19\",\n                \"\",\n                \"\",\n                \"mii1_rxd0\",\n                \"kbd_col6\",\n                \"ehrpwm2A\",\n                \"pr1_mii1_txd2\",\n                \"pr1_pru1_gpi6\",\n                \"pr1_pru1_gpo6\",\n                \"gpio4_10\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_31\",\n        \"gpio\": 63,\n        \"mux\": \"gpmc_csn2\",\n        \"eeprom\": 39,\n        \"key\": \"P8_20\",\n        \"muxRegOffset\": \"0x084\",\n        \"options\": [\n            \"gpmc_csn2\",\n            \"gpmc_be1n\",\n            \"mmc1_cmd\",\n            \"pr1_edio_data_in7\",\n            \"pr1_edio_data_out7\",\n            \"pr1_pru1_pru_r30_13\",\n            \"pr1_pru1_pru_r31_13\",\n            \"gpio1_31\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V9\",\n            \"BSM\": \"P1\"\n        },\n        \"ai\": {\n            \"gpio\": 190,\n            \"ball\": {\n                \"abc\": [\n                    \"AC4\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1780\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_cmd\",\n                \"spi3_sclk\",\n                \"\",\n                \"\",\n                \"vin2b_d6\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d6\",\n                \"eCAP2_in_PWM2_out\",\n                \"pr2_mii1_txd2\",\n                \"pr2_pru0_gpi3\",\n                \"pr2_pru0_gpo3\",\n                \"gpio6_30\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_30\",\n        \"gpio\": 62,\n        \"mux\": \"gpmc_csn1\",\n        \"eeprom\": 38,\n        \"key\": \"P8_21\",\n        \"muxRegOffset\": \"0x080\",\n        \"options\": [\n            \"gpmc_csn1\",\n            \"gpmc_clk\",\n            \"mmc1_clk\",\n            \"pr1_edio_data_in6\",\n            \"pr1_edio_data_out6\",\n            \"pr1_pru1_pru_r30_12\",\n            \"pr1_pru1_pru_r31_12\",\n            \"gpio1_30\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U9\",\n            \"BSM\": \"P2\"\n        },\n        \"ai\": {\n            \"gpio\": 189,\n            \"ball\": {\n                \"abc\": [\n                    \"AD4\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x177C\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_clk\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin2b_d7\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d7\",\n                \"ehrpwm2_tripzone_input\",\n                \"pr2_mii1_txd3\",\n                \"pr2_pru0_gpi2\",\n                \"pr2_pru0_gpo2\",\n                \"gpio6_29\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_5\",\n        \"gpio\": 37,\n        \"mux\": \"gpmc_ad5\",\n        \"eeprom\": 25,\n        \"key\": \"P8_22\",\n        \"muxRegOffset\": \"0x014\",\n        \"options\": [\n            \"gpmc_ad5\",\n            \"mmc1_dat5\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_5\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V8\",\n            \"BSM\": \"T1\"\n        },\n        \"ai\": {\n            \"gpio\": 23,\n            \"ball\": {\n                \"abc\": [\n                    \"AD6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1798\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat5\",\n                \"spi4_d1\",\n                \"uart10_txd\",\n                \"\",\n                \"vin2b_d0\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d0\",\n                \"ehrpwm3B\",\n                \"pr2_mii1_rxd2\",\n                \"pr2_pru0_gpi9\",\n                \"pr2_pru0_gpo9\",\n                \"gpio1_23\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_4\",\n        \"gpio\": 36,\n        \"mux\": \"gpmc_ad4\",\n        \"eeprom\": 24,\n        \"key\": \"P8_23\",\n        \"muxRegOffset\": \"0x010\",\n        \"options\": [\n            \"gpmc_ad4\",\n            \"mmc1_dat4\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_4\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U8\",\n            \"BSM\": \"T2\"\n        },\n        \"ai\": {\n            \"gpio\": 22,\n            \"ball\": {\n                \"abc\": [\n                    \"AC8\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1794\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat4\",\n                \"spi4_sclk\",\n                \"uart10_rxd\",\n                \"\",\n                \"vin2b_d1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d1\",\n                \"ehrpwm3A\",\n                \"pr2_mii1_rxd3\",\n                \"pr2_pru0_gpi8\",\n                \"pr2_pru0_gpo8\",\n                \"gpio1_22\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_1\",\n        \"gpio\": 33,\n        \"mux\": \"gpmc_ad1\",\n        \"eeprom\": 21,\n        \"key\": \"P8_24\",\n        \"muxRegOffset\": \"0x004\",\n        \"options\": [\n            \"gpmc_ad1\",\n            \"mmc1_dat1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_1\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V7\",\n            \"BSM\": \"R2\"\n        },\n        \"ai\": {\n            \"gpio\": 192,\n            \"ball\": {\n                \"abc\": [\n                    \"AC6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1788\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat1\",\n                \"spi3_d0\",\n                \"uart5_txd\",\n                \"\",\n                \"vin2b_d4\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d4\",\n                \"eQEP3B_in\",\n                \"pr2_mii1_txd0\",\n                \"pr2_pru0_gpi5\",\n                \"pr2_pru0_gpo5\",\n                \"gpio7_0\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_0\",\n        \"gpio\": 32,\n        \"mux\": \"gpmc_ad0\",\n        \"eeprom\": 20,\n        \"key\": \"P8_25\",\n        \"muxRegOffset\": \"0x000\",\n        \"options\": [\n            \"gpmc_ad0\",\n            \"mmc1_dat0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_0\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U7\",\n            \"BSM\": \"R3\"\n        },\n        \"ai\": {\n            \"gpio\": 191,\n            \"ball\": {\n                \"abc\": [\n                    \"AC7\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1784\",\n                \"\"\n            ],\n            \"options\": [\n                \"mmc3_dat0\",\n                \"spi3_d1\",\n                \"uart5_rxd\",\n                \"\",\n                \"vin2b_d5\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin5a_d5\",\n                \"eQEP3A_in\",\n                \"pr2_mii1_txd1\",\n                \"pr2_pru0_gpi4\",\n                \"pr2_pru0_gpo4\",\n                \"gpio6_31\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_29\",\n        \"gpio\": 61,\n        \"mux\": \"gpmc_csn0\",\n        \"eeprom\": 37,\n        \"key\": [\n            \"P8_26\",\n            \"BAT75\"\n        ],\n        \"led\": [\n            null,\n            \"bat75\"\n        ],\n        \"muxRegOffset\": \"0x07c\",\n        \"options\": [\n            \"gpmc_csn0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio1_29\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V6\",\n            \"BSM\": \"P3\"\n        },\n        \"ai\": {\n            \"gpio\": 124,\n            \"ball\": {\n                \"abc\": [\n                    \"B3\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15B8\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d20\",\n                \"\",\n                \"vin2b_d3\",\n                \"rgmii1_rxd3\",\n                \"vout2_d3\",\n                \"vin3a_de0\",\n                \"vin3a_d12\",\n                \"\",\n                \"mii1_rxer\",\n                \"\",\n                \"eCAP3_in_PWM3_out\",\n                \"pr1_mii1_rxer\",\n                \"pr1_pru1_gpi17\",\n                \"pr1_pru1_gpo17\",\n                \"gpio4_28\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO0_19\",\n        \"gpio\": 19,\n        \"mux\": \"xdma_event_intr0\",\n        \"eeprom\": 37,\n        \"key\": [\n            \"WIFI\",\n            \"P2_31\"\n        ],\n        \"led\": [\n            \"wifi\",\n            null\n        ],\n        \"muxRegOffset\": \"0x1b0\",\n        \"options\": [\n            \"xdma_event_intr0\",\n            \"NA\",\n            \"timer4\",\n            \"clkout1\",\n            \"spi1_cs1\",\n            \"pr1_pru1_pru_r31\",\n            \"EMU2\",\n            \"gpio0_19\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A15\",\n            \"BSM\": \"A4\"\n        }\n    },\n    {\n        \"name\": \"GPIO2_22\",\n        \"gpio\": 86,\n        \"mux\": \"lcd_vsync\",\n        \"eeprom\": 57,\n        \"key\": [\n            \"P8_27\",\n            \"SERVO_1\",\n            \"P2_35\"\n        ],\n        \"muxRegOffset\": \"0x0e0\",\n        \"options\": [\n            \"lcd_vsync\",\n            \"gpmc_a8\",\n            \"NA\",\n            \"pr1_edio_data_in2\",\n            \"pr1_edio_data_out2\",\n            \"pr1_pru1_pru_r30_8\",\n            \"pr1_pru1_pru_r31_8\",\n            \"gpio2_22\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U5\",\n            \"BSM\": \"F3\"\n        },\n        \"ai\": {\n            \"gpio\": 119,\n            \"ball\": {\n                \"abc\": [\n                    \"E11\",\n                    \"A8\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15D8\",\n                \"0x1628\"\n            ],\n            \"options\": [\n                \"vout1_vsync\",\n                \"\",\n                \"\",\n                \"vin4a_vsync0\",\n                \"vin3a_vsync0\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_sclk\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_pru1_gpi17\",\n                \"pr2_pru1_gpo17\",\n                \"gpio4_23\",\n                \"Driver off\",\n                \"vout1_d19\",\n                \"\",\n                \"emu15\",\n                \"vin4a_d3\",\n                \"vin3a_d3\",\n                \"obs12\",\n                \"obs28\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in3\",\n                \"pr2_edio_data_out3\",\n                \"pr2_pru0_gpi16\",\n                \"pr2_pru0_gpo16\",\n                \"gpio8_19\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_24\",\n        \"gpio\": 88,\n        \"mux\": \"lcd_pclk\",\n        \"eeprom\": 59,\n        \"key\": [\n            \"P8_28\",\n            \"SERVO_2\",\n            \"P1_35\",\n            \"PRU1_10\"\n        ],\n        \"muxRegOffset\": \"0x0e8\",\n        \"options\": [\n            \"lcd_pclk\",\n            \"gpmc_a10\",\n            \"pr1_mii0_crs\",\n            \"pr1_edio_data_in4\",\n            \"pr1_edio_data_out4\",\n            \"pr1_pru1_pru_r30_10\",\n            \"pr1_pru1_pru_r31_10\",\n            \"gpio2_24\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V5\",\n            \"BSM\": \"F1\"\n        },\n        \"ai\": {\n            \"gpio\": 115,\n            \"ball\": {\n                \"abc\": [\n                    \"D11\",\n                    \"C9\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15C8\",\n                \"0x162C\"\n            ],\n            \"options\": [\n                \"vout1_clk\",\n                \"\",\n                \"\",\n                \"vin4a_fld0\",\n                \"vin3a_fld0\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_cs0\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio4_19\",\n                \"Driver off\",\n                \"vout1_d20\",\n                \"\",\n                \"emu16\",\n                \"vin4a_d4\",\n                \"vin3a_d4\",\n                \"obs13\",\n                \"obs29\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in4\",\n                \"pr2_edio_data_out4\",\n                \"pr2_pru0_gpi17\",\n                \"pr2_pru0_gpo17\",\n                \"gpio8_20\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_23\",\n        \"gpio\": 87,\n        \"mux\": \"lcd_hsync\",\n        \"eeprom\": 58,\n        \"key\": [\n            \"P8_29\",\n            \"SERVO_3\",\n            \"P1_2\"\n        ],\n        \"muxRegOffset\": \"0x0e4\",\n        \"options\": [\n            \"lcd_hsync\",\n            \"gpmc_a9\",\n            \"gpmc_a2\",\n            \"pr1_edio_data_in3\",\n            \"pr1_edio_data_out3\",\n            \"pr1_pru1_pru_r30_9\",\n            \"pr1_pru1_pru_r31_9\",\n            \"gpio2_23\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R5\",\n            \"BSM\": \"F2\"\n        },\n        \"ai\": {\n            \"gpio\": 118,\n            \"ball\": {\n                \"abc\": [\n                    \"C11\",\n                    \"A9\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15D4\",\n                \"0x1630\"\n            ],\n            \"options\": [\n                \"vout1_hsync\",\n                \"\",\n                \"\",\n                \"vin4a_hsync0\",\n                \"vin3a_hsync0\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_d0\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio4_22\",\n                \"Driver off\",\n                \"vout1_d21\",\n                \"\",\n                \"emu17\",\n                \"vin4a_d5\",\n                \"vin3a_d5\",\n                \"obs14\",\n                \"obs30\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in5\",\n                \"pr2_edio_data_out5\",\n                \"pr2_pru0_gpi18\",\n                \"pr2_pru0_gpo18\",\n                \"gpio8_21\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_25\",\n        \"gpio\": 89,\n        \"mux\": \"lcd_ac_bias_en\",\n        \"eeprom\": 60,\n        \"key\": [\n            \"P8_30\",\n            \"SERVO_4\",\n            \"P1_4\",\n            \"PRU1_11\"\n        ],\n        \"muxRegOffset\": \"0x0ec\",\n        \"options\": [\n            \"lcd_ac_bias_en\",\n            \"gpmc_a11\",\n            \"pr1_mii1_crs\",\n            \"pr1_edio_data_in5\",\n            \"pr1_edio_data_out5\",\n            \"pr1_pru1_pru_r30_11\",\n            \"pr1_pru1_pru_r31_11\",\n            \"gpio2_25\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R6\",\n            \"BSM\": \"E1\"\n        },\n        \"ai\": {\n            \"gpio\": 116,\n            \"ball\": {\n                \"abc\": [\n                    \"B10\",\n                    \"B9\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15CC\",\n                \"0x1634\"\n            ],\n            \"options\": [\n                \"vout1_de\",\n                \"\",\n                \"\",\n                \"vin4a_de0\",\n                \"vin3a_de0\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_d1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio4_20\",\n                \"Driver off\",\n                \"vout1_d22\",\n                \"\",\n                \"emu18\",\n                \"vin4a_d6\",\n                \"vin3a_d6\",\n                \"obs15\",\n                \"obs31\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in6\",\n                \"pr2_edio_data_out6\",\n                \"pr2_pru0_gpi19\",\n                \"pr2_pru0_gpo19\",\n                \"gpio8_22\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART5_CTSN\",\n        \"gpio\": 10,\n        \"mux\": \"lcd_data14\",\n        \"eeprom\": 7,\n        \"key\": \"P8_31\",\n        \"muxRegOffset\": \"0x0d8\",\n        \"options\": [\n            \"lcd_data14\",\n            \"gpmc_a18\",\n            \"NA\",\n            \"mcasp0_axr1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_10\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V4\",\n            \"BSM\": \"L1\"\n        },\n        \"ai\": {\n            \"gpio\": 238,\n            \"ball\": {\n                \"abc\": [\n                    \"C8\",\n                    \"G16\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1614\",\n                \"0x173C\"\n            ],\n            \"options\": [\n                \"vout1_d14\",\n                \"\",\n                \"emu13\",\n                \"vin4a_d14\",\n                \"vin3a_d14\",\n                \"obs9\",\n                \"obs25\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_uart0_txd\",\n                \"\",\n                \"pr2_pru0_gpi11\",\n                \"pr2_pru0_gpo11\",\n                \"gpio8_14\",\n                \"Driver off\",\n                \"mcasp4_axr0\",\n                \"\",\n                \"spi3_d0\",\n                \"uart8_ctsn\",\n                \"uart4_rxd\",\n                \"\",\n                \"vout2_d18\",\n                \"\",\n                \"vin4a_d18\",\n                \"vin5a_d13\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART5_RTSN\",\n        \"gpio\": 11,\n        \"mux\": \"lcd_data15\",\n        \"eeprom\": 8,\n        \"key\": [\n            \"P8_32\",\n            \"BAT50\"\n        ],\n        \"led\": [\n            null,\n            \"bat50\"\n        ],\n        \"muxRegOffset\": \"0x0dc\",\n        \"options\": [\n            \"lcd_data15\",\n            \"gpmc_a19\",\n            \"NA\",\n            \"mcasp0_ahclkx\",\n            \"mcasp0_axr3\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_11\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T5\",\n            \"BSM\": \"M3\"\n        },\n        \"ai\": {\n            \"gpio\": 239,\n            \"ball\": {\n                \"abc\": [\n                    \"C7\",\n                    \"D17\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1618\",\n                \"0x1740\"\n            ],\n            \"options\": [\n                \"vout1_d15\",\n                \"\",\n                \"emu14\",\n                \"vin4a_d15\",\n                \"vin3a_d15\",\n                \"obs10\",\n                \"obs26\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_ecap0_ecap_capin_apwm_o\",\n                \"\",\n                \"pr2_pru0_gpi12\",\n                \"pr2_pru0_gpo12\",\n                \"gpio8_15\",\n                \"Driver off\",\n                \"mcasp4_axr1\",\n                \"\",\n                \"spi3_cs0\",\n                \"uart8_rtsn\",\n                \"uart4_txd\",\n                \"\",\n                \"vout2_d19\",\n                \"\",\n                \"vin4a_d19\",\n                \"vin5a_d12\",\n                \"\",\n                \"\",\n                \"pr2_pru1_gpi0\",\n                \"pr2_pru1_gpo0\",\n                \"\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART4_RTSN\",\n        \"gpio\": 9,\n        \"mux\": \"lcd_data13\",\n        \"eeprom\": 6,\n        \"key\": [\n            \"P8_33\",\n            \"E2_4\"\n        ],\n        \"muxRegOffset\": \"0x0d4\",\n        \"options\": [\n            \"lcd_data13\",\n            \"gpmc_a17\",\n            \"NA\",\n            \"mcasp0_fsr\",\n            \"mcasp0_axr3\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_9\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V3\",\n            \"BSM\": \"L2\"\n        },\n        \"ai\": {\n            \"gpio\": 237,\n            \"ball\": {\n                \"abc\": [\n                    \"C6\",\n                    \"AF9\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1610\",\n                \"0x14E8\"\n            ],\n            \"options\": [\n                \"vout1_d13\",\n                \"\",\n                \"emu12\",\n                \"vin4a_d13\",\n                \"vin3a_d13\",\n                \"obs8\",\n                \"obs24\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_uart0_rxd\",\n                \"\",\n                \"pr2_pru0_gpi10\",\n                \"pr2_pru0_gpo10\",\n                \"gpio8_13\",\n                \"Driver off\",\n                \"vin1a_fld0\",\n                \"vin1b_vsync1\",\n                \"\",\n                \"\",\n                \"vout3_clk\",\n                \"uart7_txd\",\n                \"\",\n                \"timer15\",\n                \"spi3_d1\",\n                \"kbd_row1\",\n                \"eQEP1B_in\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio3_1\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART3_RTSN\",\n        \"gpio\": 81,\n        \"mux\": \"lcd_data11\",\n        \"eeprom\": 56,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm1\",\n            \"sysfs\": 4,\n            \"index\": 1,\n            \"muxmode\": 2,\n            \"path\": \"ehrpwm.1:1\",\n            \"name\": \"EHRPWM1B\",\n            \"chip\": \"48302000\",\n            \"addr\": \"48302200\"\n        },\n        \"key\": \"P8_34\",\n        \"muxRegOffset\": \"0x0cc\",\n        \"options\": [\n            \"lcd_data11\",\n            \"gpmc_a15\",\n            \"NA\",\n            \"mcasp0_ahclkr\",\n            \"mcasp0_axr2\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_17\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V3\",\n            \"BSM\": \"K1\"\n        },\n        \"ai\": {\n            \"gpio\": 235,\n            \"ball\": {\n                \"abc\": [\n                    \"D8\",\n                    \"G6\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1608\",\n                \"0x1564\"\n            ],\n            \"options\": [\n                \"vout1_d11\",\n                \"\",\n                \"emu10\",\n                \"vin4a_d11\",\n                \"vin3a_d11\",\n                \"obs6\",\n                \"obs22\",\n                \"obs_dmarq2\",\n                \"\",\n                \"\",\n                \"pr2_uart0_cts_n\",\n                \"\",\n                \"pr2_pru0_gpi8\",\n                \"pr2_pru0_gpo8\",\n                \"gpio8_11\",\n                \"Driver off\",\n                \"vin2a_vsync0\",\n                \"\",\n                \"\",\n                \"vin2b_vsync1\",\n                \"vout2_vsync\",\n                \"emu9\",\n                \"\",\n                \"uart9_txd\",\n                \"spi4_d1\",\n                \"kbd_row3\",\n                \"ehrpwm1A\",\n                \"pr1_uart0_rts_n\",\n                \"pr1_edio_data_in4\",\n                \"pr1_edio_data_out4\",\n                \"gpio4_0\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART4_CTSN\",\n        \"gpio\": 8,\n        \"mux\": \"lcd_data12\",\n        \"eeprom\": 5,\n        \"key\": [\n            \"P8_35\",\n            \"E2_3\"\n        ],\n        \"muxRegOffset\": \"0x0d0\",\n        \"options\": [\n            \"lcd_data12\",\n            \"gpmc_a16\",\n            \"NA\",\n            \"mcasp0_aclkr\",\n            \"mcasp0_axr2\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_8\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V2\",\n            \"BSM\": \"L3\"\n        },\n        \"ai\": {\n            \"gpio\": 236,\n            \"ball\": {\n                \"abc\": [\n                    \"A5\",\n                    \"AD9\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x160C\",\n                \"0x14E4\"\n            ],\n            \"options\": [\n                \"vout1_d12\",\n                \"\",\n                \"emu11\",\n                \"vin4a_d12\",\n                \"vin3a_d12\",\n                \"obs7\",\n                \"obs23\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_uart0_rts_n\",\n                \"\",\n                \"pr2_pru0_gpi9\",\n                \"pr2_pru0_gpo9\",\n                \"gpio8_12\",\n                \"Driver off\",\n                \"vin1a_de0\",\n                \"vin1b_hsync1\",\n                \"\",\n                \"vout3_d17\",\n                \"vout3_de\",\n                \"uart7_rxd\",\n                \"\",\n                \"timer16\",\n                \"spi3_sclk\",\n                \"kbd_row0\",\n                \"eQEP1A_in\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio3_0\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART3_CTSN\",\n        \"gpio\": 80,\n        \"mux\": \"lcd_data10\",\n        \"eeprom\": 55,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm1\",\n            \"sysfs\": 3,\n            \"index\": 0,\n            \"muxmode\": 2,\n            \"path\": \"ehrpwm.1:0\",\n            \"name\": \"EHRPWM1A\",\n            \"chip\": \"48302000\",\n            \"addr\": \"48302200\"\n        },\n        \"key\": [\n            \"P8_36\",\n            \"SERVO_PWR_EN\"\n        ],\n        \"muxRegOffset\": \"0x0c8\",\n        \"options\": [\n            \"lcd_data10\",\n            \"gpmc_a14\",\n            \"ehrpwm1A\",\n            \"mcasp0_axr0\",\n            \"mcasp0_axr0\",\n            \"pr1_mii0_rxd1\",\n            \"uart3_ctsn\",\n            \"gpio2_16\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U3\",\n            \"BSM\": \"K2\"\n        },\n        \"ai\": {\n            \"gpio\": 234,\n            \"ball\": {\n                \"abc\": [\n                    \"D7\",\n                    \"F2\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1604\",\n                \"0x1568\"\n            ],\n            \"options\": [\n                \"vout1_d10\",\n                \"\",\n                \"emu3\",\n                \"vin4a_d10\",\n                \"vin3a_d10\",\n                \"obs5\",\n                \"obs21\",\n                \"obs_irq2\",\n                \"\",\n                \"\",\n                \"pr2_edio_sof\",\n                \"\",\n                \"pr2_pru0_gpi7\",\n                \"pr2_pru0_gpo7\",\n                \"gpio8_10\",\n                \"Driver off\",\n                \"vin2a_d0\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d23\",\n                \"emu10\",\n                \"\",\n                \"uart9_ctsn\",\n                \"spi4_d0\",\n                \"kbd_row4\",\n                \"ehrpwm1B\",\n                \"pr1_uart0_rxd\",\n                \"pr1_edio_data_in5\",\n                \"pr1_edio_data_out5\",\n                \"gpio4_1\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART5_TXD\",\n        \"gpio\": 78,\n        \"mux\": \"lcd_data8\",\n        \"eeprom\": 53,\n        \"key\": [\n            \"P8_37\",\n            \"UT5_4\"\n        ],\n        \"muxRegOffset\": \"0x0c0\",\n        \"options\": [\n            \"lcd_data8\",\n            \"gpmc_a12\",\n            \"NA\",\n            \"mcasp0_aclkx\",\n            \"NA\",\n            \"NA\",\n            \"uart2_ctsn\",\n            \"gpio2_14\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U1\",\n            \"BSM\": \"J1\"\n        },\n        \"ai\": {\n            \"gpio\": 232,\n            \"ball\": {\n                \"abc\": [\n                    \"E8\",\n                    \"A21\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15FC\",\n                \"0x1738\"\n            ],\n            \"options\": [\n                \"vout1_d8\",\n                \"\",\n                \"uart6_rxd\",\n                \"vin4a_d8\",\n                \"vin3a_d8\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edc_sync1_out\",\n                \"\",\n                \"pr2_pru0_gpi5\",\n                \"pr2_pru0_gpo5\",\n                \"gpio8_8\",\n                \"Driver off\",\n                \"mcasp4_fsx\",\n                \"mcasp4_fsr\",\n                \"spi3_d1\",\n                \"uart8_txd\",\n                \"i2c4_scl\",\n                \"\",\n                \"vout2_d17\",\n                \"\",\n                \"vin4a_d17\",\n                \"vin5a_d14\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART5_RXD\",\n        \"gpio\": 79,\n        \"mux\": \"lcd_data9\",\n        \"eeprom\": 54,\n        \"key\": [\n            \"P8_38\",\n            \"UT5_3\"\n        ],\n        \"muxRegOffset\": \"0x0c4\",\n        \"options\": [\n            \"lcd_data9\",\n            \"gpmc_a13\",\n            \"NA\",\n            \"mcasp0_fsx\",\n            \"NA\",\n            \"NA\",\n            \"uart2_rtsn\",\n            \"gpio2_15\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U2\",\n            \"BSM\": \"K3\"\n        },\n        \"ai\": {\n            \"gpio\": 233,\n            \"ball\": {\n                \"abc\": [\n                    \"D9\",\n                    \"C18\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1600\",\n                \"0x1734\"\n            ],\n            \"options\": [\n                \"vout1_d9\",\n                \"\",\n                \"uart6_txd\",\n                \"vin4a_d9\",\n                \"vin3a_d9\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_latch_in\",\n                \"\",\n                \"pr2_pru0_gpi6\",\n                \"pr2_pru0_gpo6\",\n                \"gpio8_9\",\n                \"Driver off\",\n                \"mcasp4_aclkx\",\n                \"mcasp4_aclkr\",\n                \"spi3_sclk\",\n                \"uart8_rxd\",\n                \"i2c4_sda\",\n                \"\",\n                \"vout2_d16\",\n                \"\",\n                \"vin4a_d16\",\n                \"vin5a_d15\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_12\",\n        \"gpio\": 76,\n        \"mux\": \"lcd_data6\",\n        \"eeprom\": 51,\n        \"key\": [\n            \"P8_39\",\n            \"SERVO_5\"\n        ],\n        \"muxRegOffset\": \"0x0b8\",\n        \"options\": [\n            \"lcd_data6\",\n            \"gpmc_a6\",\n            \"pr1_edio_data_in6\",\n            \"eqep2_index\",\n            \"pr1_edio_data_out6\",\n            \"pr1_pru1_pru_r30_6\",\n            \"pr1_pru1_pru_r31_6\",\n            \"gpio2_12\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T3\",\n            \"BSM\": \"J3\"\n        },\n        \"ai\": {\n            \"gpio\": 230,\n            \"ball\": {\n                \"abc\": [\n                    \"F8\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15F4\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d6\",\n                \"\",\n                \"emu8\",\n                \"vin4a_d22\",\n                \"vin3a_d22\",\n                \"obs4\",\n                \"obs20\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edc_latch1_in\",\n                \"\",\n                \"pr2_pru0_gpi3\",\n                \"pr2_pru0_gpo3\",\n                \"gpio8_6\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_13\",\n        \"gpio\": 77,\n        \"mux\": \"lcd_data7\",\n        \"eeprom\": 52,\n        \"key\": [\n            \"P8_40\",\n            \"SERVO_6\"\n        ],\n        \"muxRegOffset\": \"0x0bc\",\n        \"options\": [\n            \"lcd_data7\",\n            \"gpmc_a7\",\n            \"pr1_edio_data_in7\",\n            \"eqep2_strobe\",\n            \"pr1_edio_data_out_7\",\n            \"pr1_pru1_pru_r30_7\",\n            \"pr1_pru1_pru_r31_7\",\n            \"gpio2_13\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T4\",\n            \"BSM\": \"J2\"\n        },\n        \"ai\": {\n            \"gpio\": 231,\n            \"ball\": {\n                \"abc\": [\n                    \"E7\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15F8\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d7\",\n                \"\",\n                \"emu9\",\n                \"vin4a_d23\",\n                \"vin3a_d23\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edc_sync0_out\",\n                \"\",\n                \"pr2_pru0_gpi4\",\n                \"pr2_pru0_gpo4\",\n                \"gpio8_7\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_10\",\n        \"gpio\": 74,\n        \"mux\": \"lcd_data4\",\n        \"eeprom\": 49,\n        \"key\": [\n            \"P8_41\",\n            \"SERVO_7\"\n        ],\n        \"muxRegOffset\": \"0x0b0\",\n        \"options\": [\n            \"lcd_data4\",\n            \"gpmc_a4\",\n            \"pr1_mii0_txd1\",\n            \"eQEP2A_in\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_4\",\n            \"pr1_pru1_pru_r31_4\",\n            \"gpio2_10\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T1\",\n            \"BSM\": \"H2\"\n        },\n        \"ai\": {\n            \"gpio\": 228,\n            \"ball\": {\n                \"abc\": [\n                    \"E9\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15EC\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d4\",\n                \"\",\n                \"emu6\",\n                \"vin4a_d20\",\n                \"vin3a_d20\",\n                \"obs2\",\n                \"obs18\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr1_ecap0_ecap_capin_apwm_o\",\n                \"\",\n                \"pr2_pru0_gpi1\",\n                \"pr2_pru0_gpo1\",\n                \"gpio8_4\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_11\",\n        \"gpio\": 75,\n        \"mux\": \"lcd_data5\",\n        \"eeprom\": 50,\n        \"key\": [\n            \"P8_42\",\n            \"SERVO_8\"\n        ],\n        \"muxRegOffset\": \"0x0b4\",\n        \"options\": [\n            \"lcd_data5\",\n            \"gpmc_a5\",\n            \"pr1_mii0_txd0\",\n            \"eqep2b_in\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_5\",\n            \"pr1_pru1_pru_r31_5\",\n            \"gpio2_11\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T2\",\n            \"BSM\": \"H1\"\n        },\n        \"ai\": {\n            \"gpio\": 229,\n            \"ball\": {\n                \"abc\": [\n                    \"F9\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15F0\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d5\",\n                \"\",\n                \"emu7\",\n                \"vin4a_d21\",\n                \"vin3a_d21\",\n                \"obs3\",\n                \"obs19\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edc_latch0_in\",\n                \"\",\n                \"pr2_pru0_gpi2\",\n                \"pr2_pru0_gpo2\",\n                \"gpio8_5\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_8\",\n        \"gpio\": 72,\n        \"mux\": \"lcd_data2\",\n        \"eeprom\": 47,\n        \"key\": \"P8_43\",\n        \"muxRegOffset\": \"0x0a8\",\n        \"options\": [\n            \"lcd_data2\",\n            \"gpmc_a2\",\n            \"pr1_mii0_txd3\",\n            \"ehrpwm2_tripzone_input\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_2\",\n            \"pr1_pru1_pru_r31_2\",\n            \"gpio2_8\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R3\",\n            \"BSM\": \"G1\"\n        },\n        \"ai\": {\n            \"gpio\": 226,\n            \"ball\": {\n                \"abc\": [\n                    \"F10\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15E4\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d2\",\n                \"\",\n                \"emu2\",\n                \"vin4a_d18\",\n                \"vin3a_d18\",\n                \"obs0\",\n                \"obs16\",\n                \"obs_irq1\",\n                \"\",\n                \"\",\n                \"pr1_uart0_rxd\",\n                \"\",\n                \"pr2_pru1_gpi20\",\n                \"pr2_pru1_gpo20\",\n                \"gpio8_2\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_9\",\n        \"gpio\": 73,\n        \"mux\": \"lcd_data3\",\n        \"eeprom\": 48,\n        \"key\": \"P8_44\",\n        \"muxRegOffset\": \"0x0ac\",\n        \"options\": [\n            \"lcd_data3\",\n            \"gpmc_a3\",\n            \"pr1_mii0_txd2\",\n            \"ehrpwm0_synco\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_3\",\n            \"pr1_pru1_pru_r31_3\",\n            \"gpio2_9\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R4\",\n            \"BSM\": \"H3\"\n        },\n        \"ai\": {\n            \"gpio\": 227,\n            \"ball\": {\n                \"abc\": [\n                    \"G11\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15E8\",\n                \"\"\n            ],\n            \"options\": [\n                \"vout1_d3\",\n                \"\",\n                \"emu5\",\n                \"vin4a_d19\",\n                \"vin3a_d19\",\n                \"obs1\",\n                \"obs17\",\n                \"obs_dmarq1\",\n                \"\",\n                \"\",\n                \"pr1_uart0_txd\",\n                \"\",\n                \"pr2_pru0_gpi0\",\n                \"pr2_pru0_gpo0\",\n                \"gpio8_3\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_6\",\n        \"gpio\": 70,\n        \"mux\": \"lcd_data0\",\n        \"eeprom\": 45,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm2\",\n            \"sysfs\": 5,\n            \"index\": 0,\n            \"muxmode\": 3,\n            \"path\": \"ehrpwm.2:0\",\n            \"name\": \"EHRPWM2A\",\n            \"chip\": \"48304000\",\n            \"addr\": \"48304200\"\n        },\n        \"key\": \"P8_45\",\n        \"muxRegOffset\": \"0x0a0\",\n        \"options\": [\n            \"lcd_data0\",\n            \"gpmc_a0\",\n            \"pr1_mii_mt0_clk\",\n            \"ehrpwm2A\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_0\",\n            \"pr1_pru1_pru_r31_0\",\n            \"gpio2_6\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R1\",\n            \"BSM\": \"G3\"\n        },\n        \"ai\": {\n            \"gpio\": 224,\n            \"ball\": {\n                \"abc\": [\n                    \"F11\",\n                    \"B7\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15DC\",\n                \"0x161C\"\n            ],\n            \"options\": [\n                \"vout1_d0\",\n                \"\",\n                \"uart5_rxd\",\n                \"vin4a_d16\",\n                \"vin3a_d16\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_cs2\",\n                \"\",\n                \"pr1_uart0_cts_n\",\n                \"\",\n                \"pr2_pru1_gpi18\",\n                \"pr2_pru1_gpo18\",\n                \"gpio8_0\",\n                \"Driver off\",\n                \"vout1_d16\",\n                \"\",\n                \"uart7_rxd\",\n                \"vin4a_d0\",\n                \"vin3a_d0\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in0\",\n                \"pr2_edio_data_out0\",\n                \"pr2_pru0_gpi13\",\n                \"pr2_pru0_gpo13\",\n                \"gpio8_16\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO2_7\",\n        \"gpio\": 71,\n        \"mux\": \"lcd_data1\",\n        \"eeprom\": 46,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm2\",\n            \"sysfs\": 6,\n            \"index\": 1,\n            \"muxmode\": 3,\n            \"path\": \"ehrpwm.2:1\",\n            \"name\": \"EHRPWM2B\",\n            \"chip\": \"48304000\",\n            \"addr\": \"48304200\"\n        },\n        \"key\": \"P8_46\",\n        \"muxRegOffset\": \"0x0a4\",\n        \"options\": [\n            \"lcd_data1\",\n            \"gpmc_a1\",\n            \"pr1_mii0_txen\",\n            \"ehrpwm2B\",\n            \"NA\",\n            \"pr1_pru1_pru_r30_1\",\n            \"pr1_pru1_pru_r31_1\",\n            \"gpio2_7\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R2\",\n            \"BSM\": \"G2\"\n        },\n        \"ai\": {\n            \"gpio\": 225,\n            \"ball\": {\n                \"abc\": [\n                    \"G10\",\n                    \"A10\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15E0\",\n                \"0x1638\"\n            ],\n            \"options\": [\n                \"vout1_d1\",\n                \"\",\n                \"uart5_txd\",\n                \"vin4a_d17\",\n                \"vin3a_d17\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr1_uart0_rts_n\",\n                \"\",\n                \"pr2_pru1_gpi19\",\n                \"pr2_pru1_gpo19\",\n                \"gpio8_1\",\n                \"Driver off\",\n                \"vout1_d23\",\n                \"\",\n                \"emu19\",\n                \"vin4a_d7\",\n                \"vin3a_d7\",\n                \"\",\n                \"\",\n                \"\",\n                \"spi3_cs3\",\n                \"\",\n                \"pr2_edio_data_in7\",\n                \"pr2_edio_data_out7\",\n                \"pr2_pru0_gpi20\",\n                \"pr2_pru0_gpo20\",\n                \"gpio8_23\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"VDD_3V3\",\n        \"key\": [\n            \"P9_3\",\n            \"P9_4\",\n            \"P1_14\",\n            \"P2_23\",\n            \"E1_2\",\n            \"E2_2\",\n            \"E3_2\",\n            \"E4_2\",\n            \"GP0_2\",\n            \"GP1_2\",\n            \"S1_1_2\",\n            \"S1_2_2\",\n            \"UT0_2\",\n            \"UT1_2\",\n            \"UT5_2\",\n            \"DSM2_1\",\n            \"I2C_2\"\n        ]\n    },\n    {\n        \"name\": \"VDD_5V\",\n        \"key\": [\n            \"P9_5\",\n            \"P9_6\",\n            \"P1_1\"\n        ]\n    },\n    {\n        \"name\": \"SYS_5V\",\n        \"key\": [\n            \"P9_7\",\n            \"P9_8\",\n            \"P1_24\",\n            \"P2_13\",\n            \"GPS_5\"\n        ]\n    },\n    {\n        \"name\": \"PWR_BUT\",\n        \"key\": [\n            \"P9_9\",\n            \"P2_12\"\n        ],\n        \"ball\": {\n            \"BSM\": \"T11\"\n        },\n        \"ai\": {\n            \"gpio\": null,\n            \"ball\": {\n                \"abc\": [\n                    \"PMIC - G8\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"\",\n                \"\"\n            ],\n            \"options\": [\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"SYS_RESETn\",\n        \"key\": [\n            \"P9_10\",\n            \"P2_26\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A10\",\n            \"BSM\": \"R11\"\n        },\n        \"ai\": {\n            \"gpio\": null,\n            \"ball\": {\n                \"abc\": [\n                    \"F23\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1864\",\n                \"\"\n            ],\n            \"options\": [\n                \"rstoutn\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART4_RXD\",\n        \"gpio\": 30,\n        \"mux\": \"gpmc_wait0\",\n        \"eeprom\": 18,\n        \"key\": [\n            \"P9_11\",\n            \"DSM2_3\",\n            \"P2_5\"\n        ],\n        \"muxRegOffset\": \"0x070\",\n        \"options\": [\n            \"gpmc_wait0\",\n            \"mii2_crs\",\n            \"gpmc_csn4\",\n            \"rmii2_crs_dv\",\n            \"mmc1_sdcd\",\n            \"pr1_mii1_col\",\n            \"uart4_rxd\",\n            \"gpio0_30\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T17\",\n            \"BSM\": \"P15\"\n        },\n        \"ai\": {\n            \"gpio\": 241,\n            \"ball\": {\n                \"abc\": [\n                    \"B19\",\n                    \"B8\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x172C\",\n                \"0x1620\"\n            ],\n            \"options\": [\n                \"mcasp3_axr0\",\n                \"\",\n                \"mcasp2_axr14\",\n                \"uart7_ctsn\",\n                \"uart5_rxd\",\n                \"\",\n                \"\",\n                \"vin6a_d1\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_mii1_rxer\",\n                \"pr2_pru0_gpi14\",\n                \"pr2_pru0_gpo14\",\n                \"\",\n                \"Driver off\",\n                \"vout1_d17\",\n                \"\",\n                \"uart7_txd\",\n                \"vin4a_d1\",\n                \"vin3a_d1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"pr2_edio_data_in1\",\n                \"pr2_edio_data_out1\",\n                \"pr2_pru0_gpi14\",\n                \"pr2_pru0_gpo14\",\n                \"gpio8_17\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_28\",\n        \"gpio\": 60,\n        \"mux\": \"gpmc_ben1\",\n        \"eeprom\": 36,\n        \"key\": [\n            \"P9_12\",\n            \"P2_8\"\n        ],\n        \"muxRegOffset\": \"0x078\",\n        \"options\": [\n            \"gpmc_ben1\",\n            \"mii2_col\",\n            \"NA\",\n            \"mmc2_dat3\",\n            \"NA\",\n            \"NA\",\n            \"mcasp0_aclkr\",\n            \"gpio1_28\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U18\",\n            \"BSM\": \"N14\"\n        },\n        \"ai\": {\n            \"gpio\": 128,\n            \"ball\": {\n                \"abc\": [\n                    \"B14\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16AC\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_aclkr\",\n                \"mcasp7_axr2\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d0\",\n                \"\",\n                \"vin4a_d0\",\n                \"\",\n                \"i2c4_sda\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio5_0\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART4_TXD\",\n        \"gpio\": 31,\n        \"mux\": \"gpmc_wpn\",\n        \"eeprom\": 19,\n        \"key\": [\n            \"P9_13\",\n            \"P2_7\"\n        ],\n        \"muxRegOffset\": \"0x074\",\n        \"options\": [\n            \"gpmc_wpn\",\n            \"mii2_rxerr\",\n            \"NA\",\n            \"rmii2_rxerr\",\n            \"mmc2_sdcd\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_31\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U17\",\n            \"BSM\": \"R16\"\n        },\n        \"ai\": {\n            \"gpio\": 172,\n            \"ball\": {\n                \"abc\": [\n                    \"C17\",\n                    \"AB10**\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1730\",\n                \"0x1680\"\n            ],\n            \"options\": [\n                \"mcasp3_axr1\",\n                \"\",\n                \"mcasp2_axr15\",\n                \"uart7_rtsn\",\n                \"uart5_txd\",\n                \"\",\n                \"\",\n                \"vin6a_d0\",\n                \"\",\n                \"vin5a_fld0\",\n                \"\",\n                \"pr2_mii1_rxlink\",\n                \"pr2_pru0_gpi15\",\n                \"pr2_pru0_gpo15\",\n                \"\",\n                \"Driver off\",\n                \"usb1_drvvbus\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"timer16\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio6_12\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"EHRPWM1A\",\n        \"gpio\": 50,\n        \"mux\": \"gpmc_a2\",\n        \"eeprom\": 34,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm1\",\n            \"sysfs\": 3,\n            \"index\": 0,\n            \"muxmode\": 6,\n            \"path\": \"ehrpwm.1:0\",\n            \"name\": \"EHRPWM1A\",\n            \"chip\": \"48302000\",\n            \"addr\": \"48302200\"\n        },\n        \"key\": [\n            \"P9_14\",\n            \"P2_1\"\n        ],\n        \"universalName\": [\n            \"ocp:P9_14_pinmux\",\n            \"ocp:P2_01_pinmux\",\n            \"ocp:PWM_pinmux\"\n        ],\n        \"muxRegOffset\": \"0x048\",\n        \"options\": [\n            \"gpmc_a2\",\n            \"gmii2_txd3\",\n            \"rgmii2_td3\",\n            \"mmc2_dat1\",\n            \"gpmc_a18\",\n            \"pr1_mii1_txd2\",\n            \"ehrpwm1A\",\n            \"gpio1_18\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U14\",\n            \"BSM\": \"P12\"\n        },\n        \"ai\": {\n            \"gpio\": 121,\n            \"ball\": {\n                \"abc\": [\n                    \"D6\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15AC\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d17\",\n                \"\",\n                \"vin2b_d6\",\n                \"rgmii1_txd0\",\n                \"vout2_d6\",\n                \"\",\n                \"vin3a_d9\",\n                \"\",\n                \"mii1_txd2\",\n                \"\",\n                \"ehrpwm3A\",\n                \"pr1_mii1_rxd2\",\n                \"pr1_pru1_gpi14\",\n                \"pr1_pru1_gpo14\",\n                \"gpio4_25\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_16\",\n        \"gpio\": 48,\n        \"mux\": \"mii1_rxd3\",\n        \"eeprom\": 32,\n        \"key\": \"P9_15\",\n        \"muxRegOffset\": \"0x040\",\n        \"options\": [\n            \"gpmc_a0\",\n            \"gmii2_txen\",\n            \"rgmii2_tctl\",\n            \"rmii2_txen\",\n            \"gpmc_a16\",\n            \"pr1_mii_mt1_clk\",\n            \"ehrpwm1_tripzone_input\",\n            \"gpio1_16\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R13\",\n            \"BSM\": \"T12\"\n        },\n        \"ai\": {\n            \"gpio\": 76,\n            \"ball\": {\n                \"abc\": [\n                    \"AG4\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1514\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d8\",\n                \"vin1b_d7\",\n                \"\",\n                \"\",\n                \"vout3_d15\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"kbd_row2\",\n                \"eQEP2_index\",\n                \"\",\n                \"pr1_pru0_gpi5\",\n                \"pr1_pru0_gpo5\",\n                \"gpio3_12\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_16\",\n        \"gpio\": 64,\n        \"mux\": \"gpmc_csn3\",\n        \"eeprom\": null,\n        \"key\": [\n            \"P9_15B\",\n            \"P2_20\"\n        ],\n        \"muxRegOffset\": \"0x088\",\n        \"options\": [\n            \"gpmc_csn3\",\n            \"gpmc_a3\",\n            \"rmii2_crs_dv\",\n            \"mmc2_cmd\",\n            \"pr1_mii0_crs\",\n            \"pr1_mdio_data\",\n            \"gpio2_0\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T13\",\n            \"BSM\": \"R7\"\n        }\n    },\n    {\n        \"name\": \"EHRPWM1B\",\n        \"gpio\": 51,\n        \"mux\": \"gpmc_a3\",\n        \"eeprom\": 35,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm1\",\n            \"sysfs\": 4,\n            \"index\": 1,\n            \"muxmode\": 6,\n            \"path\": \"ehrpwm.1:1\",\n            \"name\": \"EHRPWM1B\",\n            \"chip\": \"48302000\",\n            \"addr\": \"48302200\"\n        },\n        \"key\": \"P9_16\",\n        \"muxRegOffset\": \"0x04c\",\n        \"options\": [\n            \"gpmc_a3\",\n            \"gmii2_txd2\",\n            \"rgmii2_td2\",\n            \"mmc2_dat2\",\n            \"gpmc_a19\",\n            \"pr1_mii1_txd1\",\n            \"ehrpwm1B\",\n            \"gpio1_19\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T14\",\n            \"BSM\": \"T13\"\n        },\n        \"ai\": {\n            \"gpio\": 122,\n            \"ball\": {\n                \"abc\": [\n                    \"C5\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15B0\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin2a_d18\",\n                \"\",\n                \"vin2b_d5\",\n                \"rgmii1_rxc\",\n                \"vout2_d5\",\n                \"\",\n                \"vin3a_d10\",\n                \"\",\n                \"mii1_txd3\",\n                \"\",\n                \"ehrpwm3B\",\n                \"pr1_mii1_rxd1\",\n                \"pr1_pru1_gpi15\",\n                \"pr1_pru1_gpo15\",\n                \"gpio4_26\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"I2C1_SCL\",\n        \"gpio\": 5,\n        \"mux\": \"spi0_cs0\",\n        \"eeprom\": 3,\n        \"key\": [\n            \"P9_17\",\n            \"I2C_3\",\n            \"P1_6\"\n        ],\n        \"muxRegOffset\": \"0x15c\",\n        \"options\": [\n            \"spi0_cs0\",\n            \"mmc2_sdwp\",\n            \"i2c1_scl\",\n            \"ehrpwm0_synci\",\n            \"pr1_uart0_txd\",\n            \"pr1_edio_data_in1\",\n            \"pr1_edio_data_out1\",\n            \"gpio0_5\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A16\",\n            \"BSM\": \"A14\"\n        },\n        \"ai\": {\n            \"gpio\": 209,\n            \"ball\": {\n                \"abc\": [\n                    \"B24\",\n                    \"F12\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x17CC\",\n                \"0x16B8\"\n            ],\n            \"options\": [\n                \"spi2_cs0\",\n                \"uart3_rtsn\",\n                \"uart5_txd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_17\",\n                \"Driver off\",\n                \"mcasp1_axr1\",\n                \"\",\n                \"\",\n                \"uart6_txd\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_hsync0\",\n                \"\",\n                \"\",\n                \"i2c5_scl\",\n                \"pr2_mii_mt0_clk\",\n                \"pr2_pru1_gpi9\",\n                \"pr2_pru1_gpo9\",\n                \"gpio5_3\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"I2C1_SDA\",\n        \"gpio\": 4,\n        \"mux\": \"spi0_d1\",\n        \"eeprom\": 2,\n        \"key\": [\n            \"P9_18\",\n            \"I2C_4\",\n            \"P1_12\"\n        ],\n        \"muxRegOffset\": \"0x158\",\n        \"options\": [\n            \"spi0_d1\",\n            \"mmc1_sdwp\",\n            \"i2c1_sda\",\n            \"ehrpwm0_tripzone_input\",\n            \"pr1_uart0_rxd\",\n            \"pr1_edio_data_in0\",\n            \"pr1_edio_data_out0\",\n            \"gpio0_4\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B16\",\n            \"BSM\": \"B14\"\n        },\n        \"ai\": {\n            \"gpio\": 208,\n            \"ball\": {\n                \"abc\": [\n                    \"G17\",\n                    \"G12\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x17C8\",\n                \"0x16B4\"\n            ],\n            \"options\": [\n                \"spi2_d0\",\n                \"uart3_ctsn\",\n                \"uart5_rxd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_16\",\n                \"Driver off\",\n                \"mcasp1_axr0\",\n                \"\",\n                \"\",\n                \"uart6_rxd\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_vsync0\",\n                \"\",\n                \"\",\n                \"i2c5_sda\",\n                \"pr2_mii0_rxer\",\n                \"pr2_pru1_gpi8\",\n                \"pr2_pru1_gpo8\",\n                \"gpio5_2\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"I2C2_SCL\",\n        \"gpio\": 13,\n        \"mux\": \"uart1_rtsn\",\n        \"eeprom\": 9,\n        \"key\": [\n            \"P9_19\",\n            \"P1_28\"\n        ],\n        \"muxRegOffset\": \"0x17c\",\n        \"options\": [\n            \"uart1_rtsn\",\n            \"timer5\",\n            \"d_can0_rx\",\n            \"i2c2_scl\",\n            \"spi1_cs1\",\n            \"pr1_uart0_rts_n\",\n            \"pr1_edc_latch1_in\",\n            \"gpio0_13\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D17\",\n            \"BSM\": \"A10\"\n        },\n        \"ai\": {\n            \"gpio\": 102,\n            \"ball\": {\n                \"abc\": [\n                    \"R6\",\n                    \"F4\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1440\",\n                \"0x157C\"\n            ],\n            \"options\": [\n                \"gpmc_a0\",\n                \"\",\n                \"vin3a_d16\",\n                \"vout3_d16\",\n                \"vin4a_d0\",\n                \"\",\n                \"vin4b_d0\",\n                \"i2c4_scl\",\n                \"uart5_rxd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_3\",\n                \"Driver off\",\n                \"vin2a_d5\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d18\",\n                \"emu15\",\n                \"\",\n                \"\",\n                \"uart10_rtsn\",\n                \"kbd_col2\",\n                \"eQEP2A_in\",\n                \"pr1_edio_sof\",\n                \"pr1_pru1_gpi2\",\n                \"pr1_pru1_gpo2\",\n                \"gpio4_6\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"I2C2_SDA\",\n        \"gpio\": 12,\n        \"mux\": \"uart1_ctsn\",\n        \"eeprom\": 10,\n        \"key\": [\n            \"P9_20\",\n            \"P1_26\"\n        ],\n        \"muxRegOffset\": \"0x178\",\n        \"options\": [\n            \"uart1_ctsn\",\n            \"NA\",\n            \"d_can0_tx\",\n            \"i2c2_sda\",\n            \"spi1_cs0\",\n            \"pr1_uart0_cts_n\",\n            \"pr1_edc_latch0_in\",\n            \"gpio0_12\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D18\",\n            \"BSM\": \"B10\"\n        },\n        \"ai\": {\n            \"gpio\": 101,\n            \"ball\": {\n                \"abc\": [\n                    \"T9\",\n                    \"D2\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1444\",\n                \"0x1578\"\n            ],\n            \"options\": [\n                \"gpmc_a1\",\n                \"\",\n                \"vin3a_d17\",\n                \"vout3_d17\",\n                \"vin4a_d1\",\n                \"\",\n                \"vin4b_d1\",\n                \"i2c4_sda\",\n                \"uart5_txd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_4\",\n                \"Driver off\",\n                \"vin2a_d4\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d19\",\n                \"emu14\",\n                \"\",\n                \"\",\n                \"uart10_ctsn\",\n                \"kbd_col1\",\n                \"ehrpwm1_synco\",\n                \"pr1_edc_sync0_out\",\n                \"pr1_pru1_gpi1\",\n                \"pr1_pru1_gpo1\",\n                \"gpio4_5\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART2_TXD\",\n        \"gpio\": 3,\n        \"mux\": \"spi0_d0\",\n        \"eeprom\": 1,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm0\",\n            \"sysfs\": 1,\n            \"index\": 1,\n            \"muxmode\": 3,\n            \"path\": \"ehrpwm.0:1\",\n            \"name\": \"EHRPWM0B\",\n            \"chip\": \"48300000\",\n            \"addr\": \"48300200\"\n        },\n        \"key\": [\n            \"P9_21\",\n            \"GPS_4\",\n            \"P1_10\"\n        ],\n        \"muxRegOffset\": \"0x154\",\n        \"options\": [\n            \"spi0_d0\",\n            \"uart2_txd\",\n            \"i2c2_scl\",\n            \"ehrpwm0B\",\n            \"pr1_uart_rts_n\",\n            \"pr1_edio_latch_in\",\n            \"EMU3\",\n            \"gpio0_3\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B17\",\n            \"BSM\": \"B13\"\n        },\n        \"ai\": {\n            \"gpio\": 67,\n            \"ball\": {\n                \"abc\": [\n                    \"AF8\",\n                    \"B22\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x14F0\",\n                \"0x17C4\"\n            ],\n            \"options\": [\n                \"vin1a_vsync0\",\n                \"vin1b_de1\",\n                \"\",\n                \"\",\n                \"vout3_vsync\",\n                \"uart7_rtsn\",\n                \"\",\n                \"timer13\",\n                \"spi3_cs0\",\n                \"\",\n                \"eQEP1_strobe\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio3_3\",\n                \"Driver off\",\n                \"spi2_d1\",\n                \"uart3_txd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_15\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART2_RXD\",\n        \"gpio\": 2,\n        \"mux\": \"spi0_sclk\",\n        \"eeprom\": 0,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm0\",\n            \"sysfs\": 0,\n            \"index\": 0,\n            \"muxmode\": 3,\n            \"path\": \"ehrpwm.0:0\",\n            \"name\": \"EHRPWM0A\",\n            \"chip\": \"48300000\",\n            \"addr\": \"48300200\"\n        },\n        \"key\": [\n            \"P9_22\",\n            \"GPS_3\",\n            \"P1_8\"\n        ],\n        \"muxRegOffset\": \"0x150\",\n        \"options\": [\n            \"spi0_sclk\",\n            \"uart2_rxd\",\n            \"i2c2_sda\",\n            \"ehrpwm0A\",\n            \"pr1_uart_cts_n\",\n            \"pr1_edio_sof\",\n            \"EMU2\",\n            \"gpio0_2\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A17\",\n            \"BSM\": \"A13\"\n        },\n        \"ai\": {\n            \"gpio\": 179,\n            \"ball\": {\n                \"abc\": [\n                    \"B26\",\n                    \"A26\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x169C\",\n                \"0x17C0\"\n            ],\n            \"options\": [\n                \"xref_clk2\",\n                \"mcasp2_axr10\",\n                \"mcasp1_axr6\",\n                \"mcasp3_ahclkx\",\n                \"mcasp7_ahclkx\",\n                \"\",\n                \"vout2_clk\",\n                \"\",\n                \"vin4a_clk0\",\n                \"\",\n                \"timer15\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio6_19\",\n                \"Driver off\",\n                \"spi2_sclk\",\n                \"uart3_rxd\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_14\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_17\",\n        \"gpio\": 49,\n        \"mux\": \"gpmc_a1\",\n        \"eeprom\": 33,\n        \"key\": [\n            \"P9_23\",\n            \"GP0_4\"\n        ],\n        \"muxRegOffset\": \"0x044\",\n        \"options\": [\n            \"gpmc_a1\",\n            \"gmii2_rxdv\",\n            \"rgmii2_rctl\",\n            \"mmc2_dat0\",\n            \"gpmc_a17\",\n            \"pr1_mii1_txd3\",\n            \"ehrpwm0_synco\",\n            \"gpio1_17\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V14\",\n            \"BSM\": \"R12\"\n        },\n        \"ai\": {\n            \"gpio\": 203,\n            \"ball\": {\n                \"abc\": [\n                    \"A22\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x17B4\",\n                \"\"\n            ],\n            \"options\": [\n                \"spi1_cs1\",\n                \"\",\n                \"sata1_led\",\n                \"spi2_cs1\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio7_11\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO1_25\",\n        \"gpio\": 57,\n        \"mux\": \"gpmc_wpn\",\n        \"eeprom\": null,\n        \"key\": [\n            \"GP0_3\",\n            \"P2_6\"\n        ],\n        \"muxRegOffset\": \"0x064\",\n        \"options\": [\n            \"gpmc_wpn\",\n            \"gmii2_rxer\",\n            \"gpmc_csn5\",\n            \"rmii2_rxer\",\n            \"mmc2_sdcd\",\n            \"pr1_mii1_txen\",\n            \"uart4_txd\",\n            \"gpio1_25\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"U16\",\n            \"BSM\": \"T15\"\n        }\n    },\n    {\n        \"name\": \"GPIO3_2\",\n        \"gpio\": 98,\n        \"mux\": \"gmii1_rxer\",\n        \"eeprom\": null,\n        \"key\": \"GP1_3\",\n        \"muxRegOffset\": \"0x110\",\n        \"options\": [\n            \"gmii1_rxer\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_2\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"J15\",\n            \"BSM\": \"E15\"\n        }\n    },\n    {\n        \"name\": \"GPIO3_1\",\n        \"gpio\": 97,\n        \"mux\": \"gmii1_crs\",\n        \"eeprom\": null,\n        \"key\": \"GP1_4\",\n        \"muxRegOffset\": \"0x10c\",\n        \"options\": [\n            \"gmii1_crs\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_1\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"H17\",\n            \"BSM\": \"F14\"\n        }\n    },\n    {\n        \"name\": \"UART1_TXD\",\n        \"gpio\": 15,\n        \"mux\": \"uart1_txd\",\n        \"eeprom\": 12,\n        \"key\": [\n            \"P9_24\",\n            \"UT1_4\",\n            \"P2_9\"\n        ],\n        \"muxRegOffset\": \"0x184\",\n        \"options\": [\n            \"uart1_txd\",\n            \"mmc2_sdwp\",\n            \"d_can1_rx\",\n            \"i2c1_scl\",\n            \"NA\",\n            \"pr1_uart0_txd_mux1\",\n            \"NA\",\n            \"gpio0_15\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D15\",\n            \"BSM\": \"B11\"\n        },\n        \"ai\": {\n            \"gpio\": 175,\n            \"ball\": {\n                \"abc\": [\n                    \"F20\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x168C\",\n                \"\"\n            ],\n            \"options\": [\n                \"gpio6_15\",\n                \"mcasp1_axr9\",\n                \"dcan2_rx\",\n                \"uart10_txd\",\n                \"\",\n                \"\",\n                \"vout2_vsync\",\n                \"\",\n                \"vin4a_vsync0\",\n                \"i2c3_scl\",\n                \"timer2\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio6_15\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO3_21\",\n        \"gpio\": 117,\n        \"mux\": \"mcasp0_ahclkx\",\n        \"eeprom\": 66,\n        \"key\": [\n            \"P9_25\",\n            \"P1_29\",\n            \"PRU0_7\"\n        ],\n        \"muxRegOffset\": \"0x1ac\",\n        \"options\": [\n            \"mcasp0_ahclkx\",\n            \"NA\",\n            \"mcasp0_axr3\",\n            \"mcasp1_axr1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A14\",\n            \"BSM\": \"C4\"\n        },\n        \"ai\": {\n            \"gpio\": 177,\n            \"ball\": {\n                \"abc\": [\n                    \"D18\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1694\",\n                \"\"\n            ],\n            \"options\": [\n                \"xref_clk0\",\n                \"mcasp2_axr8\",\n                \"mcasp1_axr4\",\n                \"mcasp1_ahclkx\",\n                \"mcasp5_ahclkx\",\n                \"\",\n                \"\",\n                \"vin6a_d0\",\n                \"hdq0\",\n                \"clkout2\",\n                \"timer13\",\n                \"pr2_mii1_col\",\n                \"pr2_pru1_gpi5\",\n                \"pr2_pru1_gpo5\",\n                \"gpio6_17\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"UART1_RXD\",\n        \"gpio\": 14,\n        \"mux\": \"uart1_rxd\",\n        \"eeprom\": 11,\n        \"key\": [\n            \"P9_26\",\n            \"UT1_3\",\n            \"P2_11\"\n        ],\n        \"muxRegOffset\": \"0x180\",\n        \"options\": [\n            \"uart1_rxd\",\n            \"mmc1_sdwp\",\n            \"d_can1_tx\",\n            \"i2c1_sda\",\n            \"NA\",\n            \"pr1_uart0_rxd_mux1\",\n            \"pr1_pru1_pru_r31_16\",\n            \"gpio0_14\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D16\",\n            \"BSM\": \"A11\"\n        },\n        \"ai\": {\n            \"gpio\": 88,\n            \"ball\": {\n                \"abc\": [\n                    \"E21\",\n                    \"AE2\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1688\",\n                \"0x1544\"\n            ],\n            \"options\": [\n                \"gpio6_14\",\n                \"mcasp1_axr8\",\n                \"dcan2_tx\",\n                \"uart10_rxd\",\n                \"\",\n                \"\",\n                \"vout2_hsync\",\n                \"\",\n                \"vin4a_hsync0\",\n                \"i2c3_sda\",\n                \"timer1\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio6_14\",\n                \"Driver off\",\n                \"vin1a_d20\",\n                \"vin1b_d3\",\n                \"\",\n                \"\",\n                \"vout3_d3\",\n                \"\",\n                \"vin3a_d4\",\n                \"\",\n                \"\",\n                \"kbd_col5\",\n                \"pr1_edio_data_in4\",\n                \"pr1_edio_data_out4\",\n                \"pr1_pru0_gpi17\",\n                \"pr1_pru0_gpo17\",\n                \"gpio3_24\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO3_19\",\n        \"gpio\": 115,\n        \"mux\": \"mcasp0_fsr\",\n        \"eeprom\": 64,\n        \"key\": [\n            \"P9_27\",\n            \"P2_34\",\n            \"PRU0_5\",\n            \"E1_4\"\n        ],\n        \"muxRegOffset\": \"0x1a4\",\n        \"options\": [\n            \"mcasp0_fsr\",\n            \"NA\",\n            \"mcasp0_axr3\",\n            \"mcasp1_fsx\",\n            \"EMU2\",\n            \"pr1_pru0_pru_r30_5\",\n            \"pr1_pru0_pru_r31_5\",\n            \"gpio3_19\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C13\",\n            \"BSM\": \"B3\"\n        },\n        \"ai\": {\n            \"gpio\": 111,\n            \"ball\": {\n                \"abc\": [\n                    \"C3\",\n                    \"J14\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x15A0\",\n                \"0x16B0\"\n            ],\n            \"options\": [\n                \"vin2a_d14\",\n                \"\",\n                \"\",\n                \"rgmii1_txd3\",\n                \"vout2_d9\",\n                \"\",\n                \"\",\n                \"\",\n                \"mii1_txclk\",\n                \"\",\n                \"eQEP3B_in\",\n                \"pr1_mii_mr1_clk\",\n                \"pr1_pru1_gpi11\",\n                \"pr1_pru1_gpo11\",\n                \"gpio4_15\",\n                \"Driver off\",\n                \"mcasp1_fsr\",\n                \"mcasp7_axr3\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d1\",\n                \"\",\n                \"vin4a_d1\",\n                \"\",\n                \"i2c4_scl\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio5_1\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"SPI1_CS0\",\n        \"gpio\": 113,\n        \"mux\": \"mcasp0_ahclkr\",\n        \"eeprom\": 63,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ecap2\",\n            \"sysfs\": 7,\n            \"index\": 0,\n            \"muxmode\": 4,\n            \"path\": \"ecap.2\",\n            \"name\": \"ECAPPWM2\",\n            \"universalMode\": \"pwm2\",\n            \"chip\": \"48304000\",\n            \"addr\": \"48304100\"\n        },\n        \"key\": [\n            \"P9_28\",\n            \"GP0_6\",\n            \"P2_30\",\n            \"PRU0_3\"\n        ],\n        \"muxRegOffset\": \"0x19c\",\n        \"options\": [\n            \"mcasp0_ahclkr\",\n            \"NA\",\n            \"mcasp0_axr2\",\n            \"spi1_cs0\",\n            \"eCAP2_in_PWM2_out\",\n            \"pr1_pru0_pru_r30_3\",\n            \"pr1_pru0_pru_r31_3\",\n            \"gpio3_17\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C12\",\n            \"BSM\": \"B1\"\n        },\n        \"ai\": {\n            \"gpio\": 113,\n            \"ball\": {\n                \"abc\": [\n                    \"A12\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16E0\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr11\",\n                \"mcasp6_fsx\",\n                \"mcasp6_fsr\",\n                \"spi3_cs0\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d12\",\n                \"\",\n                \"\",\n                \"timer8\",\n                \"pr2_mii0_txd1\",\n                \"pr2_pru1_gpi13\",\n                \"pr2_pru1_gpo13\",\n                \"gpio4_17\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"SPI1_D0\",\n        \"gpio\": 111,\n        \"mux\": \"mcasp0_fsx\",\n        \"eeprom\": 61,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm0\",\n            \"sysfs\": 1,\n            \"index\": 1,\n            \"muxmode\": 1,\n            \"path\": \"ehrpwm.0:1\",\n            \"name\": \"EHRPWM0B\",\n            \"chip\": \"48300000\",\n            \"addr\": \"48300200\"\n        },\n        \"key\": [\n            \"P9_29\",\n            \"S1_1_4\",\n            \"S1_2_4\",\n            \"P1_33\",\n            \"PRU0_1\"\n        ],\n        \"muxRegOffset\": \"0x194\",\n        \"options\": [\n            \"mcasp0_fsx\",\n            \"ehrpwm0B\",\n            \"NA\",\n            \"spi1_d0\",\n            \"mmc1_sdcd\",\n            \"pr1_pru0_pru_r30_1\",\n            \"pr1_pru0_pru_r31_1\",\n            \"gpio3_15\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B13\",\n            \"BSM\": \"A2\"\n        },\n        \"ai\": {\n            \"gpio\": 139,\n            \"ball\": {\n                \"abc\": [\n                    \"A11\",\n                    \"D14\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16D8\",\n                \"0x16A8\"\n            ],\n            \"options\": [\n                \"mcasp1_axr9\",\n                \"mcasp6_axr1\",\n                \"\",\n                \"spi3_d1\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d14\",\n                \"\",\n                \"\",\n                \"timer6\",\n                \"pr2_mii0_txd3\",\n                \"pr2_pru1_gpi11\",\n                \"pr2_pru1_gpo11\",\n                \"gpio5_11\",\n                \"Driver off\",\n                \"mcasp1_fsx\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_de0\",\n                \"\",\n                \"\",\n                \"i2c3_scl\",\n                \"pr2_mdio_data\",\n                \"\",\n                \"\",\n                \"gpio7_30\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"SPI1_D1\",\n        \"gpio\": 112,\n        \"mux\": \"mcasp0_axr0\",\n        \"eeprom\": 62,\n        \"key\": [\n            \"P9_30\",\n            \"S1_1_3\",\n            \"S1_2_3\",\n            \"P2_32\",\n            \"PRU0_2\"\n        ],\n        \"muxRegOffset\": \"0x198\",\n        \"options\": [\n            \"mcasp0_axr0\",\n            \"NA\",\n            \"NA\",\n            \"spi1_d1\",\n            \"mmc2_sdcd\",\n            \"pr1_pru0_pru_r30_2\",\n            \"pr1_pru0_pru_r31_2\",\n            \"gpio3_16\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D12\",\n            \"BSM\": \"B2\"\n        },\n        \"ai\": {\n            \"gpio\": 140,\n            \"ball\": {\n                \"abc\": [\n                    \"B13\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16DC\",\n                \"\"\n            ],\n            \"options\": [\n                \"mcasp1_axr10\",\n                \"mcasp6_aclkx\",\n                \"mcasp6_aclkr\",\n                \"spi3_d0\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d13\",\n                \"\",\n                \"\",\n                \"timer7\",\n                \"pr2_mii0_txd2\",\n                \"pr2_pru1_gpi12\",\n                \"pr2_pru1_gpo12\",\n                \"gpio5_12\",\n                \"Driver off\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\"\n            ]\n        }\n    },\n    {\n        \"name\": \"SPI1_SCLK\",\n        \"gpio\": 110,\n        \"mux\": \"mcasp0_aclkx\",\n        \"eeprom\": 65,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ehrpwm0\",\n            \"sysfs\": 0,\n            \"index\": 0,\n            \"muxmode\": 1,\n            \"path\": \"ehrpwm.0:0\",\n            \"name\": \"EHRPWM0A\",\n            \"chip\": \"48300000\",\n            \"addr\": \"48300200\"\n        },\n        \"key\": [\n            \"P9_31\",\n            \"S1_1_5\",\n            \"S1_2_5\",\n            \"P1_36\"\n        ],\n        \"muxRegOffset\": \"0x190\",\n        \"options\": [\n            \"mcasp0_aclkx\",\n            \"ehrpwm0A\",\n            \"NA\",\n            \"spi1_sclk\",\n            \"mmc0_sdcd\",\n            \"pr1_pru0_pru_r30_0\",\n            \"pr1_pru0_pru_r31_0\",\n            \"gpio3_14\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A13\",\n            \"BSM\": \"A1\"\n        },\n        \"ai\": {\n            \"gpio\": 138,\n            \"ball\": {\n                \"abc\": [\n                    \"B12\",\n                    \"C14\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16D4\",\n                \"0x16A4\"\n            ],\n            \"options\": [\n                \"mcasp1_axr8\",\n                \"mcasp6_axr0\",\n                \"\",\n                \"spi3_sclk\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d15\",\n                \"\",\n                \"\",\n                \"timer5\",\n                \"pr2_mii0_txen\",\n                \"pr2_pru1_gpi10\",\n                \"pr2_pru1_gpo10\",\n                \"gpio5_10\",\n                \"Driver off\",\n                \"mcasp1_aclkx\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_fld0\",\n                \"\",\n                \"\",\n                \"i2c3_sda\",\n                \"pr2_mdio_mdclk\",\n                \"pr2_pru1_gpi7\",\n                \"pr2_pru1_gpo7\",\n                \"gpio7_31\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"VDD_ADC\",\n        \"key\": [\n            \"P9_32\",\n            \"ADC_2\",\n            \"P1_17\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A9\",\n            \"BSM\": \"B9\"\n        },\n        \"ai\": {\n            // 0 = 1.8V, 1 = 3.3V\n            \"gpio\": 91,\n            \"ball\": {\n                \"abc\": [\n                    \"AD3\",\n                    \"\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x1550\",\n                \"\"\n            ],\n            \"options\": [\n                \"vin1a_d23\",\n                \"vin1b_d0\",\n                \"\",\n                \"\",\n                \"vout3_d0\",\n                \"\",\n                \"vin3a_d7\",\n                \"\",\n                \"\",\n                \"kbd_col8\",\n                \"pr1_edio_data_in7\",\n                \"pr1_edio_data_out7\",\n                \"pr1_pru0_gpi20\",\n                \"pr1_pru0_gpo20\",\n                \"gpio3_27\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"AIN4\",\n        \"ain\": 4,\n        \"eeprom\": 71,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_33\",\n            \"P1_27\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C8\",\n            \"BSM\": \"C7\"\n        },\n        \"ai\": {\n            \"ain\": 7,\n            \"gpio\": 503\n        }\n    },\n    {\n        \"name\": \"GNDA_ADC\",\n        \"key\": [\n            \"P9_34\",\n            \"ADC_1\",\n            \"P1_18\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B9\",\n            \"BSM\": \"B7\"\n        }\n    },\n    {\n        \"name\": \"AIN6\",\n        \"ain\": 6,\n        \"eeprom\": 73,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_35\",\n            \"P1_2\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A8\",\n            \"BSM\": \"C9\"\n        },\n        \"ai\": {\n            \"ain\": 4,\n            \"gpio\": 500\n        }\n    },\n    {\n        \"name\": \"AIN5\",\n        \"ain\": 5,\n        \"eeprom\": 72,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_36\",\n            \"P2_35\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B8\",\n            \"BSM\": \"C8\"\n        },\n        \"ai\": {\n            \"ain\": 6,\n            \"gpio\": 502\n        }\n    },\n    {\n        \"name\": \"AIN2\",\n        \"ain\": 2,\n        \"eeprom\": 69,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_37\",\n            \"ADC_5\",\n            \"P1_23\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B7\",\n            \"BSM\": \"B6\"\n        },\n        \"ai\": {\n            \"ain\": 3,\n            \"gpio\": 498\n        }\n    },\n    {\n        \"name\": \"AIN3\",\n        \"ain\": 3,\n        \"eeprom\": 70,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_38\",\n            \"ADC_6\",\n            \"P1_25\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"A7\",\n            \"BSM\": \"C6\"\n        },\n        \"ai\": {\n            \"ain\": 2,\n            \"gpio\": 497\n        }\n    },\n    {\n        \"name\": \"AIN0\",\n        \"ain\": 0,\n        \"eeprom\": 67,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_39\",\n            \"ADC_3\",\n            \"P1_19\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B6\",\n            \"BSM\": \"A8\"\n        },\n        \"ai\": {\n            \"ain\": 0,\n            \"gpio\": 496\n        }\n    },\n    {\n        \"name\": \"AIN1\",\n        \"ain\": 1,\n        \"eeprom\": 68,\n        \"scale\": 4096,\n        \"key\": [\n            \"P9_40\",\n            \"ADC_4\",\n            \"P1_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C7\",\n            \"BSM\": \"B8\"\n        },\n        \"ai\": {\n            \"ain\": 1,\n            \"gpio\": 497\n        }\n    },\n    {\n        \"name\": \"AIN7\",\n        \"ain\": 7,\n        \"eeprom\": null,\n        \"scale\": 4096,\n        \"key\": \"P2_36\",\n        \"ball\": {\n            \"ZCZ\": \"C9\",\n            \"BSM\": \"D7\"\n        }\n    },\n    {\n        \"name\": \"CLKOUT2\",\n        \"gpio\": 116,\n        \"mux\": \"mcasp0_axr1\",\n        \"eeprom\": null,\n        \"key\": [\n            \"P9_41\",\n            \"GP0_5\",\n            \"P2_28\",\n            \"PRU0_6\"\n        ],\n        \"muxRegOffset\": \"0x1a8\",\n        \"options\": [\n            \"mcasp0_axr1\",\n            \"eQEP0_index\",\n            \"mcasp1_axr0\",\n            \"EMU3\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_20\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D13\",\n            \"BSM\": \"C3\"\n        },\n        \"ai\": {\n            \"gpio\": 180,\n            \"ball\": {\n                \"abc\": [\n                    \"C23\",\n                    \"C1\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16A0\",\n                \"0x1580\"\n            ],\n            \"options\": [\n                \"xref_clk3\",\n                \"mcasp2_axr11\",\n                \"mcasp1_axr7\",\n                \"mcasp4_ahclkx\",\n                \"mcasp8_ahclkx\",\n                \"\",\n                \"vout2_de\",\n                \"hdq0\",\n                \"vin4a_de0\",\n                \"clkout3\",\n                \"timer16\",\n                \"\",\n                \"\",\n                \"\",\n                \"gpio6_20\",\n                \"Driver off\",\n                \"vin2a_d6\",\n                \"\",\n                \"\",\n                \"\",\n                \"vout2_d17\",\n                \"emu16\",\n                \"\",\n                \"\",\n                \"mii1_rxd1\",\n                \"kbd_col3\",\n                \"eQEP2B_in\",\n                \"pr1_mii_mt1_clk\",\n                \"pr1_pru1_gpi3\",\n                \"pr1_pru1_gpo3\",\n                \"gpio4_7\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"CLKOUT2\",\n        \"gpio\": 20,\n        \"mux\": \"xdma_event_intr1\",\n        \"eeprom\": 13,\n        \"key\": [\n            \"P9_41B\",\n            \"P1_20\"\n        ],\n        \"muxRegOffset\": \"0x1b4\",\n        \"options\": [\n            \"xdma_event_intr1\",\n            \"NA\",\n            \"NA\",\n            \"clkout2\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_20\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"D14\",\n            \"BSM\": \"B4\"\n        }\n    },\n    {\n        \"name\": \"GPIO0_7\",\n        \"gpio\": 7,\n        \"mux\": \"ecap0_in_pwm0_out\",\n        \"eeprom\": 4,\n        // From am335x technical manual, p.183\n        // http://www.ti.com/lit/ug/spruh73n/spruh73n.pdf\n        \"pwm\": {\n            \"module\": \"ecap0\",\n            \"sysfs\": 2,\n            \"index\": 0,\n            \"muxmode\": 0,\n            \"path\": \"ecap.0\",\n            \"name\": \"ECAPPWM0\",\n            \"chip\": \"48300000\",\n            \"addr\": \"48300100\"\n        },\n        \"key\": [\n            \"P9_42\",\n            \"S1_2_6\",\n            \"P2_29\"\n        ],\n        \"muxRegOffset\": \"0x164\",\n        \"options\": [\n            \"eCAP0_in_PWM0_out\",\n            \"uart3_txd\",\n            \"spi1_cs1\",\n            \"pr1_ecap0_ecap_capin_apwm_o\",\n            \"spi1_sclk\",\n            \"mmc0_sdwp\",\n            \"xdma_event_intr2\",\n            \"gpio0_7\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C18\",\n            \"BSM\": \"C5\"\n        },\n        \"ai\": {\n            \"gpio\": 114,\n            \"ball\": {\n                \"abc\": [\n                    \"E14\",\n                    \"C2\"\n                ]\n            },\n            \"muxRegOffset\": [\n                \"0x16E4\",\n                \"0x159C\"\n            ],\n            \"options\": [\n                \"mcasp1_axr12\",\n                \"mcasp7_axr0\",\n                \"\",\n                \"spi3_cs1\",\n                \"\",\n                \"\",\n                \"\",\n                \"vin6a_d11\",\n                \"\",\n                \"\",\n                \"timer9\",\n                \"pr2_mii0_txd0\",\n                \"pr2_pru1_gpi14\",\n                \"pr2_pru1_gpo14\",\n                \"gpio4_18\",\n                \"Driver off\",\n                \"vin2a_d13\",\n                \"\",\n                \"\",\n                \"rgmii1_txctl\",\n                \"vout2_d10\",\n                \"\",\n                \"\",\n                \"\",\n                \"mii1_rxdv\",\n                \"kbd_row8\",\n                \"eQEP3A_in\",\n                \"pr1_mii1_txd0\",\n                \"pr1_pru1_gpi10\",\n                \"pr1_pru1_gpo10\",\n                \"gpio4_14\",\n                \"Driver off\"\n            ]\n        }\n    },\n    {\n        \"name\": \"GPIO0_7\",\n        \"gpio\": 114,\n        \"mux\": \"ecap0_in_pwm0_out\",\n        \"eeprom\": null,\n        \"key\": [\n            \"P9_42B\",\n            \"E1_3\",\n            \"P1_31\",\n            \"PRU0_4\"\n        ],\n        \"muxRegOffset\": \"0x1a0\",\n        \"options\": [\n            \"mcasp0_aclkr\",\n            \"eQEP0A_in\",\n            \"mcasp0_axr2\",\n            \"mcasp1_aclkx\",\n            \"mmc0_sdwp\",\n            \"pr1_pru0_pru_r30_4\",\n            \"pr1_pru0_pru_r31_4\",\n            \"gpio3_18\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B12\",\n            \"BSM\": \"A3\"\n        }\n    },\n    {\n        \"name\": \"USB1_DRVVBUS\",\n        \"gpio\": 109,\n        \"key\": \"P1_3\",\n        \"muxRegOffset\": \"0x134\",\n        \"mux\": \"USB1_DRVVBUS\",\n        \"eeprom\": null,\n        \"options\": [\n            \"USB1_DRVVBUS\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_13\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"F15\",\n            \"BSM\": \"M14\"\n        }\n    },\n    {\n        \"name\": \"USB1_VBUS\",\n        \"key\": \"P1_5\",\n        \"ball\": {\n            \"ZCZ\": \"T18\",\n            \"BSM\": \"M15\"\n        },\n        \"muxRegOffset\": \"0x130\"\n    },\n    {\n        \"name\": \"VIN_USB\",\n        \"key\": \"P1_7\",\n        \"ball\": {\n            \"BSM\": [\n                \"P9\",\n                \"R9\",\n                \"T9\"\n            ]\n        }\n    },\n    {\n        \"name\": \"USB1_DN\",\n        \"key\": \"P1_9\",\n        \"ball\": {\n            \"ZCZ\": \"R18\",\n            \"BSM\": \"L16\"\n        },\n        \"muxRegOffset\": \"0x120\"\n    },\n    {\n        \"name\": \"USB1_DP\",\n        \"key\": \"P1_11\",\n        \"ball\": {\n            \"ZCZ\": \"R17\",\n            \"BSM\": \"L15\"\n        },\n        \"muxRegOffset\": \"0x124\"\n    },\n    {\n        \"name\": \"USB1_ID\",\n        \"key\": \"P1_13\",\n        \"ball\": {\n            \"ZCZ\": \"P17\",\n            \"BSM\": \"L14\"\n        },\n        \"muxRegOffset\": \"0x12c\"\n    },\n    {\n        \"name\": \"VIN_BAT\",\n        \"key\": \"P2_14\",\n        \"ball\": {\n            \"BSM\": [\n                \"P8\",\n                \"R8\",\n                \"T8\"\n            ]\n        }\n    },\n    {\n        \"name\": \"BAT_TEMP\",\n        \"key\": \"P2_16\",\n        \"ball\": {\n            \"BSM\": \"N6\"\n        }\n    },\n    {\n        \"name\": \"UART0_RXD\",\n        \"gpio\": 42,\n        \"mux\": \"uart0_rxd\",\n        \"eeprom\": null,\n        \"key\": [\n            \"UT0_3\",\n            \"P1_32\"\n        ],\n        \"muxRegOffset\": \"0x170\",\n        \"options\": [\n            \"uart0_rxd\",\n            \"spi1_cs0\",\n            \"dcan0_tx\",\n            \"i2c2_sda\",\n            \"eCAP2_in_PWM2_out\",\n            \"pr1_pru1_pru_r30_14\",\n            \"pr1_pru1_pru_r31_14\",\n            \"gpio1_10\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"E15\",\n            \"BSM\": \"A12\"\n        }\n    },\n    {\n        \"name\": \"UART0_TXD\",\n        \"gpio\": 43,\n        \"mux\": \"uart0_txd\",\n        \"eeprom\": null,\n        \"key\": [\n            \"UT0_4\",\n            \"P1_30\"\n        ],\n        \"muxRegOffset\": \"0x174\",\n        \"options\": [\n            \"uart0_rxd\",\n            \"spi1_cs1\",\n            \"dcan0_4x\",\n            \"i2c2_scl\",\n            \"eCAP1_in_PWM1_out\",\n            \"pr1_pru1_pru_r30_15\",\n            \"pr1_pru1_pru_r31_15\",\n            \"gpio1_11\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"E16\",\n            \"BSM\": \"B12\"\n        }\n    },\n    {\n        \"name\": \"GPIO1_20\",\n        \"gpio\": 52,\n        \"mux\": \"gpmc_a4\",\n        \"eeprom\": null,\n        \"key\": \"P2_10\",\n        \"muxRegOffset\": \"0x050\",\n        \"options\": [\n            \"gpmc_a4\",\n            \"gmii2_txd1\",\n            \"rgmii2_td1\",\n            \"rmii2_txd1\",\n            \"gpmc_a20\",\n            \"pr1_mii1_txd0\",\n            \"eQEP1A_in\",\n            \"gpio1_20\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"R14\",\n            \"BSM\": \"R13\"\n        }\n    },\n    {\n        \"name\": \"GPIO1_27\",\n        \"gpio\": 59,\n        \"mux\": \"gpmc_a11\",\n        \"eeprom\": null,\n        \"key\": \"P2_2\",\n        \"muxRegOffset\": \"0x06c\",\n        \"options\": [\n            \"gpmc_a11\",\n            \"gmii2_rxd0\",\n            \"rgmii2_rd0\",\n            \"rmii2_rxd0\",\n            \"gpmc_a27\",\n            \"pr1_mii1_rxer\",\n            \"mcasp0_axr1\",\n            \"gpio1_27\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"V17\",\n            \"BSM\": \"T16\"\n        }\n    },\n    {\n        \"name\": \"GPIO1_26\",\n        \"gpio\": 58,\n        \"mux\": \"gpmc_a10\",\n        \"eeprom\": null,\n        \"key\": \"P2_4\",\n        \"muxRegOffset\": \"0x068\",\n        \"options\": [\n            \"gpmc_a10\",\n            \"gmii2_rxd1\",\n            \"rgmii2_rd1\",\n            \"rmii2_rxd1\",\n            \"gpmc_a26\",\n            \"pr1_mii1_rxdv\",\n            \"mcasp0_axr0\",\n            \"gpio1_26\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"T16\",\n            \"BSM\": \"R15\"\n        }\n    },\n    {\n        \"name\": \"GPIO1_9\",\n        \"gpio\": 41,\n        \"mux\": \"uart0_rtsn\",\n        \"eeprom\": null,\n        \"key\": \"P2_25\",\n        \"muxRegOffset\": \"0x16c\",\n        \"options\": [\n            \"uart0_rtsn\",\n            \"uart4_txd\",\n            \"dcan1_rx\",\n            \"i2c1_scl\",\n            \"spi1_d1\",\n            \"spi1_cs0\",\n            \"pr1_edc_sync1_out\",\n            \"gpio1_9\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"E17\",\n            \"BSM\": \"C13\"\n        }\n    },\n    {\n        \"name\": \"GPIO1_8\",\n        \"gpio\": 40,\n        \"mux\": \"uart0_ctsn\",\n        \"eeprom\": null,\n        \"key\": \"P2_27\",\n        \"muxRegOffset\": \"0x168\",\n        \"options\": [\n            \"uart0_ctsn\",\n            \"uart4_txd\",\n            \"dcan1_tx\",\n            \"i2c1_sda\",\n            \"spi1_d0\",\n            \"timer7\",\n            \"pr1_edc_sync0_out\",\n            \"gpio1_8\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"E18\",\n            \"BSM\": \"C12\"\n        }\n    },\n    {\n        \"name\": \"MMC0_SDCD\",\n        \"gpio\": 6,\n        \"mux\": \"spi0_cs1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x160\",\n        \"options\": [\n            \"spi0_cs1\",\n            \"uart3_rxd\",\n            \"eCAP1_in_PWM1_out\",\n            \"mmc0_pow\",\n            \"xdma_event_intr2\",\n            \"mmc0_sdcd\",\n            \"EMU4\",\n            \"gpio0_6\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C15\",\n            \"BSM\": \"C14\"\n        }\n    },\n    {\n        \"name\": \"MDIO_DATA\",\n        \"gpio\": 0,\n        \"mux\": \"mdio_data\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x148\",\n        \"options\": [\n            \"mdio_data\",\n            \"timer6\",\n            \"uart5_rxd\",\n            \"uart3_ctsn\",\n            \"mmc0_sdcd\",\n            \"mmc1_cmd\",\n            \"mmc2_cmd\",\n            \"gpio0_0\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"M17\",\n            \"BSM\": \"E13\"\n        }\n    },\n    {\n        \"name\": \"MDIO_CLK\",\n        \"gpio\": 1,\n        \"mux\": \"mdio_clk\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x14c\",\n        \"options\": [\n            \"mdio_clk\",\n            \"timer5\",\n            \"uart5_txd\",\n            \"uart3_rtsn\",\n            \"mmc0_wp\",\n            \"mmc1_clk\",\n            \"mmc2_clk\",\n            \"gpio0_1\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"M18\",\n            \"BSM\": \"D13\"\n        }\n    },\n    {\n        \"name\": \"MII_TX3\",\n        \"gpio\": 16,\n        \"mux\": \"gmii1_txd3\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x11c\",\n        \"options\": [\n            \"gmii1_txd3\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_16\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"J18\",\n            \"BSM\": \"G15\"\n        }\n    },\n    {\n        \"name\": \"MII_TX2\",\n        \"gpio\": 17,\n        \"mux\": \"gmii1_txd2\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x120\",\n        \"options\": [\n            \"gmii1_txd2\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_17\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K15\",\n            \"BSM\": \"G16\"\n        }\n    },\n    {\n        \"name\": \"USB0_DRVVBUS\",\n        \"gpio\": 18,\n        \"mux\": \"USB0_DRVVBUS\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x11c\",\n        \"options\": [\n            \"USB0_DRVVBUS\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_18\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"F16\",\n            \"BSM\": \"J15\"\n        }\n    },\n    {\n        \"name\": \"MII_TX1\",\n        \"gpio\": 21,\n        \"mux\": \"gmii1_txd1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x124\",\n        \"options\": [\n            \"gmii1_txd1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K16\",\n            \"BSM\": \"H14\"\n        }\n    },\n    {\n        \"name\": \"MII_TX1\",\n        \"gpio\": 21,\n        \"mux\": \"gmii1_txd1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x124\",\n        \"options\": [\n            \"gmii1_txd1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K16\",\n            \"BSM\": \"H14\"\n        }\n    },\n    {\n        \"name\": \"MII_TX0\",\n        \"gpio\": 28,\n        \"mux\": \"gmii1_txd0\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x128\",\n        \"options\": [\n            \"gmii1_txd0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_28\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K17\",\n            \"BSM\": \"H15\"\n        }\n    },\n    {\n        \"name\": \"MII_TX0\",\n        \"gpio\": 28,\n        \"mux\": \"gmii1_txd0\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x128\",\n        \"options\": [\n            \"gmii1_txd0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_28\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K17\",\n            \"BSM\": \"H15\"\n        }\n    },\n    {\n        \"name\": \"GPIO0_29\",\n        \"gpio\": 29,\n        \"mux\": \"rmii1_refclk\",\n        \"eeprom\": null,\n        \"key\": \"S1_1_6\",\n        \"muxRegOffset\": \"0x144\",\n        \"options\": [\n            \"rmii1_refclk\",\n            \"NA\",\n            \"spi1_cs0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio0_28\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"H18\",\n            \"BSM\": \"J14\"\n        }\n    },\n    {\n        \"name\": \"MII_RX3\",\n        \"gpio\": 82,\n        \"mux\": \"gmii1_rxd3\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x134\",\n        \"options\": [\n            \"gmii1_rxd3\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_18\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"L17\",\n            \"BSM\": \"D14\"\n        }\n    },\n    {\n        \"name\": \"MII_RX2\",\n        \"gpio\": 83,\n        \"mux\": \"gmii1_rxd2\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x138\",\n        \"options\": [\n            \"gmii1_rxd2\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_19\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"L16\",\n            \"BSM\": \"D15\"\n        }\n    },\n    {\n        \"name\": \"MII_RX1\",\n        \"gpio\": 84,\n        \"mux\": \"gmii1_rxd1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x13c\",\n        \"options\": [\n            \"gmii1_rxd1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_20\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"L15\",\n            \"BSM\": \"D16\"\n        }\n    },\n    {\n        \"name\": \"MII_RX0\",\n        \"gpio\": 85,\n        \"mux\": \"gmii1_rxd0\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x140\",\n        \"options\": [\n            \"gmii1_rxd0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_21\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"M16\",\n            \"BSM\": \"E14\"\n        }\n    },\n    {\n        \"name\": \"MMC0_DAT3\",\n        \"gpio\": 90,\n        \"mux\": \"mmc0_dat3\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x0f0\",\n        \"options\": [\n            \"mmc0_dat3\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_26\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"F17\",\n            \"BSM\": \"C15\"\n        }\n    },\n    {\n        \"name\": \"MMC0_DAT2\",\n        \"gpio\": 91,\n        \"mux\": \"mmc0_dat2\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x0f4\",\n        \"options\": [\n            \"mmc0_dat2\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_27\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"F18\",\n            \"BSM\": \"C16\"\n        }\n    },\n    {\n        \"name\": \"MMC0_DAT1\",\n        \"gpio\": 92,\n        \"mux\": \"mmc0_dat1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x0f8\",\n        \"options\": [\n            \"mmc0_dat1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_28\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"G15\",\n            \"BSM\": \"A15\"\n        }\n    },\n    {\n        \"name\": \"MMC0_DAT0\",\n        \"gpio\": 93,\n        \"mux\": \"mmc0_dat0\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x0fc\",\n        \"options\": [\n            \"mmc0_dat0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_29\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"G16\",\n            \"BSM\": \"A16\"\n        }\n    },\n    {\n        \"name\": \"MMC0_CLK\",\n        \"gpio\": 94,\n        \"mux\": \"mmc0_clk\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x100\",\n        \"options\": [\n            \"mmc0_clk\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_30\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"G17\",\n            \"BSM\": \"B15\"\n        }\n    },\n    {\n        \"name\": \"MMC0_CMD\",\n        \"gpio\": 95,\n        \"mux\": \"mmc0_cmd\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x104\",\n        \"options\": [\n            \"mmc0_cmd\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio2_31\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"G18\",\n            \"BSM\": \"B16\"\n        }\n    },\n    {\n        \"name\": \"MII_COL\",\n        \"gpio\": 96,\n        \"mux\": \"gmii1_col\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x108\",\n        \"options\": [\n            \"gmii1_col\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_0\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"H16\",\n            \"BSM\": \"F15\"\n        }\n    },\n    {\n        \"name\": \"MII_TXEN\",\n        \"gpio\": 99,\n        \"mux\": \"gmii1_txen\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x114\",\n        \"options\": [\n            \"gmii1_txen\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_3\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"J16\",\n            \"BSM\": \"G14\"\n        }\n    },\n    {\n        \"name\": \"MII_RXDV\",\n        \"gpio\": 100,\n        \"mux\": \"gmii1_rxdv\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x118\",\n        \"options\": [\n            \"gmii1_rxdv\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_4\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"J17\",\n            \"BSM\": \"F16\"\n        }\n    },\n    {\n        \"name\": \"I2C0_SDA\",\n        \"gpio\": 101,\n        \"mux\": \"I2C0_SDA\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x188\",\n        \"options\": [\n            \"I2C0_SDA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_5\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C17\",\n            \"BSM\": \"C11\"\n        }\n    },\n    {\n        \"name\": \"I2C0_SCL\",\n        \"gpio\": 102,\n        \"mux\": \"I2C0_SCL\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x18c\",\n        \"options\": [\n            \"I2C0_SCL\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_6\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C16\",\n            \"BSM\": \"C10\"\n        }\n    },\n    {\n        \"name\": \"EMU0\",\n        \"gpio\": 103,\n        \"mux\": \"EMU0\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x1e4\",\n        \"options\": [\n            \"EMU0\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_7\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"C14\",\n            \"BSM\": \"E2\"\n        }\n    },\n    {\n        \"name\": \"EMU1\",\n        \"gpio\": 104,\n        \"mux\": \"EMU1\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x1e8\",\n        \"options\": [\n            \"EMU1\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_8\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"B14\",\n            \"BSM\": \"E3\"\n        }\n    },\n    {\n        \"name\": \"MII_TXCLK\",\n        \"gpio\": 105,\n        \"mux\": \"gmii1_txclk\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x12c\",\n        \"options\": [\n            \"gmii1_txclk\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_9\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"K18\",\n            \"BSM\": \"H16\"\n        }\n    },\n    {\n        \"name\": \"MII_RXCLK\",\n        \"gpio\": 106,\n        \"mux\": \"gmii1_rxclk\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x130\",\n        \"options\": [\n            \"gmii1_rxclk\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_10\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"L18\",\n            \"BSM\": \"E16\"\n        }\n    },\n    {\n        \"name\": \"MII_RXCLK\",\n        \"gpio\": 106,\n        \"mux\": \"gmii1_rxclk\",\n        \"eeprom\": null,\n        \"muxRegOffset\": \"0x130\",\n        \"options\": [\n            \"gmii1_rxclk\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"NA\",\n            \"gpio3_10\"\n        ],\n        \"ball\": {\n            \"ZCZ\": \"L18\",\n            \"BSM\": \"E16\"\n        }\n    }\n];\n\nvar pins = {};\nfor (var i in pinIndex) {\n    if (Array.isArray(pinIndex[i].key)) {\n        for (var j = 0; j < pinIndex[i].key.length; j++) {\n            var myKey = pinIndex[i].key[j];\n            //console.log(\"key[\" + j + \"].[\" + myKey + \"]: \" + i);\n            pins[myKey] = i;\n        }\n    } else if (typeof pinIndex[i] != 'undefined') {\n        pins[pinIndex[i].key] = i;\n    }\n    if (typeof pinIndex[i].gpio == 'number') {\n        pins[\"GPIO_\" + pinIndex[i].gpio] = i;\n    }\n    if (typeof pinIndex[i].eeprom == 'number') {\n        pins[\"EEPROM_\" + pinIndex[i].eeprom] = i;\n    }\n    if (typeof pinIndex[i].ain == 'number') {\n        pins[\"A\" + pinIndex[i].ain] = i;\n    }\n    if (typeof pinIndex[i].muxRegOffset == 'string') {\n        var offset = pinIndex[i].muxRegOffset.toUpperCase();\n        pins[\"MUX_\" + offset] = i;\n    }\n}\n\nvar uarts = {\n    \"/dev/ttyO0\": {},\n    \"/dev/ttyO1\": {\n        \"devicetree\": \"BB-UART1\",\n        \"rx\": \"P9_26\",\n        \"tx\": \"P9_24\"\n    },\n    \"/dev/ttyO2\": {\n        \"devicetree\": \"BB-UART2\",\n        \"rx\": \"P9_22\",\n        \"tx\": \"P9_21\"\n    },\n    \"/dev/ttyO3\": {},\n    \"/dev/ttyO4\": {\n        \"devicetree\": \"BB-UART4\",\n        \"rx\": \"P9_11\",\n        \"tx\": \"P9_13\"\n    },\n    \"/dev/ttyO5\": {\n        \"devicetree\": \"BB-UART5\",\n        \"rx\": \"P8_38\",\n        \"tx\": \"P8_37\"\n    }\n};\n\nvar i2c = {\n    \"/dev/i2c-0\": {},\n    \"/dev/i2c-1\": {\n        \"devicetree\": \"BB-I2C1\",\n        \"path\": \"/dev/i2c-2\",\n        \"sda\": \"P9_18\",\n        \"scl\": \"P9_17\"\n    },\n    \"/dev/i2c-1a\": {\n        \"devicetree\": \"BB-I2C1A\",\n        \"path\": \"/dev/i2c-2\",\n        \"sda\": \"P9_26\",\n        \"scl\": \"P9_24\"\n    },\n    \"/dev/i2c-2\": {\n        \"path\": \"/dev/i2c-1\",\n        \"sda\": \"P9_20\",\n        \"scl\": \"P9_19\"\n    }\n};\n\nvar getPinObject = function (key) {\n    if (typeof key == \"string\") {\n        // Ignore case\n        key = key.toUpperCase();\n        // Replace alternate separators and leading zeros\n        key = key.replace(/[\\.\\-_ ]0*/g, \"_\");\n    }\n    if (typeof key == \"number\") {\n        key = \"GPIO_\" + key;\n    }\n    //console.log(key);\n    //console.log(pins[key]);\n    if (typeof pinIndex[pins[key]] == \"object\") {\n        var pinObject = Object.assign({}, pinIndex[pins[key]]);\n\n        // Only keep the matching index led\n        if (pinObject.led) {\n            //console.log(\"pinObject[\" + key + \"]: \" + JSON.stringify(pinObject));\n            if (Array.isArray(pinObject.led)) {\n                //console.log(\"pinObject.key: \" + pinObject.key);\n                var i = pinObject.key.indexOf(key);\n                if (i >= 0) {\n                    var led = pinObject.led[i];\n                    pinObject.led = led;\n                    //console.log(\"pinObject.led[\" + i + \"]: \" + led);\n                } else {\n                    pinObject.led = null;\n                }\n            }\n        }\n\n        // Remove other keys\n        pinObject.key = key;\n    } else {\n        return (null);\n    }\n\n    return (pinObject);\n};\n\nvar getPinKeys = function (filter) {\n    var keys = [];\n    for (var key in pins) {\n        if (typeof filter != 'undefined') {\n            if (key.search(filter) >= 0) {\n                keys.push(key);\n            }\n        } else {\n            keys.push(key);\n        }\n    }\n    return (keys);\n};\n\n// from https://stackoverflow.com/questions/15478954/sort-array-elements-string-with-numbers-natural-sort\nvar naturalCompare = function (a, b) {\n    var ax = [],\n        bx = [];\n\n    a.replace(/(\\d+)|(\\D+)/g, function (_, $1, $2) {\n        ax.push([$1 || Infinity, $2 || \"\"])\n    });\n    b.replace(/(\\d+)|(\\D+)/g, function (_, $1, $2) {\n        bx.push([$1 || Infinity, $2 || \"\"])\n    });\n\n    while (ax.length && bx.length) {\n        var an = ax.shift();\n        var bn = bx.shift();\n        var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);\n        if (nn) return nn;\n    }\n\n    return ax.length - bx.length;\n}\n\n\n\nmodule.exports = {\n    getPinObject: getPinObject,\n    getPinKeys: getPinKeys,\n    naturalCompare: naturalCompare,\n    uarts: uarts,\n    i2c: i2c\n}"
  },
  {
    "path": "src/bonescript.js",
    "content": "var _bonescript = {};\n_bonescript.modules = {};\n_bonescript._callbacks = {};\n_bonescript._seqnum = 0;\n_bonescript.on = {};\n_bonescript.on.connect = function () {};\n_bonescript.on.connecting = function () {};\n_bonescript.on.disconnect = function () {};\n_bonescript.on.connect_failed = function () {};\n_bonescript.on.error = function (err) {\n    throw (new Error(err))\n};\n_bonescript.on.reconnect = function () {};\n_bonescript.on.reconnect_failed = function () {};\n_bonescript.on.reconnecting = function () {};\n_bonescript.on.initialized = function () {};\n\n(function () {\n    if (typeof document == 'undefined') {\n        var io = require('socket.io-client');\n        var crypto = require('crypto');\n        module.exports.startClient = function (host, callback) {\n            var passphrase_hash;\n            if (host.password)\n                passphrase_hash = crypto.createHash('sha256').update(host.password).digest(\"hex\"); //generate sha256 hash for supplied password\n            _bonescript.on.initialized = callback;\n            var socket = _onSocketIOLoaded(host.address, host.port, io, passphrase_hash);\n        }\n        return;\n    }\n    require = myrequire;\n    var head = document.getElementsByTagName('head')[0];\n    var script = document.createElement('script');\n    script.type = 'text/javascript';\n    script.src = '___INSERT_HOST___/socket.io/socket.io.js';\n    script.charset = 'UTF-8';\n    var scriptObj = head.appendChild(script);\n    scriptObj.onload = _onSocketIOLoaded;\n}());\n\nfunction _onSocketIOLoaded(host, port, socketio, passphrase_hash) {\n    //console.log(\"socket.io loaded\");\n    if (typeof host == 'undefined') host = '___INSERT_HOST___';\n    if (typeof port == 'undefined') port = 80;\n    if (typeof socketio == 'undefined' && typeof io != 'undefined') socketio = io;\n    var socket;\n    if (typeof host == 'string')\n        socket = socketio('http://' + host + ':' + port, {\n            extraHeaders: {\n                'Authorization': typeof passphrase_hash != 'undefined' ? passphrase_hash : null //send passphrase_has as Authorization extraheader\n            }\n        });\n    else\n        socket = socketio('___INSERT_HOST___', {\n            port: port\n        });\n    socket.on('require', getRequireData);\n    socket.on('bonescript', _seqcall);\n    socket.on('connect', _bonescript.on.connect);\n    socket.on('connecting', _bonescript.on.connecting);\n    socket.on('disconnect', _bonescript.on.disconnect);\n    socket.on('connect_failed', _bonescript.on.connect_failed);\n    socket.on('error', _bonescript.on.error);\n    socket.on('reconnect', _bonescript.on.reconnect);\n    socket.on('reconnect_failed', _bonescript.on.reconnect_failed);\n    socket.on('reconnecting', _bonescript.on.reconnecting);\n    socket.on('initialized', _bonescript.on.initialized);\n\n    function getRequireData(m) {\n        if (!m.module || !m.data)\n            throw ('Invalid \"require\" message sent for \"' + m.module + '\"');\n        //console.log('Initialized module: ' + m.module);\n        _bonescript.modules[m.module] = {};\n        for (var x in m.data) {\n            if (!m.data[x].type || !m.data[x].name || (typeof m.data[x].value == 'undefined'))\n                throw ('Invalid data in \"require\" message sent for \"' + m.module + '.' + m.data[x] + '\"');\n            if (m.data[x].type == 'function') {\n                // define the function\n                if (!m.data[x].value)\n                    throw ('Missing args in \"require\" message sent for \"' + m.module + '.' + m.data[x] + '\"');\n                var myargs = m.data[x].value;\n\n                // eval of objString builds the call data out of arguments passed in\n                var objString = '';\n                for (var y in myargs) {\n                    if (isNaN(y)) continue; // Need to find the source of this bug\n                    if (myargs[y] == 'callback') continue;\n                    objString += ' if(typeof ' + myargs[y] + ' == \"function\") {\\n';\n                    objString += '  ' + myargs[y] + ' = ' + myargs[y] + '.toString();\\n';\n                    objString += ' }\\n';\n                    objString += ' calldata.' + myargs[y] + ' = ' + myargs[y] + ';\\n';\n                }\n                var argsString = myargs.join(', ');\n                var handyfunc = '_bonescript.modules[\"' + m.module + '\"].' + m.data[x].name +\n                    ' = ' +\n                    'function (' + argsString + ') {\\n' +\n                    ' var calldata = {};\\n' +\n                    objString +\n                    ' if(callback) {\\n' +\n                    '  _bonescript._callbacks[_bonescript._seqnum] = callback;\\n' +\n                    '  calldata.seq = _bonescript._seqnum;\\n' +\n                    '  calldata.length = callback.length;\\n' +\n                    '  _bonescript._seqnum++;\\n' +\n                    ' }\\n' +\n                    ' socket.emit(\"' + m.module + '$' + m.data[x].name + '\", calldata);\\n' +\n                    '};\\n';\n                eval(handyfunc);\n            } else {\n                _bonescript.modules[m.module][m.data[x].name] = m.data[x].value;\n            }\n        }\n        _bonescript.modules[m.module].socket = socket;\n        _bonescript.on.initialized();\n    }\n\n    return (socket);\n}\n\nfunction _seqcall(data) {\n    if ((typeof data.seq != 'number') || (typeof _bonescript._callbacks[data.seq] != 'function'))\n        throw \"Invalid callback message received: \" + JSON.stringify(data);\n    if (_bonescript._callbacks[data.seq].length == 1)\n        _bonescript._callbacks[data.seq](data);\n    else\n        _bonescript._callbacks[data.seq](data.err, data.resp);\n    if (data.oneshot) delete _bonescript._callbacks[data.seq];\n}\n\n// Require must be synchronous to be able to return data structures and\n// functions and therefore cannot call socket.io. All exported modules must\n// be exported ahead of time.\nfunction myrequire(module) {\n    if (typeof _bonescript == 'undefined')\n        throw 'No BoneScript modules are not currently available';\n    if (typeof _bonescript.modules[module] == 'undefined')\n        throw 'Module \"' + module + '\" is not currently available';\n    return (_bonescript.modules[module]);\n}\n\nif (typeof module != 'undefined') {\n    module.exports.require = myrequire;\n}"
  },
  {
    "path": "src/constants.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\nmodule.exports = {\n    OUTPUT: \"out\",\n    INPUT: \"in\",\n    INPUT_PULLUP: \"in_pullup\",\n    HIGH: 1,\n    LOW: 0,\n    LSBFIRST: 1, // used in: shiftOut(dataPin, clockPin, bitOrder, val)\n    MSBFIRST: 0,\n    CHANGE: \"both\",\n    RISING: \"rising\",\n    FALLING: \"falling\",\n    ANALOG_OUTPUT: \"analog_out\"\n}"
  },
  {
    "path": "src/eeprom.js",
    "content": "// Functions derived from https://github.com/joyent/node/blob/master/lib/buffer.js are:\n//\n// Copyright Joyent, Inc. and other Node contributors. All rights reserved.\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n// IN THE SOFTWARE.\n\nvar fs = require('fs');\nvar buffer = require('buffer');\nvar util = require('util');\nvar winston = require('winston');\nvar bone = require('./bone');\n\nvar debug = process.env.DEBUG ? true : false;\n\n// Function derived from https://github.com/joyent/node/blob/master/lib/buffer.js\nif (!buffer.Buffer.prototype.readUint16BE) {\n    buffer.Buffer.prototype.readUint16BE = function (offset) {\n        var val = 0;\n        val = this[offset] << 8;\n        val |= this[offset + 1];\n        return (val);\n    };\n}\n\n// Function derived from https://github.com/joyent/node/blob/master/lib/buffer.js\nif (!buffer.Buffer.prototype.hexSlice) {\n    var toHex = function (n) {\n        if (n < 16) return '0' + n.toString(16);\n        return n.toString(16);\n    };\n    buffer.Buffer.prototype.hexSlice = function (start, end) {\n        var len = this.length;\n        if (!start || start < 0) start = 0;\n        if (!end || end < 0 || end > len) end = len;\n\n        var out = '';\n        for (var i = start; i < end; i++) {\n            out += toHex(this[i]);\n        }\n        return (out);\n    };\n}\n\n// Function derived from https://github.com/joyent/node/blob/master/lib/buffer.js\nif (!buffer.Buffer.prototype.writeUint16BE) {\n    buffer.Buffer.prototype.writeUint16BE = function (value, offset) {\n        this[offset] = (value & 0xff00) >>> 8;\n        this[offset + 1] = value & 0x00ff;\n    };\n}\n\n// Function derived from https://github.com/joyent/node/blob/master/lib/buffer.js\n// fill(value, start=0, end=buffer.length)\nif (!buffer.Buffer.prototype.fill) {\n    buffer.Buffer.prototype.fill = function (value, start, end) {\n        value || (value = 0);\n        start || (start = 0);\n        end || (end = this.length);\n\n        for (var i = start; i < end; i++) {\n            this[i] = value;\n        }\n    };\n}\n\n// Function derived from https://github.com/joyent/node/blob/master/lib/buffer.js\nif (!buffer.Buffer.prototype.hexWrite) {\n    buffer.Buffer.prototype.hexWrite = function (string, offset, length) {\n        offset = +offset || 0;\n        var remaining = this.length - offset;\n        if (!length) {\n            length = remaining;\n        } else {\n            length = +length;\n            if (length > remaining) {\n                length = remaining;\n            }\n        }\n\n        // must be an even number of digits\n        var strLen = string.length;\n        if (strLen % 2) {\n            throw new Error('Invalid hex string');\n        }\n        if (length > strLen / 2) {\n            length = strLen / 2;\n        }\n\n        for (var i = 0; i < length; i++) {\n            var byte = parseInt(string.substr(i * 2, 2), 16);\n            if (isNaN(byte)) throw new Error('Invalid hex string');\n            this[offset + i] = byte;\n        }\n        return i;\n    };\n}\n\nvar eepromData = new buffer.Buffer(244);\n\nvar readEeproms = function (files) {\n    var data = {};\n    for (var file in files) {\n        var raw = fetchEepromData(file);\n        var parsed = null;\n        if (raw) {\n            if (files[file].type == 'bone') {\n                parsed = parseMainEeprom(raw);\n                if (parsed) parsed.type = 'bone';\n            } else {\n                parsed = parseCapeEeprom(raw);\n                if (parsed) parsed.type = 'cape';\n            }\n            if (parsed) {\n                data[file] = parsed;\n            }\n        }\n    }\n    return (data);\n};\n\nvar fetchEepromData = function (address) {\n    try {\n        if (debug) winston.debug('Reading EEPROM at ' + address);\n        var eepromFile =\n            fs.openSync(\n                address,\n                'r'\n            );\n        fs.readSync(eepromFile, eepromData, 0, 244, 0);\n        return (eepromData);\n    } catch (ex) {\n        if (debug) winston.debug('Unable to open EEPROM at ' + address + ': ' + ex);\n        return (null);\n    }\n};\n\nvar parseMainEeprom = function (x) {\n    var data = {};\n    data.header = x.hexSlice(0, 4);\n    if (data.header != 'aa5533ee') {\n        winston.error('Unknown EEPROM format: ' + data.header);\n        return (null);\n    }\n    data.boardName = x.toString('ascii', 4, 12).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.version = x.toString('ascii', 12, 16).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.serialNumber = x.toString('ascii', 16, 28).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.configOption = x.hexSlice(28, 60);\n    return (data);\n};\n\nvar parseCapeEeprom = function (x) {\n    var data = {};\n    data.header = x.hexSlice(0, 4);\n    if (data.header != 'aa5533ee') {\n        winston.error('Unknown EEPROM format: ' + data.header);\n        return (null);\n    }\n    data.formatRev = x.toString('ascii', 4, 6);\n    if (data.formatRev != 'A0') {\n        winston.error('Unknown EEPROM format revision: ' + data.formatRev);\n        return (null);\n    }\n    data.boardName = x.toString('ascii', 6, 38).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.version = x.toString('ascii', 38, 42).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.manufacturer = x.toString('ascii', 42, 58).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.partNumber = x.toString('ascii', 58, 74).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.numPins = x.readUint16BE(74);\n    data.serialNumber = x.toString('ascii', 76, 88).trim().replace(/^\\x00+|\\x00+$/g, '');\n    data.currentVDD_3V3EXP = x.readUint16BE(236);\n    data.currentVDD_5V = x.readUint16BE(238);\n    data.currentSYS_5V = x.readUint16BE(240);\n    data.DCSupplied = x.readUint16BE(242);\n    data.mux = {};\n    var pins = bone.getPinKeys(\"EEPROM\");\n    for (var i = 0; i < pins.length; i++) {\n        var pin = bone.getPinObject(pins[i]);\n        if (typeof pin.eeprom != 'undefined') {\n            var pinOffset = pin.eeprom * 2 + 88;\n            var pinData = x.readUint16BE(pinOffset);\n            var pinObject = {};\n            var used = (pinData & 0x8000) >> 15;\n            if (used || debug) {\n                pinObject.used = used ? 'used' : 'available';\n                if (debug) pinObject.data = x.hexSlice(pinOffset, pinOffset + 2);\n                var direction = (pinData & 0x6000) >> 13;\n                switch (direction) {\n                case 1:\n                    pinObject.direction = 'in';\n                    break;\n                case 2:\n                    pinObject.direction = 'out';\n                    break;\n                case 3:\n                    pinObject.direction = 'bidir';\n                    break;\n                default:\n                    winston.error('Unknown direction value: ' + direction);\n                }\n                pinObject.slew = (pinData & 0x40) ? 'slow' : 'fast';\n                pinObject.rx = (pinData & 0x20) ? 'enabled' : 'disabled';\n                var pullup = (pinData & 0x18) >> 3;\n                switch (pullup) {\n                case 1:\n                    pinObject.pullup = 'disabled';\n                    break;\n                case 2:\n                    pinObject.pullup = 'pullup';\n                    break;\n                case 0:\n                    pinObject.pullup = 'pulldown';\n                    break;\n                default:\n                    winston.error('Unknown pullup value: ' + pullup);\n                }\n                pinObject.mode = (pinData & 0x0007);\n                try {\n                    // read mux from debugfs\n                    var muxReadout = fs.readFileSync('/sys/kernel/debug/omap_mux/' + bone[pin].mux, 'ascii');\n                    pinObject.function = muxReadout.split(\"\\n\")[2].split(\"|\")[pinObject.mode].replace('signals:', '').trim();\n                } catch (ex) {\n                    if (debug) winston.debug('Unable to read pin mux function name: ' + bone[pin].mux);\n                }\n                data.mux[pin] = pinObject;\n            }\n        }\n    }\n    return (data);\n};\n\nvar fillCapeEepromData = function (data) {\n    eepromData.fill();\n    eepromData.hexWrite('aa5533ee', 0, 4);\n    eepromData.write('A0', 4, 2, 'ascii');\n    if (data.boardName.length > 32) {\n        data.boardName.length = 32;\n    }\n    eepromData.write(data.boardName, 6, 32, 'ascii');\n    if (data.version.length > 4) {\n        data.version.length = 4;\n    }\n    eepromData.write(data.version, 38, 4, 'ascii');\n    if (data.manufacturer.length > 16) {\n        data.manufacturer.length = 16;\n    }\n    eepromData.write(data.manufacturer, 42, 16, 'ascii');\n    if (data.partNumber.length > 16) {\n        data.partNumber.length = 16;\n    }\n    eepromData.write(data.partNumber, 58, 16, 'ascii');\n    eepromData.writeUint16BE(data.numPins, 74, 'ascii');\n    if (data.serialNumber.length > 12) {\n        data.serialNumber.length = 12;\n    }\n    eepromData.write(data.serialNumber, 76, 12, 'ascii');\n    eepromData.writeUint16BE(data.currentVDD_3V3EXP, 236);\n    eepromData.writeUint16BE(data.currentVDD_5V, 238);\n    eepromData.writeUint16BE(data.currentSYS_5V, 240);\n    eepromData.writeUint16BE(data.DCSupplied, 242);\n    for (var pin in data.mux) {\n        if (typeof bone[pin].eeprom != 'undefined') {\n            var pinOffset = bone[pin].eeprom * 2 + 88;\n            var pinObject = data.mux[pin];\n            var pinData = 0;\n            if (pinObject.used == 'used') pinData |= 0x8000;\n            switch (pinObject.direction) {\n            case 'in':\n                pinData |= 0x2000;\n                break;\n            case 'out':\n                pinData |= 0x4000;\n                break;\n            case 'bidir':\n                pinData |= 0x6000;\n                break;\n            default:\n                winston.error('Unknown direction value: ' + pinObject.direction);\n                pinData |= 0x2000;\n            }\n            if (pinObject.slew == 'slow') pinData |= 0x40;\n            if (pinObject.rx == 'enabled') pinData |= 0x20;\n            var pullup = (pinData & 0x18) >> 3;\n            switch (pinObject.pullup) {\n            case 'disabled':\n                pinData |= 0x08;\n                break;\n            case 'pullup':\n                pinData |= 0x10;\n                break;\n            case 'pulldown':\n                break;\n            default:\n                winston.error('Unknown pullup value: ' + pullup);\n            }\n            pinData |= (pinObject.mode & 0x0007);\n            eepromData.writeUint16BE(pinData, pinOffset);\n        }\n    }\n    return (eepromData);\n};\n\nvar defaultEepromFiles = {\n    '/sys/bus/i2c/drivers/at24/1-0050/eeprom': {\n        type: 'bone'\n    },\n    '/sys/bus/i2c/drivers/at24/1-0051/eeprom': {\n        type: 'bone'\n    },\n    '/sys/bus/i2c/drivers/at24/3-0054/eeprom': {\n        type: 'cape'\n    },\n    '/sys/bus/i2c/drivers/at24/3-0055/eeprom': {\n        type: 'cape'\n    },\n    '/sys/bus/i2c/drivers/at24/3-0056/eeprom': {\n        type: 'cape'\n    },\n    '/sys/bus/i2c/drivers/at24/3-0057/eeprom': {\n        type: 'cape'\n    },\n    'test-bone.eeprom': {\n        type: 'bone'\n    },\n    'test-cape.eeprom': {\n        type: 'cape'\n    },\n};\nmodule.exports = {\n    readEeproms: readEeproms,\n    fillCapeEepromData: fillCapeEepromData\n}"
  },
  {
    "path": "src/ffiimp.js",
    "content": "var bone = require('./bone');\nvar fs = require('fs');\nvar my = require('./my');\nvar shell = my.require('shelljs');\nvar winston = my.require('winston');\nvar ffi = my.require('ffi');\n\nvar debug = process.env.DEBUG ? true : false;\n//function to convert bonescript pin identifier to MRAA's format\nvar mraaGPIO = function (pin) {\n    var pinObject = bone.getPinObject(pin);\n    var pinNo;\n    if (typeof pinObject != 'object') {\n        throw (\"Invalid pin: \" + pin);\n    }\n    if (pinObject.key.indexOf('P8') != -1) {\n        pinNo = Number(pinObject.key.replace('P8_', ''));\n    } else if (pinObject.key.indexOf('P9') != -1) {\n        pinNo = Number(pinObject.key.replace('P9_', ''));\n        pinNo += 46;\n    }\n    return '0x' + pinNo.toString(16);\n};\n// function to write a .c file at path , similar to writeTextFile\nvar writeCModule = function (filename, data, callback) {\n    if (filename.indexOf(\".c\") == -1)\n        filename += \".c\";\n    if (typeof callback == 'function') {\n        var cb = function (err) {\n            callback({\n                'err': err\n            });\n        };\n        fs.writeFile(filename, data, 'utf-8', cb);\n    } else {\n        try {\n            return fs.writeFileSync(filename, data, 'utf-8');\n        } catch (ex) {\n            winston.error(\"writeCModule error: \" + ex);\n            return (false);\n        }\n    }\n};\n//load C module from shared object at path\nvar loadCModule = function (path, args, mraa) {\n    //compile at the path if shared object does not exist\n    if (path.indexOf('.c') != -1)\n        path = path.replace('.c', '');\n    mraa = mraa || false; // link mraa\n    var inPath = path + '.c';\n    var shellCmd = 'gcc -shared -fpic ' + inPath + ' -o ' + path + '.so';\n    if (mraa) shellCmd += ' -lmraa';\n    if (debug) winston.debug('loadCModule: shellCmd = ' + shellCmd);\n\n    // Consider not running if .so newer than .c\n    shell.exec(shellCmd);\n\n    if (ffi.exists)\n        return ffi.Library(path, args);\n    else {\n        winston.info(\"loadCModule: Could not load module FFI\");\n        return \"ffi not loaded\";\n    }\n};\n\nmodule.exports = {\n    mraaGPIO: mraaGPIO,\n    loadCModule: loadCModule,\n    writeCModule: writeCModule\n}"
  },
  {
    "path": "src/functions.js",
    "content": "//\n// Copyright (C) 2012 - Cabin Programs, Ken Keller\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of\n// this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to\n// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n// of the Software, and to permit persons to whom the Software is furnished to do\n// so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n// Bits and Bytes\n//    lowByte(value)\n//    highByte(value)\n//    bitRead(value, bitnum)\n//    bitWrite(value, bitnum, bitdata)\n//    bitSet(value, bitnum)\n//    bitClear(value, bitnum)\n//    bit(bitnum)\n//\n// Trigonometry\n//    sin(radians)\n//    cos(radians)\n//    tan(radians)\n//\n//  Math\n//    min(x,y)\n//    max(x,y)\n//    abs(x)\n//    constrain(x, a, b)\n//    map(value, fromLow, fromHigh, toLow, toHigh)\n//    pow(x, y)\n//    sqrt(x)\n//\n//  Random Numbers\n//    randomSeed(x)\n//    random(min, max)\n//    random(max)\n//\n\n\n// Returns the lower 8 bits of  value\nvar lowByte = function (value) {\n    return (value & 0x0ff);\n};\n\n// Returns the value shifted right by 8 bits\nvar highByte = function (value) {\n    return (lowByte(value >> 8));\n};\n\n// Returns the value of the bit number specified (return:0 or 1)\nvar bitRead = function (value, bitnum) {\n    return ((value >> bitnum) & 0x01);\n};\n\n// Returns value with bit changed to specified data\nvar bitWrite = function (value, bitnum, bitdata) {\n    value = value & ~(0x01 << bitnum);\n    bitdata = (bitdata & 0x01) << bitnum;\n    return (value | bitdata);\n};\n\n// Returns value with specified bit set\nvar bitSet = function (value, bitnum) {\n    return (value | (0x01 << bitnum));\n};\n\n// Returns value with specified bit clear\nvar bitClear = function (value, bitnum) {\n    return (value & (~(0x01 << bitnum)));\n};\n\n//Returns a value with one specified bit number set\nvar bit = function (bitnum) {\n    return (0x01 << bitnum);\n};\n\n// Returns the sine of an angle (in radians).\nvar sin = function (radians) {\n    return (Math.sin(radians));\n};\n\n// Returns the cos of an angle (in radians).\nvar cos = function (radians) {\n    return (Math.cos(radians));\n};\n\n// Returns the tan of an angle (in radians).\nvar tan = function (radians) {\n    return (Math.tan(radians));\n};\n\n// Returns the the minimum of x or y\nvar min = function (x, y) {\n    return (Math.min(x, y));\n};\n\n// Returns the the maximum of x or y\nvar max = function (x, y) {\n    return (Math.max(x, y));\n};\n\n// Returns the the absolute value of x\nvar abs = function (x) {\n    return (Math.abs(x));\n};\n\n// Returns a value constrained within the range of a to b\n// Returns: x if x is between a and b\n//          a if x is less than a\n//          b if x is greater than b\nvar constrain = function (x, a, b) {\n    if (x > b) x = b;\n    else if (x < a) x = a;\n    return (x);\n};\n\n// Returns a value re-mapped from one range to another\nvar map = function (value, fromLow, fromHigh, toLow, toHigh) {\n    return (toLow + (((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow)));\n};\n\n// Returns x raised to y power\nvar pow = function (x, y) {\n    return (Math.pow(x, y));\n};\n\n// Returns the aquare root of x\nvar sqrt = function (x) {\n    return (Math.sqrt(x));\n};\n\n// Returns nothing\nvar randomSeedValue;\nvar randomSeed = function (x) {\n    // empty - javascript has no random seed function\n    randomSeedValue = x;\n};\n\n// Returns a pseudo-random number\n// Valid calls: random(max)\n//              random(min, max)\nvar random = function (min, max) {\n    if (isNaN(max)) {\n        max = min;\n        min = 0;\n    }\n    return ((Math.random() * (max - min)) + min);\n};\n\nmodule.exports = {\n    lowByte: lowByte,\n    highByte: highByte,\n    bitRead: bitRead,\n    bitWrite: bitWrite,\n    bitSet: bitSet,\n    bitClear: bitClear,\n    bit: bit,\n    sin: sin,\n    cos: cos,\n    tan: tan,\n    min: min,\n    max: max,\n    abs: abs,\n    constrain: constrain,\n    map: map,\n    pow: pow,\n    sqrt: sqrt,\n    randomSeed: randomSeed,\n    random: random\n}"
  },
  {
    "path": "src/hw_capemgr.js",
    "content": "var fs = require('fs');\nvar winston = require('winston');\nvar my = require('./my');\nvar parse = require('./parse');\n\nvar debug = process.env.DEBUG ? true : false;\n\nvar gpioFile = {};\nvar pwmPrefix = {};\nvar ainPrefix = \"\";\n\nvar logfile = '/var/lib/cloud9/bonescript.log';\n\nvar readPWMFreqAndValue = function (pin, pwm) {\n    var mode = {};\n    try {\n        var period = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/period');\n        var duty = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/duty');\n        mode.freq = 1.0e9 / period;\n        mode.value = duty / period;\n    } catch (ex) {}\n    return (mode);\n};\n\nvar readGPIODirection = function (n, gpio) {\n    var mode = {};\n    var directionFile = \"/sys/class/gpio/gpio\" + n + \"/direction\";\n    if (my.file_existsSync(directionFile)) {\n        mode.active = true;\n        var direction = fs.readFileSync(directionFile, 'utf-8');\n        direction = direction.replace(/^\\s+|\\s+$/g, '');\n        mode.direction = direction;\n    }\n    return (mode);\n};\n\nvar readPinMux = function (pin, mode, callback) {\n    var pinctrlFile = '/sys/kernel/debug/pinctrl/44e10800.pinmux/pins';\n    var muxRegOffset = parseInt(pin.muxRegOffset, 16);\n    var readPinctrl = function (err, data) {\n        if (err) {\n            mode.err = 'readPinctrl error: ' + err;\n            if (debug) winston.debug(mode.err);\n            callback(mode);\n        }\n        mode = parse.modeFromPinctrl(data, muxRegOffset, 0x44e10800, mode);\n        callback(mode);\n    };\n    var tryPinctrl = function (exists) {\n        if (exists) {\n            fs.readFile(pinctrlFile, 'utf8', readPinctrl);\n        } else {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): no valid mux data');\n            callback(mode);\n        }\n    };\n    if (callback) {\n        my.file_exists(pinctrlFile, tryPinctrl);\n    } else {\n        try {\n            var data2 = fs.readFileSync(pinctrlFile, 'utf8');\n            mode = parse.modeFromPinctrl(data2, muxRegOffset, 0x44e10800, mode);\n        } catch (ex) {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): ' + ex);\n        }\n    }\n    return (mode);\n};\n\nvar setPinMode = function (pin, pinData, template, resp, callback) {\n    if (debug) winston.debug('hw.setPinMode(' + [pin.key, pinData, template, JSON.stringify(resp)] + ');');\n    if (debug) winston.debug('typeof callack = ' + typeof callback);\n    if (template == 'bspm') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (callback) {\n            doCreateDT(resp);\n            return (resp);\n        }\n        if (pin.led) {\n            gpioFile[pin.key] = '/sys/class/leds/beaglebone::' + pin.led + '/brightness';\n        }\n    } else if (template == 'bspwm') {\n        if (callback) {\n            my.load_dt('am33xx_pwm', null, resp, doCreateDT);\n            return (resp);\n        }\n        if (!my.load_dt('am33xx_pwm')) {\n            resp.err = 'Error loading am33xx_pwm devicetree overlay';\n            return (resp);\n        }\n    } else {\n        resp.err = 'Unknown pin mode template';\n        if (callback) {\n            callback(resp);\n            return (resp);\n        }\n    }\n\n    // only synchronous stuff at this point\n\n    if (!my.create_dt(pin, pinData, template)) {\n        resp.err = 'Error loading devicetree overlay for ' + pin.key + ' using template ' + template;\n        return (resp);\n    }\n    if (template == 'bspwm') {\n        try {\n            var ocp = my.is_ocp();\n            var p = 'bs_pwm_test_' + pin.key;\n            var pwm_test = my.find_sysfsFile(p, ocp, p + '.');\n            pwmPrefix[pin.pwm.name] = pwm_test;\n            fs.writeFileSync(pwm_test + '/polarity', 0);\n        } catch (ex) {\n            resp.err = 'Error enabling PWM controls: ' + ex;\n            winston.error(resp.err);\n        }\n    }\n\n    // now to define the asynchronous calls\n\n    function doCreateDT(resp) {\n        if (resp.err) {\n            callback(resp);\n            return;\n        }\n        my.create_dt(pin, pinData, template, true, false, resp, onCreateDT);\n    }\n\n    function onCreateDT(resp) {\n        if (resp.err) {\n            callback(resp);\n            return;\n        }\n        if (template == 'bspwm') {\n            my.file_find('/sys/devices', 'ocp.', 1, onFindOCP);\n        } else {\n            callback(resp);\n        }\n\n        function onFindOCP(ocp) {\n            if (ocp.err) {\n                resp.err = \"Error searching for ocp: \" + ocp.err;\n                if (debug) winston.debug(resp.err);\n                callback(resp);\n                return;\n            }\n            my.file_find(ocp.path, 'bs_pwm_test_' + pin.key + '.', 1, onFindPWM);\n        }\n\n        function onFindPWM(pwm_test) {\n            if (pwm_test.err) {\n                resp.err = \"Error searching for pwm_test: \" + pwm_test.err;\n                if (debug) winston.debug(resp.err);\n                callback(resp);\n                return;\n            }\n            my.file_find(pwm_test.path, 'period', 1, onFindPeriod);\n\n            function onFindPeriod(period) {\n                if (period.err) {\n                    resp.err = \"Error searching for period: \" + period.err;\n                    if (debug) winston.debug(resp.err);\n                    callback(resp);\n                    return;\n                }\n                pwmPrefix[pin.pwm.name] = pwm_test.path;\n                fs.writeFile(pwm_test.path + '/polarity', 0, 'ascii', onPolarityWrite);\n            }\n        }\n\n        function onPolarityWrite(err) {\n            if (err) {\n                resp.err = \"Error writing PWM polarity: \" + err;\n                if (debug) winston.debug(resp.err);\n            }\n            callback(resp);\n        }\n    }\n\n    return (resp);\n};\n\nvar setLEDPinToGPIO = function (pin, resp) {\n    var path = \"/sys/class/leds/beaglebone:green:\" + pin.led + \"/trigger\";\n\n    if (my.file_existsSync(path)) {\n        fs.writeFileSync(path, \"gpio\");\n    } else {\n        resp.err = \"Unable to find LED \" + pin.led;\n        winston.error(resp.err);\n        resp.value = false;\n    }\n\n    return (resp);\n};\n\nvar exportGPIOControls = function (pin, direction, resp, callback) {\n    if (debug) winston.debug('hw.exportGPIOControls(' + [pin.key, direction, resp] + ');');\n    var n = pin.gpio;\n    if (callback) {\n        my.file_exists(gpioFile[pin.key], onFileExists);\n        return;\n    }\n    var exists = my.file_existsSync(gpioFile[pin.key]);\n    if (exists) {\n        if (debug) winston.debug(\"gpio: \" + n + \" already exported.\");\n        fs.writeFileSync(\"/sys/class/gpio/gpio\" + n + \"/direction\",\n            direction, null);\n    } else {\n        try {\n            if (debug) winston.debug(\"exporting gpio: \" + n);\n            fs.writeFileSync(\"/sys/class/gpio/export\", \"\" + n, null);\n            if (debug) winston.debug(\"setting gpio \" + n +\n                \" direction to \" + direction);\n            fs.writeFileSync(\"/sys/class/gpio/gpio\" + n + \"/direction\",\n                direction, null);\n        } catch (ex2) {\n            resp.value = false;\n            resp.err = 'Unable to export gpio-' + n + ': ' + ex2;\n            if (debug) winston.debug(resp.err);\n            var gpioUsers =\n                fs.readFileSync('/sys/kernel/debug/gpio', 'utf-8');\n            gpioUsers = gpioUsers.split('\\n');\n        }\n    }\n\n    function onFileExists(exists) {\n        if (exists) {\n            if (debug) winston.debug(\"gpio: \" + n + \" already exported.\");\n            fs.writeFile(\"/sys/class/gpio/gpio\" + n + \"/direction\",\n                direction, null, onGPIODirectionSet);\n        } else {\n            if (debug) winston.debug(\"exporting gpio: \" + n);\n            fs.writeFile(\"/sys/class/gpio/export\", \"\" + n, null, onGPIOExport);\n        }\n    }\n\n    function onGPIOExport(err) {\n        if (err) onError(err);\n        if (debug) winston.debug(\"setting gpio \" + n +\n            \" direction to \" + direction);\n        fs.writeFile(\"/sys/class/gpio/gpio\" + n + \"/direction\",\n            direction, null, onGPIODirectionSet);\n    }\n\n    function onGPIODirectionSet(err) {\n        if (err) onError(err);\n        else callback(resp);\n    }\n\n    function onError(err) {\n        resp.err = 'Unable to export gpio-' + n + ': ' + err;\n        resp.value = false;\n        if (debug) winston.debug(resp.err);\n        findOwner();\n    }\n\n    function findOwner() {\n        fs.readFile('/sys/kernel/debug/gpio', 'utf-8', onGPIOUsers);\n    }\n\n    function onGPIOUsers(err, data) {\n        if (!err) {\n            var gpioUsers = data.split('\\n');\n            for (var x in gpioUsers) {\n                var y = gpioUsers[x].match(/gpio-(\\d+)\\s+\\((\\S+)\\s*\\)/);\n                if (y && y[1] == n) {\n                    resp.err += '\\nconsumed by ' + y[2];\n                    if (debug) winston.debug(resp.err);\n                }\n            }\n        }\n        callback(resp);\n    }\n\n    return (resp);\n};\n\nvar writeGPIOValue = function (pin, value, callback) {\n    if (typeof gpioFile[pin.key] == 'undefined') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (pin.led) {\n            gpioFile[pin.key] = \"/sys/class/leds/beaglebone:\";\n            gpioFile[pin.key] += \"green:\" + pin.led + \"/brightness\";\n        }\n        if (!my.file_existsSync(gpioFile[pin.key])) {\n            winston.error(\"Unable to find gpio: \" + gpioFile[pin.key]);\n        }\n    }\n    if (debug) winston.debug(\"gpioFile = \" + gpioFile[pin.key]);\n    if (callback) {\n        fs.writeFile(gpioFile[pin.key], '' + value, null, callback);\n    } else {\n        try {\n            fs.writeFileSync(gpioFile[pin.key], '' + value, null);\n        } catch (ex) {\n            winston.error(\"Unable to write to \" + gpioFile[pin.key]);\n        }\n    }\n};\n\nvar readGPIOValue = function (pin, resp, callback) {\n    var gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'digitalRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 2);\n            callback(resp);\n        };\n        fs.readFile(gpioFile, readFile);\n        return (true);\n    }\n    resp.value = parseInt(fs.readFileSync(gpioFile), 2);\n    return (resp);\n};\n\nvar enableAIN = function (callback) {\n    var helper = \"\";\n    if (my.load_dt('cape-bone-iio')) {\n        var ocp = my.is_ocp();\n        if (ocp) {\n            helper = my.find_sysfsFile('helper', ocp, 'helper.');\n            if (helper) {\n                ainPrefix = helper + '/AIN';\n            }\n        }\n    }\n    if (callback) {\n        callback({\n            'path': helper\n        })\n    }\n    return (helper.length > 1);\n};\n\nvar readAIN = function (pin, resp, callback) {\n    var ainFile = ainPrefix + pin.ain.toString();\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'analogRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 10) / 1800;\n            callback(resp);\n        };\n        fs.readFile(ainFile, readFile);\n        return (resp);\n    }\n    resp.value = parseInt(fs.readFileSync(ainFile), 10);\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') returned ' + resp.value;\n        winston.error(resp.err);\n    }\n    resp.value = resp.value / 1800;\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') scaled to ' + resp.value;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar writeGPIOEdge = function (pin, mode) {\n    fs.writeFileSync('/sys/class/gpio/gpio' + pin.gpio + '/edge', mode);\n\n    var resp = {};\n    resp.gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    resp.valuefd = fs.openSync(resp.gpioFile, 'r');\n    resp.value = new Buffer(1);\n\n    return (resp);\n};\n\nvar writePWMFreqAndValue = function (pin, pwm, freq, value, resp, callback) {\n    if (debug) winston.debug('hw.writePWMFreqAndValue(' + [pin.key, pwm, freq, value, resp] + ');');\n    var path = pwmPrefix[pin.pwm.name];\n    try {\n        var period = Math.round(1.0e9 / freq); // period in ns\n        var duty = Math.round(period * value);\n        fs.writeFileSync(path + '/duty', 0);\n        if (pwm.freq != freq) {\n            if (debug) winston.debug('Updating PWM period: ' + period);\n            fs.writeFileSync(path + '/period', period);\n        }\n        if (debug) winston.debug('Updating PWM duty: ' + duty);\n        fs.writeFileSync(path + '/duty', duty);\n    } catch (ex) {\n        resp.err = 'error updating PWM freq and value: ' + path + ', ' + ex;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar readEeproms = function (eeproms) {\n    var boardName = fs.readFileSync(my.is_capemgr() + '/baseboard/board-name',\n        'ascii');\n    var version = fs.readFileSync(my.is_capemgr() + '/baseboard/revision',\n        'ascii');\n    var serialNumber = fs.readFileSync(my.is_capemgr() + '/baseboard/serial-number',\n        'ascii');\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'] = {};\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].boardName = boardName;\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].version = version;\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].serialNumber = serialNumber;\n    return (eeproms);\n};\n\nvar readPlatform = function (platform) {\n    platform.name = fs.readFileSync(my.is_capemgr() + '/baseboard/board-name',\n        'ascii').trim();\n    if (platform.name == 'A335BONE') platform.name = 'BeagleBone';\n    if (platform.name == 'A335BNLT') platform.name = 'BeagleBone Black';\n    if (platform.name == 'A335PBGL') platform.name = 'PocketBeagle';\n    platform.version = fs.readFileSync(my.is_capemgr() + '/baseboard/revision',\n        'ascii').trim();\n    if (platform.version[0] == 0x1A) {\n        platform.version = '1A';\n        platform.name = 'BeagleBone Green';\n    } else if (platform.version.match(/^GR/)) {\n        platform.version = platform.version.substr(2);\n        platform.name = 'BeagleBone Green';\n    } else if (platform.version.match(/^BL/)) {\n        platform.version = platform.version.substr(2);\n        platform.name = 'BeagleBone Blue';\n    } else if (!platform.version.match(/^[\\040-\\176]*$/)) delete platform.version;\n    platform.serialNumber = fs.readFileSync(my.is_capemgr() +\n        '/baseboard/serial-number', 'ascii').trim();\n    if (!platform.serialNumber.match(/^[\\040-\\176]*$/)) delete platform.serialNumber;\n    return (platform);\n};\n\nmodule.exports = {\n    logfile: logfile,\n    readPWMFreqAndValue: readPWMFreqAndValue,\n    readGPIODirection: readGPIODirection,\n    readPinMux: readPinMux,\n    setPinMode: setPinMode,\n    setLEDPinToGPIO: setLEDPinToGPIO,\n    exportGPIOControls: exportGPIOControls,\n    writeGPIOValue: writeGPIOValue,\n    readGPIOValue: readGPIOValue,\n    enableAIN: enableAIN,\n    readAIN: readAIN,\n    writeGPIOEdge: writeGPIOEdge,\n    writePWMFreqAndValue: writePWMFreqAndValue,\n    readEeproms: readEeproms,\n    readPlatform: readPlatform,\n}"
  },
  {
    "path": "src/hw_mainline.js",
    "content": "var fs = require('fs');\nvar async = require('async');\nvar my = require('./my');\nvar parse = require('./parse');\nvar eeprom = require('./eeprom');\nvar util = require('util');\nvar winston = require('winston');\nvar shell = require('shelljs');\n\nvar debug = process.env.DEBUG ? true : false;\nif (debug) {\n    winston.remove(winston.transports.Console);\n    winston.add(winston.transports.Console, {\n        colorize: true\n    });\n}\n\nvar cbWarn = false;\n\nvar gpioFile = {};\nvar pwmPrefix = {};\nvar ainPrefix = \"/sys/bus/iio/devices/iio:device0\";\nvar SLOTS = \"/sys/devices/platform/bone_capemgr/slots\";\nvar AINdts = \"BB-ADC\";\nvar isAI = false;\nvar AI_vdd_adc_mV = 1800;\n\nvar logfile = '/var/lib/cloud9/bonescript.log';\n\n// TODO: This runs when 'require' is executed\n// and more thought should go into what happens\n// when it is run via RPC\nif (fs.existsSync(\"/proc/device-tree/model\")) {\n    var model = fs.readFileSync('/proc/device-tree/model', 'ascii').trim().replace(/\\0/g, '');\n    if (model == \"BeagleBoard.org BeagleBone AI\") {\n        isAI = true;\n    }\n}\n\nvar readPWMFreqAndValue = function (pin, pwm) {\n    var mode = {};\n    try {\n        var period = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/period_ns');\n        var duty = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/duty_ns');\n        mode.freq = 1.0e9 / period;\n        mode.value = duty / period;\n    } catch (ex) {}\n    return (mode);\n};\n\nvar readGPIODirection = function (n, gpio) {\n    var mode = {};\n    var directionFile = \"/sys/class/gpio/gpio\" + n + \"/direction\";\n    if (my.file_existsSync(directionFile)) {\n        mode.active = true;\n        var direction = fs.readFileSync(directionFile, 'utf-8');\n        direction = direction.replace(/^\\s+|\\s+$/g, '');\n        mode.direction = direction;\n    }\n    return (mode);\n};\n\nvar readPinMux = function (pin, mode, callback) {\n    var pinctrlFile =\n        isAI ? '/sys/kernel/debug/pinctrl/4a003400.pinmux/pins' :\n        '/sys/kernel/debug/pinctrl/44e10800.pinmux/pins';\n    // This does not handle the case where 2 balls are tied\n    // to the same header pin. Just grabbing first one for now.\n    var muxRegOffset = null;\n    try {\n        muxRegOffset = isAI ? parseInt(pin.muxRegOffset[0], 16) :\n            parseInt(pin.muxRegOffset, 16);\n    } catch (ex) {}\n    //handle the case when debugfs not mounted\n    if (!my.file_existsSync(pinctrlFile)) {\n        //exit code is 1 if /sys/kernel/debug not mounted\n        const umount = shell.exec('mountpoint -q /sys/kernel/debug/').code;\n        if (umount)\n            shell.exec('mount -t debugfs none /sys/kernel/debug/', {\n                silent: true\n            });\n    }\n    var readPinctrl = function (err, data) {\n        if (err) {\n            mode.err = 'readPinctrl error: ' + err;\n            if (debug) winston.debug(mode.err);\n            if (callback.length == 1) {\n                winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                callback(mode);\n            } else\n                callback(mode.err, data);\n        }\n        mode = parse.modeFromPinctrl(data, muxRegOffset, isAI ? 0x4a002000 : 0x44e10800, mode, isAI);\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            cbWarn = true;\n            callback(mode);\n        } else\n            callback(null, mode);\n    };\n    var tryPinctrl = function (exists) {\n        if (exists) {\n            fs.readFile(pinctrlFile, 'utf8', readPinctrl);\n        } else {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): no valid mux data');\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(mode);\n            } else\n                callback('readPinMux error: no valid mux data', mode);\n        }\n    };\n    if (callback) {\n        my.file_exists(pinctrlFile, tryPinctrl);\n    } else {\n        try {\n            var data2 = fs.readFileSync(pinctrlFile, 'utf8');\n            mode = parse.modeFromPinctrl(data2, muxRegOffset, isAI ? 0x4a002000 : 0x44e10800, mode, isAI);\n        } catch (ex) {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): ' + ex);\n        }\n    }\n    return (mode);\n};\n\nvar setPinMode = function (pin, pinData, template, resp, callback) {\n    if (debug) winston.debug('hw.setPinMode(' + [pin.key, pinData, template, JSON.stringify(resp)] + ');');\n    var p = \"ocp:\" + pin.key + \"_pinmux\";\n    gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    if (isAI) {\n        if (callback) callback(resp);\n        return (resp);\n    }\n    if (!pin.universalName) {\n        pin.universalName = [p];\n        if (pin.ball && pin.ball.ZCZ) pin.universalName.push(\"ocp:\" + pin.ball.ZCZ + \"_pinmux\");\n    }\n    var pinmux = my.find_sysfsFile(p, my.is_ocp(), pin.universalName);\n    if (pinmux) {\n        var state = undefined;\n        if ((pinData & 7) == 7) {\n            state = 'gpio';\n            switch (pinData & 0x18) {\n            case 0x00:\n                state = 'gpio_pd';\n                break;\n            case 0x10:\n                state = 'gpio_pu';\n                break;\n            default:\n                break;\n            }\n        } else if (template == 'bspwm' || template == 'pwm') {\n            state = \"pwm\";\n            if (pin.pwm.universalMode) state = pin.pwm.universalMode;\n        } else {\n            resp.err = 'Unknown pin mode template';\n            winston.error(resp.err);\n        }\n        if (!resp.err) {\n            fs.writeFileSync(pinmux + \"/state\", state);\n        }\n    } else {\n        resp.err = 'No pinmux for ' + pin.key;\n        if (debug) winston.debug(resp.err);\n    }\n\n    if (template == 'bspwm') {\n        // Buld a path like: /sys/devices/platform/ocp/48304000.epwmss/48304200.ehrpwm/pwm/pwmchip5/pwm5-:0\n        // pin.pwm.chip looks up the first address and pin.pwm.addr looks up the second\n        // file_find figures which pwmchip to use\n        // pin.pwm.index tells with half of the PWM to use (0 or 1)\n        var chipPath = my.file_find('/sys/devices/platform/ocp', pin.pwm.chip, 1);\n        if (debug) winston.debug(\"chipPath = \" + chipPath);\n        var addrPath = my.file_find(chipPath, pin.pwm.addr, 1);\n        if (debug) winston.debug(\"addrPath = \" + addrPath);\n        var pwmchipPath = my.file_find(addrPath + '/pwm', 'pwmchip', 1);\n        if (debug) winston.debug(\"pwmchipPath = \" + pwmchipPath);\n        var pwmPath = my.file_find(pwmchipPath, \"pwm.*\" + pin.pwm.index + \"$\", 1);\n        if (debug) winston.debug(\"pwmPath = \" + pwmPath);\n        if (pwmchipPath && !pwmPath) {\n            fs.appendFileSync(pwmchipPath + '/export', pin.pwm.index);\n            pwmPath = my.file_find(pwmchipPath, \"pwm.*\" + pin.pwm.index + \"$\", 1);\n            if (debug) winston.debug(\"pwmPath = \" + pwmPath);\n        }\n        if (pwmPath) {\n            pwmPrefix[pin.pwm.name] = pwmPath;\n        }\n        //fs.appendFileSync(pwmPrefix[pin.pwm.name]+'/enable', 1);\n    }\n\n    if (callback) callback(resp);\n    return (resp);\n};\n\nvar setLEDPinToGPIO = function (pin, resp) {\n    if (debug) winston.debug('setLEDPinTGPIO: ' + pin.key);\n    var path;\n    if (Array.isArray(pin.led)) {\n        resp.err = \"Unable to handle LED definition as array \" + pin.led;\n        winston.error(resp.err);\n        resp.value = false;\n        return (resp);\n    }\n    path = \"/sys/class/leds/\" + pin.led + \"/trigger\";\n\n    if (my.file_existsSync(path)) {\n        fs.writeFileSync(path, \"gpio\");\n    } else {\n        resp.err = \"Unable to find LED \" + pin.led;\n        winston.error(resp.err);\n        resp.value = false;\n    }\n\n    return (resp);\n};\n\nvar exportGPIOControls = function (pin, direction, resp, callback) {\n    if (debug) winston.debug('hw.exportGPIOControls(' + [pin.key, direction, resp] + ');');\n    var n = pin.gpio;\n    var exists = my.file_existsSync(gpioFile[pin.key]);\n\n    if (!exists) {\n        if (debug) winston.debug(\"exporting gpio: \" + n);\n        fs.writeFileSync(\"/sys/class/gpio/export\", \"\" + n, null);\n    }\n    var directionFile = \"/sys/class/gpio/gpio\" + n + \"/direction\";\n    if (debug) winston.debug('Writing GPIO direction(' + direction + ') to ' +\n        directionFile + ');');\n    fs.writeFileSync(directionFile, direction);\n    return (resp);\n};\n\nvar writeGPIOValue = function (pin, value, callback) {\n    if (typeof gpioFile[pin.key] == 'undefined') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (pin.led) {\n            gpioFile[pin.key] = \"/sys/class/leds/\" + pin.led + \"/brightness\";\n        }\n        if (!my.file_existsSync(gpioFile[pin.key])) {\n            winston.error(\"Unable to find gpio: \" + gpioFile[pin.key]);\n        }\n    }\n    if (debug) winston.debug(\"gpioFile = \" + gpioFile[pin.key]);\n    if (callback) {\n        fs.writeFile(gpioFile[pin.key], '' + value, null, callback);\n    } else {\n        try {\n            fs.writeFileSync(gpioFile[pin.key], '' + value, null);\n        } catch (ex) {\n            winston.error(\"Unable to write to \" + gpioFile[pin.key]);\n        }\n    }\n};\n\nvar readGPIOValue = function (pin, resp, callback) {\n    var gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'digitalRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 2);\n            if (callback.length == 1) {\n                winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                callback(resp);\n            } else\n                callback(resp.err, resp.value);\n        };\n        fs.readFile(gpioFile, readFile);\n        return (true);\n    }\n    resp.value = parseInt(fs.readFileSync(gpioFile), 2);\n    return (resp);\n};\n\nvar enableAIN = function (callback) {\n    if (!my.file_existsSync(ainPrefix)) {\n        if (debug) winston.debug('enableAIN: loading ' + AINdts);\n        fs.writeFileSync(SLOTS, AINdts); // Loads AINdts\n    }\n    if (!my.file_existsSync(ainPrefix)) {\n        if (debug) winston.debug('enableAIN: load of ' + AINdts + ' failed');\n    }\n    if (callback) {\n        callback({\n            'path': ainPrefix\n        });\n    }\n    return (ainPrefix);\n};\n\nvar readAIN = function (pin, resp, callback) {\n    var maxValue = (isAI && (AI_vdd_adc_mV == 1800)) ? 2234 : 4095;\n    var ainFile = ainPrefix + '/in_voltage' + pin.ain.toString() + '_raw';\n    if (debug) winston.debug(\"readAIN: ainFile=\" + ainFile);\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'analogRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 10) / maxValue;\n            if (callback.length == 1) {\n                winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                callback(resp);\n            } else\n                callback(resp.err, resp.value);\n        };\n        fs.readFile(ainFile, readFile);\n        return (resp);\n    }\n    resp.value = parseInt(fs.readFileSync(ainFile), 10);\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') returned ' + resp.value;\n        winston.error(resp.err);\n    }\n    resp.value = resp.value / maxValue;\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') scaled to ' + resp.value;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar writeGPIOEdge = function (pin, mode) {\n    fs.writeFileSync('/sys/class/gpio/gpio' + pin.gpio + '/edge', mode);\n\n    var resp = {};\n    resp.gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    resp.valuefd = fs.openSync(resp.gpioFile, 'r');\n    resp.value = new Buffer(1);\n\n    return (resp);\n};\n\nvar writePWMFreqAndValue = function (pin, pwm, freq, value, resp, callback) {\n    if (debug) winston.debug('hw.writePWMFreqAndValue(' + [pin.key, util.inspect(pwm), freq, value, resp] + ');');\n    var path = pwmPrefix[pin.pwm.name];\n    try {\n        var period = Math.round(1.0e9 / freq); // period in ns\n        var duty = Math.round(period * value);\n        var currentPeriod = fs.readFileSync(path + '/period'); //read Current Period for smooth PWM\n        var currentDuty = fs.readFileSync(path + '/duty_cycle'); //read Current Duty for smooth PWM\n        var pwmEnabled = Number(fs.readFileSync(path + '/enable')); //check whether PWM is enabled\n        var disablePWM = !(duty * freq); //when duty||frequency ==0 , disablePWM to avoid spikes\n\n        if (debug) winston.debug('hw.writePWMFreqAndValue: pwm.freq=' + pwm.freq +\n            ', freq=' + freq + ', period=' + period);\n        //smooth PWM Implementation\n        if (!disablePWM && pwmEnabled) {\n            if (period > currentDuty) {\n                if (debug) winston.debug('Updating PWM period: ' + period);\n                fs.writeFileSync(path + '/period', period);\n                if (debug) winston.debug('Updating PWM duty: ' + duty);\n                fs.writeFileSync(path + '/duty_cycle', duty);\n            } else if (duty < currentPeriod) {\n                if (debug) winston.debug('Updating PWM duty: ' + duty);\n                fs.writeFileSync(path + '/duty_cycle', duty);\n                if (debug) winston.debug('Updating PWM period: ' + period);\n                fs.writeFileSync(path + '/period', period);\n            }\n        } else {\n            var tryAgain = true;\n            var tries = 0;\n\n            async.until(function () { //try accessing 'path/enable' until no EACCES error is thrown (max 10 times)\n                return !tryAgain; //to account for udev delay\n            }, stopPWM, updatePeriodAndDuty); //async.until(test,iteratee,callback)\n\n            function stopPWM(callback) {\n                try {\n                    if (debug) winston.debug('Stopping PWM');\n                    fs.writeFileSync(path + '/enable', \"0\\n\");\n                    tryAgain = false; //do not try again\n                    callback(null); //if no error\n                } catch (ex2) {\n                    if (debug) winston.debug('Error stopping PWM: ' + ex2);\n                    if (ex2.code == 'EACCES') {\n                        tries++;\n                        if (tries < 10)\n                            tryAgain = true; //if EACCES error thrown try again for a maximum of 10 times\n                        else\n                            tryAgain = false;\n                        callback(null); //async.until requires an err first format callback &\n                    } else { //if there is an error iteration stops, so neglect the error if EACCES thrown\n                        tryAgain = false;\n                        callback(ex2);\n                    }\n                }\n            }\n\n            function updatePeriodAndDuty() {\n                // It appears that the first time you set the pwm you have to\n                // set the period before you set the duty_cycle\n                if (!disablePWM) { //if duty||frequency == 0 do not re-enable PWM (to avoid spikes)\n                    try {\n                        if (debug) winston.debug('Updating PWM period: ' + period);\n                        fs.writeFileSync(path + '/period', period + \"\\n\");\n                    } catch (ex2) {\n                        winston.info('Unable to update PWM period, period is set to ' +\n                            currentPeriod +\n                            \"\\tIs other half of PWM enabled?\");\n                    }\n                    try {\n                        if (debug) winston.debug('Starting PWM');\n                        fs.writeFileSync(path + '/enable', \"1\\n\");\n                    } catch (ex2) {\n                        if (debug) winston.debug('Error starting PWM: ' + ex2);\n                    }\n                }\n                if (debug) winston.debug('Updating PWM duty: ' + duty);\n                //if(duty == 0) winston.error('Updating PWM duty: ' + duty);\n                if (!disablePWM)\n                    fs.writeFileSync(path + '/duty_cycle', duty + \"\\n\");\n            }\n        }\n    } catch (ex) {\n        resp.err = 'error updating PWM freq and value: ' + path + ', ' + ex;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar readEeproms = function (eeproms) {\n    var EepromFiles = {\n        '/sys/bus/i2c/devices/0-0050/0-00500/nvmem': {\n            type: 'bone'\n        },\n        '/sys/bus/i2c/devices/2-0054/2-00540/nvmem': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/devices/2-0055/2-00550/nvmem': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/devices/2-0056/2-00560/nvmem': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/devices/2-0057/2-00570/nvmem': {\n            type: 'cape'\n        }\n    };\n    eeproms = eeprom.readEeproms(EepromFiles);\n    return (eeproms);\n};\n\nvar readPlatform = function (platform) {\n    var eeproms = eeprom.readEeproms({\n        '/sys/bus/i2c/devices/0-0050/0-00500/nvmem': {\n            type: 'bone'\n        }\n    });\n    var x = eeproms['/sys/bus/i2c/devices/0-0050/0-00500/nvmem'];\n    platform.name = fs.readFileSync('/proc/device-tree/model', 'ascii').trim().replace(/\\0/g, '');\n    if (platform.name.indexOf('Green') > 0) {\n        platform.name = platform.name.replace('TI AM335x', 'SeeedStudio')\n    }\n    if (platform.name.indexOf('Arduino') > 0) {\n        platform.name = platform.name.replace('TI AM335x', '')\n    }\n    platform.name = platform.name.replace('TI AM335x BeagleBone', 'BeagleBoard.org BeagleBone');\n    platform.name = platform.name.replace('TI AM5728 BeagleBoard-X15', 'BeagleBoard.org BeagleBoard-X15');\n    if (x && x.version) {\n        platform.version = x.version;\n        if (!platform.version.match(/^[\\040-\\176]*$/)) delete platform.version;\n    }\n    if (x && x.serialNumber) {\n        platform.serialNumber = x.serialNumber;\n        if (!platform.serialNumber.match(/^[\\040-\\176]*$/)) delete platform.serialNumber;\n    }\n    try {\n        platform.dogtag = fs.readFileSync('/etc/dogtag', 'ascii');\n    } catch (ex) {}\n    return (platform);\n};\n\nvar getPin = function (pin) {\n    pin = my.getpin(pin);\n    if (isAI && typeof pin.ai == \"object\") {\n        Object.assign(pin, pin.ai);\n        delete pin.ai;\n    }\n    if (debug) winston.debug('hw.getPin(): pin=' + JSON.stringify(pin) + ' iAI=' + isAI);\n    return (pin);\n};\n\nmodule.exports = {\n    logfile: logfile,\n    readPWMFreqAndValue: readPWMFreqAndValue,\n    readGPIODirection: readGPIODirection,\n    readPinMux: readPinMux,\n    setPinMode: setPinMode,\n    setLEDPinToGPIO: setLEDPinToGPIO,\n    exportGPIOControls: exportGPIOControls,\n    writeGPIOValue: writeGPIOValue,\n    readGPIOValue: readGPIOValue,\n    enableAIN: enableAIN,\n    readAIN: readAIN,\n    writeGPIOEdge: writeGPIOEdge,\n    writePWMFreqAndValue: writePWMFreqAndValue,\n    readEeproms: readEeproms,\n    readPlatform: readPlatform,\n    getPin: getPin\n}"
  },
  {
    "path": "src/hw_oldkernel.js",
    "content": "// Used for 3.2 kernel using /sys/kernel/debug/omap_mux/\n\nvar fs = require('fs');\nvar my = require('./my');\nvar parse = require('./parse');\nvar eeprom = require('./eeprom');\nvar hw_capemgr = require('./hw_capemgr');\nvar winston = require('winston');\n\nvar debug = true;\n\nvar gpioFile = {};\nvar pwmPrefix = {};\n\nvar logfile = '/var/lib/cloud9/bonescript.log';\n\nvar readPWMFreqAndValue = function (pin, pwm) {\n    var mode = {};\n    try {\n        var duty_percent = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/duty_percent');\n        mode.freq = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/period_freq');\n        mode.value = duty_percent / 100.0;\n    } catch (ex) {\n        mode.err = 'cannot set PWM frequency and value: ' + ex;\n    }\n    return (mode);\n};\n\nvar readGPIODirection = hw_capemgr.readGPIODirection;\n\nvar readPinMux = function (pin, mode, callback) {\n    var muxFile = '/sys/kernel/debug/omap_mux/' + pin.mux;\n    var readOmapMux = function (err, data) {\n        if (err) {\n            mode.err = 'readOmapMux error: ' + err;\n            if (debug) winston.debug(mode.err);\n            callback(mode);\n        }\n        mode = parse.modeFromOmapMux(data, mode);\n        callback(mode);\n    };\n    var tryOmapMux = function (exists) {\n        if (exists) {\n            fs.readFile(muxFile, 'utf8', readOmapMux);\n        }\n    };\n    if (callback) {\n        my.file_exists(muxFile, tryOmapMux);\n    } else {\n        try {\n            var data = fs.readFileSync(muxFile, 'utf8');\n            mode = parse.modeFromOmapMux(data, mode);\n        } catch (ex) {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): ' + ex);\n        }\n    }\n    return (mode);\n};\n\nvar setPinMode = function (pin, pinData, template, resp) {\n    var muxFile = '/sys/kernel/debug/omap_mux/' + pin.mux;\n    var n = pin.gpio;\n\n    try {\n        var fd = fs.openSync(muxFile, 'w');\n        fs.writeSync(fd, pinData.toString(16), null);\n    } catch (ex) {\n        resp.err = 'Error writing to ' + muxFile + ': ' + ex;\n        return (resp);\n    }\n\n    if (template == 'bspm') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (pin.led) {\n            gpioFile[pin.key] = '/sys/class/leds/beaglebone::' + pin.led + '/brightness';\n        }\n    } else if (template == 'bspwm') {\n        resp.path = '/sys/class/pwm/' + pin.pwm.path;\n        var path = resp.path;\n        pwmPrefix[pin.pwm.name] = path;\n\n        // Clear up any unmanaged usage\n        fs.writeFileSync(path + '/request', '0');\n\n        // Allocate and configure the PWM\n        fs.writeFileSync(path + '/request', '1');\n        fs.writeFileSync(path + '/period_freq', '0');\n        fs.writeFileSync(path + '/polarity', '0');\n        fs.writeFileSync(path + '/run', '1');\n    }\n    return (resp);\n};\n\nvar setLEDPinToGPIO = function (pin, resp) {\n    var path = \"/sys/class/leds/beaglebone::\" + pin.led + \"/trigger\";\n\n    if (my.file_existsSync(path)) {\n        fs.writeFileSync(path, \"gpio\");\n    } else {\n        resp.err = \"Unable to find LED: \" + pin.led;\n        winston.error(resp.err);\n        resp.value = false;\n    }\n\n    return (resp);\n};\n\nvar exportGPIOControls = hw_capemgr.exportGPIOControls;\n\nvar writeGPIOValue = function (pin, value, callback) {\n    if (typeof gpioFile[pin.key] == 'undefined') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (pin.led) {\n            gpioFile[pin.key] = \"/sys/class/leds/beaglebone:\";\n            gpioFile[pin.key] += \":\" + pin.led + \"/brightness\";\n        }\n        if (!my.file_existsSync(gpioFile[pin.key])) {\n            winston.error(\"Unable to find gpio: \" + gpioFile[pin.key]);\n        }\n    }\n    if (debug) winston.debug(\"gpioFile = \" + gpioFile[pin.key]);\n    if (callback) {\n        fs.writeFile(gpioFile[pin.key], '' + value, null, callback);\n    } else {\n        try {\n            fs.writeFileSync(gpioFile[pin.key], '' + value, null);\n        } catch (ex) {\n            winston.error(\"Unable to write to \" + gpioFile[pin.key]);\n        }\n    }\n};\n\nvar readGPIOValue = hw_capemgr.readGPIOValue;\n\nvar enableAIN = function () {\n    return (true);\n};\n\nvar readAIN = function (pin, resp, callback) {\n    var ainFile = '/sys/bus/platform/devices/tsc/ain' + (pin.ain + 1).toString();\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'analogRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 10) / 4096;\n            callback(resp);\n        };\n        fs.readFile(ainFile, readFile);\n        return (resp);\n    }\n    resp.value = parseInt(fs.readFileSync(ainFile), 10);\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') returned ' + resp.value;\n        winston.error(resp.err);\n    }\n    resp.value = resp.value / 4096;\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') scaled to ' + resp.value;\n    }\n    return (resp);\n};\n\nvar writeGPIOEdge = hw_capemgr.writeGPIOEdge;\n\nvar writePWMFreqAndValue = function (pin, pwm, freq, value, resp) {\n    var path = pwmPrefix[pin.pwm.name];\n    if (pwm.freq != freq) {\n        fs.writeFileSync(path + '/run', '0');\n        fs.writeFileSync(path + '/duty_percent', '0');\n        fs.writeFileSync(path + '/period_freq', Math.round(freq));\n        fs.writeFileSync(path + '/run', '1');\n    }\n    fs.writeFileSync(path + '/duty_percent', Math.round(value * 100));\n    return (resp);\n};\n\nvar readEeproms = function (eeproms) {\n    var EepromFiles = {\n        '/sys/bus/i2c/drivers/at24/1-0050/eeprom': {\n            type: 'bone'\n        },\n        '/sys/bus/i2c/drivers/at24/3-0054/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/3-0055/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/3-0056/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/3-0057/eeprom': {\n            type: 'cape'\n        }\n    };\n    eeproms = eeprom.readEeproms(EepromFiles);\n    return (eeproms);\n};\n\nvar readPlatform = function (platform) {\n    return (platform);\n};\n\nmodule.exports = {\n    logfile: logfile,\n    readPWMFreqAndValue: readPWMFreqAndValue,\n    readGPIODirection: readGPIODirection,\n    readPinMux: readPinMux,\n    setPinMode: setPinMode,\n    setLEDPinToGPIO: setLEDPinToGPIO,\n    exportGPIOControls: exportGPIOControls,\n    writeGPIOValue: writeGPIOValue,\n    readGPIOValue: readGPIOValue,\n    enableAIN: enableAIN,\n    readAIN: readAIN,\n    writeGPIOEdge: writeGPIOEdge,\n    writePWMFreqAndValue: writePWMFreqAndValue,\n    readEeproms: readEeproms,\n    readPlatform: readPlatform\n}"
  },
  {
    "path": "src/hw_simulator.js",
    "content": "var fs = require('fs');\nvar winston = require('winston');\nvar my = require('./my');\n\nvar gpioFile = {};\n\nvar logfile = 'bonescript.log';\nvar readPWMFreqAndValue = function (pin, pwm) {\n    winston.info('readPWMFreqAndValue(' + [pin.key, pwm.key] + ')');\n    var mode = {};\n    mode.freq = pwm.freq;\n    mode.value = pwm.value;\n    return (mode);\n};\n\nvar readGPIODirection = function (n, gpio) {\n    winston.info('readGPIODirection(' + [n] + ')');\n    var mode = {};\n    if (typeof gpio[n] != 'undefined') {\n        if (gpio[n].active) {\n            mode.active = true;\n        } else {\n            mode.active = false;\n        }\n        mode.direction = gpio[n].direction;\n    }\n    return (mode);\n};\n\nvar readPinMux = function (pin, mode, callback) {\n    winston.info('readPinMux(' + [pin.key] + ')');\n    if (callback) {\n        if (callback.length == 1)\n            callback(mode);\n        else\n            callback(null, mode);\n    }\n    return (mode);\n};\n\nvar setPinMode = function (pin, pinData, template, resp) {\n    winston.info('setPinMode(' + [pin.key, pinData, template] + ')');\n    gpioFile[pin.key] = true;\n    return (resp);\n};\n\nvar setLEDPinToGPIO = function (pin, resp) {\n    winston.info('setLEDPinToGPIO(' + [pin.key] + ')');\n    return (resp);\n};\n\nvar exportGPIOControls = function (pin, direction, resp) {\n    winston.info('expertGPIOControls(' + [pin.key, direction] + ')');\n    return (resp);\n};\n\nvar writeGPIOValue = function (pin, value, callback) {\n    winston.info('writeGPIOValue(' + [pin.key, value] + ')');\n    if (callback) {\n        callback();\n    }\n};\n\nvar readGPIOValue = function (pin, resp, callback) {\n    winston.info('readGPIOValue(' + [pin.key] + ')');\n    if (callback) {\n        resp.value = 0;\n        if (callback.length == 1)\n            callback(resp);\n        else\n            callback(null, resp.value);\n        return (true);\n    }\n    resp.value = 0;\n    return (resp);\n};\n\nvar enableAIN = function () {\n    winston.info('enableAIN()');\n    return (true);\n};\n\nvar readAIN = function (pin, resp, callback) {\n    winston.info('readAIN(' + [pin.key] + ')');\n    resp.value = 0;\n    if (callback) {\n        if (callback.length == 1)\n            callback(resp);\n        else\n            callback(null, resp.value);\n    }\n    return (resp);\n};\n\nvar writeGPIOEdge = function (pin, mode) {\n    winston.info('writeGPIOEdge(' + [pin.key, mode] + ')');\n    var resp = {};\n    return (resp);\n};\n\nvar writePWMFreqAndValue = function (pin, pwm, freq, value, resp) {\n    winston.info('writePWMFreqAndValue(' + [pin.key, pwm.name, freq, value] + ')');\n    return (resp);\n};\n\nvar readEeproms = function (eeproms) {\n    winston.info('readEeproms()');\n    var boardName = 'A335BNLT';\n    var version = '';\n    var serialNumber = '';\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'] = {};\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].boardName = boardName;\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].version = version;\n    eeproms['/sys/bus/i2c/drivers/at24/1-0050/eeprom'].serialNumber = serialNumber;\n    return (eeproms);\n};\n\nvar readPlatform = function (platform) {\n    winston.info('readPlatform()');\n    platform.name = 'BeagleBone Simulator';\n    return (platform);\n};\n\nvar getPin = function (pin) {\n    return (my.getpin(pin));\n};\n\nmodule.exports = {\n    logfile: logfile,\n    readPWMFreqAndValue: readPWMFreqAndValue,\n    readGPIODirection: readGPIODirection,\n    readPinMux: readPinMux,\n    setPinMode: setPinMode,\n    setLEDPinToGPIO: setLEDPinToGPIO,\n    exportGPIOControls: exportGPIOControls,\n    writeGPIOValue: writeGPIOValue,\n    readGPIOValue: readGPIOValue,\n    enableAIN: enableAIN,\n    readAIN: readAIN,\n    writeGPIOEdge: writeGPIOEdge,\n    writePWMFreqAndValue: writePWMFreqAndValue,\n    readEeproms: readEeproms,\n    readPlatform: readPlatform,\n    getPin: getPin\n}"
  },
  {
    "path": "src/hw_universal.js",
    "content": "var fs = require('fs');\nvar winston = require('winston');\nvar my = require('./my');\nvar parse = require('./parse');\nvar eeprom = require('./eeprom');\n\nvar debug = process.env.DEBUG ? true : false;\n\nvar gpioFile = {};\nvar pwmPrefix = {};\nvar ainPrefix = \"\";\n\nvar logfile = '/var/lib/cloud9/bonescript.log';\n\nvar readPWMFreqAndValue = function (pin, pwm) {\n    var mode = {};\n    try {\n        var period = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/period_ns');\n        var duty = fs.readFileSync(pwmPrefix[pin.pwm.name] + '/duty_ns');\n        mode.freq = 1.0e9 / period;\n        mode.value = duty / period;\n    } catch (ex) {}\n    return (mode);\n};\n\nvar readGPIODirection = function (n, gpio) {\n    var mode = {};\n    var directionFile = \"/sys/class/gpio/gpio\" + n + \"/direction\";\n    if (my.file_existsSync(directionFile)) {\n        mode.active = true;\n        var direction = fs.readFileSync(directionFile, 'utf-8');\n        direction = direction.replace(/^\\s+|\\s+$/g, '');\n        mode.direction = direction;\n    }\n    return (mode);\n};\n\nvar readPinMux = function (pin, mode, callback) {\n    var pinctrlFile = '/sys/kernel/debug/pinctrl/44e10800.pinmux/pins';\n    var muxRegOffset = parseInt(pin.muxRegOffset, 16);\n    var readPinctrl = function (err, data) {\n        if (err) {\n            mode.err = 'readPinctrl error: ' + err;\n            if (debug) winston.debug(mode.err);\n            callback(mode);\n        }\n        mode = parse.modeFromPinctrl(data, muxRegOffset, 0x44e10800, mode);\n        callback(mode);\n    };\n    var tryPinctrl = function (exists) {\n        if (exists) {\n            fs.readFile(pinctrlFile, 'utf8', readPinctrl);\n        } else {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): no valid mux data');\n            callback(mode);\n        }\n    };\n    if (callback) {\n        my.file_exists(pinctrlFile, tryPinctrl);\n    } else {\n        try {\n            var data2 = fs.readFileSync(pinctrlFile, 'utf8');\n            mode = parse.modeFromPinctrl(data2, muxRegOffset, 0x44e10800, mode);\n        } catch (ex) {\n            if (debug) winston.debug('getPinMode(' + pin.key + '): ' + ex);\n        }\n    }\n    return (mode);\n};\n\nvar setPinMode = function (pin, pinData, template, resp, callback) {\n    if (debug) winston.debug('hw.setPinMode(' + [pin.key, pinData, template, JSON.stringify(resp)] + ');');\n    var p = pin.key + \"_pinmux\";\n    if (pin.universalName) p = pin.universalName + \"_pinmux\";\n    var pinmux = my.find_sysfsFile(p, my.is_ocp(), p + '.');\n    if (!pinmux) {\n        throw p + \" was not found under \" + my.is_ocp();\n    }\n    if ((pinData & 7) == 7) {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        fs.writeFileSync(pinmux + \"/state\", 'gpio');\n    } else if (template == 'bspwm') {\n        fs.writeFileSync(pinmux + \"/state\", 'pwm');\n        pwmPrefix[pin.pwm.name] = '/sys/class/pwm/pwm' + pin.pwm.sysfs;\n        if (!my.file_existsSync(pwmPrefix[pin.pwm.name])) {\n            fs.appendFileSync('/sys/class/pwm/export', pin.pwm.sysfs);\n        }\n        fs.appendFileSync(pwmPrefix[pin.pwm.name] + '/run', 1);\n    } else {\n        resp.err = 'Unknown pin mode template';\n    }\n    if (callback) callback(resp);\n    return (resp);\n};\n\nvar setLEDPinToGPIO = function (pin, resp) {\n    var path = \"/sys/class/leds/beaglebone:green:\" + pin.led + \"/trigger\";\n\n    if (my.file_existsSync(path)) {\n        fs.writeFileSync(path, \"gpio\");\n    } else {\n        resp.err = \"Unable to find LED \" + pin.led;\n        winston.error(resp.err);\n        resp.value = false;\n    }\n\n    return (resp);\n};\n\nvar exportGPIOControls = function (pin, direction, resp, callback) {\n    if (debug) winston.debug('hw.exportGPIOControls(' + [pin.key, direction, resp] + ');');\n    var n = pin.gpio;\n    var exists = my.file_existsSync(gpioFile[pin.key]);\n\n    if (!exists) {\n        if (debug) winston.debug(\"exporting gpio: \" + n);\n        fs.writeFileSync(\"/sys/class/gpio/export\", \"\" + n, null);\n    }\n    var directionFile = \"/sys/class/gpio/gpio\" + n + \"/direction\";\n    if (debug) winston.debug('Writing GPIO direction(' + direction + ') to ' +\n        directionFile + ');');\n    fs.writeFileSync(directionFile, direction);\n    return (resp);\n};\n\nvar writeGPIOValue = function (pin, value, callback) {\n    if (typeof gpioFile[pin.key] == 'undefined') {\n        gpioFile[pin.key] = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n        if (pin.led) {\n            gpioFile[pin.key] = \"/sys/class/leds/beaglebone:\";\n            gpioFile[pin.key] += \"green:\" + pin.led + \"/brightness\";\n        }\n        if (!my.file_existsSync(gpioFile[pin.key])) {\n            winston.error(\"Unable to find gpio: \" + gpioFile[pin.key]);\n        }\n    }\n    if (debug) winston.debug(\"gpioFile = \" + gpioFile[pin.key]);\n    if (callback) {\n        fs.writeFile(gpioFile[pin.key], '' + value, null, callback);\n    } else {\n        try {\n            fs.writeFileSync(gpioFile[pin.key], '' + value, null);\n        } catch (ex) {\n            winston.error(\"Unable to write to \" + gpioFile[pin.key]);\n        }\n    }\n};\n\nvar readGPIOValue = function (pin, resp, callback) {\n    var gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'digitalRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 2);\n            callback(resp);\n        };\n        fs.readFile(gpioFile, readFile);\n        return (true);\n    }\n    resp.value = parseInt(fs.readFileSync(gpioFile), 2);\n    return (resp);\n};\n\nvar enableAIN = function (callback) {\n    var helper = \"\";\n    if (my.load_dt('cape-bone-iio')) {\n        var ocp = my.is_ocp();\n        if (ocp) {\n            helper = my.find_sysfsFile('helper', ocp, 'helper.');\n            if (helper) {\n                ainPrefix = helper + '/AIN';\n            }\n        }\n    } else {\n        if (debug) winston.debug('enableAIN: load of cape-bone-iio failed');\n    }\n    if (callback) {\n        callback({\n            'path': helper\n        })\n    }\n    return (helper.length > 1);\n};\n\nvar readAIN = function (pin, resp, callback) {\n    var ainFile = ainPrefix + pin.ain.toString();\n    if (callback) {\n        var readFile = function (err, data) {\n            if (err) {\n                resp.err = 'analogRead error: ' + err;\n                winston.error(resp.err);\n            }\n            resp.value = parseInt(data, 10) / 1800;\n            callback(resp);\n        };\n        fs.readFile(ainFile, readFile);\n        return (resp);\n    }\n    resp.value = parseInt(fs.readFileSync(ainFile), 10);\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') returned ' + resp.value;\n        winston.error(resp.err);\n    }\n    resp.value = resp.value / 1800;\n    if (isNaN(resp.value)) {\n        resp.err = 'analogRead(' + pin.key + ') scaled to ' + resp.value;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar writeGPIOEdge = function (pin, mode) {\n    fs.writeFileSync('/sys/class/gpio/gpio' + pin.gpio + '/edge', mode);\n\n    var resp = {};\n    resp.gpioFile = '/sys/class/gpio/gpio' + pin.gpio + '/value';\n    resp.valuefd = fs.openSync(resp.gpioFile, 'r');\n    resp.value = new Buffer(1);\n\n    return (resp);\n};\n\nvar writePWMFreqAndValue = function (pin, pwm, freq, value, resp, callback) {\n    if (debug) winston.debug('hw.writePWMFreqAndValue(' + [pin.key, pwm, freq, value, resp] + ');');\n    var path = pwmPrefix[pin.pwm.name];\n    try {\n        var period = Math.round(1.0e9 / freq); // period in ns\n        if (pwm.freq != freq) {\n            if (debug) winston.debug('Stopping PWM');\n            fs.writeFileSync(path + '/run', \"0\\n\");\n            if (debug) winston.debug('Setting duty to 0');\n            fs.writeFileSync(path + '/duty_ns', \"0\\n\");\n            try {\n                if (debug) winston.debug('Updating PWM period: ' + period);\n                fs.writeFileSync(path + '/period_ns', period + \"\\n\");\n            } catch (ex2) {\n                period = fs.readFileSync(path + '/period_ns');\n                winston.info('Unable to update PWM period, period is set to ' + period);\n            }\n            if (debug) winston.debug('Starting PWM');\n            fs.writeFileSync(path + '/run', \"1\\n\");\n        }\n        var duty = Math.round(period * value);\n        if (debug) winston.debug('Updating PWM duty: ' + duty);\n        //if(duty == 0) winston.error('Updating PWM duty: ' + duty);\n        fs.writeFileSync(path + '/duty_ns', duty + \"\\n\");\n    } catch (ex) {\n        resp.err = 'error updating PWM freq and value: ' + path + ', ' + ex;\n        winston.error(resp.err);\n    }\n    return (resp);\n};\n\nvar readEeproms = function (eeproms) {\n    var EepromFiles = {\n        '/sys/bus/i2c/drivers/at24/0-0050/eeprom': {\n            type: 'bone'\n        },\n        '/sys/bus/i2c/drivers/at24/2-0054/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/2-0055/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/2-0056/eeprom': {\n            type: 'cape'\n        },\n        '/sys/bus/i2c/drivers/at24/2-0057/eeprom': {\n            type: 'cape'\n        }\n    };\n    eeproms = eeprom.readEeproms(EepromFiles);\n    return (eeproms);\n};\n\nvar readPlatform = function (platform) {\n    var eeproms = eeprom.readEeproms({\n        '/sys/bus/i2c/drivers/at24/0-0050/eeprom': {\n            type: 'bone'\n        }\n    });\n    var x = eeproms['/sys/bus/i2c/drivers/at24/0-0050/eeprom'];\n    if (x.boardName == 'A335BONE') platform.name = 'BeagleBone';\n    if (x.boardName == 'A335BNLT') platform.name = 'BeagleBone Black';\n    platform.version = x.version;\n    if (!platform.version.match(/^[\\040-\\176]*$/)) delete platform.version;\n    platform.serialNumber = x.serialNumber;\n    if (!platform.serialNumber.match(/^[\\040-\\176]*$/)) delete platform.serialNumber;\n    try {\n        platform.dogtag = fs.readFileSync('/etc/dogtag', 'ascii');\n    } catch (ex) {}\n    return (platform);\n};\n\nmodule.exports = {\n    logfile: logfile,\n    readPWMFreqAndValue: readPWMFreqAndValue,\n    readGPIODirection: readGPIODirection,\n    readPinMux: readPinMux,\n    setPinMode: setPinMode,\n    setLEDPinToGPIO: setLEDPinToGPIO,\n    exportGPIOControls: exportGPIOControls,\n    writeGPIOValue: writeGPIOValue,\n    readGPIOValue: readGPIOValue,\n    enableAIN: enableAIN,\n    readAIN: readAIN,\n    writeGPIOEdge: writeGPIOEdge,\n    writePWMFreqAndValue: writePWMFreqAndValue,\n    readEeproms: readEeproms,\n    readPlatform: readPlatform\n}"
  },
  {
    "path": "src/iic.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\nvar bone = require('./bone');\nvar my = require('./my');\n\nvar m = {};\nm.name = 'i2c';\nm.module = my.require('i2c');\nm.ports = bone.i2c;\nm.events = {\n    'data': ['data']\n};\nm.openPorts = {};\nm.doOpen = function (args) {\n    var path = args.port[0];\n    if (m.ports[args.port[0]].path) path = m.ports[args.port[0]].path;\n    if (typeof args.options !== typeof {}) args.options = {};\n    args.options.device = path;\n    var openPort = new m.module(args.port[1], args.options);\n    return (openPort);\n};\n\nmodule.exports = {\n    i2cOpen: my.wrapOpen(m, ['options']),\n    i2cScan: my.wrapCall(m, 'scan', [], ['err', 'data']),\n    i2cWriteByte: my.wrapCall(m, 'writeByte', ['byte'], ['err']),\n    i2cWriteBytes: my.wrapCall(m, 'writeBytes', ['command', 'bytes'], ['err']),\n    i2cReadByte: my.wrapCall(m, 'readByte', [], ['err', 'res']),\n    i2cReadBytes: my.wrapCall(m, 'readBytes', ['command', 'length'], ['err', 'res']),\n    i2cStream: my.wrapCall(m, 'stream', ['command', 'length', 'delay'], [])\n}"
  },
  {
    "path": "src/index.d.ts",
    "content": "// Type definitions for bonescript 0.6\n// Project: https://github.com/jadonk/bonescript\n// Definitions by: Troy W. <https://github.com/troywweber7>\n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n\nimport * as SerialPort from 'serialport';\nimport * as VError from 'verror';\n\n// OBJECTS\nexport const bone: BoneObj;\n\n// FUNCTIONS - TODO obliterate all \"any\" types where possible! --- TWW\n// https://github.com/jadonk/bonescript#system\n\nexport function getPlatform(callback?: (error: ErrorType, platform: PlatformObj) => void): any;\n\nexport function echo(data: string, callback?: (error: ErrorType, data: string) => void): any;\n\nexport function readTextFile(filename: string, callback?: (error: ErrorType, data: string) => void): string;\n\nexport function writeTextFile(filename: string, data: any, callback?: (error: ErrorType) => void): any;\n\nexport function writeCModule(filename: string, data: any, callback?: (error: ErrorType) => void): any;\n\nexport function setDate(date: string, callback?: (error: ErrorType) => void): any;\n\nexport function analogRead(pin: string, callback?: (err: ErrorType, value: number) => void): any;\n\nexport function analogWrite(pin: string, value: number, freq?: number, callback?: ErrorCb): any;\n\nexport function attachInterrupt(\n    pin: string,\n    handler: InterruptFn,\n    mode: InterruptType,\n    callback?: AttachIntCb\n): any;\n\nexport function detachInterrupt(pin: string, callback?: DetachIntCb): any;\n\nexport function digitalRead(pin: string, callback?: (err: ErrorType, value: number) => void): any;\n\nexport function digitalWrite(pin: string, value: PinStateType, callback?: DigitalWriteCb): any;\n\nexport function pinMode(\n    pin: string,\n    direction: 'in' | 'out' | 'analog_out' | 'in_pullup',\n    mux?: string,\n    pullup?: 'disabled' | 'pullup' | 'pulldown',\n    slew?: 'fast' | 'slow',\n    callback?: PinModeCb\n): any;\n\nexport function getPinMode(pin: string, callback?: (err: ErrorType, mode: PinModeObj) => void): any;\n\nexport function shiftOut(dataPin: string, clockPin: string, bitOrder: BitOrderType, val: number, callback?: ErrorCb): any;\n\n// https://github.com/jadonk/bonescript#serial\nexport function serialOpen(port: any, options: any, callback?: ErrorCb): any;\n\nexport function serialWrite(port: any, data: any, callback?: ErrorCb): any;\n\nexport const serialParsers: typeof SerialPort.parsers;\n\nexport function i2cOpen(port: any, address: any, options: any, callback?: ErrorCb): any;\n\nexport function i2cScan(port: any, callback?: ErrorCb): any;\n\nexport function i2cWriteByte(port: any, byte: any, callback?: ErrorCb): any;\n\nexport function i2cWriteBytes(port: any, command: any, bytes: any, callback?: ErrorCb): any;\n\nexport function i2cReadByte(port: any, callback?: ErrorCb): any;\n\nexport function i2cReadBytes(port: any, command: any, length: any, callback?: ErrorCb): any;\n\nexport function i2cStream(port: any, command: any, length: any, callback?: ErrorCb): any;\n// ffi\nexport function loadCModule(filename: string, data: any, isMRAA?: boolean): any;\n\nexport function lowByte(value: number): number;\n\nexport function highByte(value: number): number;\n\nexport function bitRead(value: number, bitnum: number): number;\n\nexport function bitWrite(value: number, bitnum: number, bitdata: any): number;\n\nexport function bitSet(value: number, bitnum: number): number;\n\nexport function bitClear(value: number, bitnum: number): number;\n\nexport function bit(bitnum: number): number;\n\nexport function min(x: number, y: number): number;\n\nexport function max(x: number, y: number): number;\n\nexport function abs(x: number): number;\n\nexport function constrain(x: number, a: number, b: number): number;\n\nexport function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number;\n\nexport function pow(x: number, y: number): number;\n\nexport function sqrt(x: number): number;\n\nexport function sin(radians: number): number;\n\nexport function cos(radians: number): number;\n\nexport function tan(radians: number): number;\n\nexport function randomSeed(x: number): void;\n\nexport function random(min: number, max?: number): number;\n\nexport function delay(...args: any[]): any;\n\nexport function autorun(...args: any[]): any;\n\nexport function serverStart(...args: any[]): any;\n\nexport function socketJSReqHandler(...args: any[]): any;\n\nexport function addSocketListeners(...args: any[]): any;\n\nexport function setGlobals(...args: any[]): any;\n\n// CONSTANTS\nexport const OUTPUT: 'out';\nexport const INPUT: 'in';\nexport const INPUT_PULLUP: 'in_pullup';\nexport const ANALOG_OUTPUT: 'analog_out';\nexport const HIGH: 1;\nexport const LOW: 0;\nexport const LSBFIRST: 1;\nexport const MSBFIRST: 0;\nexport const CHANGE: 'both';\nexport const RISING: 'rising';\nexport const FALLING: 'falling';\n\n// INTERFACES - adjusted based on observation / testing\ninterface PlatformObj {\n    name: string;\n    platform: BoneObj;\n    bonescript: string;\n    serialNumber?: string;\n    dogtag?: string;\n    os: {\n        hostname: string,\n        type: string,\n        arch: string,\n        release: string,\n        uptime: number,\n        loadavg: number[],\n        totalmem: number,\n        freemem: number,\n        networkInterfaces?: any\n    };\n}\n\nexport interface PinModeObj {\n    gpio?: {\n        active: boolean,\n        direction: 'in' | 'out',\n        allocated: boolean,\n    };\n    modes: string[];\n    mux?: number;\n    name: string;\n    pin: string;\n    pinState: string;\n    pullup?: 'disabled' | 'pullup' | 'pulldown';\n    pwm?: {\n        freq: number,\n        value: number,\n    };\n    rx?: 'enabled' | 'disabled';\n    slew?: 'fast' | 'slow';\n}\n\ninterface BoneObj {\n    i2c: i2cObj;\n    uarts: UartsObj;\n    getPinKeys(): string[];\n    getPinObjects(): any;\n    naturalCompare(): any;\n}\n\ninterface PinsObj {\n    [i: string]: PinInfo;\n}\n\ninterface UartsObj {\n    [i: string]: UartInfo;\n}\n\ninterface i2cObj {\n    [i: string]: i2cInfo;\n}\n\nexport interface PinInfo {\n    // Analog In\n    ain?: number;\n    // GPIO / LEDs / Analog In\n    eeprom?: number;\n    // GPIO / LEDs\n    gpio?: number;\n    key: string;\n    // LEDs\n    led?: string;\n    mux?: string;\n    muxRegOffset?: string;\n    // All\n    name: string;\n    options?: string[];\n    // PWM\n    pwm?: PwmInfo;\n    scale?: number;\n    universalName?: string;\n}\n\ninterface PwmInfo {\n    addr: string;\n    chip: string;\n    index: number;\n    module: string;\n    muxmode: number;\n    name: string;\n    path: string;\n    sysfs: number;\n}\n\ninterface UartInfo {\n    devicetree?: string;\n    rx?: string;\n    tx?: string;\n}\n\ninterface i2cInfo {\n    devicetree?: string;\n    path?: string;\n    scl?: string;\n    sda?: string;\n}\n\n// TYPES - adjusted based on observation / testing\ntype PinStateType = typeof HIGH | typeof LOW;\ntype PinModeType = typeof ANALOG_OUTPUT | typeof INPUT | typeof INPUT_PULLUP | typeof OUTPUT;\ntype InterruptType = typeof RISING | typeof FALLING | typeof CHANGE;\ntype BitOrderType = typeof LSBFIRST | typeof MSBFIRST;\ntype ErrorCb = (err: ErrorType) => void;\ntype InterruptFn = (resp: {\n    pin: PinInfo,\n    value: number\n}) => void;\ntype AttachIntCb = (resp: {\n    pin: PinInfo,\n    attached: boolean\n}) => void;\ntype DetachIntCb = (resp: {\n    pin: PinInfo,\n    detached: boolean\n}) => void;\ntype PinModeCb = (resp: {\n    value: number,\n    err: VError\n}) => void;\ntype DigitalWriteCb = (resp: {\n    data: any,\n    err: VError\n}) => void;\ntype ErrorType = VError;\n"
  },
  {
    "path": "src/index.js",
    "content": "// Copyright (C) 2011 - Texas Instruments, Jason Kridner\n//\n//\nvar fs = require('fs');\nvar child_process = require('child_process');\nvar os = require('os');\nvar bone = require('./bone'); // Database of pins\nvar functions = require('./functions'); // functions.js defines several math/bit functions that are handy\nvar package_json = require('../package.json');\nvar g = require('./constants');\nvar my = require('./my');\nvar serial = require('./serial');\nvar iic = require('./iic');\nvar winston = my.require('winston');\nvar fibers = my.require('fibers');\nvar epoll = my.require('epoll');\nvar autorun = require('./autorun');\nvar server = require('./server');\nvar socketHandlers = require('./socket_handlers');\nvar ffi = require('./ffiimp');\nvar rc = require('./rc');\n\nvar debug = process.env.DEBUG ? true : false;\n\nvar cbWarn = false;\n\n// Detect if we are on a Beagle\nvar hw;\nif (os.type() == 'Linux' && os.arch() == 'arm') {\n    var osVer = (\"\" + os.release()).split('.');\n    if (debug) console.log(osVer.join(\":\"));\n    if (my.is_new_capemgr() || osVer[0] > 4 ||\n        (osVer[0] == 4 && osVer[1] >= 4)) {\n        // Used for 4.4+ kernels using capemgr and universal helpers\n        hw = require('./hw_mainline');\n        if (debug) console.log('Using Mainline interface');\n    } else if (my.is_cape_universal()) {\n        // Used for 3.8 kernels using a single universal overlay with pinmux helpers\n        //  located in debugfs at /sys/kernel/debug/pinctrl/44e10800.pinmux/pins\n        hw = require('./hw_universal');\n        if (debug) console.log('Using Universal Cape interface');\n    } else if (my.is_capemgr()) {\n        // Used for 3.8 kernels using an older out-of-tree version of CapeMgr\n        hw = require('./hw_capemgr');\n        if (debug) console.log('Using CapeMgr interface');\n    } else {\n        // Used for 3.2 kernels using /sys/kernel/debug/omap_mux/\n        hw = require('./hw_oldkernel');\n        if (debug) console.log('Using 3.2 kernel interface');\n    }\n} else {\n    // Incomplete implementation of a set of hardware stubs to run on non BeagleBone targets\n    hw = require('./hw_simulator');\n    if (debug) winston.debug('Using simulator mode');\n}\n\nif (debug) {\n    winston.add(winston.transports.File, {\n        filename: hw.logfile,\n        level: 'debug'\n    });\n    winston.level = 'debug';\n} else {\n    winston.setLevels(winston.config.syslog.levels);\n}\n\nif (debug) winston.debug('index.js loaded');\n\nvar f = {};\n\n// Keep track of allocated resources\nvar gpio = {};\nvar gpioInt = {};\nvar pwm = {};\nvar ain = false;\n\n// returned object has:\n//  mux: index of mux mode\n//  options: array of mode names\n//  slew: 'fast' or 'slow'\n//  rx: 'enabled' or 'disabled'\n//  pullup: 'diabled', 'pullup' or 'pulldown'\n//  pin: key string for pin\n//  name: pin name\n//  pwm: object if pwm enabled, undefind otherwise\n//    freq: frequency of PWM\n//    value: duty cycle of PWM as number between 0 and 1\n//  gpio: object if GPIO enabled, undefined otherwise\n//    active: GPIO is enabled by the kernel\n//    allocated: boolean for if it is allocated by this application\n//    direction: 'in' or 'out' (allocated might be false)\nf.getPinMode = function (pin, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('getPinMode(' + pin.key + ');');\n    var mode = {\n        'pin': pin.key,\n        'name': pin.name\n    };\n    if (pin.options) mode.options = pin.options;\n\n    // Get PWM settings if applicable\n    if (\n        (typeof pin.pwm != 'undefined') // pin has PWM capabilities\n        &&\n        (typeof pwm[pin.pwm.name] != 'undefined') // PWM used for this pin is enabled\n        &&\n        (pin.key == pwm[pin.pwm.name].key) // PWM is allocated for this pin\n    ) {\n        mode.pwm = hw.readPWMFreqAndValue(pin, pwm[pin.pwm.name]);\n    }\n\n    // Get GPIO settings if applicable\n    if ((typeof pin.gpio != 'undefined')) {\n        var n = pin.gpio;\n        mode.gpio = hw.readGPIODirection(n, gpio);\n        if (typeof gpio[n] == 'undefined') {\n            mode.gpio.allocated = false;\n        } else {\n            mode.gpio.allocated = true;\n        }\n    }\n\n    // Get pinmux settings\n    mode = hw.readPinMux(pin, mode, callback);\n    return (mode);\n};\nf.getPinMode.args = ['pin', 'callback'];\n\nf.pinMode = function (pin, direction, mux, pullup, slew, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('pinMode(' + [pin.key, direction, mux, pullup, slew] + ');');\n    if (direction == g.INPUT_PULLUP) pullup = 'pullup';\n    pullup = pullup || ((direction == g.INPUT) ? 'pulldown' : 'disabled');\n    slew = slew || 'fast';\n    mux = (typeof mux != 'undefined') ? mux : 7; // default to GPIO mode\n    var resp = {\n        value: true\n    };\n    var template = 'bspm';\n    var n = pin.gpio;\n\n    if (\n        direction == g.ANALOG_OUTPUT ||\n        mux == g.ANALOG_OUTPUT ||\n        (typeof pin.pwm != 'undefined' && mux == pin.pwm.muxmode)\n    ) {\n        if (\n            (typeof pin.pwm == 'undefined') || // pin does not have PWM capability\n            (typeof pin.pwm.muxmode == 'undefined') // required muxmode is not provided\n        ) {\n            var err = 'pinMode only supports ANALOG_OUTPUT for PWM pins: ' + pin.key;\n            winston.info(err);\n            if (callback) { //support both nodestyle and oldstyle callbacks based on arguments length\n                if (callback.length == 1) {\n                    if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                    cbWarn = true;\n                    callback({\n                        value: false,\n                        err: err\n                    });\n                } else\n                    callback(err, false);\n            }\n            return (false);\n        }\n        direction = g.OUTPUT;\n        mux = pin.pwm.muxmode;\n        template = 'bspwm';\n        pwm[pin.pwm.name] = {\n            'key': pin.key,\n            'freq': 0\n        };\n    }\n\n    if (!pin.mux) {\n        winston.info('pinMode: Missing mux name for pin object: ' + JSON.stringify(pin));\n    }\n\n    // Handle case where pin is allocated as a gpio-led\n    if (debug) winston.debug('pinMode: pin.led = ' + pin.led);\n    if (pin.led) {\n        if ((direction != g.OUTPUT) || (mux != 7)) {\n            resp.err = 'pinMode only supports GPIO output for LEDs: ' + pin.key;\n            winston.info(resp.err);\n            resp.value = false;\n            if (callback) callback(resp);\n            return (false);\n        }\n\n        resp = hw.setLEDPinToGPIO(pin, resp);\n        if (typeof resp.err == 'undefined') {\n            gpio[n] = true;\n        }\n        if (callback) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(resp);\n            } else\n                callback(resp.err, resp.value);\n        }\n        return (resp.value);\n    }\n\n    // Figure out the desired value\n    var pinData = my.pin_data(slew, direction, pullup, mux);\n\n    // May be required: mount -t debugfs none /sys/kernel/debug\n    resp = hw.setPinMode(pin, pinData, template, resp);\n\n    if (typeof resp.err != 'undefined') {\n        if (debug) winston.debug('Unable to configure mux for pin ' + pin + ': ' + resp.err);\n        // It might work if the pin is already muxed to desired mode\n        var currentMode = f.getPinMode(pin);\n        if (currentMode.mux != mux) {\n            resp.value = false;\n            winston.info(resp.err);\n            delete gpio[n];\n            if (callback) {\n                if (callback.length == 1) {\n                    if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                    cbWarn = true;\n                    callback(resp);\n                } else\n                    callback(resp.err, resp.value);\n            }\n            return (resp.value);\n        }\n    }\n\n    // Enable GPIO and set direction\n    if (mux == 7) {\n        // Export the GPIO controls\n        resp = hw.exportGPIOControls(pin, direction, resp);\n        if (typeof resp.err != 'undefined') {\n            if (typeof gpio[n] == 'undefined') {\n                delete gpio[n];\n            }\n        } else {\n            gpio[n] = true;\n        }\n    } else {\n        delete gpio[n];\n    }\n\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            cbWarn = true;\n            callback(resp);\n        } else\n            callback(resp.err, resp.value);\n    }\n    return (resp.value);\n};\nf.pinMode.args = ['pin', 'direction', 'mux', 'pullup', 'slew', 'callback'];\n\nf.digitalWrite = function (pin, value, callback) {\n    var myCallback = false;\n    if (callback) myCallback = function (resp) {\n        if (!resp || (typeof resp != 'object')) resp = {\n            'data': resp\n        };\n        callback(resp);\n    }\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('digitalWrite(' + [pin.key, value] + ');');\n    value = parseInt(Number(value), 2) ? 1 : 0;\n    //handle case digitalWrite() on Analog_Out\n    if (typeof pin.pwm != 'undefined' && typeof f.getPinMode(pin).mux != 'undefined') {\n        var gpioEnabled = (7 == f.getPinMode(pin).mux); //check whether pin set as gpio\n        if (!gpioEnabled) {\n            winston.debug([pin.key, value] + ' set as ANALOG_OUTPUT modifying duty cycle according to value');\n            f.analogWrite(pin, value, 2000, myCallback); //write duty cycle as per value\n            return (true);\n        }\n    }\n\n    hw.writeGPIOValue(pin, value, myCallback);\n\n    return (true);\n};\nf.digitalWrite.args = ['pin', 'value', 'callback'];\n\nf.digitalRead = function (pin, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('digitalRead(' + [pin.key] + ');');\n    var resp = {};\n    if (typeof pin.ain != 'undefined') {\n        if (callback) {\n            f.analogRead(pin, analogCallback);\n        } else {\n            resp.value = f.analogRead(pin);\n            if (resp.value >= 0.5) {\n                resp.value = g.HIGH;\n            } else {\n                resp.value = g.LOW;\n            }\n        }\n    } else {\n        resp = hw.readGPIOValue(pin, resp, callback);\n    }\n\n    function analogCallback(x) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            cbWarn = true;\n            callback(analogValue(x));\n        } else\n            callback(x.err, analogValue(x).value);\n    }\n\n    function analogValue(x) {\n        if (typeof x.value == 'undefined') return;\n        if (x.value >= 0.5) {\n            x.value = g.HIGH;\n        } else {\n            x.value = g.LOW;\n        }\n        return x;\n    }\n\n    return (resp.value);\n};\nf.digitalRead.args = ['pin', 'callback'];\n\nf.analogRead = function (pin, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('analogRead(' + [pin.key] + ');');\n    var resp = {};\n    if (!ain) {\n        ain = hw.enableAIN();\n    }\n    if (typeof pin.ain == 'undefined') {\n        resp.value = f.digitalRead(pin, callback);\n    } else {\n        resp = hw.readAIN(pin, resp, callback);\n    }\n\n    return (resp.value);\n};\nf.analogRead.args = ['pin', 'callback'];\n\nf.shiftOut = function (dataPin, clockPin, bitOrder, val, callback) {\n    dataPin = hw.getPin(dataPin);\n    clockPin = hw.getPin(clockPin);\n    if (debug) winston.debug('shiftOut(' + [dataPin.key, clockPin.key, bitOrder, val] + ');');\n    var i = 0;\n    var bit;\n    var clock = 0;\n\n    function next(err) {\n        if (debug) winston.debug('i = ' + i);\n        if (debug) winston.debug('clock = ' + clock);\n        if (err || i == 8) {\n            callback({\n                'err': err\n            });\n            return;\n        }\n        if (bitOrder == g.LSBFIRST) {\n            bit = val & (1 << i);\n        } else {\n            bit = val & (1 << (7 - i));\n        }\n        if (clock === 0) {\n            clock = 1;\n            if (bit) {\n                f.digitalWrite(dataPin, g.HIGH, next);\n            } else {\n                f.digitalWrite(dataPin, g.LOW, next);\n            }\n        } else if (clock == 1) {\n            clock = 2;\n            f.digitalWrite(clockPin, g.HIGH, next);\n        } else if (clock == 2) {\n            i++;\n            clock = 0;\n            f.digitalWrite(clockPin, g.LOW, next);\n        }\n    }\n\n    if (callback) {\n        next();\n    } else {\n        for (i = 0; i < 8; i++) {\n            if (bitOrder == g.LSBFIRST) {\n                bit = val & (1 << i);\n            } else {\n                bit = val & (1 << (7 - i));\n            }\n\n            if (bit) {\n                f.digitalWrite(dataPin, g.HIGH);\n            } else {\n                f.digitalWrite(dataPin, g.LOW);\n            }\n            f.digitalWrite(clockPin, g.HIGH);\n            f.digitalWrite(clockPin, g.LOW);\n        }\n    }\n};\nf.shiftOut.args = ['dataPin', 'clockPin', 'bitOrder', 'val', 'callback'];\n\nf.attachInterrupt = function (pin, handler, mode, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('attachInterrupt(' + [pin.key, handler, mode] + ');');\n    var n = pin.gpio;\n    var resp = {\n        'pin': pin,\n        'attached': false\n    };\n\n    // Check if we don't have the required Epoll module\n    if (!epoll.exists) {\n        resp.err = 'attachInterrupt: requires Epoll module';\n        if (debug) winston.debug(resp.err);\n        if (callback) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(resp);\n            } else {\n                var err = resp.err;\n                delete resp.err;\n                callback(err, resp);\n            }\n        }\n        return (resp.attached);\n    }\n\n    // Check if pin isn't already configured as GPIO\n    if (typeof gpio[n] == 'undefined') {\n        resp.err = 'attachInterrupt: pin ' + pin.key + ' not already configured as GPIO';\n        if (debug) winston.debug(resp.err);\n        resp.attached = false;\n        resp.configured = false;\n        if (callback) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(resp);\n            } else {\n                var err = resp.err;\n                delete resp.err;\n                callback(err, resp);\n            }\n        }\n        return (resp);\n    }\n\n    // Check if someone already has a handler configured\n    if (typeof gpioInt[n] != 'undefined') {\n        resp.err = 'attachInterrupt: pin ' + pin.key + ' already has an interrupt handler assigned';\n        if (debug) winston.debug(resp.err);\n        resp.attached = false;\n        resp.configured = true;\n        if (callback) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(resp);\n            } else {\n                var err = resp.err;\n                delete resp.err;\n                callback(err, resp);\n            }\n        }\n        return (resp.attached);\n    }\n\n    handler = (typeof handler === \"string\") ? my.myeval('(' + handler + ')') : handler;\n\n    var intHandler = function (err, fd, events) {\n        var m = {};\n        if (err) {\n            m.err = err;\n        }\n        fs.readSync(gpioInt[n].valuefd, gpioInt[n].value, 0, 1, 0);\n        m.pin = pin;\n        m.value = parseInt(gpioInt[n].value.toString(), 2);\n        if (typeof handler == 'function') m.output = handler(m);\n        else m.output = {\n            handler: handler\n        };\n        if (m.output && (typeof callback == 'function')) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                cbWarn = true;\n                callback(m);\n            } else {\n                var err = m.err;\n                delete m.err;\n                callback(err, m);\n            }\n        }\n    };\n\n    try {\n        gpioInt[n] = hw.writeGPIOEdge(pin, mode);\n        gpioInt[n].epoll = new epoll.Epoll(intHandler);\n        fs.readSync(gpioInt[n].valuefd, gpioInt[n].value, 0, 1, 0);\n        gpioInt[n].epoll.add(gpioInt[n].valuefd, epoll.Epoll.EPOLLPRI);\n        resp.attached = true;\n    } catch (ex) {\n        resp.err = 'attachInterrupt: GPIO input file not opened: ' + ex;\n        if (debug) winston.debug(resp.err);\n    }\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            cbWarn = true;\n            callback(resp);\n        } else {\n            var err = resp.err;\n            delete resp.err;\n            callback(err, resp);\n        }\n    }\n    return (resp.attached);\n};\nf.attachInterrupt.args = ['pin', 'handler', 'mode', 'callback'];\n\nf.detachInterrupt = function (pin, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('detachInterrupt(' + [pin.key] + ');');\n    var n = pin.gpio;\n    if (typeof gpio[n] == 'undefined' || typeof gpioInt[n] == 'undefined') {\n        if (callback) {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                callback({\n                    'pin': pin,\n                    'detached': false\n                });\n            } else\n                callback(true, {\n                    'pin': pin,\n                    'detached': false\n                });\n        }\n        return (false);\n    }\n    gpioInt[n].epoll.remove(gpioInt[n].valuefd);\n    delete gpioInt[n];\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            callback({\n                'pin': pin,\n                'detached': true\n            });\n        } else\n            callback(null, {\n                'pin': pin,\n                'detached': true\n            });\n    }\n    return (true);\n};\nf.detachInterrupt.args = ['pin', 'callback'];\n\n// See http://processors.wiki.ti.com/index.php/AM335x_PWM_Driver's_Guide\n// That guide isn't useful for the new pwm_test interface\nf.analogWrite = function (pin, value, freq, callback) {\n    pin = hw.getPin(pin);\n    if (debug) winston.debug('analogWrite(' + [pin.key, value, freq] + ');');\n    freq = freq || 2000.0;\n    var resp = {};\n\n    // Make sure the pin has a PWM associated\n    if (typeof pin.pwm == 'undefined') {\n        //handle analogWrite() on digital OUTPUT\n        if (typeof pin.gpio != 'undefined') {\n            if (value >= 0.5) {\n                if (callback)\n                    f.digitalWrite(pin, g.HIGH, callback);\n                else\n                    f.digitalWrite(pin, g.HIGH);\n                return (true);\n            } else {\n                if (callback)\n                    f.digitalWrite(pin, g.LOW, callback);\n                else\n                    f.digitalWrite(pin, g.LOW);\n                return (true);\n            }\n        }\n        resp.err = 'analogWrite: ' + pin.key + ' does not support analogWrite()';\n        winston.error(resp.err);\n        if (callback) callback(resp);\n        return (false);\n    }\n\n    // Make sure there is no one else who has the PWM\n    if (\n        (typeof pwm[pin.pwm.name] != 'undefined') // PWM needed by this pin is already allocated\n        &&\n        (pin.key != pwm[pin.pwm.name].key) // allocation is not by this pin\n    ) {\n        resp.err = 'analogWrite: ' + pin.key + ' requires pwm ' + pin.pwm.name +\n            ' but it is already in use by ' + pwm[pin.pwm.name].key;\n        winston.error(resp.err);\n        if (callback) callback(resp);\n        return (false);\n    }\n\n    // Enable PWM controls if not already done\n    if (typeof pwm[pin.pwm.name] == 'undefined') {\n        var pinMode = f.getPinMode(pin.key);\n        var slew = pinMode.slew || 'fast';\n        var pullup = pinMode.pullup || 'disabled';\n        f.pinMode(pin, g.ANALOG_OUTPUT, pin.pwm.muxmode, pullup, slew);\n    }\n\n    // Perform update\n    resp = hw.writePWMFreqAndValue(pin, pwm[pin.pwm.name], freq, value, resp);\n\n    // Save off the freq, value and PWM assignment\n    pwm[pin.pwm.name].freq = freq;\n    pwm[pin.pwm.name].value = value;\n\n    // All done\n    if (callback) callback(resp);\n    return (true);\n};\nf.analogWrite.args = ['pin', 'value', 'freq', 'callback'];\n\nf.getEeproms = function (callback) {\n    var eeproms = {};\n    eeproms = hw.readEeproms(eeproms);\n    if (eeproms == {}) {\n        if (debug) winston.debug('No valid EEPROM contents found');\n    }\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            callback(eeproms);\n        } else\n            callback(eeproms == {} ? 'No valid EEPROM contents found' : null, eeproms);\n    }\n    return (eeproms);\n};\nf.getEeproms.args = ['callback'];\n\nf.readTextFile = function (filename, callback) {\n    if (typeof callback == 'function') {\n        var cb = function (err, data) {\n            callback({\n                'err': err,\n                'data': data\n            });\n        };\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            fs.readFile(filename, 'ascii', cb);\n        } else\n            fs.readFile(filename, 'ascii', callback);\n    } else {\n        return fs.readFileSync(filename, 'ascii');\n    }\n};\nf.readTextFile.args = ['filename', 'callback'];\n\nf.writeTextFile = function (filename, data, callback) {\n    if (typeof callback == 'function') {\n        var cb = function (err) {\n            callback({\n                'err': err\n            });\n        };\n        fs.writeFile(filename, data, 'ascii', cb);\n    } else {\n        try {\n            return fs.writeFileSync(filename, data, 'ascii');\n        } catch (ex) {\n            winston.error(\"writeTextFile error: \" + ex);\n            return (false);\n        }\n    }\n};\nf.writeTextFile.args = ['filename', 'data', 'callback'];\n\nf.getPlatform = function (callback) {\n    var platform = {\n        'platform': bone,\n        'name': \"BeagleBone\",\n        'bonescript': package_json.version,\n        'os': {}\n    };\n    platform.os.hostname = os.hostname();\n    platform.os.type = os.type();\n    platform.os.arch = os.arch();\n    platform.os.release = os.release();\n    platform.os.uptime = os.uptime();\n    platform.os.loadavg = os.loadavg();\n    platform.os.totalmem = os.totalmem();\n    platform.os.freemem = os.freemem();\n    platform.os.networkInterfaces = os.networkInterfaces();\n    platform = hw.readPlatform(platform);\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            callback(platform);\n        } else\n            callback(null, platform);\n    }\n    return (platform);\n};\nf.getPlatform.args = ['callback'];\n\nf.echo = function (data, callback) {\n    winston.info(data);\n    if (callback) {\n        if (callback.length == 1) {\n            if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n            callback({\n                'data': data\n            });\n        } else\n            callback(null, data);\n    }\n    return (data);\n};\nf.echo.args = ['data', 'callback'];\n\nf.setDate = function (date, callback) {\n    child_process.execFile('date', ['-s', date], dateResponse)\n\n    function dateResponse(error, stdout, stderr) {\n        if (typeof callback != 'function') return;\n        else {\n            if (callback.length == 1) {\n                if (!cbWarn) winston.warning(\"single argument callbacks will be deprecated.please use node-style error-first callbacks: callback(err,response)\");\n                callback({\n                    'error': error,\n                    'stdout': stdout,\n                    'stderr': stderr\n                });\n            } else\n                callback({\n                    'error': error,\n                    'stderr': stderr\n                }, stdout);\n        }\n    }\n};\nf.setDate.args = ['date', 'callback'];\n\nf.delay = function (ms) {\n    var fiber = fibers.current;\n    if (typeof fiber == 'undefined') {\n        winston.error('sleep may only be called within the setup or run functions');\n        return;\n    }\n    setTimeout(function () {\n        fiber.run();\n    }, ms);\n    fibers.yield();\n};\n\n// Exported variables\nf.bone = bone; // this likely needs to be platform and be detected\nfor (var x in functions) {\n    f[x] = functions[x];\n}\nfor (var x in serial) {\n    f[x] = serial[x];\n}\nfor (var x in iic) {\n    f[x] = iic[x];\n}\nfor (var x in g) {\n    f[x] = g[x];\n}\nfor (var x in autorun) {\n    f[x] = autorun[x];\n}\nfor (var x in server) {\n    f[x] = server[x];\n}\nfor (var x in socketHandlers) {\n    f[x] = socketHandlers[x];\n}\nfor (var x in ffi) {\n    f[x] = ffi[x];\n}\nfor (var x in rc) {\n    f[x] = rc[x];\n}\n\n\nvar alreadyRan = false;\n\nfunction run() {\n    if (debug) winston.debug('Calling run()');\n    if (alreadyRan) return (false);\n    alreadyRan = true;\n    // 'setup' and 'loop' are globals that may or may not be defined\n    if (typeof global.setup == 'function' || typeof global.loop == 'function') {\n        fibers(function () {\n            if (typeof global.setup == 'function') {\n                winston.debug('Running setup()');\n                global.setup();\n            }\n            if (typeof global.loop == 'function') {\n                if (debug) winston.debug('Starting loop()');\n                while (1) {\n                    global.loop();\n                }\n            }\n        }).run();\n    }\n}\nprocess.nextTick(run);\n\n// Global variable assignments\n// This section is broken out because it will eventually be deprecated\nf.setGlobals = function () {\n    for (var x in f) {\n        global[x] = f[x];\n    }\n    global.run = run;\n};\nmodule.exports = f;"
  },
  {
    "path": "src/my.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\n//\n// This is meant to hold some private functions\n//\nvar fs = require('fs');\nvar winston = require('winston');\nvar child_process = require('child_process');\nvar bone = require('./bone');\nvar g = require('./constants');\n\nvar debug = process.env.DEBUG ? true : false;\nvar sysfsFiles = {};\n\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy\nvar myRequire = function (packageName, onfail) {\n    var module;\n    var exists;\n    var proxyHandler = {};\n\n    function proxyGet(target, name) {\n        if (name === \"exists\") {\n            return exists;\n        }\n        if (!module && exists) {\n            module = require(packageName);\n        }\n        return module[name];\n    }\n\n    proxyHandler.get = proxyGet;\n\n    function proxyFunction() {\n        if (!module && exists) {\n            module = require(packageName);\n        }\n        return module.apply(this, arguments);\n    }\n\n    var y = new Proxy(proxyFunction, proxyHandler);\n    try {\n        exists = require.resolve(packageName);\n    } catch (ex) {\n        exists = false;\n        if (debug) winston.debug(\"Optional package '\" + packageName + \"' not loaded\");\n        if (onfail) onfail();\n    }\n    return (y);\n};\n\nvar fibers = myRequire('fibers');\n\nvar is_new_capemgr = function (callback) {\n    var exists = file_existsSync('/sys/devices/platform/bone_capemgr/slots');\n    if (callback) callback(exists);\n    return (exists);\n};\n\nvar is_capemgr = function (callback) {\n    return (find_sysfsFile('capemgr', '/sys/devices', 'bone_capemgr.', callback));\n};\n\nvar is_ocp = function (callback) {\n    var found = find_sysfsFile('ocp', '/sys/devices', 'ocp.', callback);\n    if (debug) winston.debug(\"is_ocp, found = \" + found);\n    if (typeof found == 'undefined') {\n        found = find_sysfsFile('ocp', '/sys/devices/platform', 'ocp', callback);\n        if (debug) winston.debug(\"is_ocp, found2 = \" + found);\n    }\n    return (found);\n};\n\nvar is_cape_universal = function (callback) {\n    var ocp = is_ocp();\n    if (debug) winston.debug('is_ocp() = ' + ocp);\n    var cape_universal = find_sysfsFile('cape-universal', ocp, 'cape-universal.', callback);\n    if (debug) winston.debug('is_cape_universal() = ' + cape_universal);\n    return (cape_universal);\n};\n\nvar find_sysfsFile = function (name, path, prefix, callback) {\n    if (debug) winston.debug('find_sysfsFile(' + name + ',' + path + ',' + prefix + ')');\n    if (typeof sysfsFiles[name] == 'undefined') {\n        if (callback) {\n            sysfsFiles[name] = file_find(path, prefix, 1, onFindCapeMgr);\n        } else {\n            sysfsFiles[name] = file_find(path, prefix, 1);\n        }\n    } else {\n        if (callback) callback({\n            path: sysfsFiles[name]\n        });\n    }\n\n    function onFindCapeMgr(resp) {\n        if (typeof resp.path == 'undefined') sysfsFiles[name] = false;\n        else sysfsFiles[name] = resp.path;\n        callback(resp);\n    }\n\n    return (sysfsFiles[name]);\n};\n\nfile_exists = fs.exists;\nfile_existsSync = fs.existsSync;\nif (typeof file_exists == 'undefined') {\n    var path = require('path');\n    file_exists = path.exists;\n    file_existsSync = path.existsSync;\n}\n\nvar file_find = function (path, prefix, attempts, callback) {\n    var resp = {};\n    resp.attempts = 0;\n    if (typeof attempts == 'undefined') attempts = 1;\n\n    if (callback) {\n        fs.readdir(path, onReadDir);\n    } else {\n        while (resp.attempts < attempts) {\n            try {\n                var files = fs.readdirSync(path);\n                onReadDir(null, files);\n            } catch (ex) {\n                if (debug) winston.debug('Error reading ' + path);\n                return (resp.path);\n            }\n            if (resp.path) return (resp.path);\n        }\n        return (resp.path);\n    }\n\n    function onReadDir(err, files) {\n        resp.attempts++;\n        if (err) {\n            resp.err = 'Error listing directory ' + path + ': ' + err;\n            if (callback) callback(resp);\n            return;\n        }\n        for (var j in files) {\n            if (Array.isArray(prefix)) {\n                for (var k = 0; k < prefix.length; k++) {\n                    if (files[j].search(prefix[k]) == 0) {\n                        resp.path = path + '/' + files[j];\n                        if (callback) callback(resp);\n                        return;\n                    }\n                }\n            } else {\n                if (files[j].search(prefix) === 0) {\n                    resp.path = path + '/' + files[j];\n                    if (callback) callback(resp);\n                    return;\n                }\n            }\n        }\n        if (callback) {\n            if (resp.attempts >= attempts) {\n                resp.err = 'Did not find ' + prefix + ' in ' + path;\n                callback(resp);\n            } else {\n                fs.readdir(path, onReadDir);\n            }\n        }\n    }\n\n    return (resp.path);\n};\n\n// Note, this just makes sure there was an attempt to load the\n// devicetree fragment, not if it was successful\nvar load_dt = function (name, pin, resp, callback) {\n    if (debug) winston.debug('load_dt(' + [name, pin ? pin.key : null, JSON.stringify(resp)] + ')');\n    resp = resp || {};\n    var slotsFile;\n    var lastSlots;\n    var writeAttempts = 0;\n    var readAttempts = 0;\n    if (pin) {\n        var slotRegex = new RegExp('\\\\d+(?=\\\\s*:.*,bs.*' + pin.key + ')', 'gm');\n    }\n    var capemgr = is_capemgr();\n    onFindCapeMgr({\n        path: capemgr\n    });\n\n    function onFindCapeMgr(x) {\n        if (debug) winston.debug('onFindCapeMgr: path = ' + x.path);\n        if (typeof x.path == 'undefined') {\n            resp.err = \"CapeMgr not found: \" + x.err;\n            winston.error(resp.err);\n            if (callback) callback(resp);\n            return (false);\n        }\n        slotsFile = x.path + '/slots';\n        var slots;\n        try {\n            slots = fs.readFileSync(slotsFile, 'ascii');\n        } catch (ex) {\n            resp.err = ex;\n        }\n        onReadSlots(resp.err, slots);\n    }\n\n    function onReadSlots(err, slots) {\n        readAttempts++;\n        if (err) {\n            resp.err = 'Unable to read from CapeMgr slots: ' + err;\n            winston.error(resp.err);\n            if (callback) callback(resp);\n            return (false);\n        }\n        lastSlots = slots;\n        var index = slots.indexOf(name);\n        if (debug) winston.debug('onReadSlots: index = ' + index + ', readAttempts = ' + readAttempts);\n        if (index >= 0) {\n            // Fragment is already loaded\n            if (callback) callback(resp);\n        } else if (readAttempts <= 1) {\n            // Attempt to load fragment\n            try {\n                if (debug) winston.debug('Writing ' + name + ' to ' + slotsFile);\n                fs.writeFileSync(slotsFile, name, 'ascii');\n            } catch (ex) {\n                resp.err = ex;\n            }\n            onWriteSlots(resp.err);\n        } else {\n            resp.err = 'Error waiting for CapeMgr slot to load';\n            callback(resp);\n        }\n    }\n\n    function onWriteSlots(err) {\n        writeAttempts++;\n        if (err) {\n            resp.err = 'Write to CapeMgr slots failed: ' + err;\n            if (pin && writeAttempts <= 1) unloadSlot();\n            else {\n                if (callback) callback(resp);\n                return (false);\n            }\n        }\n        var slots;\n        try {\n            slots = fs.readFileSync(slotsFile, 'ascii');\n        } catch (ex) {\n            resp.err = ex;\n        }\n        onReadSlots(resp.err, slots);\n    }\n\n    function unloadSlot() {\n        var slot = lastSlots.match(slotRegex);\n        if (slot && slot[0]) {\n            if (debug) winston.debug('Attempting to unload conflicting slot ' +\n                slot[0] + ' for ' + name);\n            try {\n                fs.writeFileSync(slotsFile, '-' + slot[0], 'ascii');\n            } catch (ex) {\n                resp.err = ex;\n            }\n            onUnloadSlot(resp.err);\n        } else {\n            if (callback) callback(resp);\n            return (false);\n        }\n    }\n\n    function onUnloadSlot(err) {\n        if (err) {\n            resp.err = \"Unable to unload conflicting slot: \" + err;\n            callback(resp);\n            return;\n        }\n        try {\n            fs.writeFileSync(slotsFile, name, 'ascii');\n        } catch (ex) {\n            resp.err = ex;\n        }\n        onWriteSlots(resp.err);\n    }\n\n    if (debug) winston.debug('load_dt resp: ' + JSON.stringify(resp));\n    if (debug) winston.debug('load_dt return: ' + (typeof resp.err == 'undefined'));\n    return (typeof resp.err == 'undefined');\n};\n\nvar create_dt = function (pin, data, template, load, force_create, resp, callback) {\n    if (debug) winston.debug('create_dt(' + [pin.key, data, template, load, force_create, JSON.stringify(resp)] + ')');\n    resp = resp || {};\n    template = template || 'bspm';\n    load = (typeof load === 'undefined') ? true : load;\n    var fragment = template + '_' + pin.key + '_' + data.toString(16);\n    var dtsFilename = '/lib/firmware/' + fragment + '-00A0.dts';\n    var dtboFilename = '/lib/firmware/' + fragment + '-00A0.dtbo';\n\n    if (force_create) {\n        createDTS();\n    } else {\n        var exists = file_existsSync(dtboFilename);\n        onDTBOExistsTest(exists);\n    }\n\n    function onDTBOExistsTest(exists) {\n        if (exists) {\n            onDTBOExists();\n        } else {\n            createDTS();\n        }\n    }\n\n    function createDTS() {\n        var templateFilename = require.resolve('bonescript').replace('main.js',\n            'dts/' + template + '_template.dts');\n        if (debug) winston.debug('Creating template: ' + templateFilename);\n        var dts = fs.readFileSync(templateFilename, 'utf8');\n        dts = dts.replace(/!PIN_KEY!/g, pin.key);\n        dts = dts.replace(/!PIN_DOT_KEY!/g, pin.key.replace(/_/, '.'));\n        dts = dts.replace(/!PIN_FUNCTION!/g, pin.options[data & 7]);\n        dts = dts.replace(/!PIN_OFFSET!/g, pin.muxRegOffset);\n        dts = dts.replace(/!DATA!/g, '0x' + data.toString(16));\n        if (pin.pwm) {\n            dts = dts.replace(/!PWM_MODULE!/g, pin.pwm.module);\n            dts = dts.replace(/!PWM_INDEX!/g, pin.pwm.index);\n            dts = dts.replace(/!DUTY_CYCLE!/g, 500000);\n        }\n        try {\n            fs.writeFileSync(dtsFilename, dts, 'ascii');\n        } catch (ex) {\n            resp.err = ex;\n        }\n        onDTSWrite(resp.err);\n    }\n\n    function onDTSWrite(err) {\n        if (err) {\n            resp.err = 'Error writing ' + dtsFilename + ': ' + err;\n            if (debug) winston.debug(resp.err);\n            if (callback) callback(resp);\n            return (resp);\n        }\n        var command = 'dtc -O dtb -o ' + dtboFilename + ' -b 0 -@ ' + dtsFilename;\n        try {\n            child_process.execSync(command);\n        } catch (ex) {\n            resp.err = ex;\n        }\n        dtcHandler(resp.err);\n    }\n\n    function dtcHandler(error, stdout, stderr) {\n        if (debug) winston.debug('dtcHandler: ' +\n            JSON.stringify({\n                error: error,\n                stdout: stdout,\n                stderr: stderr\n            }));\n        if (!error) onDTBOExists();\n    }\n\n    function onDTBOExists() {\n        if (debug) winston.debug('onDTBOExists()');\n        if (load) load_dt(fragment, pin, resp);\n    }\n\n    if (callback) callback(resp);\n    return (typeof resp.err == 'undefined');\n};\n\nvar myeval = function (x) {\n    winston.debug('myeval(\"' + x + '\");');\n    var y;\n    try {\n        y = eval(x);\n    } catch (ex) {\n        y = undefined;\n        winston.error('myeval error: ' + ex);\n        throw ('myeval error: ' + ex);\n    }\n    winston.debug('result = ' + y);\n    return (y);\n};\n\nvar getpin = function (pin) {\n    if (typeof pin == 'object') return (pin);\n    else {\n        var pinObject = bone.getPinObject(pin);\n        if (typeof pinObject != 'object') {\n            throw (\"Invalid pin: \" + pin);\n        }\n        return (pinObject);\n    }\n};\n\nvar wrapCall = function (m, func, funcArgs, cbArgs) {\n    if (!m.module.exists) {\n        if (debug) winston.debug(m.name + ' support module not loaded.');\n        return (function () {});\n    }\n    funcArgs.unshift('port');\n    funcArgs.push('callback');\n    var newFunction = function () {\n        var args = [];\n        var port = arguments[0];\n        var callback = false;\n        for (var i = 1; i < arguments.length; i++) {\n            winston.debug('Adding argument ' + funcArgs[i] + ' to wrapper');\n            if (funcArgs[i] == 'callback') {\n                callback = arguments[i];\n                var wrappedCallback = function () {\n                    var cbData = {};\n                    for (var j = 0; j < cbArgs.length; j++) {\n                        cbData[cbArgs[j]] = arguments[j];\n                    }\n                    cbData.event = 'callback';\n                    winston.debug('cbData = ' + JSON.stringify(cbData));\n                    callback(cbData);\n                };\n                args.push(wrappedCallback);\n            } else {\n                args.push(arguments[i]);\n            }\n        }\n        if (!m.openPorts[port]) {\n            if (callback) callback({\n                'err': m.name + ' ' + port + ' not opened'\n            });\n            return (false);\n        }\n        winston.debug('Calling ' + m.name + '[' + port + '].' + func + '(' + args + ')');\n        var x = m.openPorts[port][func].apply(\n            m.openPorts[port], args);\n        if (callback) callback({\n            'event': 'return',\n            'return': x\n        });\n        return (x);\n    };\n    newFunction.args = funcArgs;\n    return (newFunction);\n};\n\nvar wrapOpen = function (m, openArgs) {\n    if (!m.module.exists) {\n        if (debug) winston.debug(m.name + ' support module not loaded.');\n        return (function () {});\n    }\n    openArgs.unshift('port');\n    openArgs.push('callback');\n    var newFunction = function () {\n        var args = {};\n        for (var i = 0; i < openArgs.length; i++) {\n            args[openArgs[i]] = arguments[i];\n        }\n        var port = args.port;\n        var callback = args.callback;\n        winston.debug(m.name + ' opened with ' + JSON.stringify(arguments));\n        if (m.ports[port] && m.ports[port].devicetree) {\n            var fragment = m.ports[port].devicetree;\n            if (!is_capemgr()) {\n                if (callback) callback({\n                    err: 'Kernel does not include CapeMgr module'\n                });\n                return (false);\n            }\n            if (!load_dt(fragment)) {\n                if (callback) callback({\n                    'err': 'Devicetree overlay fragment ' +\n                        fragment + ' not loaded'\n                });\n                return (false);\n            }\n        }\n        m.openPorts[port] = m.doOpen(args);\n        if (!m.openPorts[port]) {\n            if (callback) callback({\n                'err': 'Unable to ' + m.name\n            });\n            return (false);\n        }\n        for (var e in m.events) {\n            var addHandler = function (m, port, e) {\n                var handler = function () {\n                    var myargs = arguments;\n                    myargs.event = e;\n                    for (var i = 0; i < arguments.length; i++) {\n                        myargs[m.events[e][i]] = arguments[i];\n                    }\n                    callback(myargs);\n                };\n                m.openPorts[port].on(e, handler);\n            };\n            addHandler(m, port, e);\n        }\n        if (callback) callback({\n            'event': 'return',\n            'value': true\n        });\n        return (true);\n    };\n    newFunction.args = openArgs;\n    return (newFunction);\n};\n\nvar pin_data = function (slew, direction, pullup, mux) {\n    var pinData = 0;\n    if (slew == 'slow') pinData |= 0x40;\n    if (direction != g.OUTPUT) pinData |= 0x20;\n    switch (pullup) {\n    case 'disabled':\n        pinData |= 0x08;\n        break;\n    case 'pullup':\n        pinData |= 0x10;\n        break;\n    default:\n        break;\n    }\n    pinData |= (mux & 0x07);\n    return (pinData);\n};\n\n// Inspired by\n//   https://github.com/luciotato/waitfor/blob/master/waitfor.js\n//   https://github.com/0ctave/node-sync/blob/master/lib/sync.js\nvar wait_for = function (fn, myargs, result_name, no_error) {\n    var fiber = fibers.current;\n    var yielded = false;\n    var args = [];\n    var result;\n\n    for (var i in fn.args) {\n        if (fn.args[i] == 'callback') {\n            args.push(myCallback);\n        } else {\n            args.push(myargs[i]);\n        }\n    }\n\n    if (typeof fiber == 'undefined') {\n        if (no_error) {\n            // No callback required (fire and forget)\n            fn.apply(this, args);\n        } else {\n            var stack = new Error().stack;\n            var err = 'As of BoneScript 0.2.5, synchronous calls must be made\\n' +\n                'within a fiber such as within loop() or setup():\\n' + stack;\n            winston.error(err);\n            throw (err);\n        }\n    } else {\n        fn.apply(this, args);\n        if (!myCallback.called) {\n            yielded = true;\n            fibers.yield();\n        }\n    }\n\n    function myCallback(x) {\n        if (debug) winston.debug('Callback: ' + fn.name + ' ' + x.err);\n        if (myCallback.called) return;\n        if (typeof result_name == 'undefined') {\n            result = x;\n        } else if (typeof x[result_name] != 'undefined') {\n            result = x[result_name];\n        }\n        if (typeof x.err != 'undefined' && x.err) {\n            //var fn_name = fn.toString().substr('function '.length);\n            //fn_name = fn_name.substr(0, fn_name.indexOf('('));\n            if (debug) winston.debug(fn.name + ' ' + x.err);\n        }\n        myCallback.called = true;\n        if (typeof fiber == 'undefined' && no_error) return;\n        if (yielded) fiber.run();\n    }\n\n    return (result);\n};\n\nmodule.exports = {\n    require: myRequire,\n    is_new_capemgr: is_new_capemgr,\n    is_capemgr: is_capemgr,\n    is_ocp: is_ocp,\n    is_cape_universal: is_cape_universal,\n    find_sysfsFile: find_sysfsFile,\n    file_exists: file_exists,\n    file_existsSync: file_existsSync,\n    file_find: file_find,\n    load_dt: load_dt,\n    create_dt: create_dt,\n    myeval: myeval,\n    getpin: getpin,\n    wrapCall: wrapCall,\n    wrapOpen: wrapOpen,\n    pin_data: pin_data,\n    wait_for: wait_for\n}"
  },
  {
    "path": "src/parse.js",
    "content": "var winston = require('winston');\n\nvar debug = process.env.PARSE_DEBUG ? true : false;\n\n// This parses pinmux data from the register value\nvar modeFromStatus = function (pinData, mode, isAI) {\n    mode = mode || {};\n    mode.mux = isAI ? (pinData & 0x0f) : (pinData & 0x07);\n    mode.slew = (isAI ? (pinData & (1 << 19)) : (pinData & (1 << 6))) ? 'slow' : 'fast';\n    mode.rx = (isAI ? (pinData & (1 << 18)) : (pinData & (1 << 5))) ? 'enabled' : 'disabled';\n    var pullup = isAI ? ((pinData & (3 << 16)) >> 16) : ((pinData & (3 << 3)) >> 3);\n    switch (pullup) {\n    case 1:\n        mode.pullup = 'disabled';\n        break;\n    case 2:\n        mode.pullup = 'pullup';\n        break;\n    case 0:\n        mode.pullup = 'pulldown';\n        break;\n    default:\n        winston.error('Unknown pullup value: ' + pullup);\n    }\n    return (mode);\n};\n\nvar modeFromOmapMux = function (readout, mode) {\n    if (debug) winston.debug('' + readout);\n    mode = mode || {};\n    // The format read from debugfs looks like this:\n    // name: mcasp0_axr0.spi1_d1 (0x44e10998/0x998 = 0x0023), b NA, t NA\n    // mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE3\n    // signals: mcasp0_axr0 | ehrpwm0_tripzone | NA | spi1_d1 | mmc2_sdcd_mux1 | NA | NA | gpio3_16\n    var breakdown = '';\n    try {\n        breakdown = readout.split('\\n');\n    } catch (ex) {\n        winston.info('Unable to parse mux readout \"' + readout + '\": ' + ex);\n        return (mode);\n    }\n    try {\n        // Parse the muxmode number, '3' in the above example\n        mode.mux = breakdown[1].split('|')[1].substr(-1);\n        // Parse the mux register value, '0x0023' in the above example\n        var pinData = parseInt(breakdown[0].split('=')[1].substr(1, 6), 16);\n        if (debug) winston.debug('pinData = ' + pinData);\n        mode = modeFromStatus(pinData, mode);\n    } catch (ex2) {\n        winston.info('Unable to parse mux mode \"' + breakdown + '\": ' + ex2);\n    }\n    try {\n        mode.options = breakdown[2].split('|');\n        for (var option in mode.options) {\n            var x = '' + mode.options[option];\n            try {\n                mode.options[option] = x.replace(/ /g, '').replace('signals:', '');\n            } catch (ex) {\n                winston.info('Unable to parse option \"' + x + '\": ' + ex);\n                mode.options[option] = 'NA';\n            }\n        }\n    } catch (ex3) {\n        winston.info('Unable to parse options \"' + breakdown + '\": ' + ex3);\n        mode.options = null;\n    }\n    return (mode);\n};\n\nvar modeFromPinctrl = function (pins, muxRegOffset, muxBase, mode, isAI) {\n    if (debug) winston.debug('' + pins);\n    muxBase = muxBase || 0x44e10800;\n    mode = mode || {};\n    // The format read from debugfs looks like this:\n    // registered pins: 142\n    // ...\n    // pin 108 (44e109b0) 00000027 pinctrl-single\n    // ...\n    //\n    // new format is:\n    // registered pins: 142\n    // ...\n    // pin 0 (PIN0) 44e10800 00000027 pinctrl-single\n    // ...\n    //\n    var pinLines = pins.split('\\n');\n    var numRegistered = pinLines[0].replace(/registered pins: (\\d+)/, \"$1\");\n    var pattern = /pin (\\d+) (\\(PIN\\d+\\))? \\(?([0-9a-f\\.]+)\\(? ([0-9a-f]+) pinctrl-single/;\n    var muxAddress = muxBase + muxRegOffset;\n    for (var i = 0; i < numRegistered; i++) {\n        if (debug) winston.debug('pinLine = ' + pinLines[i + 1]);\n        var parsedFields = pattern.exec(pinLines[i + 1]);\n        if (debug) winston.debug('parsedFields = ' + parsedFields);\n        //var index = parseInt(parsedFields[1], 10);\n        var address = parseInt(parsedFields[3], 16);\n        var status = parseInt(parsedFields[4], 16);\n        if (address == muxAddress) {\n            mode = modeFromStatus(status, mode, isAI);\n            return (mode);\n        }\n    }\n    //winston.error('Did not find status at ' + muxAddress);\n    return (mode);\n};\n\nmodule.exports = {\n    modeFromStatus: modeFromStatus,\n    modeFromOmapMux: modeFromOmapMux,\n    modeFromPinctrl: modeFromPinctrl\n}"
  },
  {
    "path": "src/rc.js",
    "content": "// Copyright (C) 2017 - Texas Instruments, Jason Kridner\nvar my = require('./my');\nvar rc = my.require('roboticscape');\n\nif (rc.exists) {\n\n    var rcInitialize = function (callback) {\n        var i = rc.initialize();\n        var x = {};\n        if (i) {\n            x.error = i;\n        }\n        if (callback) callback(x);\n        return (i);\n    };\n    rcInitialize.args = ['callback'];\n\n    var rcState = function (state, callback) {\n        var x = {};\n        if (state) {\n            rc.state(state);\n        } else {\n            state = rc.state();\n        }\n        x.state = state;\n        if (callback) callback(x);\n        return (state);\n    };\n    rcState.args = ['state', 'callback'];\n\n    var rcLED = function (led, value, callback) {\n        if (typeof value !== 'undefined') {\n            rc.led(led, value);\n        }\n        if (callback) callback();\n    };\n    rcLED.args = ['led', 'value', 'callback'];\n\n    var rcOn = function (event, callback) {\n        function myCallback() {\n            callback({\n                'event': event\n            });\n        }\n        rc.on(event, myCallback);\n    };\n    rcOn.args = ['event', 'callback'];\n\n    var rcMotor = function (motor, value, callback) {\n        if (typeof value !== 'undefined') {\n            rc.motor(motor, value);\n        } else {\n            rc.motor(motor);\n        }\n        if (callback) callback();\n    };\n    rcMotor.args = ['motor', 'value', 'callback'];\n\n    var rcServo = function (option, value, callback) {\n        if (typeof value !== 'undefined') {\n            rc.servo(option, value);\n        } else {\n            rc.servo(option);\n        }\n        if (callback) callback();\n    };\n    rcServo.args = ['option', 'value', 'callback'];\n\n    var rcBMP = function (option, callback) {\n        var value\n        if (typeof option !== 'undefined') {\n            value = rc.bmp(option);\n        }\n        if (callback) callback(null, value);\n        else return value;\n    };\n    rcBMP.args = ['option', 'callback'];\n\n    var rcIMU = function (option, callback) {\n        var value\n        if (typeof option !== 'undefined') {\n            value = rc.imu(option);\n        }\n        if (callback) callback(null, value);\n        else return value;\n    };\n    rcIMU.args = ['option', 'callback'];\n\n    var rcEncoder = function (encoder, value, callback) {\n        var x = {};\n        x.encoder = encoder;\n        var i;\n        if (typeof value !== 'undefined') {\n            i = rc.encoder(encoder, value);\n        } else {\n            i = rc.encoder(encoder);\n            x.value = i;\n        }\n        if (callback) callback(x);\n    };\n    rcEncoder.args = ['encoder', 'value', 'callback'];\n\n    module.exports = {\n        rcInitialize: rcInitialize,\n        rcState: rcState,\n        rcLED: rcLED,\n        rcOn: rcOn,\n        rcMotor: rcMotor,\n        rcServo: rcServo,\n        rcBMP: rcBMP,\n        rcIMU: rcIMU,\n        rcEncoder: rcEncoder\n    };\n}"
  },
  {
    "path": "src/serial.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\nvar bone = require('./bone');\nvar my = require('./my');\n\nvar m = {};\nm.name = 'serialport';\nm.module = my.require('serialport');\nm.ports = bone.uarts;\nm.events = {\n    'open': [],\n    'data': ['data']\n};\nm.openPorts = {};\nm.doOpen = function (args) {\n    var path = args.port;\n    if (m.ports[args.port].path) path = m.ports[args.port].path;\n    var openPort = new m.module.SerialPort(path, args.options);\n    return (openPort);\n};\nmodule.exports = {\n    serialOpen: my.wrapOpen(m, ['options']),\n    serialWrite: my.wrapCall(m, 'write', ['data'], ['err', 'results']),\n\n    serialParsers: m.module.exists ? m.module.parsers : {}\n}"
  },
  {
    "path": "src/server.js",
    "content": "// Copyright (C) 2011 - Texas Instruments, Jason Kridner\n//\n//\nvar fs = require('fs');\nvar http = require('http');\nvar events = require('events');\nvar crypto = require('crypto');\nvar my = require('./my');\nvar winston = my.require('winston');\nvar express = my.require('express');\nvar socketHandlers = my.require('./socket_handlers');\n\nvar serverEmitter = new events.EventEmitter();\n\nvar debug = process.env.DEBUG ? true : false;\n\nvar systemd = my.require('systemd');\nif (!systemd.exists) {\n    if (debug) winston.debug(\"Startup as socket-activated service under systemd not enabled\");\n}\n\nvar serverStart = function (port, directory, passphrase, callback) {\n    if (port === undefined) {\n        port = (process.env.LISTEN_PID > 0) ? 'systemd' : ((process.env.PORT) ? process.env.PORT : 80);\n    }\n    if (directory === undefined) {\n        directory = (process.env.SERVER_DIR) ? process.env.SERVER_DIR : '/usr/share/bone101';\n    }\n    var passphrase_hash;\n    if (passphrase) {\n        if (passphrase.hash) //whether passphrase supplied as hash/text\n            passphrase_hash = passphrase.data;\n        else\n            passphrase_hash = crypto.createHash('sha256').update(passphrase.data).digest(\"hex\"); //generate hash\n    }\n    var server = mylisten(port, directory, passphrase_hash);\n    serverEmitter.on('newListner', addServerListener);\n\n    function addServerListener(event, listener) {\n        console.log('got here'); //TODO: not getting here\n        if (debug) winston.debug('Got request to add listener to ' + event);\n        var serverEvent = event.replace(/^server\\$/, '');\n        if (serverEvent) {\n            if (debug) winston.debug('Adding listener to server$' + serverEvent);\n            server.on(serverEvent, listener);\n        }\n    }\n\n    if (callback) {\n        callback({\n            server: server,\n            serverEmitter: serverEmitter\n        });\n    }\n\n    return (serverEmitter);\n};\n\nfunction mylisten(port, directory, passphrase_hash) {\n    winston.info(\"Opening port \" + port + \" to serve up \" + directory);\n    var app = express();\n    app.get('/bonescript.js', socketHandlers.socketJSReqHandler);\n    app.use('/bone101', express.static(directory));\n    app.use('/bone101/static', express.static(directory + \"/static\"));\n    app.use(express.static(directory));\n    var server = http.createServer(app);\n    socketHandlers.addSocketListeners(server, serverEmitter, passphrase_hash);\n    server.listen(port);\n    return (server);\n}\n\nmodule.exports = {\n    serverStart: serverStart\n}"
  },
  {
    "path": "src/socket_handlers.js",
    "content": "// Copyright (C) 2011 - Texas Instruments, Jason Kridner\n//\n//\nvar b = require('../main');\nvar fs = require('fs');\nvar url = require('url');\nvar child_process = require('child_process');\nvar my = require('./my');\nvar winston = my.require('winston');\nvar socketio = my.require('socket.io');\nvar debug = process.env.DEBUG ? true : false;\n\nvar socketJSReqHandler = function (req, res) {\n    function sendFile(err, file) {\n        if (err) {\n            res.writeHead(500, {\n                \"Content-Type\": \"text/plain\"\n            });\n            res.end(err + '\\n');\n            return;\n        }\n        res.setHeader('Content-Type', 'text/javascript');\n        file = file.replace(/___INSERT_HOST___/g, host);\n        res.end(file);\n    }\n    var parsedUrl = url.parse(req.url);\n    var uri = parsedUrl.pathname;\n    var host = 'http://' + req.headers.host;\n    if (uri == '/bonescript.js') {\n        var filename = __dirname + '/bonescript.js';\n        if (debug) winston.debug('filename = ' + filename)\n        fs.readFile(filename, 'utf8', sendFile);\n    }\n}\n\nvar addSocketListeners = function (server, serverEmitter, passphrase_hash) {\n    var io = socketio(server);\n    if (passphrase_hash) { //attach middleware to handle authentication\n        io.use(function (socket, next) {\n            socket.auth = false; //consider the all sockets initially as unauthorized \n            if (socket.handshake.headers.authorization) {\n                if (socket.handshake.headers.authorization == passphrase_hash) {\n                    socket.auth = true; //authorize the socket\n                    next();\n                } else\n                    next(new Error(\"Authentication Failed : incorrect passphrase !!\"));\n            } else {\n                next(new Error(\"Authentication data not send !!\"));\n            }\n        });\n    }\n    if (debug) winston.debug('Listening for new socket.io clients');\n    io.on('connection', function (socket) {\n        if (socket.auth || !passphrase_hash)\n            onconnect(socket);\n        else\n            socket.disconnect('unauthorized');\n    });\n\n    function onconnect(socket) {\n        winston.debug('Client connected');\n        serverEmitter.emit('socket$connect', socket);\n\n        // on disconnect\n        socket.on('disconnect', function () {\n            if (debug) winston.debug('Client disconnected');\n            serverEmitter.emit('socket$disconnect');\n        });\n\n        socket.on('message', serverMessage);\n\n        spawn(socket);\n\n        var modmsg = {};\n        modmsg.module = 'bonescript';\n        modmsg.data = {};\n\n        var callMyFunc = function (name, m) {\n            var myCallback = function (resp) {\n                if (debug) winston.debug(name + ' replied to ' + JSON.stringify(m) + ' with ' + JSON.stringify(resp));\n                if (typeof m.seq == 'undefined') return;\n                if (!resp || (typeof resp != 'object')) resp = {\n                    'data': resp\n                };\n                resp.seq = m.seq;\n                // TODO: consider setting 'oneshot'\n                if (debug) winston.debug('Sending message \"bonescript\": ' + JSON.stringify(resp));\n                socket.emit('bonescript', resp);\n            };\n            var myCallback_nodestyle = function (err, resp) {\n                if (debug) winston.debug(name + ' replied to ' + JSON.stringify(m) + ' with ' + JSON.stringify(resp));\n                if (typeof m.seq == 'undefined') return;\n                // TODO: consider setting 'oneshot'\n                if (debug) winston.debug('Sending message \"bonescript\": ' + JSON.stringify(resp));\n                socket.emit('bonescript', {\n                    err: err,\n                    resp: resp,\n                    seq: m.seq\n                });\n            };\n            try {\n                var callargs = [];\n                for (var arg in b[name].args) {\n                    var argname = b[name].args[arg];\n                    if (argname == 'callback') {\n                        if (typeof m.seq == 'number') {\n                            if (m.length == 1)\n                                callargs.push(myCallback);\n                            else\n                                callargs.push(myCallback_nodestyle);\n                        } else callargs.push(null);\n                    } else if (typeof m[argname] != 'undefined') {\n                        callargs.push(m[argname]);\n                    } else {\n                        callargs.push(undefined);\n                    }\n                }\n                if (debug) winston.debug('Calling ' + name + '(' + callargs.join(',') + ')');\n                b[name].apply(this, callargs);\n            } catch (ex) {\n                if (debug) winston.debug('Error handing ' + name + ' message: ' + ex);\n                if (debug) winston.debug('m = ' + JSON.stringify(m));\n            }\n        };\n\n        var addSocketX = function (message, name) {\n            var onFuncMessage = function (m) {\n                callMyFunc(name, m);\n            };\n            socket.on(message, onFuncMessage);\n        };\n\n        var b = require('../main');\n        for (var i in b) {\n            if (typeof b[i] == 'function') {\n                if (typeof b[i].args != 'undefined') {\n                    modmsg.data[i] = {};\n                    modmsg.data[i].name = i;\n                    modmsg.data[i].type = 'function';\n                    modmsg.data[i].value = b[i].args;\n                    addSocketX('bonescript$' + i, i);\n                }\n            } else {\n                modmsg.data[i] = {};\n                modmsg.data[i].name = i;\n                modmsg.data[i].type = typeof b[i];\n                modmsg.data[i].value = b[i];\n            }\n        }\n\n        socket.emit('require', modmsg);\n    }\n\n    function serverMessage(message) {\n        serverEmitter.emit('message', message);\n    }\n\n    return (io);\n}\n// most heavily borrowed from https://github.com/itchyny/browsershell\nfunction spawn(socket) {\n    var stream = '';\n    var timer;\n    var len = 0;\n    var c;\n\n    socket.on('shell', receive);\n    return (receive);\n\n    function receive(msg) {\n        if (!c) {\n            try {\n                if (debug) winston.debug('Spawning bash');\n                c = child_process.spawn('/bin/bash', ['-i'], {\n                    customFds: [-1, -1, -1]\n                });\n                c.stdout.on('data', send);\n                c.stderr.on('data', send);\n                c.on('exit', function () {\n                    socket.emit('shell', send('\\nexited\\n'));\n                    c = undefined;\n                });\n                socket.on('disconnect', function () {\n                    if (debug) winston.debug('Killing bash');\n                    c.kill('SIGHUP');\n                });\n            } catch (ex) {\n                c = undefined;\n                send('Error invoking bash');\n                winston.error('Error invoking bash');\n            }\n        }\n        if (c) {\n            if (msg) {\n                c.stdin.write(msg + '\\n', 'utf-8');\n            }\n        } else {\n            winston.error('Unable to invoke child process');\n        }\n    }\n\n    function send(data) {\n        // add data to the stream\n        stream += data.toString();\n        ++len;\n\n        // clear any existing timeout if it exists\n        if (timer) clearTimeout(timer);\n\n        // set new timeout\n        timer = setTimeout(function () {\n            socket.emit('shell', stream);\n            stream = '';\n            len = 0;\n        }, 100);\n\n        // send data if over threshold\n        if (len > 1000) {\n            clearTimeout(timer);\n            socket.emit('shell', stream);\n            stream = '';\n            len = 0;\n        }\n    }\n}\n\nmodule.exports = {\n    socketJSReqHandler: socketJSReqHandler,\n    addSocketListeners: addSocketListeners\n}"
  },
  {
    "path": "systemd/bonescript-autorun.service",
    "content": "[Unit]\nDescription=Bonescript autorun\nConditionPathExists=|/var/lib/cloud9\n\n[Service]\nWorkingDirectory=/usr/lib/node_modules/bonescript\nEnvironmentFile=/etc/default/node\nExecStart=/usr/bin/node autorun.js\nSyslogIdentifier=bonescript-autorun\n\n[Install]\nWantedBy=multi-user.target\n"
  },
  {
    "path": "systemd/bonescript.service",
    "content": "[Unit]\nDescription=Bonescript server\nConditionPathExists=|/usr/share/bone101\n\n[Service]\nWorkingDirectory=/usr/share/bone101\nEnvironmentFile=/etc/default/node\nExecStart=npm start -g bonescript\nSyslogIdentifier=bonescript\n\n[Install]\nWantedBy=multi-user.target\n"
  },
  {
    "path": "systemd/bonescript.socket",
    "content": "[Socket]\nListenStream=80\n\n[Install]\nWantedBy=sockets.target\n"
  },
  {
    "path": "test/TODO/bacon_test.js",
    "content": "/*\n * Setup\n */\nvar b = require(\"bonescript\"); // Read BoneScript library\n\n// Map used pins\nvar LED_RED = \"P9_42\";\nvar LED_BLUE = \"P9_16\";\nvar LED_GREEN = \"P9_14\";\nvar BUTTON = \"P8_19\";\nvar S_DATA  = \"P9_18\";\nvar S_CLOCK = \"P9_22\";\nvar S_LATCH = \"P9_17\";\nvar S_CLEAR = \"P9_15\";\nvar POT = 'P9_36';\n\n// Define global variables\nvar state = false;\nvar segments = [ 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90 ];\nvar port = '/dev/i2c-2';\nvar address = 0x1c;\n\n// Configure pins\nb.pinMode(LED_RED, b.OUTPUT);\nb.pinMode(LED_BLUE, b.OUTPUT);\nb.pinMode(BUTTON, b.INPUT);\nb.pinMode(S_DATA,  b.OUTPUT);\nb.pinMode(S_CLOCK, b.OUTPUT);\nb.pinMode(S_LATCH, b.OUTPUT);\nb.pinMode(S_CLEAR, b.OUTPUT);\n\n// Initial pin states\nb.digitalWrite(S_DATA,  b.LOW);\nb.digitalWrite(S_CLOCK, b.LOW);\nb.digitalWrite(S_LATCH, b.LOW);\nb.digitalWrite(S_CLEAR, b.HIGH);\n\n// Configure accelerometer\nb.i2cOpen(port, address, {}, onI2C); // Open I2C port\nb.i2cWriteBytes(port, 0x2a, [0x00]); // Set accelerometer in STANDBY mode\nb.i2cWriteBytes(port, 0x0e, [0x00]); // Set accelerometer scale to 2G\nb.i2cWriteBytes(port, 0x2a, [0x01]); // Set accelerometer in ACTIVE mode\n\n/*\n * Add handlers\n */\nblink(); // Call blink() to start it iterating\nsetInterval(readButton, 100); // Call readButton() every 100ms\nsetInterval(update7Seg, 100); // Call update7Seg() every 100ms\nsetInterval(readAccel, 200); // Call readAccel() every 200ms\n\n/*\n * Define functions\n */\nfunction blink() {\n    state = !state;\n    if(state) setTimeout(blink, 10); // Leave LED on for 10ms\n    if(!state) setTimeout(blink, 990); // Leave LED off for 990ms\n\tb.digitalWrite(LED_RED, state ? b.HIGH : b.LOW);\n}\n\nfunction readButton() {\n    // Read BUTTON status\n    var status = b.digitalRead(BUTTON, onDigitalRead);\n}\n\nfunction onDigitalRead(x) {\n    if(x.err) return;\n    var status = x.value;\n    \n    // Set LED_BLUE to HIGH if BUTTON is LOW\n    b.digitalWrite(LED_BLUE, status ? b.LOW : b.HIGH);\n}\n\nfunction update7Seg() {\n    // Read the voltage from potentiometer\n    b.analogRead(POT, onAnalogRead);\n}\n\nfunction onAnalogRead(x) {\n    if(x.err) return;\n    var value = x.value;\n\n    // Convert floating point value 0-1 to digit 0-9\n    var digit = parseInt(value*10, 10) % 10;\n    \n    // Shift out the character LED pattern\n    b.shiftOut(S_DATA, S_CLOCK, b.MSBFIRST, segments[digit]);\n    b.digitalWrite(S_LATCH, b.HIGH);\n    b.digitalWrite(S_LATCH, b.LOW);\n}\n\nfunction onI2C() {\n}\n\nfunction readAccel() {\n    b.i2cReadBytes(port, 1, 6, onReadBytes);\n}\n\nfunction onReadBytes(x) {\n    if(x.event == 'callback') {\n        var X = convertToG(x.res[0]); // First byte is X\n        var brightness = Math.abs(X);\n        if(brightness > 1) brightness = 1;\n        b.analogWrite(LED_GREEN, brightness);\n    }\n}\n\nfunction convertToG(x) {\n    if(x >= 128) x = -((x^0xFF)+1); // Get two's complement\n    x = x / 64; // Scale to G\n    x = x.toFixed(2); // Limit decimal places\n    return(x);\n}\n\n\n"
  },
  {
    "path": "test/TODO/basic_sanity.sh",
    "content": "#!/bin/sh\ncd $(dirname $0)\nnode -pe \"'Name: ' + require('../index').getPlatform().name\"\nnode -pe \"'Version: ' + require('../index').getPlatform().bonescript\"\nnode -pe \"require('../index').digitalRead('P8_19')\"\n"
  },
  {
    "path": "test/TODO/constants.js",
    "content": "// Copyright (C) 2013 - Texas Instruments, Jason Kridner\n\nexports.OUTPUT = \"out\";\nexports.INPUT = \"in\";\nexports.INPUT_PULLUP = \"in_pullup\";\nexports.HIGH = 1;\nexports.LOW = 0;\nexports.LSBFIRST = 1;  // used in: shiftOut(dataPin, clockPin, bitOrder, val)\nexports.MSBFIRST = 0;\nexports.CHANGE = \"both\";\nexports.RISING = \"rising\";\nexports.FALLING = \"falling\";\n"
  },
  {
    "path": "test/TODO/eeprom.js",
    "content": "//   test process:\n//     $ node eeprom.js\n//     $ node eeprom.js -w test-eeproms.json\n//     $ echo \"a18bf9b65d676cd0a6e07b13fa06a362  test-cape.eeprom\" | md5sum -c\n//     $ node eeprom.js -rmy-eeproms.json cape:test-cape.eeprom\n//     $ node eeprom.js -r cape:test-cape.eeprom verify-eeproms.json\n//     $ diff my-eeproms.json verify-eeproms.json\n//     $ node eeprom.js -wmy-eeproms.json test-cape.eeprom verify-cape.eeprom\n//     $ echo \"a18bf9b65d676cd0a6e07b13fa06a362  verify-cape.eeprom\" | md5sum -c\nvar printUsage = function() {\n   var usageString =\n       'Print usage:\\n' +\n       '\\n' +\n       '  node bonescript/eeprom.js -h\\n' +\n       '\\n' +\n       '\\n' +\n       'Read eeproms and write the output to a JSON-compatible file:\\n' +\n       '\\n' +\n       '  node bonescript/eeprom.js [-r [type:source.eeprom ...] destination.json] \\n' +\n       '\\n' +\n       '    type               : the word \"bone\" or \"cape\"\\n' +\n       '    source.eeprom      : source eeprom file\\n' +\n       '\\n' +\n       '\\n' +\n       'Read JSON eeproms file and write the output to eeprom(s):\\n' +\n       '\\n' +\n       '  node bonescript/eeprom.js -w source.json [[source-eeprom] destination.eeprom]\\n' +\n       '\\n' +\n       '    source.json        : source JSON file containing one or more eeprom structures\\n' +\n       '    destination.eeprom : where to write the output,\\n' +\n       '                         must either match eeprom structure name or\\n' +\n       '                         provide a source-eeprom parameter\\n' +\n       '    source-eeprom      : which eeprom structure to use as source\\n';\n   winston.error(usageString);\n};\n\n// Only run this section when run as a stand-alone application\nif(!module.parent) {\n    var eeproms = {};\n    var destinationJSON = '';\n    process.argv.shift();\n    process.argv.shift();\n    if((process.argv.length > 0) && (process.argv[0].match(/^-w/i))) {\n        // Write EEPROMs\n        var sourceJSON = process.argv.shift().substr(2);\n        var sourceEeprom = '';\n        var destinationEeprom = '';\n        if(sourceJSON === '') {\n            sourceJSON = process.argv.shift();\n        }\n        if(process.argv.length > 2) {\n            printUsage();\n            throw('Too many arguments');\n        } else if(process.argv.length > 0) {\n            sourceEeprom = destinationEeprom = process.argv.pop();\n            if(process.argv.length > 0) {\n                sourceEeprom = process.argv.pop();\n            }\n        }\n        try {\n            winston.info('Reading '+sourceJSON);\n            var jsonFile = fs.readFileSync(sourceJSON, 'ascii');\n            winston.info('Parsing '+sourceJSON);\n            if(debug) winston.info(jsonFile);\n            eeproms = JSON.parse(jsonFile);\n        } catch(ex) {\n            throw('Unable to parse '+sourceJSON+': '+ex);\n        }\n        // If source file isn't nested, make it\n        if(eeproms.type) {\n            if(destinationEeprom === '') {\n                printUsage();\n                throw('Destination must be specified if not part of the JSON file');\n            }\n            eeproms[destinationEeprom] = eeproms;\n        }\n        for(var x in eeproms) {\n            if((sourceEeprom === '') || (x == sourceEeprom)) {\n                winston.info('Writing eeprom '+x);\n                if(eeproms[x].type != 'cape') {\n                    throw('Only type \"cape\" is currently handled');\n                }\n                fillCapeEepromData(eeproms[x]);\n                if(debug) winston.debug(util.inspect(eepromData, true, null));\n                if(destinationEeprom === '') {\n                    fs.writeFileSync(x, eepromData);\n                } else {\n                    winston.info('Writing to file '+destinationEeprom);\n                    fs.writeFileSync(destinationEeprom, eepromData);\n                }\n            } else {\n                winston.info('Skipping eeprom '+x);\n            }\n        }\n    } else if(process.argv.length === 0 ||\n              ((process.argv.length > 0) && (process.argv[0].match(/^-r/i)))) {\n        // Read EEPROMs\n        var eepromsToRead = defaultEepromFiles;\n        if(process.argv.length > 0) {\n            destinationJSON = process.argv.shift().substr(2);\n            if(destinationJSON === '') {\n                destinationJSON = process.argv.pop();\n            }\n        }\n        if(process.argv.length > 0) {\n            eepromsToRead = {};\n            while(process.argv.length > 0) {\n                var eepromFile = process.argv.shift().split(':');\n                if(eepromFile.length != 2) {\n                    printUsage();\n                    throw('Source eeproms must be of the format <type>:<file>');\n                }\n                eepromsToRead[eepromFile[1]] = { type: eepromFile[2] };\n            }\n        }\n        eeproms = readEeproms(eepromsToRead);\n        if(eeproms == {}) {\n            winston.info('No valid EEPROM contents found');\n        } else {\n            var eepromsString = JSON.stringify(eeproms, null, 2);\n            if(destinationJSON === '') {\n                console.log(eepromsString);\n            } else {\n                winston.info('Writing JSON file to '+destinationJSON);\n                fs.writeFileSync(destinationJSON, eepromsString);\n            }\n        }\n    } else {\n        printUsage();\n        return(0);\n    }\n}\n"
  },
  {
    "path": "test/TODO/fix-ssh.js",
    "content": "var b = require('bonescript');\n\nb.getPlatform(onGetPlatform);\n\nfunction onGetPlatform(x) {\n    if(!x.name || !x.serialNumber || !x.version)\n        err('getPlatform returned ' + JSON.stringify(x));\n    console.log('Name = ' + x.name);\n    console.log('S/N = ' + x.serialNumber);\n    console.log('Version = ' + x.version);\n    console.log('BoneScript version = ' + x.bonescript);\n    b.setDate(Date().toString(), onSetDate);\n}\n\nfunction onSetDate(x) {\n    b.socket.on('shell', onShell);\n    b.socket.emit('shell', '\\n');\n    b.socket.emit('shell', 'rm /etc/dropbear/dropbear_rsa_host_key\\n');\n    //b.socket.emit('shell', 'systemctl --system daemon-reload\\n');\n    b.socket.emit('shell', 'systemctl stop dropbear.socket\\n');\n    b.socket.emit('shell', '/etc/init.d/dropbear stop\\n');\n    b.socket.emit('shell', '/etc/init.d/dropbear start\\n');\n    //b.socket.emit('shell', 'systemctl status dropbear.socket\\n');\n    b.socket.emit('shell', 'journalctl -f\\n');\n    setTimeout(complete, 10000);\n    //complete();\n}\n\nfunction onShell(x) {\n    console.log('shell: ' + x);\n    //if(x.indexOf('Listening on dropbear.socket') >= 0)\n        //complete();\n}\n\nfunction complete() {\n    console.log('***PASS***');\n    process.exit(0);\n}\n\nfunction err(x) {\n    console.log('***FAIL*** ' + x);\n    throw(x);\n}\n\nfunction printJSON(x) {\n    console.log('x = ' + JSON.stringify(x));\n}\n"
  },
  {
    "path": "test/TODO/fix-ssh.sh",
    "content": "#!/bin/sh\nset -x\nset -e\nnode remote_bonetest.js fix-ssh.js\n"
  },
  {
    "path": "test/TODO/gitconfig",
    "content": "[receive]\n\tdenyCurrentBranch = warn\n"
  },
  {
    "path": "test/TODO/remote_bonetest.js",
    "content": "var io = require('../node_modules/socket.io/node_modules/socket.io-client');\nvar fs = require('fs');\n\nvar clientName = process.env.TARGET_NAME || 'http://192.168.7.2:80';\n\nif(process.argv.length != 3) {\n    console.log('Usage: node ' + process.argv[1] + ' <app.js>');\n    process.exit(-1);\n}\n\nvar _bonescript = {};\n_bonescript.modules = {};\n_bonescript._callbacks = {};\n_bonescript._seqnum = 0;\n_bonescript.on = {};\n_bonescript.on.connect = function(){ console.log('socket.io: connect'); };\n_bonescript.on.connecting = function(){ console.log('socket.io: connecting'); };\n_bonescript.on.disconnect = function(){ console.log('socket.io: disconnect'); };\n_bonescript.on.connect_failed = function(){ console.log('socket.io: connect_failed'); };\n_bonescript.on.error = function(){ console.log('socket.io: error'); };\n_bonescript.on.reconnect = function(){ console.log('socket.io: reconnect'); };\n_bonescript.on.reconnect_failed = function(){ console.log('socket.io: reconnect_failed'); };\n_bonescript.on.reconnecting = function(){ console.log('socket.io: reconnecting'); };\n_bonescript.on.initialized = function(){ console.log('socket.io: initialized'); };\n\nfunction _onSocketIOLoaded() {\n    console.log(\"socket.io loaded\");\n    var socket = io.connect(clientName);\n    socket.on('require', getRequireData);\n    socket.on('bonescript', _seqcall);\n    socket.on('connect', _bonescript.on.connect);\n    socket.on('connecting', _bonescript.on.connecting);\n    socket.on('disconnect', _bonescript.on.disconnect);\n    socket.on('connect_failed', _bonescript.on.connect_failed);\n    socket.on('error', _bonescript.on.error);\n    socket.on('reconnect', _bonescript.on.reconnect);\n    socket.on('reconnect_failed', _bonescript.on.reconnect_failed);\n    socket.on('reconnecting', _bonescript.on.reconnecting);\n    socket.on('initialized', _bonescript.on.initialized);\n\n    function getRequireData(m) {\n        if(!m.module || !m.data)\n            throw('Invalid \"require\" message sent for \"' + m.module + '\"');\n        console.log('Initialized module: ' + m.module);\n        _bonescript.modules[m.module] = {};\n        for(var x in m.data) {\n            if(!m.data[x].type || !m.data[x].name || (typeof m.data[x].value == 'undefined'))\n                throw('Invalid data in \"require\" message sent for \"' + m.module + '.' + m.data[x] + '\"');\n            if(m.data[x].type == 'function') {\n                // define the function\n                if(!m.data[x].value)\n                    throw('Missing args in \"require\" message sent for \"' + m.module + '.' + m.data[x] + '\"');\n                var myargs = m.data[x].value;\n\n                // eval of objString builds the call data out of arguments passed in\n                var objString = '';\n                for(var y in myargs) {\n                    if(isNaN(y)) continue;  // Need to find the source of this bug\n                    if(myargs[y] == 'callback') continue;\n                    objString += ' if(typeof ' + myargs[y] + ' == \"function\") {\\n';\n                    objString += '  ' + myargs[y] + ' = ' + myargs[y] + '.toString();\\n';\n                    objString += ' }\\n';\n                    objString += ' calldata.' + myargs[y] + ' = ' + myargs[y] + ';\\n';\n                }\n                var argsString = myargs.join(', ');\n                var handyfunc = '_bonescript.modules[\"' + m.module + '\"].' + m.data[x].name +\n                    ' = ' +\n                    'function (' + argsString + ') {\\n' +\n                    ' var calldata = {};\\n' +\n                    objString +\n                    ' if(callback) {\\n' +\n                    '  _bonescript._callbacks[_bonescript._seqnum] = callback;\\n' +\n                    '  calldata.seq = _bonescript._seqnum;\\n' +\n                    '  _bonescript._seqnum++;\\n' +\n                    ' }\\n' +\n                    ' socket.emit(\"' + m.module + '$' + m.data[x].name + '\", calldata);\\n' +\n                    '};\\n';\n                eval(handyfunc);\n            } else {\n                _bonescript.modules[m.module][m.data[x].name] = m.data[x].value;\n            }\n        }\n        _bonescript.modules[m.module].socket = socket;\n        _bonescript.on.initialized();\n    }\n}\n\nfunction _seqcall(data) {\n    if((typeof data.seq != 'number') || (typeof _bonescript._callbacks[data.seq] != 'function'))\n        throw \"Invalid callback message received: \" + JSON.stringify(data);\n    _bonescript._callbacks[data.seq](data);\n    if(data.oneshot) delete _bonescript._callbacks[data.seq];\n}\n\n// Require must be synchronous to be able to return data structures and\n// functions and therefore cannot call socket.io. All exported modules must\n// be exported ahead of time.\nvar require = function(module) {\n    if(typeof _bonescript.modules[module] == 'undefined')\n        throw 'Module \"' + module + '\" is not currently available';\n    return(_bonescript.modules[module]);\n};\n\nvar test = function() {\n    try {\n        console.log('Loading ' + process.argv[2]);\n        var script = fs.readFileSync(process.argv[2], 'ascii');\n        //console.log('Executing: ' + script);\n        eval(script);\n    } catch(ex) {\n        console.log('***FAIL*** ' + ex);\n        process.exit(-2);\n    }\n};\n\n_bonescript.on.initialized = test;\n_onSocketIOLoaded();\n"
  },
  {
    "path": "test/TODO/setdate.js",
    "content": "var b = require('bonescript');\n\nb.getPlatform(onGetPlatform);\n\nfunction onGetPlatform(x) {\n    if(!x.name || !x.serialNumber || !x.version)\n        err('getPlatform returned ' + JSON.stringify(x));\n    console.log('Name = ' + x.name);\n    console.log('S/N = ' + x.serialNumber);\n    console.log('Version = ' + x.version);\n    console.log('BoneScript version = ' + x.bonescript);\n    b.setDate(Date().toString(), onSetDate);\n}\n\nfunction onSetDate(x) {\n    complete();\n}\n\nfunction complete() {\n    console.log('***PASS***');\n    process.exit(0);\n}\n\nfunction err(x) {\n    console.log('***FAIL*** ' + x);\n    throw(x);\n}\n\nfunction printJSON(x) {\n    console.log('x = ' + JSON.stringify(x));\n}\n"
  },
  {
    "path": "test/TODO/test-analogwrite.js",
    "content": "var b = require('bonescript');\nb.analogWrite('P9_16', 0.01);\n"
  },
  {
    "path": "test/TODO/test-digitalread.js",
    "content": "var b = require('bonescript');\n\nb.pinMode('P8_19', b.INPUT, undefined, undefined, undefined, doRead);\n\nfunction doRead() {\n    b.digitalRead('P8_19', function(x) {\n        console.log(JSON.stringify(x));\n    });\n}\n"
  },
  {
    "path": "test/TODO/test-digitalwrite.js",
    "content": "var b = require('bonescript');\n\nb.pinMode('P9_16', b.ANALOG_OUTPUT);\n\nglobal.setup = function() {\n    b.analogWrite('P9_14', 0.2);\n    b.pinMode('P9_14', b.OUTPUT);\n    b.digitalWrite('P9_14', false);\n    b.digitalWrite('P9_14', true);\n    \n    console.log(JSON.stringify(b.getPinMode('P9_16')));\n    b.pinMode('P9_16', b.OUTPUT);\n    console.log(JSON.stringify(b.getPinMode('P9_16')));\n    b.digitalWrite('P9_16', false);\n    console.log(JSON.stringify(b.getPinMode('P9_16')));\n    b.digitalWrite('P9_16', true);\n    console.log(JSON.stringify(b.getPinMode('P9_16')));\n};\n"
  },
  {
    "path": "test/TODO/test-eeproms.json",
    "content": "{\n  \"test-lcd7-cape.eeprom\": {\n    \"type\": \"cape\",\n    \"header\": \"aa5533ee\",\n    \"formatRev\": \"A0\",\n    \"boardName\": \"BeagleBone LCD Cape\",\n    \"version\": \"01\",\n    \"manufacturer\": \"BeagleBoardToys\",\n    \"partNumber\": \"BB-BONE-LCD7-01\",\n    \"numPins\": 30,\n    \"serialNumber\": \"52114P130000\",\n    \"currentVDD_3V3EXP\": 2,\n    \"currentVDD_5V\": 2,\n    \"currentSYS_5V\": 2,\n    \"DCSupplied\": 2000,\n    \"mux\": {\n      \"P8_20\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_31\"\n      },\n      \"P8_27\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_vsync\"\n      },\n      \"P8_28\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_pclk\"\n      },\n      \"P8_29\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_hsync\"\n      },\n      \"P8_30\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_ac_bias_en\"\n      },\n      \"P8_31\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data14\"\n      },\n      \"P8_32\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data15\"\n      },\n      \"P8_33\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data13\"\n      },\n      \"P8_34\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data11\"\n      },\n      \"P8_35\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data12\"\n      },\n      \"P8_36\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data10\"\n      },\n      \"P8_37\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data8\"\n      },\n      \"P8_38\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data9\"\n      },\n      \"P8_39\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data6\"\n      },\n      \"P8_40\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data7\"\n      },\n      \"P8_41\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data4\"\n      },\n      \"P8_42\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data5\"\n      },\n      \"P8_43\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data2\"\n      },\n      \"P8_44\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data3\"\n      },\n      \"P8_45\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data0\"\n      },\n      \"P8_46\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data1\"\n      },\n      \"P9_14\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 6,\n        \"function\": \"ehrpwm1a\"\n      },\n      \"P9_15\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_16\"\n      },\n      \"P9_16\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_19\"\n      },\n      \"P9_23\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_17\"\n      },\n      \"P9_37\": {\n        \"used\": \"used\",\n        \"function\": \"ain2\"\n      },\n      \"P9_38\": {\n        \"used\": \"used\",\n        \"function\": \"ain3\"\n      },\n      \"P9_39\": {\n        \"used\": \"used\",\n        \"function\": \"ain0\"\n      },\n      \"P9_40\": {\n        \"used\": \"used\",\n        \"function\": \"ain1\"\n      },\n      \"P9_42\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio0_7\"\n      }\n    }\n  }\n  , \"test-lcd35-cape.eeprom\": {\n    \"type\": \"cape\",\n    \"header\": \"aa5533ee\",\n    \"formatRev\": \"A0\",\n    \"boardName\": \"BeagleBone LCD Cape\",\n    \"version\": \"01\",\n    \"manufacturer\": \"BeagleBoardToys\",\n    \"partNumber\": \"BB-BONE-LCD3-01\",\n    \"numPins\": 30,\n    \"serialNumber\": \"08124P130000\",\n    \"currentVDD_3V3EXP\": 2,\n    \"currentVDD_5V\": 2,\n    \"currentSYS_5V\": 2,\n    \"DCSupplied\": 0,\n    \"mux\": {\n      \"P8_20\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_31\"\n      },\n      \"P8_27\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_vsync\"\n      },\n      \"P8_28\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_pclk\"\n      },\n      \"P8_29\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_hsync\"\n      },\n      \"P8_30\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_ac_bias_en\"\n      },\n      \"P8_31\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data14\"\n      },\n      \"P8_32\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data15\"\n      },\n      \"P8_33\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data13\"\n      },\n      \"P8_34\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data11\"\n      },\n      \"P8_35\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data12\"\n      },\n      \"P8_36\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data10\"\n      },\n      \"P8_37\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data8\"\n      },\n      \"P8_38\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data9\"\n      },\n      \"P8_39\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data6\"\n      },\n      \"P8_40\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data7\"\n      },\n      \"P8_41\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data4\"\n      },\n      \"P8_42\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data5\"\n      },\n      \"P8_43\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data2\"\n      },\n      \"P8_44\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data3\"\n      },\n      \"P8_45\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data0\"\n      },\n      \"P8_46\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data1\"\n      },\n      \"P9_14\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 6,\n        \"function\": \"ehrpwm1a\"\n      },\n      \"P9_15\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_16\"\n      },\n      \"P9_16\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_19\"\n      },\n      \"P9_23\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio1_17\"\n      },\n      \"P9_37\": {\n        \"used\": \"used\",\n        \"function\": \"ain2\"\n      },\n      \"P9_38\": {\n        \"used\": \"used\",\n        \"function\": \"ain3\"\n      },\n      \"P9_39\": {\n        \"used\": \"used\",\n        \"function\": \"ain0\"\n      },\n      \"P9_40\": {\n        \"used\": \"used\",\n        \"function\": \"ain1\"\n      },\n      \"P9_42\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio0_7\"\n      }\n    }\n  }\n  , \"test-dvi-cape.eeprom\": {\n    \"type\": \"cape\",\n    \"header\": \"aa5533ee\",\n    \"formatRev\": \"A0\",\n    \"boardName\": \"BeagleBone DVI-D CAPE\",\n    \"version\": \"01\",\n    \"manufacturer\": \"Beagleboardtoys\",\n    \"partNumber\": \"BB-BONE-DVID-01\",\n    \"numPins\": 25,\n    \"serialNumber\": \"WWYYDVIDnnnn\",\n    \"currentVDD_3V3EXP\": 2,\n    \"currentVDD_5V\": 2,\n    \"currentSYS_5V\": 2,\n    \"DCSupplied\": 0,\n    \"mux\": {\n      \"P8_27\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_vsync\"\n      },\n      \"P8_28\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_pclk\"\n      },\n      \"P8_29\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_hsync\"\n      },\n      \"P8_30\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_ac_bias_en\"\n      },\n      \"P8_31\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data14\"\n      },\n      \"P8_32\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data15\"\n      },\n      \"P8_33\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data13\"\n      },\n      \"P8_34\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data11\"\n      },\n      \"P8_35\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data12\"\n      },\n      \"P8_36\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data10\"\n      },\n      \"P8_37\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data8\"\n      },\n      \"P8_38\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data9\"\n      },\n      \"P8_39\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data6\"\n      },\n      \"P8_40\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data7\"\n      },\n      \"P8_41\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data4\"\n      },\n      \"P8_42\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data5\"\n      },\n      \"P8_43\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data2\"\n      },\n      \"P8_44\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data3\"\n      },\n      \"P8_45\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data0\"\n      },\n      \"P8_46\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"disabled\",\n        \"mode\": 0,\n        \"function\": \"lcd_data1\"\n      }\n    }\n  },\n \"TowerTech-TT3201-CAN-Cape.eeprom\": {\n    \"type\": \"cape\",\n    \"header\": \"aa5533ee\",\n    \"formatRev\": \"A0\",\n    \"boardName\": \"TT3201 CAN Cape\",\n    \"version\": \"01\",\n    \"manufacturer\": \"TowerTech\",\n    \"partNumber\": \"TT3201-001\",\n    \"numPins\": 30,\n    \"serialNumber\": \"12050100002\",\n    \"currentVDD_3V3EXP\": 1,\n    \"currentVDD_5V\": 0,\n    \"currentSYS_5V\": 0,\n    \"DCSupplied\": 0,\n    \"mux\": {\n      \"P9_26\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"pullup\": \"pulldown\",\n        \"mode\": 2,\n        \"function\": \"d_can1_tx\"\n      },\n      \"P9_24\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 2,\n        \"function\": \"d_can1_rx\"\n      },\n      \"P9_27\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio3_19\"\n      },\n      \"P9_25\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 7,\n        \"function\": \"gpio3_21\"\n      },\n      \"P9_42\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 2,\n        \"function\": \"spi1_cs1\"\n      },\n      \"P9_28\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 3,\n        \"function\": \"spi1_cs0\"\n      },\n      \"P9_31\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 3,\n        \"function\": \"spi1_sclk\"\n      },\n      \"P9_29\": {\n        \"used\": \"used\",\n        \"direction\": \"out\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 3,\n        \"function\": \"spi1_d0\"\n      },\n      \"P9_30\": {\n        \"used\": \"used\",\n        \"direction\": \"in\",\n        \"rx\": \"enabled\",\n        \"pullup\": \"pullup\",\n        \"mode\": 3,\n        \"function\": \"spi1_d1\"\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "test/TODO/test-getpinmode.js",
    "content": "var b = require('bonescript');\nvar fs = require('fs');\nvar my = require('../src/my.js');\n\nglobal.setup = function() {\n    var capemgr = my.is_capemgr();\n    var slots = fs.readFileSync(capemgr + '/slots', 'ascii');\n    console.log(slots);\n    var slot = slots.match(/^\\s*\\d+\\s*:.*,bs.*P9_14/gm);\n    console.log(slot);\n    slot = slots.match(/\\d+(?=\\s*:.*,bs.*P9_14)/gm);\n    console.log(slot);\n    if(slot && slot[0]) {\n        fs.writeFileSync(capemgr + '/slots', '-'+slot[0], 'ascii');\n    }\n    slots = fs.readFileSync(capemgr + '/slots', 'ascii');\n    console.log(slots);\n\n    deleteFile('/lib/firmware/bspwm_P9_14_e-00A0.dtbo');\n    deleteFile('/lib/firmware/bspwm_P9_14_6-00A0.dtbo');\n    \n    function deleteFile(filename) {\n        if(my.file_existsSync(filename)) {\n            fs.unlinkSync(filename);\n        }\n    }\n    \n    b.analogWrite('P9_14', 0.9);\n    \n    console.log(JSON.stringify(b.getPinMode('USR3')));\n    console.log(JSON.stringify(b.getPinMode('P9_12')));\n    console.log(JSON.stringify(b.getPinMode('P9_13')));\n    console.log(JSON.stringify(b.getPinMode('P9_14')));\n    console.log(JSON.stringify(b.getPinMode('P9_35')));\n    \n    console.log(JSON.stringify(b.getPinMode('P9_15')));\n    b.writeTextFile('/sys/class/gpio/unexport', ''+b.bone.pins.P9_15.gpio);\n    console.log(JSON.stringify(b.getPinMode('P9_15')));\n    b.pinMode('P9_15', b.OUTPUT);\n    console.log(JSON.stringify(b.getPinMode('P9_15')));\n\n    console.log('got here: ' + b.analogWrite('P9_14', 0.1));\n};\n"
  },
  {
    "path": "test/TODO/test-globalsetuploop.js",
    "content": "var b = require('bonescript');\nvar x = 0;\n\nglobal.setup = function() {\n    b.pinMode('P9_14', b.ANALOG_OUTPUT);\n};\n\nglobal.loop = function() {\n    //console.log(x);\n    b.analogWrite('P9_14', x);\n    x += 0.001;\n    if(x >= 1.0) x = 0;\n};\n\n"
  },
  {
    "path": "test/TODO/test-i2c-accel.js",
    "content": "var b = require('bonescript');\nvar port = '/dev/i2c-2'\nvar address = 0x1c;\nvar data = [0xAA, 0x55, 0x33, 0xEE, 65, 51, 51, 53, 66, 78, 76, 84];\nvar GSCALE = 2;\n\nb.i2cOpen(port, address, {}, onI2C);\nb.i2cScan(port, onScan);\nb.i2cWriteBytes(port, 0x2a, [1], onWriteBytes);\n\nfunction onI2C(x) {\n    if(x.event == 'data') {\n        console.log('data = ' + JSON.stringify(x.data));\n    }\n}\n\nfunction onScan(x) {\n    console.log('scan = ' + JSON.stringify(arguments));\n}\n\nfunction onWriteBytes(x) {\n    console.log('writeBytes = ' + JSON.stringify(arguments));\n    //if(x.event == 'callback') b.i2cWriteByte(port, 0, onWriteByte);\n    if(x.event == 'callback') b.i2cReadBytes(port, 1, 6, onReadBytes);\n}\n\nfunction onWriteByte(x) {\n    console.log('writeByte = ' + JSON.stringify(arguments));\n    if(x.event == 'callback') b.i2cReadBytes(port, null, 13, onReadBytes);\n}\n\nfunction onReadBytes(x) {\n    console.log('readBytes = ' + JSON.stringify(arguments));\n    //if(x.event == 'callback') process.exit(0);\n}\n"
  },
  {
    "path": "test/TODO/test-i2c.js",
    "content": "var b = require('bonescript');\nvar port = '/dev/i2c-0';\nvar address = 0x50;\n//var data = [0xAA, 0x55, 0x33, 0xEE, 65, 51, 51, 53, 66, 78, 76, 84];\n// Where is the first byte going?!?\n\nb.i2cOpen(port, address, {}, onI2C);\nb.i2cScan(port, onScan);\nb.i2cWriteByte(port, 0, onWriteByte);\nb.i2cReadBytes(port, null, 12, onReadBytes);\n\nfunction onI2C(x) {\n    if(x.event == 'data') {\n        console.log('data = ' + JSON.stringify(x.data));\n    }\n}\n\nfunction onScan(err, data) {\n    console.log('scan = ' + JSON.stringify(arguments));\n}\n\nfunction onWriteByte(err) {\n    console.log('writeByte = ' + JSON.stringify(err));\n}\n\nfunction onReadBytes(err, res) {\n    console.log('readBytes = ' + JSON.stringify(arguments));\n    if(err.event == 'callback') process.exit(0);\n}\n"
  },
  {
    "path": "test/TODO/test-pocketbeagle.js",
    "content": "var b = require('bonescript');\n\nvar gpios = [\n  'p1.2',\n  'p1.04',\n  'P1.6',\n  'P1_20',\n  'P1_29',\n  'P1_30',\n  'P1_31',\n  'P1_33',\n  'P1_35',\n  'P1.36',\n  'P1.37',\n  'P1_38',\n  'p2.1',\n  59,\n  23,\n  'p2_06',\n  60,\n  52,\n  65,\n  47,\n  27,\n  46,\n  'P2_26',\n  'P2_28',\n  'p2_30',\n  'p2.32',\n  'p2_33',\n  'p2_34',\n  'P2_35',\n  'P2_36',\n];\n\nfor(i in gpios) {\n  b.setMode(gpios[i], b.OUTPUT);\n}\n"
  },
  {
    "path": "test/TODO/test-serial.js",
    "content": "var b = require('bonescript');\nvar rxport = '/dev/ttyO1';\nvar txport = '/dev/ttyO4';\nvar options = { baudrate: 115200, parser: b.serialParsers.readline('\\n') };\nvar teststring = \"This is the string I'm sending out as a test\";\n\nb.serialOpen(rxport, options, onRxSerial);\n\nfunction onRxSerial(x) {\n    console.log('rx.event = ' + x.event);\n    if(x.err) throw('***FAIL*** ' + JSON.stringify(x));\n    if(x.event == 'open') {\n        b.serialOpen(txport, options, onTxSerial);\n    }\n    if(x.event == 'data') {\n        console.log('rx (' + x.data.length +\n                    ') = ' + x.data.toString('ascii'));\n    }\n}\n\nfunction onTxSerial(x) {\n    console.log('tx.event = ' + x.event);\n    if(x.err) throw('***FAIL*** ' + JSON.stringify(x));\n    if(x.event == 'open') {\n        writeRepeatedly();\n    }\n    if(x.event == 'data') {\n        console.log('tx (' + x.data.length +\n                    ') = ' + x.data.toString('ascii'));\n    }\n}\n\nfunction printJSON(x) {\n    console.log(JSON.stringify(x));\n}\n\nfunction writeRepeatedly() {\n    b.serialWrite(txport, teststring, onSerialWrite);\n}\n\nfunction onSerialWrite(x) {\n    if(x.err) console.log('onSerialWrite err = ' + x.err);\n    if(x.event == 'callback') setTimeout(writeRepeatedly, 1000);\n}\n\n"
  },
  {
    "path": "test/TODO/test-templates.js",
    "content": "var my = require('../node_modules/bonescript/my');\nvar bone = require('../node_modules/bonescript/bone');\n\nvar pin = \n    {\n        \"name\": \"PIN_NAME\",\n        \"gpio\": 0,\n        \"mux\": \"mux_name\",\n        \"eeprom\": 1,\n        \"pwm\": {\n            \"module\": \"pwm_module\",\n            \"index\": 0,\n            \"muxmode\": 4,\n            \"path\": \"pwmpath.0:0\",\n            \"name\": \"PWMNAME\"\n        },\n        \"key\": \"P_NONE\",\n        \"muxRegOffset\": \"0x0\",\n        \"options\": [\n                \"option0\",\n                \"option1\",\n                \"option2\",\n                \"option3\",\n                \"option4\",\n                \"option5\",\n                \"option6\",\n                \"option7\"\n            ]\n    };\nvar pinData = 0xFF;\n\nmy.create_dt(pin, pinData, 'bspm', false, true);\nmy.create_dt(pin, pinData, 'bspwm', false, true);\n"
  },
  {
    "path": "test/TODO/test-unloadslot.js",
    "content": "var fs = require('fs');\nvar my = require('../src/my.js');\nvar capemgr = my.is_capemgr();\nvar slots = fs.readFileSync(capemgr + '/slots', 'ascii');\nconsole.log(slots);\nvar slot = slots.match(/^\\s*\\d+\\s*:.*,bs.*P8_13/gm);\nconsole.log(slot);\nslot = slots.match(/\\d+(?=\\s*:.*,bs.*P8_13)/gm);\nconsole.log(slot);\n"
  },
  {
    "path": "test/TODO/test.sh",
    "content": "#!/bin/sh\nnode remote_bonetest.js wired_basic_test.js\n"
  },
  {
    "path": "test/TODO/update-bonescript.sh",
    "content": "#!/bin/sh\nset -x\nset -e\n\n# Get directory\ncd $(dirname $0)\ncd ..\nBS_DIR=$(pwd)\n\nssh-copy-id root@192.168.7.2\n\ncd $BS_DIR/test\nnode remote_bonetest.js setdate.js\n\nssh root@192.168.7.2 <<EOFA\nsystemctl stop bonescript\nmkdir -p ~/bonescript\ncd ~/bonescript\ngit init\nEOFA\n\nscp $BS_DIR/test/gitconfig root@192.168.7.2:.gitconfig\n\ncd $BS_DIR\ngit push 192 master\n\nssh root@192.168.7.2 <<EOFB\ncd ~/bonescript\ngit reset --hard\ngit checkout --\ncd /usr/lib/node_modules\nrm -r bonescript\nln -s ~/bonescript/node_modules/bonescript\nsystemctl stop bonescript\nsync\nEOFB\n\ncd $BS_DIR/test\nnode remote_bonetest.js setdate.js\n\n"
  },
  {
    "path": "test/TODO/watch-button.js",
    "content": "var Epoll = require('../node_modules/bonescript/node_modules/epoll').Epoll,\n  fs = require('fs'),\n  valuefd = fs.openSync('/sys/class/gpio/gpio22/value', 'r'),\n  buffer = new Buffer(1);\n\n// Create a new Epoll. The callback is the interrupt handler.\nvar poller = new Epoll(function (err, fd, events) {\n  // Read GPIO value file. Reading also clears the interrupt.\n  fs.readSync(fd, buffer, 0, 1, 0);\n  console.log(buffer.toString() === '1' ? 'pressed' : 'released');\n});\n\n// Read the GPIO value file before watching to\n// prevent an initial unauthentic interrupt.\nfs.readSync(valuefd, buffer, 0, 1, 0);\n\n// Start watching for interrupts.\npoller.add(valuefd, Epoll.EPOLLPRI);\n\n// Stop watching after 30 seconds.\nsetTimeout(function () {\n  poller.remove(valuefd).close();\n}, 30000);\n\n"
  },
  {
    "path": "test/TODO/watch-button.sh",
    "content": "#!/bin/sh\necho 22 > /sys/class/gpio/export\necho in > /sys/class/gpio/gpio22/direction\necho both > /sys/class/gpio/gpio22/edge\nnode watch-button\n"
  },
  {
    "path": "test/TODO/wired_basic_test.js",
    "content": "var b = require('bonescript');\nvar serial = {\n    in: {\n        port: '/dev/ttyO1',\n        options: { baudrate: 115200 }\n    },\n    out: {\n        port: '/dev/ttyO4',\n        options: { baudrate: 115200 },\n    }\n};\n\nvar pinDW = 'P9_12';\nvar pinDR = 'P9_14';\nvar pinGM = 'P9_20';\nvar pinAW = 'P9_21';\nvar pinAR = 'P9_35';\n//var pinST = 'P9_13';\n//var pinSR = 'P9_26';\n\nvar supported = {\n    '0.2.2': true,\n    '0.2.3': true,\n    '0.2.4': true\n};\nvar version;\n\nvar timeout = setTimeout(onTimeout, 10000);\n\nconsole.log('Testing getPlatform');\nb.getPlatform(onGetPlatform);\n\nfunction onGetPlatform(x) {\n    if(!x.name || !x.serialNumber || !x.version)\n        err('getPlatform returned ' + JSON.stringify(x));\n    console.log('Name = ' + x.name);\n    console.log('S/N = ' + x.serialNumber);\n    console.log('Version = ' + x.version);\n    console.log('BoneScript version = ' + x.bonescript);\n    if(typeof supported[x.bonescript] === undefined || !supported[x.bonescript])\n        err('BoneScript needs to be 0.2.2 or newer');\n    version = x.bonescript;\n    console.log('Testing setDate');\n    b.setDate(Date().toString(), onSetDate);\n}\n\nfunction onSetDate(x) {\n    // Different distros have different success results running 'date'\n    if(false && x.stdout !== null) {\n        err('setDate returned ' + JSON.stringify(x));\n    }\n    console.log('Testing echo');\n    b.echo('test', onEcho);\n}\n\nfunction onEcho(x) {\n    if(x.data != 'test') err('doEcho returned ' + JSON.stringify(x));\n    console.log('Testing getPinMode');\n    b.getPinMode(pinGM, onGetPinMode);\n}\n\nfunction onGetPinMode(x) {\n    if(x.mux != 3) err('getPinMode returned ' + JSON.stringify(x));\n    console.log('Testing pinMode(input,GPIO)');\n    b.pinMode(pinDR, b.INPUT, 7, 'disabled', 'fast', onPinModeInput);\n}\n\nfunction onPinModeInput(x) {\n    if(x.value !== true) err('pinMode(input) returned ' + JSON.stringify(x));\n    console.log('Testing pinMode(output,GPIO)');\n    b.pinMode(pinDW, b.OUTPUT, 7, 'disabled', 'fast', onPinModeOutput);\n}\n\nfunction onPinModeOutput(x) {\n    if(x.value !== true) err('pinMode(output) returned ' + JSON.stringify(x));\n    console.log('Testing digitalWrite(low)');\n    b.digitalWrite(pinDW, b.LOW, onDigitalWriteLow);\n}\n\nfunction onDigitalWriteLow(x) {\n    if(x.data !== null) err('digitalWrite(low) returned ' + JSON.stringify(x));\n    console.log('Testing digitalRead(low)');\n    b.digitalRead(pinDR, onDigitalReadLow);\n}\n\nfunction onDigitalReadLow(x) {\n    if(x.value != b.LOW) err('digitalRead(low) returned ' + JSON.stringify(x));\n    console.log('Testing digitalWrite(high)');\n    b.digitalWrite(pinDW, b.HIGH, onDigitalWriteHigh);\n}\n\nfunction onDigitalWriteHigh(x) {\n    if(x.data !== null) err('digitalWrite(high) returned ' + JSON.stringify(x));\n    console.log('Testing digitalRead(high)');\n    b.digitalRead(pinDR, onDigitalReadHigh);\n}\n\nfunction onDigitalReadHigh(x) {\n    if(x.value != b.HIGH) err('digitalRead(high) returned ' + JSON.stringify(x));\n    console.log('Testing analogWrite');\n    b.analogWrite(pinAW, 0.27, 2000.0, onAnalogWrite);\n}\n\nfunction onAnalogWrite(x) {\n    if(x.value !== true) err('analogWrite returned ' + JSON.stringify(x));\n    console.log('Testing analogRead');\n    setTimeout(doAnalogRead, 1000);\n}\n\nfunction doAnalogRead() {\n    b.analogRead(pinAR, onAnalogRead);\n}\n\nfunction onAnalogRead(x) {\n    if(x.value > 0.55 || x.value < 0.45)\n        err('analogRead returned ' + JSON.stringify(x));\n    console.log('Testing writeTextFile');\n    b.writeTextFile('/tmp/basic_test', 'So far so good', onWriteTextFile);\n}\n\nfunction onWriteTextFile(x) {\n    if(x.err !== null) err('writeTextFile returned ' + JSON.stringify(x));\n    console.log('Testing readTextFile');\n    b.readTextFile('/tmp/basic_test', onReadTextFile);\n}\n\nfunction onReadTextFile(x) {\n    if(x.err !== null) err('readTextFile returned ' + JSON.stringify(x));\n    if(x.data != 'So far so good')\n        err('readTextFile returned ' + JSON.stringify(x));\n    if(version != '0.2.2') doSerial();\n    else complete();\n}\n\nfunction doSerial() {\n    console.log('Testing serialOpen(in)');\n    b.serialOpen(serial.in.port, serial.in.options, onSerialInOpen);\n}\n\nfunction onSerialInOpen(x) {\n    if(x.err) err('serialOpen(in) returned' + JSON.stringify(x));\n    if(x.event == 'open') {\n        console.log('Testing serialOpen(out)');\n        b.serialOpen(serial.out.port, serial.out.options, onSerialOutOpen);\n    }\n    if(x.event == 'data') {\n        onSerialInData(x);\n    }\n}\n\nfunction onSerialOutOpen(x) {\n    if(x.err) err('serialOpen(out) returned' + JSON.stringify(x));\n    if(x.event == 'open') {\n        doSerialWrite();\n    }\n    if(x.event == 'data') {\n        err('Unexpected data on serial output port: ' + JSON.stringify(x));\n    }\n}\n\nfunction doSerialWrite() {\n    console.log('Testing serialWrite');\n    serial.size = 2000;\n    serial.data = new Buffer(serial.size);\n    for(var i = 0; i < serial.size; i++) {\n        serial.data.writeUInt8(i%255, i);\n    }\n    serial.offset = 0;\n    b.serialWrite(serial.out.port, serial.data, onSerialWrite);\n}\n\nfunction onSerialWrite(x) {\n    if(x.err) err('serialWrite returned' + JSON.stringify(x));\n}\n\nfunction onSerialInData(x) {\n    if(x.data.length < 1) \n        err('invalid serial data ' + JSON.stringify(x));\n    console.log('Recieved ' + x.data.length + ' bytes');\n    for(var i = 0; i < x.data.length; i++) {\n        if(x.data.readUInt8(i) != serial.data[serial.offset])\n            err('invalid serial data ' + JSON.stringify(x));\n        serial.offset++;\n    }\n    if(serial.offset >= serial.size) complete();\n}\n\nfunction complete() {\n    clearTimeout(timeout);\n    console.log('***PASS***');\n    process.exit(0);\n}\n\nfunction err(x) {\n    clearTimeout(timeout);\n    console.log('***FAIL*** ' + x);\n    throw(x);\n}\n\nfunction onTimeout() {\n    err('Timeout');\n}\n\nfunction printJSON(x) {\n    console.log('x = ' + JSON.stringify(x));\n}\n"
  },
  {
    "path": "test/test-analogread.js",
    "content": "var b = require('bonescript');\n\nvar pinKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pinKeys.push(\"P1_\" + i);\n    pinKeys.push(\"P2_\" + i);\n}\nfor (var i = 1; i <= 46; i++) {\n    pinKeys.push(\"P8_\" + i);\n    pinKeys.push(\"P9_\" + i);\n}\nexports.testanalogread1 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        var y = b.analogRead(pinKeys[x]);\n        test.ok(typeof y == 'number');\n    }\n    test.done();\n}\nexports.testanalogread2 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.analogRead(pinKeys[x], function (x) {\n            test.ok(typeof x.value == 'number' && !x.err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}\nexports.testanalogread3 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.analogRead(pinKeys[x], function (err, value) {\n            test.ok(typeof value == 'number' && !err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}"
  },
  {
    "path": "test/test-analogwrite.js",
    "content": "var b = require('bonescript');\n\nvar pinKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pinKeys.push(\"P1_\" + i);\n    pinKeys.push(\"P2_\" + i);\n}\nfor (var i = 1; i <= 46; i++) {\n    pinKeys.push(\"P8_\" + i);\n    pinKeys.push(\"P9_\" + i);\n}\nexports.testanalogwrite1 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        test.doesNotThrow(function () {\n            b.analogWrite(pinKeys[x], Math.random());\n        });\n    }\n    test.done();\n}\nexports.testanalogwrite2 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.analogWrite(pinKeys[x], Math.random(), 2000, function (x) {\n            test.ok(true);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}"
  },
  {
    "path": "test/test-autorun.js",
    "content": "var autorun = require('bonescript').autorun;\nvar fs = require('fs');\nvar testDir = '/tmp/autorun-test';\nvar file0 = testDir + '/autorun-test0.js';\nvar file1 = testDir + '/autorun-test1.js';\n\nexports.testAutorun = function (test) {\n    test.expect(3);\n    setTimeout(onTimeout1, 100);\n    setTimeout(onTimeout2, 1000);\n\n    if (!fs.existsSync(testDir)) {\n        fs.mkdirSync(testDir);\n    }\n    try {\n        fs.unlinkSync(file0);\n    } catch (ex) {\n        console.log('Unable to delete ' + file0);\n    }\n    try {\n        fs.unlinkSync(file1);\n    } catch (ex) {\n        console.log('Unable to delete ' + file1);\n    }\n    fs.writeFileSync(file0, 'console.log(\"got here in ' + file0 + '\");');\n    console.log('Wrote ' + file0);\n\n    var ar = autorun(testDir);\n    var apps = ar.getApps();\n    var emitter = ar.getEmitter();\n\n    emitter.on('start', function (file) {\n        console.log('Started ' + file);\n        if (file == file1) {\n            setTimeout(function () {\n                fs.unlink(file1, onUnlink);\n            }, 500);\n            test.ok(true);\n        }\n    });\n\n    emitter.on('closed', function (file) {\n        if (file == file1) {\n            ar.stop();\n            test.ok(true);\n        }\n    });\n\n    function onTimeout1() {\n        fs.writeFileSync(file1, 'console.log(\"got here in ' + file1 + '\"); setTimeout(function(){console.log(\"timeout\")}, 3000);');\n        console.log('Wrote ' + file1);\n        test.ok(true);\n    }\n\n    function onTimeout2() {\n        console.log('Done');\n        test.done();\n    }\n\n    function onUnlink() {\n        console.log('Deleted ' + file1);\n    }\n};"
  },
  {
    "path": "test/test-bone.js",
    "content": "//process.env.DEBUG = true;\nvar bone = require('bonescript').bone;\n\nvar expectedResults = [];\n\nexpectedResults.push({\n    \"name\": \"LEDs\",\n    \"search\": /^USR/,\n    \"keys\": [\"USR0\", \"USR1\", \"USR2\", \"USR3\"]\n});\n\nvar pbKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pbKeys.push(\"P1_\" + i);\n    pbKeys.push(\"P2_\" + i);\n}\nexpectedResults.push({\n    \"name\": \"PocketBeagleHeaders\",\n    \"search\": /^P[12]/,\n    \"keys\": pbKeys\n});\n\nvar boneKeys = [];\nfor (var i = 1; i <= 46; i++) {\n    boneKeys.push(\"P8_\" + i);\n    boneKeys.push(\"P9_\" + i);\n}\nboneKeys.push(\"P9_15B\");\nboneKeys.push(\"P9_41B\");\nboneKeys.push(\"P9_42B\");\nexpectedResults.push({\n    \"name\": \"BeagleBoneHeaders\",\n    \"search\": /^P[89]/,\n    \"keys\": boneKeys\n});\n\nvar ainKeys = [];\nfor (var i = 0; i <= 7; i++) {\n    ainKeys.push(\"A\" + i);\n}\nexpectedResults.push({\n    \"name\": \"AnalogInPins\",\n    \"search\": /^A[0-7]/,\n    \"keys\": ainKeys\n});\n\nvar gpioKeys = [];\nfor (var i = 0; i <= 117; i++) {\n    gpioKeys.push(\"GPIO_\" + i);\n}\nexpectedResults.push({\n    \"name\": \"GPIOPins\",\n    \"search\": /^GPIO_/,\n    \"keys\": gpioKeys\n});\n// removes must be done high-to-low to keep indexes valid\ngpioKeys.splice(108, 1); // remove GPIO3_12\ngpioKeys.splice(107, 1); // remove GPIO3_11\ngpioKeys.splice(25, 1); // remove GPIO0_25\ngpioKeys.splice(24, 1); // remove GPIO0_24\n\nvar eepromKeys = [];\nfor (var i = 0; i < 74; i++) {\n    eepromKeys.push(\"EEPROM_\" + i);\n}\nexpectedResults.push({\n    \"name\": \"EEPROM\",\n    \"search\": /^EEPROM_/,\n    \"keys\": eepromKeys\n});\n\nvar blueKeys = [];\nfor (var i = 1; i <= 6; i++) {\n    blueKeys.push(\"GP0_\" + i);\n    blueKeys.push(\"GP1_\" + i);\n    blueKeys.push(\"S1_1_\" + i);\n    blueKeys.push(\"S1_2_\" + i);\n    blueKeys.push(\"ADC_\" + i);\n}\nfor (var i = 2; i <= 6; i++) {\n    blueKeys.push(\"GPS_\" + i);\n}\nfor (var i = 1; i <= 4; i++) {\n    for (var j = 1; j <= 4; j++) {\n        blueKeys.push(\"E\" + j + \"_\" + i);\n    }\n    blueKeys.push(\"I2C_\" + i);\n    blueKeys.push(\"UT0_\" + i);\n    blueKeys.push(\"UT1_\" + i);\n    blueKeys.push(\"UT5_\" + i);\n}\nfor (var i = 1; i <= 3; i++) {\n    blueKeys.push(\"DSM2_\" + i);\n}\nblueKeys.push(\"RED\");\nblueKeys.push(\"GREEN\");\nblueKeys.push(\"WIFI\");\nblueKeys.push(\"BAT25\");\nblueKeys.push(\"BAT50\");\nblueKeys.push(\"BAT75\");\nblueKeys.push(\"BAT100\");\nblueKeys.push(\"PAUSE\");\nblueKeys.push(\"MODE\");\nexpectedResults.push({\n    \"name\": \"BeagleBoneBlue\",\n    \"search\": /^((E[1234]|GP[01]|GPS|S1_[12]|I2C|UT[015]|ADC|DSM2)_|RED|GREEN|WIFI|BAT|PAUSE|MODE)/,\n    \"keys\": blueKeys\n});\n\nvar results = {};\n\nfor (var i = 0; i < expectedResults.length; i++) {\n    var er = expectedResults[i];\n    exports['testBoneGetPinKeys' + er.name] = makeTest(i);\n}\n\nfunction makeTest(i) {\n    var search = expectedResults[i].search;\n    var expected = expectedResults[i].keys.sort(bone.naturalCompare);\n    return (function (test) {\n        test.expect(2);\n        test.doesNotThrow(function () {\n            results = bone.getPinKeys(search).sort(bone.naturalCompare);\n        });\n        test.ok(compareResults(results, expected));\n        test.done();\n    });\n}\n\nfunction compareResults(results, expected) {\n    console.log(\"results = \" + JSON.stringify(results));\n    console.log(\"expectedResults = \" + JSON.stringify(expected));\n    for (i in expected) {\n        if (results[i] != expected[i]) return (false);\n    }\n    return (true);\n}"
  },
  {
    "path": "test/test-digitalread.js",
    "content": "var b = require('bonescript');\n\nvar pinKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pinKeys.push(\"P1_\" + i);\n    pinKeys.push(\"P2_\" + i);\n}\nfor (var i = 1; i <= 46; i++) {\n    pinKeys.push(\"P8_\" + i);\n    pinKeys.push(\"P9_\" + i);\n}\nexports.testdigitalRead1 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        var y = b.digitalRead(pinKeys[x]);\n        test.ok(typeof y == 'number');\n    }\n    test.done();\n}\nexports.testdigitalRead2 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.digitalRead(pinKeys[x], function (x) {\n            test.ok(typeof x.value == 'number' && !x.err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}\nexports.testdigitalRead3 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.digitalRead(pinKeys[x], function (err, value) {\n            test.ok(typeof value == 'number' && !err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}"
  },
  {
    "path": "test/test-digitalwrite.js",
    "content": "var b = require('bonescript');\n\nvar pinKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pinKeys.push(\"P1_\" + i);\n    pinKeys.push(\"P2_\" + i);\n}\nfor (var i = 1; i <= 46; i++) {\n    pinKeys.push(\"P8_\" + i);\n    pinKeys.push(\"P9_\" + i);\n}\npinKeys = pinKeys.concat(['USR0', 'USR1', 'USR2', 'USR3']);\nexports.testdigitalwrite1 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        test.doesNotThrow(function () {\n            b.digitalWrite(pinKeys[x], b.HIGH);\n        });\n    }\n    test.done();\n}\nexports.testdigitalwrite2 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.digitalWrite(pinKeys[x], b.LOW, function () {\n            test.ok(true);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}"
  },
  {
    "path": "test/test-ffi.js",
    "content": "var b = require('bonescript');\nvar fs = require('fs');\nvar testDir = '/tmp/ffi-test';\nvar Cfile = testDir + '/ffi-test';\nvar Cfile1 = testDir + '/ffi-test1';\nvar txtFile = testDir + '/txt-test.txt'\nvar txtFile1 = testDir + '/txt-test1.txt'\nvar args = {\n    'dummy': ['int', ['void']]\n};\nvar text = \"HELLO\";\nvar cCode = `\n#include <stdio.h>\nint dummy()\n{\n   printf(\"Hello, World!\");\n   return 0;\n}\n`\nmodule.exports.testFFI = function (test) {\n\n    test.expect(8);\n    if (!fs.existsSync(testDir)) {\n        fs.mkdirSync(testDir);\n    }\n    //test writetxtFile\n    b.writeTextFile(txtFile, text);\n    if (fs.existsSync(txtFile)) {\n        console.log(\"Write Text File Successful\");\n        test.ok(true);\n    }\n    //test readtxtFile\n    if (b.readTextFile(txtFile) == text) {\n        console.log(\"Read Text File Successful\");\n        test.ok(true);\n    }\n    //test mraaGPIO()\n    var mraaGPIO = b.mraaGPIO('P9_12');\n    if (mraaGPIO === '0x3a') {\n        console.log(\"MRAA Library Load Successful\");\n        test.ok(true);\n    }\n    //test writeCModule\n    b.writeCModule(Cfile, cCode);\n    if (fs.existsSync(Cfile + '.c')) {\n        console.log(\"Write C Module Successful\");\n        test.ok(true);\n    }\n    //test loadCModule\n    var Cmodule = b.loadCModule(Cfile, args);\n    if (Cmodule == \"ffi not loaded\") {\n        console.log(\"Load C Module Unsuccesful(ffi not loaded)\");\n        test.ok(true);\n    } else {\n        var moduleRetVal = Cmodule.dummy(0);\n        //returns 0\n        console.log(\"Load C Module Succesful, returned: \" + moduleRetVal);\n        test.ok(moduleRetVal == 0);\n    } //test writetxtFile with callback\n    b.writeTextFile(txtFile1, text, function (x) {\n        if (!x.err)\n            test.ok(true);\n        onWriteTextFile();\n    });\n    //test readtxtFile with callback\n    function onWriteTextFile() {\n        b.readTextFile(txtFile1, function (err, data) {\n            if (!err && data == text)\n                test.ok(true);\n            onReadTextFile()\n        })\n    }\n    //test writeCModule with callback\n    function onReadTextFile() {\n        b.writeCModule(Cfile1, cCode, function (x) {\n            if (!x.err)\n                test.ok(true);\n            test.done();\n        });\n    }\n}"
  },
  {
    "path": "test/test-getpinmode.js",
    "content": "//process.env.DEBUG = true;\nvar b = require('bonescript');\n\nvar expectedResults = [{\n        \"pin\": \"USR0\",\n        \"name\": \"USR0\"\n    },\n    {\n        \"pin\": \"USR1\",\n        \"name\": \"USR1\"\n    },\n    {\n        \"pin\": \"USR2\",\n        \"name\": \"USR2\"\n    },\n    {\n        \"pin\": \"USR3\",\n        \"name\": \"USR3\"\n    },\n    {\n        \"pin\": \"P8_1\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P8_2\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P8_3\",\n        \"name\": \"GPIO1_6\"\n    },\n    {\n        \"pin\": \"P8_4\",\n        \"name\": \"GPIO1_7\"\n    },\n    {\n        \"pin\": \"P8_5\",\n        \"name\": \"GPIO1_2\"\n    },\n    {\n        \"pin\": \"P8_6\",\n        \"name\": \"GPIO1_3\"\n    },\n    {\n        \"pin\": \"P8_7\",\n        \"name\": \"TIMER4\"\n    },\n    {\n        \"pin\": \"P8_8\",\n        \"name\": \"TIMER7\"\n    },\n    {\n        \"pin\": \"P8_9\",\n        \"name\": \"TIMER5\"\n    },\n    {\n        \"pin\": \"P8_10\",\n        \"name\": \"TIMER6\"\n    },\n    {\n        \"pin\": \"P8_11\",\n        \"name\": \"GPIO1_13\"\n    },\n    {\n        \"pin\": \"P8_12\",\n        \"name\": \"GPIO1_12\"\n    },\n    {\n        \"pin\": \"P8_13\",\n        \"name\": \"EHRPWM2B\"\n    },\n    {\n        \"pin\": \"P8_14\",\n        \"name\": \"GPIO0_26\"\n    },\n    {\n        \"pin\": \"P8_15\",\n        \"name\": \"GPIO1_15\"\n    },\n    {\n        \"pin\": \"P8_16\",\n        \"name\": \"GPIO1_14\"\n    },\n    {\n        \"pin\": \"P8_17\",\n        \"name\": \"GPIO0_27\"\n    },\n    {\n        \"pin\": \"P8_18\",\n        \"name\": \"GPIO2_1\"\n    },\n    {\n        \"pin\": \"P8_19\",\n        \"name\": \"EHRPWM2A\"\n    },\n    {\n        \"pin\": \"P8_20\",\n        \"name\": \"GPIO1_31\"\n    },\n    {\n        \"pin\": \"P8_21\",\n        \"name\": \"GPIO1_30\"\n    },\n    {\n        \"pin\": \"P8_22\",\n        \"name\": \"GPIO1_5\"\n    },\n    {\n        \"pin\": \"P8_23\",\n        \"name\": \"GPIO1_4\"\n    },\n    {\n        \"pin\": \"P8_24\",\n        \"name\": \"GPIO1_1\"\n    },\n    {\n        \"pin\": \"P8_25\",\n        \"name\": \"GPIO1_0\"\n    },\n    {\n        \"pin\": \"P8_26\",\n        \"name\": \"GPIO1_29\"\n    },\n    {\n        \"pin\": \"P8_27\",\n        \"name\": \"GPIO2_22\"\n    },\n    {\n        \"pin\": \"P8_28\",\n        \"name\": \"GPIO2_24\"\n    },\n    {\n        \"pin\": \"P8_29\",\n        \"name\": \"GPIO2_23\"\n    },\n    {\n        \"pin\": \"P8_30\",\n        \"name\": \"GPIO2_25\"\n    },\n    {\n        \"pin\": \"P8_31\",\n        \"name\": \"UART5_CTSN\"\n    },\n    {\n        \"pin\": \"P8_32\",\n        \"name\": \"UART5_RTSN\"\n    },\n    {\n        \"pin\": \"P8_33\",\n        \"name\": \"UART4_RTSN\"\n    },\n    {\n        \"pin\": \"P8_34\",\n        \"name\": \"UART3_RTSN\"\n    },\n    {\n        \"pin\": \"P8_35\",\n        \"name\": \"UART4_CTSN\"\n    },\n    {\n        \"pin\": \"P8_36\",\n        \"name\": \"UART3_CTSN\"\n    },\n    {\n        \"pin\": \"P8_37\",\n        \"name\": \"UART5_TXD\"\n    },\n    {\n        \"pin\": \"P8_38\",\n        \"name\": \"UART5_RXD\"\n    },\n    {\n        \"pin\": \"P8_39\",\n        \"name\": \"GPIO2_12\"\n    },\n    {\n        \"pin\": \"P8_40\",\n        \"name\": \"GPIO2_13\"\n    },\n    {\n        \"pin\": \"P8_41\",\n        \"name\": \"GPIO2_10\"\n    },\n    {\n        \"pin\": \"P8_42\",\n        \"name\": \"GPIO2_11\"\n    },\n    {\n        \"pin\": \"P8_43\",\n        \"name\": \"GPIO2_8\"\n    },\n    {\n        \"pin\": \"P8_44\",\n        \"name\": \"GPIO2_9\"\n    },\n    {\n        \"pin\": \"P8_45\",\n        \"name\": \"GPIO2_6\"\n    },\n    {\n        \"pin\": \"P8_46\",\n        \"name\": \"GPIO2_7\"\n    },\n    {\n        \"pin\": \"P9_1\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P9_2\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P9_3\",\n        \"name\": \"VDD_3V3\"\n    },\n    {\n        \"pin\": \"P9_4\",\n        \"name\": \"VDD_3V3\"\n    },\n    {\n        \"pin\": \"P9_5\",\n        \"name\": \"VDD_5V\"\n    },\n    {\n        \"pin\": \"P9_6\",\n        \"name\": \"VDD_5V\"\n    },\n    {\n        \"pin\": \"P9_7\",\n        \"name\": \"SYS_5V\"\n    },\n    {\n        \"pin\": \"P9_8\",\n        \"name\": \"SYS_5V\"\n    },\n    {\n        \"pin\": \"P9_9\",\n        \"name\": \"PWR_BUT\"\n    },\n    {\n        \"pin\": \"P9_10\",\n        \"name\": \"SYS_RESETn\"\n    },\n    {\n        \"pin\": \"P9_11\",\n        \"name\": \"UART4_RXD\"\n    },\n    {\n        \"pin\": \"P9_12\",\n        \"name\": \"GPIO1_28\"\n    },\n    {\n        \"pin\": \"P9_13\",\n        \"name\": \"UART4_TXD\"\n    },\n    {\n        \"pin\": \"P9_14\",\n        \"name\": \"EHRPWM1A\"\n    },\n    {\n        \"pin\": \"P9_15\",\n        \"name\": \"GPIO1_16\"\n    },\n    {\n        \"pin\": \"P9_15B\",\n        \"name\": \"GPIO1_16\"\n    },\n    {\n        \"pin\": \"P9_16\",\n        \"name\": \"EHRPWM1B\"\n    },\n    {\n        \"pin\": \"P9_17\",\n        \"name\": \"I2C1_SCL\"\n    },\n    {\n        \"pin\": \"P9_18\",\n        \"name\": \"I2C1_SDA\"\n    },\n    {\n        \"pin\": \"P9_19\",\n        \"name\": \"I2C2_SCL\"\n    },\n    {\n        \"pin\": \"P9_20\",\n        \"name\": \"I2C2_SDA\"\n    },\n    {\n        \"pin\": \"P9_21\",\n        \"name\": \"UART2_TXD\"\n    },\n    {\n        \"pin\": \"P9_22\",\n        \"name\": \"UART2_RXD\"\n    },\n    {\n        \"pin\": \"P9_23\",\n        \"name\": \"GPIO1_17\"\n    },\n    {\n        \"pin\": \"P9_24\",\n        \"name\": \"UART1_TXD\"\n    },\n    {\n        \"pin\": \"P9_25\",\n        \"name\": \"GPIO3_21\"\n    },\n    {\n        \"pin\": \"P9_26\",\n        \"name\": \"UART1_RXD\"\n    },\n    {\n        \"pin\": \"P9_27\",\n        \"name\": \"GPIO3_19\"\n    },\n    {\n        \"pin\": \"P9_28\",\n        \"name\": \"SPI1_CS0\"\n    },\n    {\n        \"pin\": \"P9_29\",\n        \"name\": \"SPI1_D0\"\n    },\n    {\n        \"pin\": \"P9_30\",\n        \"name\": \"SPI1_D1\"\n    },\n    {\n        \"pin\": \"P9_31\",\n        \"name\": \"SPI1_SCLK\"\n    },\n    {\n        \"pin\": \"P9_32\",\n        \"name\": \"VDD_ADC\"\n    },\n    {\n        \"pin\": \"P9_33\",\n        \"name\": \"AIN4\"\n    },\n    {\n        \"pin\": \"P9_34\",\n        \"name\": \"GNDA_ADC\"\n    },\n    {\n        \"pin\": \"P9_35\",\n        \"name\": \"AIN6\"\n    },\n    {\n        \"pin\": \"P9_36\",\n        \"name\": \"AIN5\"\n    },\n    {\n        \"pin\": \"P9_37\",\n        \"name\": \"AIN2\"\n    },\n    {\n        \"pin\": \"P9_38\",\n        \"name\": \"AIN3\"\n    },\n    {\n        \"pin\": \"P9_39\",\n        \"name\": \"AIN0\"\n    },\n    {\n        \"pin\": \"P9_40\",\n        \"name\": \"AIN1\"\n    },\n    {\n        \"pin\": \"P9_41\",\n        \"name\": \"CLKOUT2\"\n    },\n    {\n        \"pin\": \"P9_41B\",\n        \"name\": \"CLKOUT2\"\n    },\n    {\n        \"pin\": \"P9_42\",\n        \"name\": \"GPIO0_7\"\n    },\n    {\n        \"pin\": \"P9_42B\",\n        \"name\": \"GPIO0_7\"\n    },\n    {\n        \"pin\": \"P9_43\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P9_44\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P9_45\",\n        \"name\": \"DGND\"\n    },\n    {\n        \"pin\": \"P9_46\",\n        \"name\": \"DGND\"\n    },\n];\n\nvar results = {};\n\nfor (var i = 0; i < expectedResults.length; i++) {\n    var er = expectedResults[i];\n    exports['testGetPinMode' + er.pin] = makeTest(i);\n}\n\nfunction makeTest(i) {\n    var pin = expectedResults[i].pin;\n    var expected = expectedResults[i];\n    return (function (test) {\n        test.expect(2);\n        test.doesNotThrow(function () {\n            results = b.getPinMode(pin);\n            // Only compare name to work on travis-ci\n            results = {\n                \"pin\": results.pin,\n                \"name\": results.name\n            };\n        });\n        test.ok(compareResults(results, expected));\n        test.done();\n    });\n}\n\nfunction compareResults(results, expected) {\n    console.log(\"results = \" + JSON.stringify(results));\n    console.log(\"expectedResults = \" + JSON.stringify(expected));\n    for (i in expected) {\n        if (results[i] != expected[i]) return (false);\n    }\n    return (true);\n}"
  },
  {
    "path": "test/test-lint.js",
    "content": "module.exports = {};\nvar beautify = require('../node_modules/js-beautify');\nvar fs = require('fs');\nvar path = require('path');\n\nvar config = JSON.parse(fs.readFileSync('./lint-config.json'));\nvar index = 0;\n\ntestDir(\"./\");\ntestDir(\"./src/\");\ntestDir(\"./test/\");\n\nfunction testDir(dir) {\n    var files = fs.readdirSync(dir);\n    files.forEach(function (file, index) {\n        testFile(dir + file);\n    });\n}\n\nfunction testFile(fileToTest) {\n    var stat = fs.statSync(fileToTest);\n    if (stat.isFile() && fileToTest.match(/js$/)) {\n        //console.log(\"Adding lint test for \" + fileToTest);\n        index++;\n        module.exports[\"testLint\" + index] = function (test) {\n            var inFile = \"a\";\n            var outFile = \"b\";\n            test.expect(2);\n            test.doesNotThrow(function () {\n                console.log(\"Running lint on \" + fileToTest);\n                inFile = fs.readFileSync(fileToTest, 'utf8');\n                outFile = beautify.js(inFile, config);\n                //fs.writeFileSync(fileToTest + \".lint\", outFile);\n            });\n            test.equal(inFile, outFile);\n            test.done();\n        };\n    }\n}"
  },
  {
    "path": "test/test-math.js",
    "content": "var math = require('../src/functions');\nvar b = require('bonescript');\n\nvar mathFns = Object.getOwnPropertyNames(math);\nfor (var x in mathFns)\n    mathFns[x] = b[mathFns[x]];\n\nfunction getRandomInt() {\n    return Math.floor(Math.random() * 100);\n}\n\nexports.testMathFunctions = function (test) {\n    test.expect(mathFns.length - 1); //randomseed does not return anything\n    for (var x in mathFns) {\n        var result = mathFns[x].call(null, getRandomInt(), getRandomInt(), getRandomInt(), getRandomInt(), getRandomInt());\n        if (typeof result == 'number') //assuming every math function returns a number\n            test.ok(true);\n    }\n    test.done();\n}"
  },
  {
    "path": "test/test-pinMode.js",
    "content": "var b = require('bonescript');\n\nvar pinKeys = [];\nfor (var i = 1; i <= 36; i++) {\n    pinKeys.push(\"P1_\" + i);\n    pinKeys.push(\"P2_\" + i);\n}\nfor (var i = 1; i <= 46; i++) {\n    pinKeys.push(\"P8_\" + i);\n    pinKeys.push(\"P9_\" + i);\n}\nfor (var i = 0; i <= 7; i++) {\n    pinKeys.push(\"A\" + i);\n}\npinKeys = pinKeys.concat(['USR0', 'USR1', 'USR2', 'USR3']);\nexports.testpinMode1 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        test.doesNotThrow(function () {\n            b.pinMode(pinKeys[x], b.OUTPUT);\n            b.pinMode(pinKeys[x], b.INPUT);\n            b.pinMode(pinKeys[x], b.INPUT_PULLUP);\n            b.pinMode(pinKeys[x], b.ANALOG_OUTPUT);\n        });\n    }\n    test.done();\n}\nexports.testpinMode2 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.pinMode(pinKeys[x], b.OUTPUT, 7, 'pullup', 'fast', function (x) {\n            test.ok(x.value && !x.err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}\nexports.testpinMode3 = function (test) {\n    test.expect(pinKeys.length);\n    for (var x in pinKeys) {\n        b.pinMode(pinKeys[x], b.OUTPUT, 7, 'pullup', 'fast', function (err, value) {\n            test.ok(value && !err);\n        });\n        if (x == pinKeys.length - 1)\n            test.done();\n    }\n}"
  },
  {
    "path": "test/test-rpc.js",
    "content": "var server = require('bonescript');\nvar bonescript = require('../src/bonescript');\nvar myserver = null;\n\nexports.setUp = function (callback) {\n    server.serverStart(8000, process.cwd(), null, mycb);\n\n    function mycb(serverObj) {\n        myserver = serverObj.server;\n        callback();\n    }\n};\n\nexports.testRPC_callbacks = function (test) {\n    test.expect(15);\n\n    bonescript.startClient({\n        address: '127.0.0.1',\n        port: 8000\n    }, getPlatformTest_oldstyle);\n\n    function getPlatformTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.getPlatform(function (platform) {\n            console.log(\"***getPlatformTest_oldstyle***\");\n            console.log(platform);\n            console.log('Name: ' + platform.name);\n            console.log('Version: ' + platform.bonescript);\n            getPlatformTest_nodestyle(platform);\n        });\n    }\n\n    function getPlatformTest_nodestyle(platform_) {\n        console.log('here');\n        var b = bonescript.require('bonescript');\n        b.getPlatform(function (err, platform) {\n            console.log(\"***getPlatformTest_nodestyle***\");\n            console.log(platform);\n            console.log('Name: ' + platform.name);\n            console.log('Version: ' + platform.bonescript);\n            test.equals(platform.name, platform_.name);\n            test.equals(platform.bonescript, platform_.bonescript);\n            pinModeTest_oldstyle();\n        });\n    }\n\n    function pinModeTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.pinMode(\"P8_13\", b.OUTPUT, 7, 'pullup', 'fast', printStatus);\n\n        function printStatus(x) {\n            console.log(\"***pinModeTest_oldstyle***\");\n            console.log('value = ' + x.value);\n            console.log('err = ' + x.err);\n            pinModeTest_nodestyle(x);\n        }\n    }\n\n    function pinModeTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.pinMode(\"P8_13\", b.OUTPUT, 7, 'pullup', 'fast', printStatus);\n\n        function printStatus(err, value) {\n            console.log(\"***pinModeTest_nodestyle***\");\n            console.log('value = ' + value);\n            console.log('err = ' + err);\n            test.equals(x.err, err);\n            test.equals(x.value, value);\n            getPinModeTest_oldstyle();\n        }\n    }\n\n    function getPinModeTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.getPinMode(\"P8_13\", printPinMux);\n\n        function printPinMux(x) {\n            console.log(\"***getPinModeTest_oldstyle***\");\n            console.log('mux = ' + x.mux);\n            console.log('pullup = ' + x.pullup);\n            console.log('slew = ' + x.slew);\n            console.log('options = ' + x.options.join(','));\n            console.log('err = ' + x.err);\n            getPinModeTest_nodestyle(x)\n        }\n    }\n\n    function getPinModeTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.getPinMode(\"P8_13\", printPinMux);\n\n        function printPinMux(err, resp) {\n            console.log(\"***getPinModeTest_nodestyle***\");\n            console.log('mux = ' + resp.mux);\n            console.log('pullup = ' + resp.pullup);\n            console.log('slew = ' + resp.slew);\n            console.log('options = ' + resp.options.join(','));\n            console.log('err = ' + resp.err);\n            test.equals(x.mux, resp.mux);\n            test.equals(x.pullup, resp.pullup);\n            test.equals(x.slew, resp.slew);\n            test.equals(x.options.join(','), resp.options.join(','));\n            digitalWriteTest();\n        }\n    }\n\n    function digitalWriteTest() {\n        var b = bonescript.require('bonescript');\n        b.digitalWrite('USR0', b.HIGH, printErr);\n\n        function printErr(x) {\n            console.log(\"***digitalWriteTest***\");\n            console.log('err = ' + x.err);\n            test.ok(true);\n            digitalReadTest_oldstyle();\n        }\n    }\n\n    function digitalReadTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.digitalRead('P8_19', printStatus);\n\n        function printStatus(x) {\n            console.log(\"***digitalReadTest_oldstyle***\");\n            console.log('x.value = ' + x.value);\n            console.log('x.err = ' + x.err);\n            digitalReadTest_nodestyle(x)\n        }\n    }\n\n    function digitalReadTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.digitalRead('P8_19', printStatus);\n\n        function printStatus(err, value) {\n            console.log(\"***digitalReadTest_nodestyle***\");\n            console.log('x.value = ' + value);\n            console.log('x.err = ' + err);\n            test.equals(x.value, value);\n            analogWriteTest()\n        }\n    }\n\n\n    function analogWriteTest() {\n        var b = bonescript.require('bonescript');\n        b.analogWrite('P9_14', 0.7, 2000, printJSON);\n\n        function printJSON(x) {\n            console.log(\"***analogWriteTest***\");\n            console.log(JSON.stringify(x));\n            test.ok(true);\n            analogReadTest_oldstyle();\n\n        }\n    }\n\n    function analogReadTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.analogRead('P9_36', printStatus);\n\n        function printStatus(x) {\n            console.log(\"***analogReadTest_oldstyle***\");\n            console.log('x.value = ' + x.value);\n            console.log('x.err = ' + x.err);\n            analogReadTest_nodestyle(x);\n        }\n    }\n\n    function analogReadTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.analogRead('P9_36', printStatus);\n\n        function printStatus(err, value) {\n            console.log(\"***analogReadTest_nodestyle***\");\n            console.log('x.value = ' + value);\n            console.log('x.err = ' + err);\n            test.equals(x.value, value);\n            attachInterruptTest_oldstyle()\n        }\n    }\n\n    function attachInterruptTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.attachInterrupt('P8_19', true, b.CHANGE, interruptCallback);\n\n        function interruptCallback(x) {\n            console.log(\"***attachInterruptTest_oldstyle***\");\n            console.log(JSON.stringify(x));\n            attachInterruptTest_nodestyle(x)\n        }\n    }\n\n    function attachInterruptTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.attachInterrupt('P8_19', true, b.CHANGE, interruptCallback);\n\n        function interruptCallback(err, resp) {\n            console.log(\"***attachInterruptTest_nodestyle***\");\n            console.log(JSON.stringify(resp));\n            test.equals(x.pin.name, resp.pin.name);\n            readTextFileTest_oldstyle();\n        }\n    }\n\n    function readTextFileTest_oldstyle() {\n        var b = bonescript.require('bonescript');\n        b.readTextFile('/etc/fstab', printStatus);\n\n        function printStatus(x) {\n            console.log(\"***readTextFileTest_oldstyle***\");\n            console.log('x.data = ' + x.data);\n            console.log('x.err = ' + x.err);\n            readTextFileTest_nodestyle(x);\n        }\n    }\n\n    function readTextFileTest_nodestyle(x) {\n        var b = bonescript.require('bonescript');\n        b.readTextFile('/etc/fstab', printStatus);\n\n        function printStatus(err, data) {\n            console.log(\"***readTextFileTest_nodestyle***\");\n            console.log('x.data = ' + data);\n            console.log('x.err = ' + err);\n            test.equals(x.data, data);\n            test.equals(x.err, err);\n            myserver.close();\n            test.done();\n        }\n    }\n}"
  },
  {
    "path": "test/test-rpc_secure.js",
    "content": "var server = require('bonescript');\nvar bonescript = require('../src/bonescript');\nvar myserver = null;\n\nexports.setUp = function (callback) {\n    server.serverStart(8000, process.cwd(), { // create a secure server by supplying credentials\n        data: 'testpass',\n        hash: false\n    }, mycb);\n\n    function mycb(serverobj) {\n        myserver = serverobj.server;\n        callback();\n    }\n};\n\nexports.testRPC_secure1 = function (test) {\n    test.expect(1);\n    bonescript.startClient({ // this should throw an  authentication error\n        address: '127.0.0.1',\n        port: 8000,\n        password: 'tdestpass'\n    }, function () {});\n    process.on('uncaughtException', function (err) {\n        console.log(err.toString());\n        test.equals(err.toString(), 'Error: Authentication Failed : incorrect passphrase !!');\n        myserver.close();\n        test.done();\n    });\n}\n\nexports.testRPC_secure2 = function (test) {\n    test.expect(1);\n    bonescript.startClient({\n        address: '127.0.0.1',\n        port: 8000,\n        password: 'testpass' // will not throw any error\n    }, function () {\n        var b = bonescript.require('bonescript');\n        b.getPlatform(function (platform) {\n            console.log('Name: ' + platform.name);\n            console.log('Version: ' + platform.bonescript);\n            test.ok(platform != 'undefined');\n            myserver.close();\n            test.done();\n        });\n    });\n}"
  },
  {
    "path": "test/test-sanity.js",
    "content": "//process.env.DEBUG = true;\n\nexports.testSanity1 = function (test) {\n    test.expect(1);\n    test.doesNotThrow(function () {\n        var b = require('bonescript');\n\n        console.log('Name: ' + b.getPlatform().name);\n        console.log('Version: ' + b.getPlatform().bonescript);\n    });\n    test.done();\n}"
  }
]