node-serialport O/S requirements - node.js

I need to be able to read the serial port from within my JS code. I recently stumbled across this component
https://github.com/voodootikigod/node-serialport
What are the requirements for the client computer O/S?
To install it, all it says to do is
npm install serialport
What is that? Where should this command be run? More details would be appreciated.
Thank you

The module you've pointed out is for node.js an event-driven Javascript application server. The emphasis here is that node.js is server-side, not something that runs in a browser.
The command you've pointed out invokes npm, a package manager for node.js. You would need to execute that command on the server where the code expects to run.
While only the author of the code will be able to give you an authoritative answer, a quick review of both the Javascript and the C++ code doesn't seem to reveal anything that's platform specific.
Well, as long as you can compile that C++ code. That looks to be a problem if your server is on Windows.
The library seems to want to treat the serial port as a regular file. While this should be an obvious way to do it if you're on a Unixish operating system (Linux, BSD, Solaris, OS X, etc -- though I don't think Macs have had serial ports in a few decades), it's not immediately clear or obvious if you can just ask Windows to open COM1 and have it work correctly.
So, chances are that you'll have a much larger chance of success if you're hosting this on a Unix than on Windows.

Related

How do I use the "nwjc" versions for Mac and Linux, on Windows?

NW.js has this feature it calls "Protect JavaScript Source Code": https://nwjs.readthedocs.io/en/latest/For%20Users/Advanced/Protect%20JavaScript%20Source%20Code/
The JavaScript source code of your application can be protected by compiling to native code and loaded by NW.js. You only have to distribute the compiled code with your app for production.
JS source code is compiled to native code with the tool nwjc , which is provided in the SDK build.
The compiled code is not cross-platform nor compatible between versions of NW.js. So you’ll need to run nwjc for each of the platforms when you package your application.
I downloaded the SDK distributions for Windows, Mac and Linux, and looked into the files inside them.
The Windows one has a "nwjc.exe" file, ready to be used and works. Good.
But the Mac and Linux ones have no .exe, but instead just a "nwjc" executable. This is obviously for running on macOS and Linux, respectively. Huh?
My used OS is Windows. I am developing my NW.js application on Windows, to be distributed on Windows, Mac and Linux. And I cannot run those Linux/macOS executables on a Windows system. But I have to do so, since they are for some reason not cross-platform.
This seems like a dead end to me. I either have to not "protect" my application (and thus have it stolen/copied/broken/hacked), or buy two separate computers (one expensive Mac and one PC for Linux) and do this step on those. Which of course defeats the whole point of "simple" cross-platform development.
Before you say so, I have tried running Linux in a VM and it's terrible. And Macs cannot even be legally emulated AFAIK.
Most likely, this is going to cause my application to be Windows-only, which is really sad since a major reason for going this route was to have "simple" cross-platformness which "just works".
Is there something I'm missing about this?
PS: I already do "crush" my code with Uglify-JS, before the "protection" stage.
The source protection works by saving a copy of the application as it is currently running in the OS's memory. This means you must run the command on the actual operating system, so it can load the app into memory and then save it as a V8 snapshot (V8 is the JS engine used by Chromium/Node/NW.js).
You can use tools like VirtualBox or VMWare to emulate other OS's on Windows. Getting OSX to run in an emulator is a pain, but there are youtube tutorials to explain how. Linux is very easy though, I'd start there if you are unfamiliar. Though running your application on actual hardware and manually testing in each OS is always best.
If this is too cumbersome, then you may consider not worrying about source protection until later. You can still set up your app for distribution on the other OS's without needing to emulate them if you don't use this feature. Though again, always best to manually test on each OS.

Programming for Linux on Windows

I am in a strange scenario, where I must use a work windows 8 desktop how ever I am writing code to be run on a real time Linux machine. I am writing code for a Real-time system, so will need to implement many non-windows headers like RTAI and such. Obviously I can not run these on windows 8, so was curious if anyone had any suggestions for compiling and testing without having to upload code to the RTOS based computer I am programming for each time I want to run a program. I unfortunately can't use a virtual machine and would like to avoid coding in the terminal in order to remotely code on the linux machine.
Any suggestions?
You can code in Windows or whatever OS you like, what system your programming computer uses has absolutely nothing to do with the target system.
The cross compiler you are using must obviously be for the intended target system. Same goes for debugger & program download tools. Your program must either run in a simulator or it must run on the real target. The latter is strongly recommended.
So all you have to do is to acquire the right software tools. Since these are almost always written for Windows, that should be easy.

RPC from Windows to linux

Is there some (working) example how to create RPC from windows to linux?
Client should be windows NT application, server is linux.
It needs to be MSRPC.
No Corba, no XML-RPC, SUN-RPC etc
MSDN says this:
RPC can be used in all client/server applications based on Windows
operating systems. It can also be used to create client and server
programs for heterogeneous network environments that include such
operating systems as Unix and Apple.
Unfortunately after spending few hours on google I'm giving up.
My expectation:
Linux node should have samba installed, because their MSRPC implementation works.
Using IDL file I generate stubs for both client and server
Client is built using MSVC
Server is build using gcc with some includes/libraries from samba (or other libs)
Linux node must have such RPC port mapper
Can someone point me out?
I think you have 2 possible ways to deal with this:
1- You can try using DCOM with wine, which means that you will actually write your code for windows, but at the same time you can test your results in the process and avoid using WinAPI calls that wine is not able to handle properly. This approach will allow you to generate stubs code from your IDL files.
2- You can try using Samba RPC Pluggable Modules, but I am afraid in this case the RPC communication will be more primitive.
Edit:
It seems there are many other ways. I found a list of libraries in DCOM-Wikipedia, j-Interop for example looks particularly promising.

Porting windows application to linux

I have an application which I need to port on Linux. I was thinking to use Free Pascal the problem is the application uses Windows API's to perform tasks such as serial port communication etc... Is there a msdn for linux users or a book covering how linux works internaly if there are apis.
I am very confused.
Well, it's sad to say but if your code in very Windows-dependend (not VCL depended!) then probably it'll be faster to write the application from the begining rather then porting it.
But if it's only serial port matter then give a try to multiplatform SynaSer library, find it here: http://synapse.ararat.cz.
hope this help :)
Robert Love has a book on Linux Systems Programming - that will cover this area and Love's books are generally good, so it is worth looking at.
It's not entirely clear from your question, but if your concern is that there are specific calls to hardware controlling functions in your Windows application that make it difficult to port I would suggest that is a misplaced fear. Both Windows and Linux operate on the principle that the application level programmer should be kept away from the hardware and that all that should be handled by the operating system kernel and only be accessible to applications via system calls. As the kernels of different operating systems face similar demands from users/applications, they tend to have system calls that do the same sorts of things. It is necessary to match the system calls to one another but I can see no reason why that should be impossible.
What may be more troublesome is that your Windows application may rely heavily on the Windows executive's windowing code/API. Again finding analogues for your code is not impossible but is likely to be a bit more complex e.g. in Linux this stuff is generally not handled in the kernel at all (unlike Windows).
But then again, your code may be written against a portable toolkit/library like Qt which would make things a lot easier.
Good luck in any case.
If the program contains GUI code you must use linux libraries like GTK/XLIB in order to create windows, forms, buttons, etc...
Windows specific functions (like EnterCriticalSection, WaitForSingleObject or _beginthreadex) must be replaced with equivalent linux api functions (a nice tutorial can be found here:
"www.ibm.com/developerworks/systems/library/es-MigratingWin32toLinux.html") or you can use libraries such as w2lpl or wine
A useful library for this kind of problems i've found at http://www.adontec.com/windows-to-linux-port-library.htm
I've had great experiences just using WINE. (https://www.winehq.org/)
You don't really port your app at all. You just make sure it doesnt violate some of the basc constraints of WINE and just run it as is. WINE (though is says it is not) is an emulator of the windows API's and will just do the translation for you. It's pretty complete in its coverage of the API's.

Remote Linux Server setup plan

I have an old computer with formatted drive lying around collecting dust, now I want to instal a linux like OS (any suggestions?) on it and install a web server, preferrably Lighttpd. I want to set up a server so that I have an environment to practice web development in PHP or Java. My problem is I dont want to hook up another set of keyboard/mouse/monitor to that old computer, and if possible I want to remote boot/shutdown the server from this computer that I use to type this question.
I did some google search, but the results are never comprehensive or suitable for my circumstance. Any input would be appreciated, book recommendation or link to a good resource are fine too.
Thanks
Qin
P.S. I did some search on stackoverflow before asking this question, if there is another similiar question being asked, let me know.
You actually needs an unattended (silent) linux installation, which may trigger beeps to tell you when the installation is done. Hope this can help you refine your search on google.
You'll definitely need at least a monitor or KVM and a keyboard if you want to install any OS on it.
For server OS, you could try going for CentOS / Ubuntu. However, if your requirement is just to practice your PHP and Java, you could even use your existing laptop / PC and, assuming windows, you can just install wamp or xampp, to install your apache/php/mysql with just clicks.

Resources