Making of the Code: A Journey with TCP

A project log for Synthetic Aperture Multispectral Imager

Using a cluster of five raspberry pis, a Flir Lepton and three Raspberry pi NOIR cameras with appropriate filters, an imager was born.

Conrad FarnsworthConrad Farnsworth 08/03/2015 at 21:040 Comments

Welp, better start documenting some of the progress that happened with this camera. To be honest, I didn't think of entering this into the hackaday prize until after we had finished much of the development.

The entirety of the (non-gui) code was written in Python. I chose python for two reasons: 1) There's an addon for everything 2) I'll spend less time debugging syntax errors.

On top of the many advantages of an easy language, what I wanted to do was a perfect fit for a scripting language. Eventually I hope to have the code ported into C or C++, however if that doesn't happen, the machine still works, and has contingencies when it doesn't work. Not optimal, but it produces the stills that are necessary for research.

Now, let's chat about TCP.

Why: Guaranteed, corruption-free delivery

Implementation: Python has a nifty way to create sockets and establish 2 way communication over a network.

Wired Ethernet communication was also going to be the method which files were transferred, so this helped things.

Program flow on slave:

Keep socket open for connection

Read packet (this allows us to reboot, shut down, or take photo)

Take photo (this was achieved using the os.system feature of python)

Send photo over SCP

Wait for another packet

Development of this was of course, fairly straightforward. In order to allow for SCP to occur, I shared the fingerprints of all of the slaves with the master. This allowed for password-less interactions between the devices.

One of the more serious issues we've been having was actually taking the pictures. Ideally, the cameras take several seconds to be activated, take a picture, and have a .jpg file produced. This had to be accounted for in the code in the form of a delay. This is not perfect, but it works.