Porting NodeJS from Windows to Linux

Porting Problem Summary:
Getting the right versions of node & serialport installed
Uninstalling Node
Getting the node.js program to run automatically
Getting the program to not shutdown upon disconnect

Changing the port designation
Changing the code due to node.js version differences
Changing the permissions to the USB port
Make int he changes stick between reboots

 

 

For 2 years now, I’ve been running my data collection server on a windows laptop. This machine has one significant flaw. There is no battery in the laptop and when we have a power glitch, the machine does not reboot. This has caused loss of data, sometimes for quite a while.

Recently, I tried to boot my ancient tower PC that contained our 2 Tb backup drive. It was dead as a doornail. I suspect the power supply got hosed somewhere along the way. I generally keep the machine off but plugged and maybe it got hosed by a surge. In any case, I did not have a replacement power supply and it was time to kill the beastly machine anyway.

Do, why not take the drive ot of the machine, and make it available as a NAS storage device? I have an old and unused/unloved toshiba netbook that I had configured as a chromebook but my son refused to use it due to the speed.

I installed Ubuntu v16 on the box, and setup samba to share the USB connected “backup” drive on my (mostly) windows network in the house.

I had a drive to USB adapter lying around along with an external power supply for the drive.  The install went ok with some learning curve on setting up samba, a USB device etc.

Then came the fun for setting up Node.js
So I used the standard Apt-get command and got node running. Then I installed npm. However, my IOT system requires the serialport package for talking to the zigbee device. I installed the latest version of serialport but the system was not running.

How to get my code into the linux machine?
I did not have an ftp server anywhere that I could either push or pull the code to the system. A bit og googling and I discovered sftp runs against Ubuntu. A bit more googleing and Discovered PUTTY has windows version of the utility.

I could not remember the ftp command for changing the local directory for the source file (I think it’s lcd)
Ok so I got the code up on the server and immediately it was not running and giving classically bad error messages. I first realized that the port designation from windows was irrelevant (COM6) and I needed the linux equivalent. I’m not a hard core Linux person so some googling led me to ttyUSB0. Next, I was getting an error after changing that and after a little though and some understanding of Unix permissions, thought it could be permissions, and do changed the Port permissions to 666. That solved the serioal port issues I was having

My first challenge was in finding the name of the serial port in Linux as m