Quantum QBits in Silicon?

Quantum Computers (and hence Quantum Software Engineering) may have taken a rather large step forward if (as The Register reports) The University of New South Wales has managed to render a qbit in plain old silicon!

Looks like I will have to start swatting up on my Quantum Algorithms… (I tried this before and it really hurt my head!)

Can’t sync to NTP server when upstream clock is not available

We were doing some software and systems testing this week, this involved setting up a completely isolated network of cameras with their own NTP server for time synchronization across them. The NTP server was configured to broadcast time updates via UDP. Everything worked OK except the NTP server stopped broadcasting once it lost time synchronization with its up-stream clock (which it lost because all connections to external networks were removed).

To resolve this problem and get the NTP server broadcasting again we had to allow it to synchronize with its own internal clock and pretend that it was a stratum 2 time source (accurate timing wasn’t required during this phase of testing).

To do this the following was added to /etc/ntpd.conf (with thanks to this post)

#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 2
#

Once the change is made, restart the NTP daemon:

sudo /etc/init.d/ntp restart

The first line allows us to sync with the local clock while the second line ‘elevates’ it to stratum 2

This isn’t a brilliant time-base but it allowed us to test basic time synchronization scenarios.

WPF Validation Error Disappearing when Switch between visual items

Typical daily trials of a Software Engineer – getting WPF error validation working can be a bit of a pain, it’s a bit buggy.

I hit a problem today whereby errors marked for text boxes on a tab would disappear if you moved away from the tab and then back again, it turned out to be a common WPF problem and this post provided a fix, you just need to wrap your tab content inside an:

<AdornerDecorator>...</AdornerDecorator>

element. Bit of a pain but at least it seemed to work once I put these elements in!

Python script to query NTP status and return it as JSON

Setting up and automatically keeping an eagle eye on NTP from software can be a bit of a (difficult) black art. A common way to query NTP status is to run:

ntpq -p

This returns some NTP status information. It’s output can be a bit difficult to work with from your software, so I have included a small python 3 script which runs runs “ntpq -p” parses, and prints the output in Json format. So instead of shelling out to ntpq you can shell out to this script and deal with the resulting json string instead… This can be handy if you don’t have access to a Python NTP library.

#!/usr/bin/python
#   Copyright 2018 Kevin Godden
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
import subprocess
import json
import re
import sys
# Shell out to 'ntpq -p'
proc = subprocess.Popen(['ntpq', '-p'], stdout=subprocess.PIPE)
# Get the output
stdout_value = proc.communicate()[0].decode("utf-8")
#remove the header lines
start = stdout_value.find("===\n")
if start == -1:
    # We may be running on windows (\r\n), try \r...
    start = stdout_value.find("===\r")
    if start == -1:
        # No, go, exit with error
        result = {'query_result': 'failed', 'data': {}}
        print(json.dumps(result))
        sys.exit(1)
# Get the data part of the string
#pay_dirt = stdout_value[start+4:]
pay_dirt = stdout_value[start:]
# search for NTP line starting with * (primary server)
exp = ("\*((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)"
       "((?P\S+)\s+)")
regex = re.compile(exp, re.MULTILINE)
r = regex.search(pay_dirt)
# Did we get anything?
if not r:
    # No, try again without the * at the beginning, get
    # the first entry instead
    exp = (" ((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)"
           "((?P\S+)\s+)")
    regex = re.compile(exp, re.MULTILINE)
    r = regex.search(pay_dirt)
data = {}
if r:
    data = r.groupdict()
# Output Result
result = {'query_result': 'ok' if r else 'failed', 'data': data}
print(json.dumps(result))

GitHub repo is here.

RuneAudio working with HifiBerry Amp+ on RaspberryPi

Raspberrypi with hififiberry Amp+ and runeaudio hifi

This is a record of how I managed to the RuneAudio v0.3-beta software working with the excellent Hifiberry Amp+. The lads at runeaudio say that software release v0.4 will support Amp+ ‘out of the box’ but v0.3-beta doesn’t and they won’t/can’t say when v0.4 of the software will be released, however with some messing it can be made to work – which is great.

I really like runeaudio, and the sound quality with Hifiberry Amp+ and 2 venerable Monitor Audio speakers is really very good!

Anyway, all of the information required to setup runeaudio to work with the Amp+ can be found in bits and pieces on the runeaudio forum thatnks to everybody there! These steps worked for me during April 2015.

I found I had to add or modify a few steps so I will detail this here. These steps worked for me, but please backup before you proceed in case something goes wrong! To get going first install the runeaudio software for the raspberry pi.

The main set of steps to get Amp+ working can be found in this post by d2000:

http://www.runeaudio.com/forum/hifiberry-amp-t545.html

I just had to add a step or two as follows:

a.) Perform step 1.

b.) Execute:

pacman-db-upgrade

to update the database, this is a new step. Without this I got an error message when I tried to run step 2.

c.) Perform Steps 2 to 13

d.) Edit /boot/config.txt again and place the following line at the end of the file:

dtoverlay=hifiberry-amp

If you reboot at this stage you may find that browsing to runeaudio’s home page produces a 404 error (I did), we fix this in the next step as detailed in this post.

e.) Edit /usr/lib/systemd/system/redis.service and replace its contents with:

[Unit]
Description=Advanced key-value store
After=network.target
[Service]
#Type=forking
User=redis
PIDFile=/run/redis/redis.pid
ExecStartPre=/bin/mkdir -p /var/lib/redis
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecStop=/usr/bin/redis-cli shutdown
Restart=always
RestartSec=1
StartLimitInterval=30
StartLimitBurst=20
[Install]
WantedBy=multi-user.target

f.) Reboot

g.) Visit runeaudio, go to the Settings page and choose ‘HiFiBerry Amp’ in the ‘I²S kernel modules’ drop-down and click apply settings.

h.) Go to the runeaudio’s MPD page and choose ‘snd_rpi_hifiberry_amp’ in the ‘Audio output Interface’ drop-down.

i.) Check that ‘Volume Control’ setting is ‘Enabled – Software’

j.) Reboot

When the system restarts you should be able to play music with software volume control, you will find that hardware volume control won’t work with this set-up, the volume keeps popping back to 100 when you try to set it!

Hardware Volume Control

To get hardware volume control working I did the following, based on the advice in this post:

a.) Execute the following to list the configured sound devices:

aplay -l

The output will look something like this:

**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_amp], device 0: HifiBerry AMP HiFi tas5713-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Try to figure out which is yours, you can see from the output above that mine is device 0, sub-device 0.

b.) Edit /etc/mpd.conf and replace the ‘audio_output’ section at the end with the following, changing the values for ‘device’ and ‘mixer_device’ to match yours:

audio_output {
        name            "snd_rpi_hifiberry_amp"
        type            "alsa"
        device          "hw:0,0"
        mixer_type      "hardware"
        mixer_control   "Master"
        mixer_device    "hw:0"
        mixer_index     "0"
        auto_resample   "no"
        auto_format     "no"
        enabled         "yes"
}

d.) When runeaudio reboots it will revert the changes in mpd.conf so you have to prevent it by making the file read-only, do this at your own peril!

chattr +i /etc/mpd.conf

Then reboot, when the system restarts you should have hardware volume control and nicer sound, you will have to turn the volume up above 20 to hear it.

Links:
Thanks to all at the runeaudio forum!

http://www.runeaudio.com/forum/hifiberry-amp-t545.html
http://www.runeaudio.com/forum/getting-404-not-found-nginx-1-4-7-t909.html
http://www.runeaudio.com/forum/hifiberry-amp-volume-t1078.html

RaspberryPi media player rune aduio, hifiberry amp+

Data Security – How to safely ‘decommission’ and old hard drive and make an attractive ornament at the same time

software engineering ireland data security

Hint: I Pickaxe does the trick!

Interesting article about unikernels

I came across this interesting article about unikernels:

http://queue.acm.org/detail.cfm?id=2566628

It will be interesting to see how all of this change in the cloud shapes up in the future and how it will effect the traditional operating system Jobbing Software Engineer!

DevOps Ireland

DevOps in Ireland? I have been very interested in DevOps ever since I watched Adam Jacob give his ChefConf 2015 keynote speech. I wondered if there are any Irish DevOps groups and a little digging revealed:

Twitter Account: @DevOpsIreland
Website (Empty!): devops.ie
LinkedIn Group: DevOps Ireland

devops.ie must be taking the iterative approach seriously as rev 1.0 of the website is up there alright…. but it’s empty! ;-)

Fascinating DevOps Talk

While browsing The Register, I came across this video Adam Jacob’s keynote speech at ChefTalk 2015 where he introduced DevOps, it’s fascinating stuff and well worth a watch!

What interests me is how methods of software development and deployment are changing so quickly and how this is bringing in new ideas and talent beyond that of the traditional small pool of software developers and engineers.

libexif binaries for Windows and Visual Studio

32bit libexif binaries for Windows (and Visual Studio) which were compiled on Windows using this method, can be downloaded from here. These are unsupported & use them at your own peril, but they work fine for me!

libexif-win32-0.6.21