Web-application design on embedded linux - node.js

I am working for a lighting automation company and we will design and develop a product which will implement Yocto/ Buildroot embedded linux operating system.
We will use a Linux SoM inside the product and the specs of the SoM is ~:
1.2/1.5GHz MPU
128/256MB RAM
4/8/16GB eMMC/SD
various peripherals UART, SPI...
At this point, Linux side must implement a Web-Based App, which monitors luminaires and control them etc. In general, project intends to control the lighting of a building/home using the web-app running on the device. Front-end shall show each luminary on the page and relevant buttons and icons help client control and monitor the luminaries. The front-end may have a couple of different pages. Overall there can be max of 250 luminaries and 10-bytes of data for each luminary.
I will have an MCU running beside which does real-time stuff and connected to Linux SoM using UART. The real-time MCU communicates to the luminaries and sends their data to Linux through UART or vice versa. The web-app should start a web-server I guess so that client can connect to the app from his/her PC/Smartphone browser. I also think I will need a database, because device should retain the data once restarted or in case of a power failure.
At this point I am not sure what kind of design should I do. I do not want to create a complex application. I do not want to do over-engineering. We are currently 2 embedded guys and 2 software guys will join us soon. I am an embedded C/C++ guy and although I know how stuff works in a very general sense for Vui.js, React.js etc. I am not really sure how well they will do on embedded linux with restricted sources such as RAM.
I have 3 different designs in my head:
1st ->
Receive data through UART directly using a high-level
language inside web-app backend (Node.js, Flask or ??? if possible)
Web-app backend (Node.js, Flask etc. or ???) either writes
received data to a database (SQLite ??) or executes it directly in a
proper way
Front-end communicates to backend through REST APIs
(Vue.js, React or ???)
2nd ->
Receive data through UART with a plain C executable file (circular buffer etc.)
Web-app backend (Node.js, Flask or ???) receives data through a local socket from
the C file and does database operations etc.
Front-end communicates to backend through REST APIs (Vue.js, React or ???)
3rd -> If flask, vue.js etc. complicates the Linux applications
Receive data through UART with a plain C executable file (circular buffer etc.)
Use lighttpd or similar to start a web-server and use fast-cgi ?
As far as I learnt from the web, with the specs of the SoM I will use, technologies such as Node.js Vue.js can be handled easily and there should be no problem at all. If so, even though it is a quite general question, how to do it in a simple & modern way?

I think the best way is the first.
In this way you build all the system with module so in the future will be easyer to change something.
All the framework you will use is maintained by big company so will live for longer

Related

How does Rabb.it stream broswer windows for users

I am just wondering how rabbit is able to give each user a diffent broswer to use from a linux machine it seems like vnc tech but I dont know please let me know if you know how they are able to do that.
There is a somewhat detailed blog post about what their architecture was here: https://bloggeek.me/rabbit-webrtc-interview/
I will quote the relevant part for longevity:
We have two main stacks, one for audio/video and one for our business
logic:
Our audio/video stack is built in Java on top of Netty:
Our SFU allows us to use WebRTC with much larger groups than the
normal use case. For our shared viewing feature (called Rabbitcast™),
we had to build a native extension to capture and delivery an HD
stream with audio from our virtual machines. Both of them use our own
WebRTC server stack to talk to the clients. Our Business Logic stack
is built on top of Node.js using a promise-based approach to keep our
sanity.
Lastly we use Redis both for intelligent caching and pub/sub. MongoDB
is our persistent storage.
I am not sure about what exactly they are using but I have some ideas how it works yeah as you already said they are using virtual machines that ported to a html5 vnc client to control and stream video and audio. Other options might be using xpra,x2go,apache guacamole to port them into a html5 client again.

EtherCat module :How to communicate with linux

I'am going to communicate EtherCAT master(CX2020) with Linux OS PC(ubuntu) for storing value from PLC on server and writing also.
By EthearCAT network protcol, it should be availave to communicate with windows plc installed twincat.
But I couldn't find the way for Linux.
Is there any solution?
There are various ways for you to communicate with a CX2020 from Linux, it all depends on your requirements and what the usage is for.
Without knowing anything about those, one option is to use the Beckhoff ADS protocol. All Beckhoff PLCs have by default ADS installed on them and you can
(with the right credentials setup for ADS) communicate with the ADS-library. The good thing about ADS is that it is open-source, and thus it's possible to
get the code for Linux.
The ADS sourcecode is available at:
https://github.com/Beckhoff/ADS
You basically need to:
Compile/Install the library on your Linux machine
Create an ADS/AMS-route to your CX2020
Create a program that uses this route to communicate with the PLC
With ADS you can access the variables directly in the CX2020 memory (both read and write!).
There are many finished wrapper libraries available for all common programming languages that you can use directly in Linux. If you're up to Python, I would
recommend checking out PyADS (https://github.com/stlehmann/pyads), which has a good user base and many examples available all around the net.

Micro:bit BBC programming bluetooth

I recently purchased Micro:Bit. I've seen that micro-python and bluetooth cannot be used at the same time due to memory capacity.
Does anyone know if I would be able to build a decent application using the javascript block programming?
The app basically has to do the following:
Read data from acceleretometer.
Acumulate some accelerometer data.
Send the information to another device connected via bluetooth.
Yes, you should be able to write a program for the microbit that does this. the official documentation describes the services that are available. I also found an example which suggests that there is an app which you can use at the phone end if that's relevant to your application.
The micropython restriction is a combination of the BLE protocol stack requiring 12 kB of RAM, and python being interpreted (so having a high RAM requirement).
You can chose the block version or test javascript - and should be able to write reasonably complex programs (even if the text entry might be best done in an editor). As a final fall-back, you can fall back on C/C++ using the microbit DAL (which seems to be built on top of the mbed offline toolchain).

Server and client side programming language and frameworks to use in embedded systems

I am going to implement an easy-to-use and eye-catching graphical user interface for management and configuration of an ethernet switch which has a flash (of just 16 MB) mounted in it, which will have an embedded linux, some specialized softwares, CLI and GUI.
I think, I should go for a web-based graphical user interface so that an admin can access it using the switch's IP. At client side I am thinking of using HTML5 or HTML4 with Javascript as GUI developed in Flex will probably take much more flash space.
However, I don't have a clear idea of server side technology to be used. Should I go for mini-apache for embedded systems with PHP (as I am familiar with Apache+PHP on x86 systems)? or is there a better alternative?
Also, should I go for a MVC type of architecture? Are there some great MVC frameworks developed for embedded systems?
Update:
Basically, I only need to provide a GUI on top of a CLI running on switch. Basic workflow of the application will be something like:
User access GUI through a web interface
User performs an action on GUI
A CLI command corresponding to the action performed is sent to the
server (running on switch)
Server runs the CLI command on the switch
Server returns result of the command back to GUI
You could use an HTTP server library like Onion (in C), GNU libmicrohttpd (in C), or Wt (in C++) to make your own specialized HTTP server (embedded inside your device).
You could also use Ocsigen in Ocaml for the same purpose.
I don't think that embarking a complete HTTP server (apache, or perhaps better lighttpd) with a PHP stack makes real sense on an embedded device (the code stack would be much bigger). On such a device the performance does not matter much (you won't get thousands of HTTP requests per second), but the code space (and process space, ie memory consumption) is quite important. (And the specialized web server solution I am suggesting uses only compiled code, which would run faster than interpreted PHP).
If you insist on having a lighttpd or apache web server in your device -which I believe is wrong-, you could make your application a FastCGI application (and code it in C, C++, Ocaml, ...).
As Simon Richter commented, you could consider making it (also) an SNMP service.

Listening a particular port on linux to access data comes from mobile device

i am newbie to Linux platform, i am working on java technology.
what i have to do is : Having a program that running on mobile devices,that sends some data to my Linux machine, now i have to create a program in java that
listen to a particular port.
access data comes on that port(which is sending by mobile device)
save that data to the database.
response back to the mobile device.
i.e. i would make my Linux system as server that can listen from many clients(mobile devices), but not getting how to configure this environment... :(
i used cent OS 5.4 and
installed jdk1.6.0_24
any help would be appreciated.....
thanx in advance!
khushi
One of Java's greatest strengths is that you can pretty much ignore the host operating system as long as you stick to core Java features. In the case you're describing, you should be able to accomplish everything by simply using the standard Java networking APIs and either the JDBC to access an existing, external database or you could choose any number of embedded Java databases such as Derby. For your stated use case, that you'll be running the application on Linux is pretty much irrelevant (which should be good news... you don't need to learn a whole operating system in addition to writing your app ;-).
Here's a nice client/server tutorial, in that it is broken into steps, and adds each new concept in another step.
Here's another client/server tutorial with much more detail.
I would write it to accept one connection at a time. Once that works, I would study the new(ish) java.lang.concurrent classes, in particular the ExecutorService, as a way of managing the worker bee handling each connection. Then change your program to handle multiple connections using those classes. Breaking it up in two steps like that will be a lot easier.

Resources