Some basic questions about Bonescript.

So I’m digging into my newly acquired Beaglebone Black and I’ve been playing a bit with the Bonescript stuff. I had some basic questions to help get me started…

  1. If I want to run my scripts from the command-line, do I just run node myScript.js?

  2. I looked through some of the source for Bonescript and it appears to largely use the /sys filesystem for performing operations. If someone spent the time to rewrite it to use /dev/mem, would this make the Bonescript more efficient? Or is utilizing the /sys file-structure just as fast?

  3. When attaching interrupts, it looks like Bonescript uses a CPP module and relies upon epoll. However, according to the node.js docs it looks like there’s a…) command that will use inotify on linux. I was just curious why go the route of native calls?

Thanks for any insight!
~ Jason

To answer some of my own questions for the curious.

  1. Running scripts from the command-line seems to work just fine. You can also just copy them into the autorun folder and they’ll be picked up and run automatically, however, I had to use the kill command to stop them.

  2. After some digging around it seems like this is the best approach for working with I/O from userspace. Opening up the /dev/mem requires root access and you still can’t perform some operations this way such as changing the pin configuration. However, if I can get my Beagle in proper working order, I think I’ll see what can be done to clean the code up a bit.

It looks like Beagles are running two different sets of IO drivers out there (must be related to the kernel version). As a result, the /sys file has changed, and the beaglescript assumes things are done the “old” way, and then when that fails (can’t open file, file doesn’t exist, etc) it tries the “new” way. It would be nice if there was a way to detect the version of kernel and then always use the appropriate method for working with the IO.

  1. Haven’t looked into this one yet but I have heard that Node.js (at least at some point) isn’t very efficient when calling to native functions. I might just play with the command and see how it affects the CPU usage.