Pizza-stabilized restaurant tables – a demonstration of restaurant table engineering

PizzaJust returned from a tour of California and came across this piece of engineering at a restaurant at SFO. Sadly, the table designers had chosen to have four points of contact between the table and the floor which is of course a disaster. Apparently, a section of pizza had the correct size and compliance to form a stable interface between the table and the floor. An adjacent table had what seemed like a better design in that a single pole came down from the table to a circular disk base but the base had five points of contact with the floor. A waitress noticed my interest and a more general discussion ensued, causing some hilarity to other patrons. It was explained that I was a nerd (we’d visited CalTech after all) and that seemed to take care of it.

Believe it or not, restaurant table stability is a common subject for discussion here, especially since one of our number is a mechanical engineer and also because we spend too much time at restaurants. So, time to develop a proper (although not very rigorous or perhaps even correct) theory…

Continue reading “Pizza-stabilized restaurant tables – a demonstration of restaurant table engineering”

Linux: setting permissions for USB serial ports using udev rules

USBIt’s pretty annoying that, by default, USB serial devices come up with somewhat restricted permissions. Sometimes adding the user to the dialout  group works, sometimes it doesn’t. The most reliable way to fix this for all time is to add a udev rule but I can never remember the syntax, hence this post…

Continue reading “Linux: setting permissions for USB serial ports using udev rules”

Restarting a Qt app programmatically

I had a requirement to restart some Qt apps remotely. This kind of thing can be a little tricky in a multi-platform environment but of course Qt makes it nice and easy – just four lines of code:

    QStringList args = QApplication::arguments();
    QProcess::startDetached(QApplication::applicationFilePath(), args);

The removeFirst() is needed because the first string in the list is the app name – the result is just the arguments that were originally passed to the app.

Java: converting a float to a byte array and back again

Many physical variables are best represented as floats and sometimes it is necessary to pass these variables across a network link. Floats are very standardized and can be safely passed around between different architectures and operating systems but need to be converted to a byte stream first (something like JSON can send floats as strings but this is pretty inefficient in time and space). In C or C++ this is pretty easy but Java is strongly typed and doesn’t make it easy to convert a float value to a byte stream and vice versa. However it can be done…

public void convertFloatToByteArray(float f, byte[] b, int offset) {
   ByteBuffer.wrap(b, offset, 4).order(ByteOrder.LITTLE_ENDIAN).putFloat(f);

public float convertByteArrayToFloat(byte[] b, int offset) {
   return ByteBuffer.wrap(b, offset, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat();

Using the scp command to copy files between Linux systems

scp is very handy for moving files between Linux systems, especially from desktops to embedded systems and vice versa. However, the syntax is always a challenge. For example, to copy a file from a remote system:

scp <username>@<machine>:<full path to file> .

would copy the specified file to the local directory. So for example:

scp pi@ fred

would copy some file called file into the local directory as a file called fred. The order can be reversed to send the file the other way.

It’s the ‘:’ that causes all the trouble…

Using Git and GitHub with Embedded Linux Systems

I often need to clone a private Git repo from GitHub onto an embedded Linux system for native compilation. The only problem is that, to clone a private repo from GitHub, there must be a public key registered for each system. To do this for every embedded system is a total pain. However, a Linux machine that has the repo on it already can act as a local server very easily.

On the embedded system, clone the repo using this command:

git clone ssh://user@

For example,

git clone ssh://richard@

would clone the repo veryinterestingrepo from the directory /home/richard on the machine at using user name richard. At some point Git will ask for the password for user richard. Once this is entered, the clone should work as expected. Pulls and pushes will work as normal as they use the remote from which the repo was cloned.