Node-Red on FreeBSD

I see that Node-Red is available for Node.js on FreeBSD via npm.

Does anybody know if FreeBSD GPIO pins are supported?

Can I install Node-Red without npm? It seems a security nightmare.

 
Something like the Arduino IDE for FreeBSD GPIO would be really nice. It is truly an easy to use interface.
And you can upload your sketch right from the editor.. Code like syntax.

I can dream right?
 
What I did for OpenBSD was to create a dead simple wiringPi API clone*, wrapping its native (ioctl-based) GPIO API.
That allowed me to port over some fairly popular prosumer Pi/Arduino libraries (motorshield, i2c_soft, mpu6050, etc).

Perhaps the same can be done for these? GPIO is quite simple so it will probably only need ~6 functions wrapped.

(* wiringPi is itself an API clone of Arduino's wiring API for the Raspberry Pi. So my clone is basically a clone of a clone).
 
That is interesting. I tried OpenBSD-76 arm64 this weekend for Rock3A. They actually support it so I got excited.
Unfortunatly PCIe bus was not supported. So that exercise was moot. Nice small footprint OS.

What arm64 board you prefer on OpenBSD?
 
WiringX was been in my area of interest. Making a shim for that would be nice.

I see what you mean about functions needed to convert.
22 functions but how many would really be needed for a translator for node.js/node-RED or similar.
No GPIO config only display like dashboard. Add more functions as proven.

Manu has some python bindings and thats about all I have seen except for gonzos perl bindings.

So does Node.js require java runtime? What serves up the javascript for Node-RED?
 
What arm64 board you prefer on OpenBSD?
Whilst not "officially" supported by OpenBSD, I tend to use the Raspberry Pi Zero 2w which works very well. It requires a slightly different WiFi firmware than the Pi 3 to function but is otherwise identical. I also like the NanoPi NEO2.

Weirdly my favorite (albeit armv7) is the pcDuinov2. Really quite a cheap piece of crap, however once you replace their butchered Ubuntu Linux with BSD, everything works so well. The CPU frequency scaling is pretty spot on too, as is the WiFi.

I see what you mean about functions needed to convert.

22 functions but how many would really be needed for a translator for node.js/node-RED or similar.
If node-red uses WiringPi underneath, then perhaps just coverage of some of these functions?:

https://projects.drogon.net/raspberry-pi/wiringpi/functions/

So does Node.js require java runtime? What serves up the javascript for Node-RED?

node.js doesn't require Java. Node.js bundles an inbuilt web server which should serve the web app. That said, it does have a tendancy to pull in loads of crap dependencies from NPM which in themselves are usually quite unportable or Linux specific. I wonder if there is something like node-red but not engineered in a typical wild-west webdev kind of way.

Maybe something like PiBakery?

Unfortunatly PCIe bus was not supported.

Thats a shame. Its always so frustrating when these devices are missing one or two critical features in an otherwise perfectly good device. Unfortunately my technical skills are nowhere near being able to implement something like this either.
 
So after reading up Node.js uses Chrome aka Google V8 javascript engine.
Node.js is a JavaScript runtime built on Google's V8 JavaScript engine

This 12 year old stack exchange is classic. Well rounded conversation on nemonics.

So Node-RED is a web application built on node.js? What is the runtime?

Node.js is the frameworks and Node-RED is a web application aka runtime ?

So fighting npm would mean chasing dependencies manually right?
That would be the biggest hurdle. Nothing stopping manual/local installation right?
Copying files over like any web server..

Once you figure out the dependencies for the GPIO type installation it should be repeatable.
You could even use a burner VM to see what it needs via npm and manually replicate.


I guess the proper way to make a shim is to work backwards. Look at each Node-RED linux GPIO function and make a FreeBSD equivelent.

# gpio mode pin inputtype
# gpio read pin
# gpio write pin level
# gpio pwm pin level
# gpio close pin

First red flag is PWM. That is a seperate module on FreeBSD.

So these are FreeBSD gpio functions in libgpio without wrappers.

gpio_open

gpio_close

gpio_pin_list

gpio_pin_config

gpio_pin_set_flags

gpio_pin_get

gpio_pin_set


Perhaps optional :

gpio_pin_toggle

gpio_pin_set_name

gpio_open_device
 
I installed node22 and it was only 100MB install. That is not bad and the packages were not offensive.
Code:
New packages to be INSTALLED:
    brotli: 1.1.0,1
    c-ares: 1.33.1
    ca_root_nss: 3.93_2
    icu: 74.2_1,1
    libnghttp2: 1.62.1
    libuv: 1.48.0
    node22: 22.6.0


When I installed npm it took an additional 250MB. Zoinkers that must be one fancy package installer..
It did not like node22 and switched to node20.

Code:
New packages to be INSTALLED:
    gettext-runtime: 0.22.5
    gmake: 4.4.1
    libffi: 3.4.6
    mpdecimal: 4.0.0
    node20: 20.16.0
    npm: 10.8.2
    npm-node20: 10.8.2_1
    python311: 3.11.9_1

Then the real kick in the nuts another 311 packages; not registered with FreeBSD package system.

Code:
 # npm install -g --unsafe-perm node-red

added 311 packages in 11m

60 packages are looking for funding
  run `npm fund` for details
npm notice

So I started with 3.0GB of freespace and now at 2.5GB. I fired off node-red and got a webpage banner from my RockPi4.

It was an experiment to see if it even works on Arm64. So it looks like a success.
 
Back
Top