home scroll deno

Current Developer Documentation

Steps to add AutoLevel to cncjs

Instructions apply to cncjs version 1.10.3 and development under Ubuntu 22.04

install nvm

cncjs 1.10.3 will only run with node version 14.
nvm allows to choose the node version.

https://linuxhint.com/ways-install-use-nodejs-ubuntu/

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

log out and back in so that .bash_rc is run

List available versions:

nvm list-remote

Install node

Install node version 14 by
nvm install 14
To make sure that the correct version of node is used,
we can set the default node version for the system:
nvm alias default 14
You have to logout and back in for it to take effect.

Install yarn

Install yarn:
npm install -g yarn

Retrieve the source code

Clone the original cncjs repository to your local computer
git clone https://github.com/cncjs/cncjs.git

Initial project install

yarn

Initial project build

Important!
First change node version to 14
nvm use 14
Then
yarn build

Steps to run cncjs

Testing without Arduino board

https://cnc.js.org/docs/faq/#testing-without-arduino-board

Arduino Serial Port Permission

Arduino Mega is connected and port appears as /dev/ttyACM0
However, error message appears as
Error opening serial port
home

https://www.arduino.cc/en/Guide/Linux#toc6

Test current permissons:
ls -l /dev/ttyACM*
gives
crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0
so root is owner.

Solution: add our user to the group:
sudo usermod -a -G dialout user

To put the change into effect:

logging out and back in should theoretically work,
but in my case, only rebooting worked.

Analyzing Program Structure

The basic structure of cncjs is as follows:

server side

The server is started by opening a terminal in the root directory of cncjs and calling
bin/cncjs
In bin/cncjs:
require('../dist/cncjs/server-cli');
In ./dist/cncjs/server-cli.js:
require('./server').createServer({
in ./src/server/index.js:
import app from './app';
const createServer = (options, callback) => {
const app = express();
in ./src/server/app.js:
const appMain = () => {
app.get(urljoin(settings.route, '/'), renderPage('index.hbs', (req, res) => {

client side

The build process generates a file named ./dist/cncjs/app/index.hbs.
It is the file that the client browser loads.
In it, various bundled javascript files are loaded.
Components
The components of the html body are in ./src/app/containers
for example, ./src/app/containers/Header/Header.jsx