bonesscript shiftout.js debugging and return value.

In the cloud9 ide I’m working on the bonescript shiftout on a BBB

`

jeffa@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2017-03-19
jeffa@beaglebone:~$ uname -a
Linux beaglebone 4.4.54-ti-r93 #1 SMP Fri Mar 17 13:08:22 UTC 2017 armv7l GNU/Linux
jeffa@beaglebone:~$

`

The shiftOut.js is not working for me. To verify that I hooked up the pins correctly I made a quick test program to toggle the four lines. Yup square wave on all four.

`

while (true) {
b.digitalWrite(sData, b.LOW);
b.digitalWrite(sClock, b.LOW);
b.digitalWrite(sLatch, b.LOW);
b.digitalWrite(sClear, b.LOW);

b.digitalWrite(sData, b.HIGH);
b.digitalWrite(sClock, b.HIGH);
b.digitalWrite(sLatch, b.HIGH);
b.digitalWrite(sClear, b.HIGH);
}

`

I’m only seeing the sClear P9_15 toggle with the shiftOut.js example and that pin is not used in the shiftOut.js function call. It really just could be wired high in the schematic as it’s never used other than to set it high during initialization. I’m not seeing any clock or serial in.

in the shiftOut documentation I read;

Return value- true if successful

callback(x)- x.err: error status message

I attempt to check the return value ;

`

var isShiftOutSuccessful = false;
// […]
// b.shiftOut(sData, sClock, b.MSBFIRST, segments[digit], doLatch);
isShiftOutSuccessful = b.shiftOut(sData, sClock, b.MSBFIRST, segments[digit], doLatch);

`

Setting breakpoints before the b.shiftOut I verify that isShiftOutSuccessful is boolean and false. I step over and isShiftOutSuccessful is now unDefined. Is this a valid way for my code to see the return value? Or do I need some fancy Dan callback fu? I briefly looked at the shiftOut source and don’t see how anything is being returned anyway… ???

I decide to attempt to debug step in to the shiftOut.js however I get an error

`

Could not open file: /usr/local/lib/node_modules/bonescript/src/index.js

The file could not be found on the file system.

`

Yet the file exists.

`

jeffa@beaglebone:~$ ll /usr/local/lib/node_modules/bonescript/src/index.js
-rw-r–r-- 1 debian debian 19675 Mar 1 08:41 /usr/local/lib/node_modules/bonescript/src/index.js
jeffa@beaglebone:~$

`

However it only has a few lines in it relative to this index.js on github which contains the shiftOut.js

I figure it’s time to ask for help.

  • What’s (maybe) wrong with my shiftOut testing?

  • How can I setup cloud9 so I could step in to shiftout for continued debugging?

FWIW I wrote some python using the Adafruit_BBIO.SPI without changing my hardware setup and it is working. Looks like the bonescript shiftOut.js is broken in my setup.

I reflashed with the following image. I’m getting the same results as reported previously with the BeagleBoard.org Debian Image 2017-03-19 . The chip select works, but none of the pins assigned to the shiftout.js work.

`

jeffa@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2017-07-01
jeffa@beaglebone:~$ uname -a
Linux beaglebone 4.4.68-ti-r111 #1 SMP Wed Jun 28 10:06:34 UTC 2017 armv7l GNU/Linux
jeffa@beaglebone:~$

`

I try calling bonescript.js with an absolute path in the require()

`

// read in the BoneScript library
//var b = require(‘bonescript’);
var b = require(’/usr/local/lib/node_modules/bonescript/src/bonescript.js’);

`

Which results in this error;

`

/usr/local/lib/node_modules/bonescript/src/bonescript.js:17
var head = document.getElementsByTagName(‘head’)[0];
^

ReferenceError: document is not defined
at /usr/local/lib/node_modules/bonescript/src/bonescript.js:17:16
at Object. (/usr/local/lib/node_modules/bonescript/src/bonescript.js:24:2)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/var/lib/cloud9/jshiftout.js:8:9)
at Module._compile (module.js:409:26)

`

Any pointers on how to debug bonescript.js I haven’t learned how to stepIn with the debugger without these two errors described. Any suggestions?