Using UART with bonescript

Hi.
I have a BBB rev C, with Debian 8.3, kernel 4.1.15-ti-rt-r40. I am logged in as a regular user (not root). I loaded BB-UART1 overlay, to activate UART1 (tried to load cape-universal first, then apply BB-UART1, but could not do it both, so I have settled to BB-UART1). I have installed minicom, and uart works just fine (tested with link to a PC, via FTDI cable).
I wrote a script to check the UART, using Cloud9 editor on BBB. the Code follows:
//****************************
var uart1var = require(“bonescript”);
var port = ‘/dev/ttyO1’;
var options = {

baudrate: 9600

};
uart1var.serialOpen(port, options, onSerial);
uart1var.serialWrite(port,‘TEST’);
function onSerial(x) {

if (x.err) {

console.log('ERROR ’ + JSON.stringify(x));

}

if (x.event == ‘open’) {

console.log(‘OPENED’);

}

if (x.event == ‘data’) {

console.log(String(x.data));

}
}
//***********************************

When I run the script I get <ERROR {“err”:“Kernel does not include CapeMgr module”}>, and I don/t know why. Any ideas where to look and what to do?
Do I need to run a “npm install -g serialport”? I understand that bonescript uses the same library, and is already installed.
If there is need for more info regarding the configuration of BBB, just say and will be done.

PS. The BBB will be a remote machine, so all configuration must be loaded at boot or run by scripts at boot by a regular user (not root). The script containing the code for UART will also be running automatically, and serve a web page, using socket.io (the socket.io part seems to work fine).

For the 4.1 kernel, you need the beta version of BoneScript to use the pinmux helpers it understands. I believe the package is:

apt-get install bonescript-beta

sudo apt-get install bonescript-beta fails, unable to locate package on fresh 2016-03-27 lxqt SD card install.

I’d like to give it a try along with node-red (which seems installed and running by default on boot with this image, which is IMHO nice).

Actually, I just started the cloud9 IDE and the blinkled.js example seems to be running without any error messages, so it looks like just the bone101 page is not working in this newest testing image which is my usual “pretending to be a newbie” starting point.

I think the current package name might be: bb-bonescript-installer-beta looking at my listing of installed packages.

I will play around with it some, try to install the node-red Bonescript nodes, and start a new thread if I discover problems.

if cape-universal is loaded, for BB-UART1 just do:

config-pin P9.24 uart
config-pin P9.26 uart

/dev/ttyO1 will now work..

Regards,

if cape-universal is loaded, for BB-UART1 just do:

config-pin P9.24 uart
config-pin P9.26 uart

/dev/ttyO1 will now work…

Regards,


Robert Nelson
https://rcn-ee.com/

Thanh you for your response
I have tried tried that on a fresh install (I manage to brick something on BBB by installing node 5.9) and it works just fine. Now I just have to put it on a script to run at startup.
But the main problem remains with the error from bonescript: <ERROR {“err”:“Kernel does not include CapeMgr module”}> when I try to run the above code.
I did a fresh debian 8.3 install and got kernel 4.1.15-ti-rt-r43, node 0.10.41, npm 1.4.21. After that:
npm install socket.io (in /var/lib/cloud9)
npm install serial port (in /var/lib/cloud9)
apt-get update
apt-get dist-upgrade
npm install npm -g
npm update
Now I have node version 0.10.42, npm version 3.8.3, bonescript 0.2.5, and kernel 4.1.15-ti-rt-r43
I didn’t do a kernel update because I noticed last time that after the update it was set to 40

Actually, the “config-pin P9.24 uart” doesn’t work for me. It needs sudo to do the work. It fooled me the first time because I used it just after a sudo “something” command. I noticed that when I put it in a script and run it.
Still, this isn’t such a big isuue right now, since I can do it wit BB-UART1. The big question is why can’t I use UART1 in bonescript.
Thank you

sudo groups $username | grep dialout > /dev/null
reboot

sudo sh -c “echo ‘BB-UART1’ > /sys/devices/platform/bone_capemgr/slots”
cat /sys/devices/platform/bone_capemgr/slots

0: PF---- -1 ne_capemgr/slots"pploader/bin# sh -c "echo ‘BB-UART1’ > /sys/devic
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-UART1

for kernel's v4.1.x+ you need bonescript 0.5.0-beta3

Regards,

I’m hardly a bonescript expert, only using it to help a friend get started with a Beaglebone, but I don’t seem to see any bonescript functions that use a UART. Is there support for UARTs in the node-js that bonescript is built on? (won’t bet the farm that I’ve got the software layering correct).

I’ve pretty much confined myself to what is documented about bonescript at: http://beagleboard.org/support/bonescript

After a bit of Googling, the bonescript GitHub: https://github.com/jadonk/bonescript suggests that bonescript inherits the serial port stuff from: https://github.com/voodootikigod/node-serialport which I think means a lot of pieces are in play that need to all be the “right versions”. Precisely the type of thing I’m trying to shield my newbie friend from. He hasn’t alluded to any need of a UART interface yet, but I’m curious about how all this stuff works together.

I’ve just started playing with 2016-03-27 and find its bonescript is much improved over what has come before. So far I’ve tested analogRead/Write and digitalWrite/Read and attachInterrupt without spurious error messages, the only minor issue so far is the default pin used for analogRead() in one of the examples seems not to be available on my BBG, but changing it to P9_39 solved it.

node -pe "require('bonescript').getPlatform().bonescript"

returns: 0.5.0-beta-3 on my 2016-03-27 system.

I get the same error on my 2016-03-27 system as you did when I run your serial port script, so the newest testing image doesn’t seem to be a solution. It is kernel 4.1.18-ti-r55

I should add, that I did the config pin commands:

/usr/local/bin/config-pin P9.24 uart
/usr/local/bin/config-pin P9.26 uart

and jumper-ed P9_24 to P9_26 and tested with:
minicom -D /dev/ttyS1

before running dorica’s serial.js script.

What i find really curious is if I change /dev/ttyO1 to /dev/ttyS1 and run the script after saving I get very different errors:

`

Debugger listening on port 15454
/usr/local/lib/node_modules/bonescript/src/serial.js:16
if(m.ports[args.port].path) path = m.ports[args.port].path;
^
TypeError: Cannot read property ‘path’ of undefined
at Object.m.doOpen (/usr/local/lib/node_modules/bonescript/src/serial.js:16:26)
at Object.exports.wrapOpen.newFunction [as serialOpen] (/usr/local/lib/node_modules/bonescript/src/my.js:419:31)
at Object. (/var/lib/cloud9/examples/serial.js:8:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at [object Object].Module.runMain [as _onTimeout] (module.js:501:10)
at Timer.listOnTimeout (timers.js:119:15)

Process exited with code: 1

`

This is way above my bonscript/node-js pay grade :slight_smile:

I don’t think this is the problem. /dev/ttyS1 exists and works with minicom (as root, after doing the config-pin uart commands) /dev/ttyO1 is a link to /dev/ttyS1. While it may not be “optimal” by default the Bonescript and Cloud9 stuff run as root, which I think is a good choice initially as there would be no end to permission problems, especially from Beaglebone users with Windows hosts.

I don’t think anyone should put a Beaglebone or Raspberry Pi, etc. live on the Internet, if you need to do it that’s a whole lot of extra expertise required. OTOH I’m happy with my IOT SBCs running behind a solid firewall for outgoing connections with trusted status among them after setting strong passwords on the default accounts and disabling root login over SSH. If I needed to serve up data to the live Internet from my IOT devices, I’d use a third party website as a middle man – one of the public mqtt brokers would be a good place to start depending how “private” you need to keep your data.

Hi,

I am seeing the same error when trying to read from serial port UART4.
"kernel does not include capemgr module "

Any help please?

I get the same error when I run the script “kernel does not include CapeMgr module” Were you ever able to find a solution to this problem? I am running the same code example using bonescript but no luck.

Your issue might be different, depending on what you have installed, but I'll write down what solution worked for me(I used socket.io and serialport):
- clean install of Debian 8.3(should be the same for newer dists)
- npm install socket.io
- npm install serialport
- apt-get update
- apt-get dist-upgrade
- cd /var/lib/cloud9 npm update

- create config_custom.sh
- nano /usr/bin/config_custom.sh
#!/bin/bash
config-pin P9.24 uart
config-pin P9.26 hart

- set execution rights
- chmod u+x /usr/bin/config_custom.sh
- create service
- nano /lib/systemd/system/config_custom.sh

[Unit]
Description=Config uart1 ex tx pins
After=generic-board-startup.service

[Service]
Type=simple
ExecStart=/usr/bin/config_custom.sh

[Install]
WantedBy=multi-user.target

- enable service
systemctl daemon-reload
systemctl enable config_custom.service

Not positive, but I think you misnamed the file in /lib/systemd/system/config_custom.sh when it should have ended in service.