Tuesday, January 17, 2017

OpenHAB nginx proxy based on user agent

This post will cover using an nginx server to conditionally proxy_pass to OpenHAB based on if the URL is being requested from the OpenHAB iOS App determined by the user agent of the request.
My setup has 3 machines of relevance:
  • Machine A hosts software known as BlueIris. This software records network enabled camera streams to disk, provides interfaces to review this footage, and can push alerts to iOS apps. This machine is not routable to the internet
  • Machine B is a Raspberry Pi 3 running OpenHAB 1.X. This machine is also not routable to the internet. 
  • Machine C is a Raspberry Pi 3 with nginx acting as a proxy. It has an SSL certificate from LetsEncrypt. It is routable to the internet, having dual homes. 
The desire is to route all traffic to Machine A, unless the request is coming from an application with the user agent containing "OpenHAB". This will be accomplished using "evil ifs". This method works for me, but your mileage may vary.


Sunday, May 31, 2015

Automatic Test Case Generation: Part 1

While discussing software test with a co-worker, we thought it would be interesting to see if we could automatically generate inputs to an arbitrary function to see if we can stimulate every branch and every conditional in an application.

Academic papers and commercial tools exist to do this, but I would like the experience of doing this myself. Additionally, furthering my understanding of programming language techniques, building a virtual machine, and working with Constraint Problem Solvers sounds very interesting.

There will be multiple steps to this process:
  1. Define a simplified programming language to target.
  2. Develop lexer/parser
  3. Develop an interpreter/VM that can:
    1. Evaluate a given function
    2. Run test cases from a file
    3. Provide Statement, MC/DC Coverage statistics
    4. Display in a human readable format
  4. Write a constraint solver. After sufficiently toiling with my custom constraint solver, use a open source constraint solver.
This post will cover Steps 1 and 2. 
First, defining the language. The design factors for this language are:
  • Easy to write & parse
  • Limited types
    • boolean, uint32, int32, float32
    • Types can be expanded as needed, but we will start with a limited set. 
  • Limited operators
    •  'NOT', 'AND', 'OR', 'XOR', 'GT', 'LT', 'EQ'
    • Can also be expanded as needed. 
  • No local variables
    • Support for this could be added, but for now we will skip it. 
  • Limited control flow
    • Allow if/else
    • No loops (for, while). See below rule.
    • Recursion is allowed. See above rule.
With these limited requirements, a sample test script can be created:

Using ANTLR4, a G4 grammar definition can also be created. I am relatively unfamiliar with this tool. I suspect the grammar could be cleaner, but this should be adequate for now. The executionStatement -> evaluationStatement -> operatorStatement part of the tree seemingly should be simplified to operatorStatement, but I don't know how to do this in ANTLR4, yet.

Running this grammar file against our sample, ANTLR4 provides us with a reasonable representation.


In the next part, I will develop a virtual machine to execute this script.  

Sunday, July 8, 2012

Windows 7 STOP 0x7B VMWare resolution

Wanting to get rid of old hardware, I attempted to convert a Windows 7 x64 computer to a VMWare image. VMWare's P2V software would not convert my machine due to a GPT partition table. I manually converted my machine by doing the following after the break

Tuesday, May 8, 2012

Building the SoftRock SDR

This is covers the build and initial testing of my SoftRock SDR Ensemble RX 2. It is an extremely flexible low cost software defined radio. The purpose of buying and building this kit it to better understand the DSP involved in audio and radio applications.

There are tons of free SDR applications, but I'd like to write my own. It isn't my goal to write and distribute a professional SDR application, but to learn the DSP involved in software defined radio.

I absolutely want to implement single side band and AM. These modulations seem easy, and would allow me to listen to 'interesting' ham chatter.
Other than snooping on conspiracy theory chat, I really want to receive the WWV time broadcasts. There are a couple WWV transmitters in the frequencies that I can access, and the timecode modulation seems accessible.

Thursday, February 23, 2012

PCBs at home with Acidic Copper(II) Chloride

What could possibly go wrong?!
It would be really cool to have my projects on PCBs instead of gigantic messes on my breadboard. The problem is at $99 a board getting them manufactured (in the US) is stupidly expensive. Making them at home looks reasonably cheap. I'd like to be able to do as small as 0603 parts at home, so lets see!

Sunday, February 12, 2012

Monday, February 6, 2012

Porting MinSoc to the Nexys2, part 2

So in my last post I expressed some frustration in porting the MinSoc to my board. Here I will resolve the issues I mentioned.