HASSP Software: Linux and SQL Server and More

In my previous blog post, we looked at all the hardware that runs the HASSP module. These components power and analyze the capsule, but what about the rest of the setup: the software. In this post, we’ll take a tour of our system installation, SQL Server instance, and custom code that makes this all work.

Operating System: Ubuntu 16.04.2

The Joule probably could  run Windows 10, but should it? After all, we only have 4GB of RAM and not a lot of storage. So for a small installation like the one we have here, Windows just wasn’t going to work out. Instead, we opted for the Ubuntu Server distribution of Linux. It’s small (< 800 MB), it sips power, works wonderfully with the hardware on the Joule.

Yes, Linux. Ever since Microsoft announced Linux support back in March of 2017, I’ve been waiting for this moment. There’s been lots of blog posts and speakers showing off how to install SQL Server on Linux (and not to mention Microsoft’s documentation pretty much puts it in easy-to-follow steps), but I haven’t as yet seen anyone actually showing anything off that runs it. One of our goals of the project was to highlight the full capabilities (and possibilities) of a SQL Server running Linux, and that’s what we’re doing here.

Recent updates to the Linux version of SQL Server include SQL Agent, which means we can use that to do what every person running SQL Server should do: run backups. Since the Joule has a MicroSD card slot in addition to it’s internal storage, we’re going to configure regular backups of the data in-flight. I figure if this thing craters, the thing most likely to survive is a MicroSD card.

The HASSP Software: Node.js

Another big plus of running Linux is that getting open source software to run on the device is pretty easy. That’s great, because we wanted to keep our code pretty simple, too. We chose node.js as our platform. If you’ve not used or heard of it, just think of it as a JavaScript framework that runs outside your browser. Like most languages, there are libraries that let you talk to SQL Server as well.

There’s one other big reason to choose node.js, though, and that’s npm. npm is the node package manager. Just like package managers in Linux, this enables you to pick and choose existing node/JavaScript modules to install in your projects. And it’s because of node and npm that we were able to really kick-start our sensor development.

Installing node.js in Linux is done pretty much like every other software package you install. Using your package manager du jour, you run a command similar to:

(Note: if you’re installing this on a desktop version of Linux, you might already have build-essential installed)

Sensor Library: Johnny-Five

Aside from my SQL Server Easy Button Project, the only other time I’ve written software that interfaces with electrical components has been just stock Arduino sketches. The Joule has an integrated GPIO interface, but we struggled mightily in trying to get it to work. In the end though, we had a thought: since most Arduino boards have a USB port, it should be possible to stream data from an application running on it to a host device. Turns out not only is it possible, there’s already an amazing JavaScript API library to do just that: Johnny-Five.

Johnny-Five is a JavaScript-based Robotics and IoT platform that runs on node.js. Using npm, you install it to your system. Once you have your Arduino board configured to run a specific firmware, the API talks to your board via USB and can interface with all your components with easy to use classes. J5 was a boon to our development, since it let us focus more on design and less on code. They have a ton of integration; if you’re looking for a fun project this might be where you start.

Installing Johnny-Five is pretty easy. From a command line, it’s essentially:

Source Code Management: GitHub

Of course we’re using Git and Github. Our software repository is out here: https://github.com/drewfurgiuele/HASSP Take a look at the code for yourself, and let me know what you think. This entire project was designed to be open source from the start, so take my code. Use it, abuse it, I don’t care! Go create!

Service Watchdog: PM2

So now we have our operating system and our software, the big question remains: how do we actually get it to run on the device? It’s not like we’re able to hook up a monitor and keyboard to the HASSP once it’s ready for flight. Instead, we opted to use PM2. PM2 is a node-based process manager. It can be configured to run at startup as a service in Linux, and you can specify which programs you want it to run, and when.

Our thought is that if, for whatever reason, the software stops responding or the hardware shuts down in flight, we want it to restart. When it does, we want our data collection to resume. PM2 should manage that for us.

Setting up PM2 is easy, and you install it via npm:

Once installed, you can specify a specific node application to run. You can find more info over on their web site.

Flight Ready

We’ve been continuously improving and adding to our software over the past couple of months, and we have a rock-stable, easy to configure and use platform. Again, this all wouldn’t be possible if it weren’t for Microsoft’s commitment to Open Source. After all, this is the High Altitude SQL Server Project. Now that you’ve seen the hardware and the software that makes this thing tick, it’s time to fly it. Make sure you stay tuned to my twitter feed or this site for announcements. We’ll have some launch day streams we’re going to run. Thanks for reading!

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *