Is it possible to run node.js on an RTOS? - node.js

I have a 8 core ARM device and I was wondering whether I could use it to build a drone. Does a real time operating system require a specific type or method of programming? Is it possible to use node.js with any of these systems?

In short, yes it is possible to run node.js on RTOS.
About RTOS
You should remove buffer delays. For example, don't block Node.js event loop or don't use Node.js process.nextTick function.
Use event-based approach for better code architecture.
Think like an embedded developer, not like web-developer.
This is an interesting and not trivial job.
About node.js details
As you can see at the link the device has Linux Kernel 4.9 LTS OS.
You can install Node.js and npm modules on Linux Kernel 4.9 LTS OS.
There can be an issue to run native functionality from Node.js. You must have node.js wrapper module in c language. Good example for Raspberry Pi is wiringpi-node
Python can be used as a node.js alternative

Related

How to run node js server on Win CE ARM embedded device?

I have a device that has an ARM processor and runs Win CE OS.
Now I have got a requirement to implement a node js server inside the device.
The same requirement was implemented on another ARM device that was running Linux
Since node is compiled for Linux they were able to run a node js server inside the device.
But there is no Win CE compatible version of node available
Is that not done yet or am i missing something?
I read about Microsoft chakracore, but I didnot understand much.
Does anybody know how to run node on Win CE running devices.
Any kind of leads/help is appreciated. Thanks
Windows CE provides an implementation of the Win32 API that is someway compatible with the full-Win32 version implemented on Windows desktop operating systems.
It also provides C/C++ libraries but, as you know, evil is in the details and those implementations can be considered a subset of those you have on the desktop and missing a single function or feature can force you to re-implement a huge amount of code to work around the limitation.
Windows CE is also meant to run on resource-limited devices with a limited amount of RAM and processing power and, honestly, node.js does not seem to exactly target this kind of platforms.
First I would like to understand if the requirement makes sense and why there is a need to mix a small real-time OS like CE with a huge interpreted and resource-hungry monster like nodejs.
windows CE has not been updated in over 3 years it is unreasonable to expect node.js to work as is on top of CE. windows on arm however (used by windows phone, windows Iot, and the ill fated surface RT) can run this https://github.com/nodejs/node-chakracore. Windows on arm only accepts thumb2 instructions, so you won't be able to use regular node.js.
This is b\c v8 just in time compiler does not produce thumb2 instructions. more reading material here: https://blogs.msdn.microsoft.com/ntdebugging/2014/05/15/understanding-arm-assembly-part-2/

writing node.js raspberrypi programs on windows/ubuntu

I've spent the past two days trying to get the node wiring-pi module running on either windows or ubuntu. It installed no problem on my RaspberryPi, but developing on RPi isn't ideal. After a ton of error messages that don't lead me very close to a solution, I'm beginning to realize that trying to set-up a node module which was designed to run on an ARM processor and getting it working on an x86 machine for development may not be the best idea.
Has anybody else dealt with this sort of thing before? How do you write your ARM based programs in an x86 environment? Developing directly on the Pi has it's own set of issues.
What I was thinking of doing was to require the wiring-pi module like this
var wpi = require('wiring-pi')|| { //recreate the required wiring-pi methods for testing on x86};
however, that would mean my npm install would also fail, or need to be different depending on if I was building directly on the raspberyPi or on the windows/ubuntu x86 system.
Anybody else have another solution to working around these sorts of issues?
I have the same problem, and came to the same realization that trying to get the ARM modules working on X86 was not feasible. Hopefully your Raspberry Pi specific calls are isolated in a module that you can then easily replace on x86. I've not found a more clever solution than that.

Node.js Capabilities for Operating System

What node.js can do on the operating system level?
Like can we building something in node which can control graphic card or speaker, or other device connected via usb?
libuv provides the low-level support for node.js. For anything not available through the node core directly, you can write modules in C++ (linking against the libusb library directly) or use an existing module like https://npmjs.org/package/usb
There's a full list of the builtin modules here. There aren't that many of them to skim through yourself. Most of what you want to do is not built in.
However, if you know C or C++, you can write your own addons that expose native objects to the JS layer. So anything you could ever want to do is possible.
And someone may have already written an npm package for it, so you don't have to. But nobody is going to summarize all 43326 packages to tell you "What node.js can do". You will have to ask for something specific, and search for it yourself.

How to simulate ThreadX application on Windows OS

I have an application using ThreadX 5.1 as the kernel.
The Image is flashed on to a hardware running an ARM 9 processor.
I'm trying to build a Simulator for the application that can be run on Windows (say XP, 32-bit).
Is there any way I can make it run on Windows, without modifying the entire source code to start calling win32 system calls?
You can build a Simulator for the application that can be run on Windows with "ThreadX for Win32".
"ThreadX for Win32"'s specification is hear.
http://rtos.com/products/threadx/Win32
Yes you can if you are willing to put in the work.
First observe that each threadx system call has an equivalent posix call except for events.
So your threadx program can run as a single process using posix threads, mutexes, etc.
Events can be handled by an external library (there are a few out there).
If you find this difficult in windows then the simplest thing to do is set up a linux vm. I use an ubuntu vm running on Virtual Box. It is very easy to set up. All you will need is the cdt version of eclipse.
Next you need to stub out all of your low level system calls.
This is also easier than you might think. For example, if you have a SPI driver to read and write to flash, you can replace your flash with a big array which is quite easy to work with at this level.
Having said all this, you may get more mileage if your threadx application is modular. Then you can test each module on it's own and you don't need to mess with threads, etc.
As a first approximation this may give you what you need without going the distance to port the whole thing to run under posix.
I have done this successfully in the past and developed a full set of unit tests for a module that allowed me to develop and test it (on my mac) before going to the target. Development is much faster and reliable this way.
Another option you may want to consider is to find a qemu project that supports your microprocessor. With some work you can develop a complete simulator for your platform and then run the real firmware under the emulator.
Good luck.

Best linux distribution to do Kernel Module programming

I want to do kernel module programming. But, all sources tell that linux distributions patch the original kernel and that module codes might not run on them. If this is true, what should i do.I tried making lfs using ubuntu but errors cropped up at almost every step. I saw somewhere that arch, gentoo, Ubuntu Server without any packages selected during the installation, slackware, susestudio etc. are vanilla distributions. So, can i use them for module programming?
Please suggest keeping in mind that i need a GUI in the distribution.
Can this be followed?
PS: I have a intel core i3 processor and will be running the distros on vmware workstation.
If you want to program kernel modules then it doesn't matter which distribution you choose. You will need to be able to recompile the kernel from source and install a new kernel yourself. Even just for a kernel module you'll want to be able to compile the latest kernel and develop against that, otherwise you won't be able to get the module accepted in to mainline.
An alternative if the module is not to be released is to develop against a particular kernel version. In this instance then the choice of distribution should be chosen based on the target for the module - not the development environment.
So pick a distribution based on what you like:
1) Desktops - (GNOME, KDE, other)
2) Ease of use - (Ubuntu, Fedora, etc vs Arch, Gentoo)
3) Cutting edge vs Stable (Arch, Fedora vs Ubuntu vs Debian, Red Hat, CentOS)
Then head off to kernelbewbies to learn a bit about getting started with kernel programming (where to get the source, how to compile it). Then read Greg Kroah-Hartman's excellent book on linux device drivers. The interfaces will have changed (it's written about version 2.6 of the kernel and version 3.6 is currently being worked on). It can be found online here
You'll also want to learn how to use git. And more importantly how to use git to generate a patch and email it without messing it up! I don't have a website for this but a bit of googling will help.

Resources