Pi-pins Not Working With Electron Project / ClockOS

Hi, I’m trying to read the state of a gpio pin in my project to detect a button push using the recommended setup by Resin with pi-pins and their resin-electronjs project but I’m getting an error when the app tries to start in the Pi, it breaks when it gets to this line https://github.com/iGerli/clockOS/blob/dev/sgerli/app/main.js#L76 , I know that because when I remove that code it doesn’t gives me any error. I think that this error is caused by require-rebuild trying to rebuild one of the dependencies of pi-pins. Any idea on how to fix this?

I’m deploying to a Pi 2 with a ili9341 tft.
All of my code is available on GitHub https://github.com/iGerli/clockOS/tree/dev/sgerli

01.02.17 14:49:16 [-0600] Recompiling node_modules/epoll...
01.02.17 14:49:16 [-0600] App threw an error during load
01.02.17 14:49:16 [-0600] Error: spawnSync node-gyp ENOENT
01.02.17 14:49:16 [-0600] at exports._errnoException (util.js:1026:11)
01.02.17 14:49:16 [-0600] at spawnSync (child_process.js:473:20)
01.02.17 14:49:16 [-0600] at spawnSync (/usr/src/app/node_modules/cross-spawn/index.js:45:14)
01.02.17 14:49:16 [-0600] at Function.Module._load (/usr/src/app/node_modules/require-rebuild/index.js:54:14)
01.02.17 14:49:16 [-0600] at Module.require (module.js:483:17)
01.02.17 14:49:16 [-0600] at require (internal/module.js:20:19)
01.02.17 14:49:16 [-0600] at bindings (/usr/src/app/node_modules/bindings/bindings.js:76:44)
01.02.17 14:49:16 [-0600] at Object.<anonymous> (/usr/src/app/node_modules/epoll/epoll.js:1:116)
01.02.17 14:49:16 [-0600] at Module._compile (module.js:556:32)
01.02.17 14:49:16 [-0600] at Object.Module._extensions..js (module.js:565:10)
01.02.17 14:49:16 [-0600] A JavaScript error occurred in the main process
01.02.17 14:49:16 [-0600] Uncaught Exception:
01.02.17 14:49:16 [-0600] Error: spawnSync node-gyp ENOENT
01.02.17 14:49:16 [-0600] at exports._errnoException (util.js:1026:11)
01.02.17 14:49:16 [-0600] at spawnSync (child_process.js:473:20)
01.02.17 14:49:16 [-0600] at spawnSync (/usr/src/app/node_modules/cross-spawn/index.js:45:14)
01.02.17 14:49:16 [-0600] at Function.Module._load (/usr/src/app/node_modules/require-rebuild/index.js:54:14)
01.02.17 14:49:16 [-0600] at Module.require (module.js:483:17)
01.02.17 14:49:16 [-0600] at require (internal/module.js:20:19)
01.02.17 14:49:16 [-0600] at bindings (/usr/src/app/node_modules/bindings/bindings.js:76:44)
01.02.17 14:49:16 [-0600] at Object.<anonymous> (/usr/src/app/node_modules/epoll/epoll.js:1:116)
01.02.17 14:49:16 [-0600] at Module._compile (module.js:556:32)
01.02.17 14:49:16 [-0600] at Object.Module._extensions..js (module.js:565:10)

I’ve seen this discussed on Github.

https://github.com/resin-io/resin-electronjs/issues/36

The result seems to be needing to revert electronjs to an earlier version in package.json, right?

Yeah, I read that but they are suggesting electron 1.2.5 but npm isn’t able to find it. (More details in that issue.)

Which one was the original commit (what SHA) that your Github link was pointing to? You’ve added changes to the dev/sgerli branch since you wrote this report, and now I’m not sure whether we are checking the same version you were. Would help checking things out, as I see that there are multiple things that you were experimenting with.

This was the original one https://github.com/iGerli/clockOS/blob/9d27543d283c5f58aef768524d8611364ff18a92/app/main.js#L76

But I’m still experiencing this in the last one.

Checking this out. It seems if I connect to the container after the application starts running and try pi-pins in a separate script, they were totally fine…

@curcuz is debugging it further, it seems like there’s some issue upstream that resin-electronjs need to work around of.

1 Like

@imrehg, @sGerli the issue was identified and fixed, expect the PR to be merged soon. Luckily it was an easy fix since the electron-rebuild maintainer fixed the issues that prevented us to rely on that module instead of require-rebuild. This is a big improvement since now the rebuild process happens on the builder at the push phase.

https://github.com/resin-io/resin-electronjs/pull/37

1 Like

@sGerli I’ve seen you’ve already incorporated @curcuz’s changes into ClockOS :clock: , very cool! I gave the latest dev commit a try locally, since things were already set up from yesterday’s debugging session).

Appears to be working much better, including the button press (just tried one button)

Though probably the buttons’ code need some logic / debouncing, a single press triggered multiple events, but I’m guessing that’s more on the library and just mentioning it as a side note :slight_smile: Looking forward to see what you are making! :smiley:

Yeah, for now I’m just trying to get things working, thanks.

1 Like

Cool project, by the way! I have been tinkering with something similar for a while. (Though it has been a long time since I worked on it – I should pick it back up!) It’s fun to have a clock you can push new code to :slight_smile:

1 Like

Yeah, thats why I started this project. I am a Pebble developer so I really like the idea of making apps and making your watch yours.

If you or someone else ever wants to collaborate I’ll be open to PRs and suggestions.

1 Like

That’s awesome! (as a Kickstarter Pebble owner :watch:, and small-time (sic) developer:). I was thinking that it would be cool to see where are you headed with the project, what’s the projected form that you’d like to achieve on the long run. :clipboard:

Is there anything that you are looking for help on? Or just suggestions in general? I often see wishlist / help-wanted types of issues working out pretty well, would-be contributors know where to start :construction:. Just a thought.

1 Like

Yeah, I’m going to do some planning and create some issues after that.

1 Like