GPIO interface

It is possible to access GPIO interface from nodejs services?

I don't actually have a Pi to check this out with, but there is a npm package called 'rpi-gpio' that looks like it's specifically for that. Now, it does look like since it's native stuff, you'd probably have to build a binary dependency, epoll, in the build system.. looks like it might take some tricks to get both epoll and rpi-gpio available to the built Pi image.. but it looks like it should be do-able.

1 Like

oh, yeah, here's a link to rpi-gpio https://www.npmjs.com/package/rpi-gpio

and to epoll https://github.com/fivdi/epoll

Thank you, other question regarding this, it is possible to know which is the linux distribution that webos is based on? I ask this becase then maybe I can use a lot of iot libraries from the raspberry pi community

I'm not entirely sure how to answer that question, it's pretty much it's own distribution. :slight_smile:

A bit of good news, is that I had to figure out how to do a npm install step myself inside a bitbake recipe, and since webOS OSE has Enact app recipes all setup, those include a npm install step . . though the webos_enact_app recipe doesn't work directly on a nodeJS service, you can do a little something like:

inherit webos_enactjs_env

SRC_URI = "git://path-to-your-source-repo"
S = "${WORKDIR}/git"

# a piece taken from https://github.com/webosose/meta-webosose/blob/7c8e550398dd3ef7ab26f59023ede177f6f9830c/meta-webos/classes/webos_enactjs_app.bbclass

do_compile() {
    cd ${S}
    rm -fr node_modules
    STATUS=-1
    while [ ${STATUS} -ne 0 ] ; do
        ATTEMPTS=$(expr ${ATTEMPTS}+1)
        if [ ${ATTEMPTS} -gt 5 ] ; then exit ${STATUS} ; fi
        echo "NPM install attempt #${ATTEMPTS} (of 5)..." && echo
        STATUS=0
        ${ENACT_NPM} --arch=${TARGET_ARCH} install || eval "STATUS=\$?"
        if [ ${STATUS} -ne 0 ] ; then
            bbwarn "...NPM process failed with status ${STATUS}"
        else
            echo "...NPM process suceeded" && echo
        fi
    done
}

do_install () {
    install -d ${D}${webos_servicesdir}/${PN}/

    # Install service info
    cp -rf ${S}/files/* ${D}

    # Install source
    cp -rf ${S}/src/* ${D}${webos_servicesdir}/${PN}/
    cp -rf ${S}/node_modules ${D}${webos_servicesdir}/${PN}/node_modules
}

your file structures may differ somewhat. and i haven't tested it with native modules, but it does look like by specifying the target arch in the npm command line, that it should build any native modules for the target arch.

@Gabriel_Gutierrez, I don't think the "Linux distribution" designation could be used here. That would be like asking what distro is Android based on. There isn't any.
Both webOS and Android are Linux based operating systems.