<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kemp's Blog</title><link>https://blog.kempj.co.uk/</link><description>Recent content on Kemp's Blog</description><generator>Hugo</generator><language>en-gb</language><copyright>Copyright &amp;copy; John Kemp</copyright><lastBuildDate>Wed, 20 May 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.kempj.co.uk/index.xml" rel="self" type="application/rss+xml"/><item><title>DeviceMaster protocol, part 3: TCP protocol outline</title><link>https://blog.kempj.co.uk/2020/05/devicemaster-protocol-part-3/</link><pubDate>Wed, 20 May 2020 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2020/05/devicemaster-protocol-part-3/</guid><description>&lt;p&gt;With the UDP side of the protocol out of the way I moved on to the TCP side, which is used to actually communicate with the device (for example to use one of the serial ports).&lt;/p&gt;</description></item><item><title>DeviceMaster protocol, part 2: UDP fields</title><link>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-2/</link><pubDate>Wed, 22 Jan 2020 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-2/</guid><description>&lt;p&gt;We ended the last post having split up the UDP scan/refresh response into individual fields, with each consisting of a value identifier, a length, and the actual content of the field. Now we come to deciphering the meaning of those fields.&lt;/p&gt;</description></item><item><title>DeviceMaster protocol, part 1: UDP protocol</title><link>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-1/</link><pubDate>Mon, 20 Jan 2020 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-1/</guid><description>&lt;p&gt;The DeviceMaster range, at least with current firmware and drivers, uses a UDP-based protocol for discovery. The obvious first step, then, was to start Wireshark and log a few scans performed via PortVision DX. The Scan function within PortVision DX sent messages of the following form to the UDP broadcast address 255.255.255.255 on port 4606:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;a9 8d fd 53 7a 1c b0 de 00 00 2c 00 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A lot of zeros there, not much to go on. Performing more scans showed the the 0x2c in byte 11 was incrementing, so this was presumably a sequence number of some kind. Leaving PortVision DX open overnight showed that it was a 16 bit count in little-endian byte order. The 0x0c byte could be specifying a function&amp;mdash;in this case a scan.&lt;/p&gt;</description></item><item><title>DeviceMaster protocol, part 0: My device and software</title><link>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-0/</link><pubDate>Sat, 18 Jan 2020 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2020/01/devicemaster-protocol-part-0/</guid><description>&lt;p&gt;This is the first post of a short series describing my effort to reverse engineer the protocol used by Comtrol for their DeviceMaster range of Ethernet device servers. These allow RS-232/422/485 connected devices to be communicated with over an ethernet network.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/DM-RTS-8Port-DB9.jpg" alt="DeviceMaster RTS 8-Port DB9"&gt;&lt;/p&gt;</description></item><item><title>Error building grep for OpenEmbedded</title><link>https://blog.kempj.co.uk/2015/09/error-building-grep-for-openembedded/</link><pubDate>Tue, 29 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/error-building-grep-for-openembedded/</guid><description>&lt;p&gt;This is another error related to using a newer version of texinfo than expected. It’s also another “wait for it to fail and then edit in the working directory” solution unless someone can provide a better option.&lt;/p&gt;&#10;&lt;p&gt;Once the build has failed with the following message:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;grep.texi:291: @itemx must follow @item&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;open up &lt;tt&gt;$GUMSTIXTOP/tmp/work/x86_64-linux/grep-native-2.5.1-r2/grep-2.5.1/doc/grep.texi&lt;/tt&gt; and delete lines 286 to 290 (inclusive). Side-effect: your generated documentation will no longer be perfect.&lt;/p&gt;</description></item><item><title>Error fetching packages for OpenEmbedded</title><link>https://blog.kempj.co.uk/2015/09/error-fetching-packages-openembedded/</link><pubDate>Thu, 24 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/error-fetching-packages-openembedded/</guid><description>&lt;p&gt;For my third post on compiling OpenEmbedded for Gumstix on a modern system, we come across errors downloading base-passwd, busybox, curl, dosfstools, fakeroot, file, gconf-dbus, git, iana-etc, ipkg, ipkg-utils, libxml-parser-perl, libxml2, mime-support, module-init-tools, netbase, openssl, pax-utils, pcmciautils, popt, pxaregs.c, setserial, sysvinit, tinylogin, tslib, udev, update-alternatives, update-rc.d, usbutils, util-linux, and zlib.&lt;/p&gt;&#10;&lt;p&gt;This is a simple problem and a simple fix: old versions of these packages are either moved to a different location or removed entirely, so we change the URLs that the build process uses. &lt;strong&gt;Beware: using alternate sources for these packages carries an inherent risk – you may be downloading a modified version without knowing. Where possible you should also add hash entries for each file based on a known good value.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>gcc error building Python in OE</title><link>https://blog.kempj.co.uk/2015/09/gcc-error-building-python-in-oe/</link><pubDate>Thu, 24 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/gcc-error-building-python-in-oe/</guid><description>&lt;p&gt;This error message provides very little clue as to what the actual problem is when compiling Python during the OpenEmbedded build process:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;gcc: error: directory”: No such file or directory&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;As it turns out (thanks to the tip &lt;a href="http://www.probableanswer.com/anwsers/321875/python2-5-with-the-Raspberry-Pi"&gt;here&lt;/a&gt;), this is caused by a change in subversion.&lt;/p&gt;&#10;&lt;p&gt;Luckily it’s easy to inject your own copy earlier in the path than the one it usually finds. Simply create a script called &lt;tt&gt;svnversion&lt;/tt&gt; in &lt;tt&gt;$GUMSTIXTOP/bitbake/bin&lt;/tt&gt; and insert the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo exported&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your problem should be solved.&lt;/p&gt;</description></item><item><title>Missing find.pl compiling OE</title><link>https://blog.kempj.co.uk/2015/09/missing-find-pl-compiling-oe/</link><pubDate>Thu, 24 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/missing-find-pl-compiling-oe/</guid><description>&lt;p&gt;I received the following error when compiling OpenEmbedded due to a file that is no longer included in Perl distributions:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;| Can’t locate find.pl in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at perlpath.pl line 7.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;There are ways to integrate a copy of the file into the build process, but my inexperience with bitbake et al. meant that when they didn’t work I couldn’t troubleshoot very well myself. Instead, I simply placed the file in /etc/perl. The contents of the file, which should be called find.pl, can be found below.&lt;/p&gt;</description></item><item><title>binutils errors compiling OE</title><link>https://blog.kempj.co.uk/2015/09/binutils-errors-compiling-oe/</link><pubDate>Wed, 23 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/binutils-errors-compiling-oe/</guid><description>&lt;p&gt;The second problem I encountered in building OpenEmbedded for our Gumstix devices was a failure when downloading binutils. Specifically, the checksum found for the downloaded file didn’t match the one that the build process expected. The message given is:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;NOTE: The MD5Sums did not match. Wanted: ‘9d22ee4dafa3a194457caf4706f9cf01’ and Got: ‘ccd264a5fa9ed992a21427c69cba91d3’&lt;br /&gt;&#10;NOTE: Task failed: Checksum of ‘ftp://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2’ failed&lt;br /&gt;&#10;NOTE: package binutils-cross-2.18-r1: task do_fetch: failed&lt;br /&gt;&#10;ERROR: TaskFailed event exception, aborting&lt;br /&gt;&#10;NOTE: package binutils-cross-2.18: failed&lt;br /&gt;&#10;ERROR: Build of /home/kemp/gumstix/gumstix-oe/org.openembedded.snapshot/packages/binutils/binutils-cross_2.18.bb do_fetch failed&lt;br /&gt;&#10;ERROR: Task 317 (/home/kemp/gumstix/gumstix-oe/org.openembedded.snapshot/packages/binutils/binutils-cross_2.18.bb, do_fetch) failed&lt;br /&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;The error is due to an incompatibility between older versions of binutils and newer versions of texinfo. This post show you how to resolve this.&lt;/p&gt;</description></item><item><title>patch version error compiling OE</title><link>https://blog.kempj.co.uk/2015/09/patch-version-error-compiling-oe/</link><pubDate>Wed, 23 Sep 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/09/patch-version-error-compiling-oe/</guid><description>&lt;p&gt;I have had to check out our Gumstix stock and find out if it’s still usable. They are a mix of old Connex and (non-Pro) Verdex boards and so the only OS I can build for them is OpenEmbedded. I have yet to find out if the currently available version from the Gumstix website actually works with these versions of the boards, but one step at a time…&lt;/p&gt;&#10;&lt;p&gt;This post walks through how to solve the following error message when building OpenEmbedded on modern systems:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;| configure: error:&lt;br /&gt;&#10;| quilt requires at least version 2.4 of GNU patch. You can download a&lt;br /&gt;&#10;| current version of patch from ftp.gnu.org, or if you already have GNU patch&lt;br /&gt;&#10;| then you can supply its path with the ‘–with-patch=’ option.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>OpenModelica vs Dymola: connect</title><link>https://blog.kempj.co.uk/2015/03/openmodelica-vs-dymola-connect/</link><pubDate>Mon, 09 Mar 2015 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2015/03/openmodelica-vs-dymola-connect/</guid><description>&lt;p&gt;In general, I target Modelica simulation at OpenModelica for the simple reason that it’s free for me to run anywhere. Having had to retarget one of the simulations at Dymola, I encountered a few differences. This post gives a quick overview of one such difference in using the &lt;code&gt;connect&lt;/code&gt; function.&lt;/p&gt;</description></item><item><title>Fixing webcam after Ubuntu 14.04 upgrade</title><link>https://blog.kempj.co.uk/2014/11/fixing-webcam-ubuntu-14-04-upgrade/</link><pubDate>Sat, 08 Nov 2014 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2014/11/fixing-webcam-ubuntu-14-04-upgrade/</guid><description>&lt;p&gt;After upgrading to Ubuntu 14.04 (Trusty Tahr), my wife found that her webcam (integrated into a Dell monitor) was no longer available in Skype and other applications. The microphone was available, so the USB connection to the monitor appeared functional. The problem turned out to be that she was not in the video group, which is required in order to access webcams. The following command resolved this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo adduser user video&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(replace &lt;tt&gt;user&lt;/tt&gt; with your own username)&lt;/p&gt;&#10;&lt;p&gt;After this you will have to log out and back in and then you should have access to your webcam.&lt;/p&gt;&#10;&lt;p&gt;I’m not sure if this also applies for a new install, so if anyone can confirm/deny then that would be great.&lt;/p&gt;</description></item><item><title>Packaging a Python app for Windows</title><link>https://blog.kempj.co.uk/2014/10/packaging-python-app-windows/</link><pubDate>Sat, 11 Oct 2014 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2014/10/packaging-python-app-windows/</guid><description>&lt;p&gt;This post gives an overview of the steps to package a Python application for distribution to Windows users in such a way that they don’t have to worry about installing Python, additional modules, and so on. This is significantly more convenient if they are not an experienced computer user, or if they simply have no need for Python otherwise. My particular approach is based around a combination of PyInstaller (to create a Windows executable) and NSIS (to create the installer). I’m not an expert in this and in fact this is my first experimentation outside of py2exe, so your own judgement should be applied. However, this technique worked for me and seems to have been used by people previously (for example, &lt;a href="http://stackoverflow.com/a/106756"&gt;this Stack Overflow answer&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>Modelica external C functions</title><link>https://blog.kempj.co.uk/2014/06/modelica-external-c-functions/</link><pubDate>Thu, 26 Jun 2014 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2014/06/modelica-external-c-functions/</guid><description>&lt;p&gt;This post looks into getting external functions working in OpenModelica and, to an extent, Dymola. There are a couple of approaches and I hope to give you a better idea of what to look out for when you come to implement your functions.&lt;/p&gt;&#10;&lt;p&gt;You may have noticed that my series on Modelica socket communication stalled somewhat after only &lt;a href="https://blog.kempj.co.uk/2013/12/20131216-modelica-socket-communication-part-1-socket-library/"&gt;one part&lt;/a&gt;). Originally, this post was going to be part 2 of the series, but it has become somewhat more general, so I’m posting it as a separate thing.&lt;/p&gt;</description></item><item><title>Plotting hardware stats via plotly</title><link>https://blog.kempj.co.uk/2014/02/plotting-hardware-stats-via-plotly/</link><pubDate>Thu, 06 Feb 2014 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2014/02/plotting-hardware-stats-via-plotly/</guid><description>&lt;p&gt;I recently signed up to try the beta of &lt;a href="http://plot.ly/"&gt;Plotly&lt;/a&gt; and decided to try it out by plotting the temperature, CPU load and RAM usage of a Raspberry Pi. Temperature, particularly, was of interest to me as I intend to stream video from the camera module, which makes heavy use of both the GPU and CPU. Plotly provide a &lt;a href="https://plot.ly/api/python"&gt;Python API&lt;/a&gt;, which suits me perfectly.&lt;/p&gt;</description></item><item><title>Modelica socket communication (Part 1: socket library)</title><link>https://blog.kempj.co.uk/2013/12/20131216-modelica-socket-communication-part-1-socket-library/</link><pubDate>Mon, 16 Dec 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/12/20131216-modelica-socket-communication-part-1-socket-library/</guid><description>&lt;p&gt;Now that I’ve demonstrated a method of using the OpenModelica CORBA interface to set up and run simulations, I will move on to a way of passing data out of and in to a running simulation (for example, to use a control algorithm that is more easily implemented in another language). I will use sockets for this as they are one of the simplest and most generic communication methods available.&lt;/p&gt;&#10;&lt;p&gt;The first step in setting up socket communication within a Modelica simulation is to create a socket library that can be called from the simulation code. Fortunately, this is very simple C code. You can find the relevant code &lt;a href="https://blog.kempj.co.uk/modelica-socket-communication-part-1-socket-library/"&gt;here&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>OpenModelica and Python via CORBA (Part 3: Python wrapper)</title><link>https://blog.kempj.co.uk/2013/12/20131216-openmodelica-and-python-via-corba-part-3-python-wrapper/</link><pubDate>Mon, 16 Dec 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/12/20131216-openmodelica-and-python-via-corba-part-3-python-wrapper/</guid><description>&lt;p&gt;&lt;a href="https://blog.kempj.co.uk/2013/10/20131030-openmodelica-and-python-via-corba-part-1-getting-started/"&gt;Part 1 (getting started)&lt;/a&gt; | &lt;a href="https://blog.kempj.co.uk/2013/10/20131031-openmodelica-and-python-via-corba-part-2-idl-compilation/"&gt;Part 2 (IDL compilation)&lt;/a&gt; | Part 3 (Python wrapper)&lt;/p&gt;&#10;&lt;p&gt;The final step in the process is to create a wrapper to allow easy programmatic control of OMC. I have posted a simple wrapper that provides the facilities required by the bouncing ball example &lt;a href="https://blog.kempj.co.uk/openmodelica-and-python-via-corba-part-3-python-wrapper/"&gt;here&lt;/a&gt;. It is not at the same level as the work by &lt;a href="http://www.ep.liu.se/ecp/076/054/ecp12076054.pdf"&gt;Ganeson et al.&lt;/a&gt; of course.&lt;/p&gt;</description></item><item><title>Compiling OpenModelica on Mint</title><link>https://blog.kempj.co.uk/2013/11/compiling-openmodelica-on-mint/</link><pubDate>Tue, 26 Nov 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/11/compiling-openmodelica-on-mint/</guid><description>&lt;p&gt;When compiling OpenModelica from source on Mint (and possibly on Ubuntu?) the compile cheat sheet in the readme gives working instructions with one exception: several packages, such as libqtwebkit-dev, aren’t installed when you run the &lt;tt&gt;sudo apt-get build-dep openmodelica&lt;/tt&gt; step. I had to use the following commands from the text further down the readme to get everything needed:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install antlr libantlr-dev&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install libreadline-dev libqt4-dev libqtwebkit-dev libqwt5-qt4-dev&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install sqlite3 libsqlite3-dev&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that I had to use to libreadline-dev instead of libreadline5-dev. Either way, that particular package was already installed, but I’ve left it here for completeness as the others on the same line weren’t.&lt;/p&gt;&#10;&lt;p&gt;I also needed to install bison and flex for the testsuite (not mentioned in the build instructions).&lt;/p&gt;&#10;&lt;p&gt;There may be other packages required that I already had installed, so my advice would be to install all of the packages they suggest rather than relying on build-dep.&lt;/p&gt;</description></item><item><title>OpenModelica and Python via CORBA (Part 2: IDL compilation)</title><link>https://blog.kempj.co.uk/2013/10/20131031-openmodelica-and-python-via-corba-part-2-idl-compilation/</link><pubDate>Thu, 31 Oct 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/10/20131031-openmodelica-and-python-via-corba-part-2-idl-compilation/</guid><description>&lt;p&gt;&lt;a href="https://blog.kempj.co.uk/2013/10/20131030-openmodelica-and-python-via-corba-part-1-getting-started/"&gt;Part 1 (getting started)&lt;/a&gt; | Part 2 (IDL compilation) | &lt;a href="https://blog.kempj.co.uk/2013/12/20131216-openmodelica-and-python-via-corba-part-3-python-wrapper/"&gt;Part 3 (Python wrapper)&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In part 1 I showed you how to get set up with the omniORB library/tools to communicate with OMC from Python. This post will show how to compile an IDL file to provide the appropriate interface to your script. This post assumes that the environment variables from last time are still set up and that you have OMC running with the &lt;tt&gt;+d=interactiveCorba&lt;/tt&gt; parameter.&lt;/p&gt;</description></item><item><title>OpenModelica and Python via CORBA (Part 1: getting started)</title><link>https://blog.kempj.co.uk/2013/10/20131030-openmodelica-and-python-via-corba-part-1-getting-started/</link><pubDate>Wed, 30 Oct 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/10/20131030-openmodelica-and-python-via-corba-part-1-getting-started/</guid><description>&lt;p&gt;Part 1 (getting started) | &lt;a href="https://blog.kempj.co.uk/2013/10/20131031-openmodelica-and-python-via-corba-part-2-idl-compilation/"&gt;Part 2 (IDL compilation)&lt;/a&gt; | &lt;a href="https://blog.kempj.co.uk/2013/12/20131216-openmodelica-and-python-via-corba-part-3-python-wrapper/"&gt;Part 3 (Python wrapper)&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In this post I’m going to be walking through the process of setting up &lt;a href="http://omniorb.sourceforge.net/"&gt;omniORB&lt;/a&gt; with Python for the purpose of interacting with the CORBA interface provided by the &lt;a href="https://openmodelica.org/"&gt;OpenModelica&lt;/a&gt; compiler (OMC). This allows OMC to be controlled from a Python script (loading simulations, changing parameters, etc). While the intention of this post is specifically that of interacting with OMC, the installation of omniORB will be the same in other situations. Note though that you may require additional setup in these other situations, for omniNames for example. I will be showing the setup process for Linux (and specifically, Mint/Ubuntu). I will assume that OpenModelica is already installed.&lt;/p&gt;</description></item><item><title>Remove OpenDNS from Mint</title><link>https://blog.kempj.co.uk/2013/10/remove-opendns-from-mint/</link><pubDate>Wed, 16 Oct 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/10/remove-opendns-from-mint/</guid><description>&lt;p&gt;It turns out that even though the Mint team make better decisions than the Ubuntu team, they’re not perfect. Hidden away in Mint’s network configuration are the OpenDNS servers set up as a fallback in case your usual DNS servers fail.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, this appears to be interacting oddly with Chrome resulting in the fallback servers being used for all requests. This has been causing all sorts of problems for me recently, most notably some &lt;em&gt;very&lt;/em&gt; aggressive blocking of sites for no apparent reason (Stack Overflow being one example).&lt;/p&gt;</description></item><item><title>Accessing LVM groups from Ubuntu</title><link>https://blog.kempj.co.uk/2013/05/accessing-lvm-groups-from-ubuntu/</link><pubDate>Thu, 16 May 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/05/accessing-lvm-groups-from-ubuntu/</guid><description>&lt;p&gt;There is a lot of confusion by users on how to deal with LVM groups when trying to recover their files from old drives (or, in our case, a newer drive that somehow got set up in that way). If all you want to do is be able to copy the files off then the following post is by far the simplest way I’ve seen:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://www.linux-sxs.org/storage/fedora2ubuntu.html"&gt;http://www.linux-sxs.org/storage/fedora2ubuntu.html&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Be careful with relative error</title><link>https://blog.kempj.co.uk/2013/04/be-careful-with-relative-error/</link><pubDate>Mon, 08 Apr 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/04/be-careful-with-relative-error/</guid><description>&lt;p&gt;When looking at sensor datasheets or similar documents there is a subtlety about relative error that may not be immediately apparent. Relative error is quoted as a percentage of the reading, but in some cases the range of interest to you might be small and have a large offset from zero.&lt;/p&gt;&#10;&lt;p&gt;Let’s take an extreme case. Imagine you have a temperature sensor that reads in Kelvin and you are measuring human skin temperature. It’s contrived I know, but bear with me here. In this case, your measurement range of interest is going to be around 300 K to 315 K. Now image you have a sensor with a relative error of 0.5%. Sounds good doesn’t it? Unfortunately that means that at a reading of 305 K (31.85 °C), your error is going to be 1.525 °C. That is slightly over 10% of your range—not so great anymore. Note that I was optimistic with the range size as well (you’re probably not going to be measuring skin temperatures around 40 °C), which makes the error even worse.&lt;/p&gt;&#10;&lt;p&gt;How does this translate to a more sensible measurement approach? In most cases you won’t have to worry. Op-amps historically have problems when the inputs have large DC offsets because the difference in the inputs becomes tiny versus the absolute input values. Weighing people is something I’m looking at currently, where a 1% relative error in the scales becomes more like a 2.25% error compared to the useful range. Not a crippling problem, but something to be aware of.&lt;/p&gt;</description></item><item><title>Associating xfig with .fig images</title><link>https://blog.kempj.co.uk/2013/01/associating-xfig-with-fig-images/</link><pubDate>Tue, 15 Jan 2013 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2013/01/associating-xfig-with-fig-images/</guid><description>&lt;p&gt;One problem I’ve encountered using Mint (though it’s not actually a Mint issue) is that xfig doesn’t get associated with .fig files. This is compounded by the fact that GNOME 3 (the basis of Cinnamon) always knows better than you, so there is no way to set your own custom file associations—if the application isn’t on the “approved” list it can’t be set.&lt;/p&gt;&#10;&lt;p&gt;After some research, I found some &lt;a href="http://ubuntuforums.org/showthread.php?t=1850568"&gt;useful information&lt;/a&gt; and here I’ll describe how to apply it to the xfig situation specifically.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;I will assume that xfig is already installed. If not then install it now (&lt;tt&gt;sudo apt-get install xfig&lt;/tt&gt;).&lt;/li&gt;&#10;&lt;li&gt;Check that a .desktop file exists to inform the system that xfig is available. To do this run &lt;tt&gt;sudo gedit /usr/share/applications/xfig.desktop&lt;/tt&gt; and check that the file roughly matches the following. If it is empty then insert the following.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;[Desktop Entry]&#10;Name=Xfig&#10;Comment=Diagram editor&#10;Exec=xfig&#10;Icon=xfig&#10;Terminal=false&#10;Type=Application&#10;Categories=Graphics;&#10;MimeType=image/x-fig;&#10;&lt;/code&gt;&lt;/pre&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;Set xfig as the default application for .fig files. Run &lt;tt&gt;sudo gedit /usr/share/applications/defaults.list&lt;/tt&gt; and insert the following anywhere (though locating it with the other &lt;tt&gt;“image/&amp;hellip;”&lt;/tt&gt; entries may be sensible).&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;image/x-xfig=xfig.desktop&#10;&lt;/code&gt;&lt;/pre&gt;&lt;ol start="4"&gt;&#10;&lt;li&gt;While you’re at it, install &lt;tt&gt;gsfonts-x11&lt;/tt&gt; then log out and back in. This will avoid issues with Times, Helvetica, and so on in your images.&lt;/li&gt;&#10;&lt;/ol&gt;</description></item><item><title>Subfloat error in LyX</title><link>https://blog.kempj.co.uk/2012/12/subfloat-error-in-lyx/</link><pubDate>Wed, 05 Dec 2012 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2012/12/subfloat-error-in-lyx/</guid><description>&lt;p&gt;When using subfloats (or subfigures as they are sometimes referred to) in LyX you may come across an error message when exporting telling you that you cannot use &lt;tt&gt;spacefactor&lt;/tt&gt; in vertical mode. The error message isn’t terribly helpful, but the solution is to add &lt;tt&gt;makeatletter&lt;/tt&gt; to the end of your preamble.&lt;/p&gt;</description></item><item><title>Python tips – Simple sensor data handling 3</title><link>https://blog.kempj.co.uk/2012/11/python-tips-simple-sensor-data-handling-3/</link><pubDate>Mon, 19 Nov 2012 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2012/11/python-tips-simple-sensor-data-handling-3/</guid><description>&lt;p&gt;&lt;a href="https://blog.kempj.co.uk/2010/05/python-tips-simple-sensor-data-handling-2/"&gt;Last time&lt;/a&gt; I covered easily reading data from a file into a useful structure. This time I will be demonstrating some summary statistics that can be generated from the data.&lt;/p&gt;</description></item><item><title>Convert images to video in Linux</title><link>https://blog.kempj.co.uk/2012/11/convert-images-to-video-in-linux/</link><pubDate>Wed, 07 Nov 2012 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2012/11/convert-images-to-video-in-linux/</guid><description>&lt;p&gt;On occasion I need to convert a series of images into a movie. For example, I have a data visualiser which generates an image for each timestamp and it nice to be able to use these to view the evolution of the sensed values over time. If you search on this topic then you’ll find a lot of people suggest using ffmpeg with a command line such as the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ffmpeg -r &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; -b &lt;span style="color:#ae81ff"&gt;1800&lt;/span&gt; -i %03d.jpg test1800.mp4&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, this assumes that all the filenames are sequentially numbered and that there are none missing (it will finish when it reaches the first missing number). I needed something a little more flexible, and eventually found &lt;a href="http://electron.mit.edu/~gsteele/ffmpeg/"&gt;this page&lt;/a&gt; which suggests the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mencoder &lt;span style="color:#e6db74"&gt;&amp;#34;mf://*.jpg&amp;#34;&lt;/span&gt; -mf fps&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; -o test.avi -ovc lavc -lavcopts vcodec&lt;span style="color:#f92672"&gt;=&lt;/span&gt;msmpeg4v2:vbitrate&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;800&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will simply read the files in the usual alphabetically sorted order. You can change &lt;tt&gt;&amp;ldquo;mf://*.jpg&amp;rdquo;&lt;/tt&gt; to adjust which files it uses, along with tweaking the framerate and bitrate.&lt;/p&gt;&#10;&lt;p&gt;Contrary to the note on that page, more recent versions of mencoder support png files as input.&lt;/p&gt;</description></item><item><title>Installing Drupal 7 in Ubuntu</title><link>https://blog.kempj.co.uk/2012/11/installing-drupal-7-in-ubuntu/</link><pubDate>Tue, 06 Nov 2012 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2012/11/installing-drupal-7-in-ubuntu/</guid><description>&lt;p&gt;I had occasion to install Drupal 7 on my own Ubuntu server recently. Many of the guides I found went into some quite unecessary steps, involved liberal use of tasksel, or made a variety of assumptions about your environment. In the end, though, I found &lt;a href="http://how-to.linuxcareer.com/how-to-install-drupal-7-on-ubuntu-linux"&gt;this guide&lt;/a&gt;, which is short, simple, and just worked.&lt;/p&gt;&#10;&lt;p&gt;The only addition I required was to run &lt;tt&gt;a2enmod rewrite&lt;/tt&gt; and to edit &lt;tt&gt;/etc/apache2/sites-available/drupal&lt;/tt&gt; to have &lt;tt&gt;AllowOverride All&lt;/tt&gt; in the entry for the &lt;tt&gt;/var/www/drupal/&lt;/tt&gt; directory.&lt;/p&gt;&#10;&lt;p&gt;Job done in almost no time.&lt;/p&gt;</description></item><item><title>Things sent to test Kemp (episode 1)</title><link>https://blog.kempj.co.uk/2012/10/things-sent-to-test-kemp-episode-1/</link><pubDate>Sat, 13 Oct 2012 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2012/10/things-sent-to-test-kemp-episode-1/</guid><description>&lt;pre&gt;$ msp430-gcc --target-help | grep 430&#10; -mcpu=CPU Select the CPU model: &lt;b&gt;430&lt;/b&gt;, 430x, 430xv2&#10;&#10;$ msp430-as --help | grep mcpu&#10; -mcpu={&lt;b&gt;430&lt;/b&gt;,430x,430xv2} select cpu model&#10;&#10;$ msp430-gcc -c -I./../include -I. -Wall -Os -gdwarf-2 ./string/isascii.c -o Build/./isascii.o&#10;/tmp/ccDRG4ve.s: Assembler messages:&#10;/tmp/ccDRG4ve.s:2: Error: &lt;b&gt;unknown cpu `430'&lt;/b&gt;&lt;/pre&gt;&#10;&lt;p&gt;Compilers, how do they work?&lt;/p&gt;</description></item><item><title>xfig cannot import eps files</title><link>https://blog.kempj.co.uk/2011/11/xfig-cannot-import-eps-files/</link><pubDate>Fri, 11 Nov 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/11/xfig-cannot-import-eps-files/</guid><description>&lt;p&gt;It seems that under Natty and Oneiric, xfig is unable to import eps files. When importing an eps you will get an error message along the lines of the following:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;ERROR from ghostscript:&#10;Error: /invalidfileaccess in --run--&#10;Operand stack:&#10; 3 --nostringval-- (filename.eps) (r)&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and then several more lines of information.&lt;/p&gt;</description></item><item><title>Installing Google Chrome on Ubuntu 11.10</title><link>https://blog.kempj.co.uk/2011/10/installing-google-chrome-on-ubuntu-11-10/</link><pubDate>Sat, 29 Oct 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/10/installing-google-chrome-on-ubuntu-11-10/</guid><description>&lt;p&gt;When attempting to install Google Chrome on Oneiric, you may encounter an error such as the following in the Ubuntu Software Centre:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Internal Error&#10;The file “google-chrome-stable_current_i386.deb” could not be opened.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;Though depending on which installer you’re using, the filename may be different of course. To work around this you can install it manually by running the following commands:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install libxss1 libcurl3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dpkg -i google-chrome-stable_current_i386.deb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Again, adjust the filename depending on the installer you have.&lt;/p&gt;</description></item><item><title>Ubuntu 11.10 – Brave or Disappointing?</title><link>https://blog.kempj.co.uk/2011/10/ubuntu-11-10-brave-or-disappointing/</link><pubDate>Mon, 10 Oct 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/10/ubuntu-11-10-brave-or-disappointing/</guid><description>&lt;p&gt;I find myself hesitant to consider upgrading to the next version of Ubuntu, and no it’s not because of the silly name (Oneiric Ocelot). It’s because I’ve just seen the list of changes and realised that Ubuntu simply isn’t a distribution that will give me what I need anymore. We are being presented with a complete removal of Ubuntu Classic (&lt;a href="https://blog.kempj.co.uk/2011/05/removing-the-ubuntu-natty-launcher-bar/"&gt;I called that one&lt;/a&gt; without needing to check the roadmap), forcing us into a corner with GNOME 3.2, Unity, and Compiz. As readers may have noticed, I have objections to using two out of those three technologies. I haven’t used the third yet (GNOME 3.2), but based on the screenshots I’ve seen it’s not promising.&lt;/p&gt;&#10;&lt;p&gt;This is an interesting moment for me, because it used to be that I’d be all over these upgrades. However, it seems that I’ve come to the age where the only important thing about an OS is that it lets me get things done quickly and without ceremony. Windows doesn’t fit this bill at work and unfortunately it’s becoming apparent that Ubuntu is determined not to as well. The big problem I have is that I’m not comfortable switching to a different distribution. Plus, the other members of the group use Ubuntu, and that opens me up to a whole world of subtle incompatibilities in the things we do. As things go, I’ll probably remain on Natty until forced to make a choice one way or the other. Who knows – maybe I’ll see someone on Oneiric and it’ll inspire me. I’m skeptical, but still hopeful.&lt;/p&gt;&#10;&lt;p&gt;But then there’s the silly name&amp;hellip;&lt;/p&gt;</description></item><item><title>Python tips – List iteration and item removal</title><link>https://blog.kempj.co.uk/2011/09/python-tips-list-iteration-and-item-removal/</link><pubDate>Mon, 26 Sep 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/09/python-tips-list-iteration-and-item-removal/</guid><description>&lt;p&gt;Occasionally my code is required to work through a list and delete items that are not wanted. Take, for example, the case of appending the data from two CSV files to create a new file with both sets of data in. It may be that they don’t have exactly the same columns in, but the common columns are the only ones you are interested in anyway. This is slightly more complex than simply ‘cat’ing the source files into the target file, so let’s assume you want to knock together a quick Python script to do it. I will first present the easy but wrong way to do it and then show how to adjust it to be correct.&lt;/p&gt;</description></item><item><title>Traditional scrollbars in Ubuntu Natty</title><link>https://blog.kempj.co.uk/2011/06/traditional-scrollbars-in-ubuntu-natty/</link><pubDate>Tue, 07 Jun 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/06/traditional-scrollbars-in-ubuntu-natty/</guid><description>&lt;p&gt;Mike Beach has &lt;a href="http://mikebeach.org/2011/05/disable-the-overlay-scrollbars-in-ubuntu-natty/"&gt;a post&lt;/a&gt; on removing the overlay scrollbars in Ubuntu Natty and getting back the traditional (usable) ones. I approve of this.&lt;/p&gt;&#10;&lt;p&gt;The command he provides is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get remove overlay-scrollbar liboverlay-scrollbar-0.1-0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In Oneiric the command (thanks to &lt;a href="http://www.webupd8.org/2011/10/things-to-tweak-after-installing-ubuntu.html"&gt;WEB UPD8&lt;/a&gt;) is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get remove overlay-scrollbar liboverlay-scrollbar3-0.2-0 liboverlay-scrollbar-0.2-0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>LyX spellcheck in Ubuntu Natty</title><link>https://blog.kempj.co.uk/2011/05/lyx-spellcheck-in-ubuntu-natty/</link><pubDate>Tue, 10 May 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/05/lyx-spellcheck-in-ubuntu-natty/</guid><description>&lt;p&gt;Among &lt;a href="https://blog.kempj.co.uk/2011/05/removing-the-ubuntu-natty-launcher-bar/"&gt;other annoying things&lt;/a&gt; in the new Ubuntu Natty release, it seems that spellchecking may become disabled in LyX. The fix is rather simple, but annoying to find if you don’t know what you’re looking for. The secret is that LyX relies on external libraries to provide its spellcheck capability, so if they’re not installed correctly or not configured correctly in LyX then it breaks. And it doesn’t tell you why.&lt;/p&gt;&#10;&lt;p&gt;The solution after a Natty upgrade (I haven’t checked on a clean install) is:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Open up LyX&lt;/li&gt;&#10;&lt;li&gt;Go to Tools &amp;gt; Preferences &amp;gt; Language Settings &amp;gt; Spellchecker&lt;/li&gt;&#10;&lt;li&gt;Chances are good that the “Spellchecker executable” option is not set to anything. Change it to your preferred library, which by default should be Enchant.&lt;/li&gt;&#10;&lt;li&gt;While you’re there, turn on the new “Spellcheck continuously” option. This is the new inline spellchecker.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Job done. Now you can continue using a function that was already working with exactly the same library before the upgrade happened.&lt;/p&gt;</description></item><item><title>Careful data handling</title><link>https://blog.kempj.co.uk/2011/05/careful-data-handling/</link><pubDate>Mon, 02 May 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/05/careful-data-handling/</guid><description>&lt;p&gt;While processing some experimental data recently I was comparing two data streams and saw:&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;RMSE&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Corr&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;n&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;p-value&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;3.26&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;0.19&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;39&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;0.25&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;In this case, “Corr” is Pearson’s correlation and the quoted p-value is for the significance of the correlation. Given a scale of -4 to 4, it looks like it’s fairly safe to say that the two data streams don’t have very much in common. The lack of samples is unfortunate but couldn’t be helped in this case.&lt;/p&gt;&#10;&lt;p&gt;It wasn’t such a simple case however, as I noticed that two of the samples shouldn’t have been included in the comparison (for very well-defined experimental reasons). Two points out of 39 shouldn’t make a big difference right? 😉 Having removed these points from the comparison I got the following results:&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;RMSE&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Corr&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;n&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;p-value&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2.05&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;0.69&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;37&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2.14e-06&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;As you can see, this made a significant difference (literally). Making a scatterplot of these results earlier on would have pointed me to this mistake much quicker.&lt;/p&gt;&#10;&lt;p&gt;Remember kids, 1) you need to know your data (why is each of those points included in the analysis?), and 2) scatterplots are your friend when looking at any type of correlation.&lt;/p&gt;</description></item><item><title>Removing the Ubuntu Natty launcher bar</title><link>https://blog.kempj.co.uk/2011/05/removing-the-ubuntu-natty-launcher-bar/</link><pubDate>Mon, 02 May 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/05/removing-the-ubuntu-natty-launcher-bar/</guid><description>&lt;p&gt;In Ubuntu 11.04 (Natty Narwhal):&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Click the far top-left button to bring up the search dialog.&lt;/li&gt;&#10;&lt;li&gt;Type “login” without the quotes and click on “Login Screen”.&lt;/li&gt;&#10;&lt;li&gt;Change “Select Ubuntu as default session” to “Select Ubuntu Classic as default session”.&lt;/li&gt;&#10;&lt;li&gt;Log out and back in.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Congratulation, you have removed the launcher bar. Prepare for 11.10 where they will no doubt remove Ubuntu Classic as an option.&lt;/p&gt;&#10;&lt;p&gt;Update:&#10;Looks like &lt;a href="https://blog.kempj.co.uk/2011/10/ubuntu-11-10-brave-or-disappointing/"&gt;I called it correctly&lt;/a&gt;. Didn’t have to be psychic for that one.&lt;/p&gt;</description></item><item><title>SQ2040 datalogger and HIH-5031 humidity sensors</title><link>https://blog.kempj.co.uk/2011/04/sq2040-datalogger-and-hih-5031-humidity-sensors/</link><pubDate>Thu, 21 Apr 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/04/sq2040-datalogger-and-hih-5031-humidity-sensors/</guid><description>&lt;p&gt;This post will show you how to connect &lt;a href="http://sensing.honeywell.com/index.cfm?ci_id=140301&amp;amp;la_id=1&amp;amp;pr_id=156098"&gt;HIH-5031 humidity sensors&lt;/a&gt; to a &lt;a href="http://www.grant.co.uk/Data+Acquisition/Products/High+precision+universal+data+loggers/Squirrel+2040/"&gt;Squirrel SQ2040 datalogger&lt;/a&gt;. The advice will also be applicable to many other sensors with three connections for power, signal (voltage), and ground.&lt;/p&gt;</description></item><item><title>Using ssconvert remotely</title><link>https://blog.kempj.co.uk/2011/04/using-ssconvert-remotely/</link><pubDate>Tue, 19 Apr 2011 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2011/04/using-ssconvert-remotely/</guid><description>&lt;p&gt;If you’ve ever used &lt;a href="http://linuxcommand.org/man_pages/ssconvert1.html"&gt;ssconvert&lt;/a&gt; (part of the gnumeric package) via an SSH session then you’re likely to have seen the horde of warnings that are displayed:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;GConf Error: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details – 1: Not running within active session)&lt;/p&gt;&#10;&lt;p&gt;… [repeated many times] …&lt;/p&gt;&#10;&lt;p&gt;(ssconvert:11925): GConf-WARNING **: Directory `/apps/gnumeric’ was not being monitored by GConfClient 0x87cf220&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;There is a simple workaround for this that may be helpful if you are calling ssconvert multiple times within a makefile or similar and don’t want to add additional huge amounts of useless output. Simply prepend &lt;code&gt;DISPLAY=:0&lt;/code&gt; onto the command and it will be happy (i.e. &lt;code&gt;DISPLAY=:0 ssconvert [args]&lt;/code&gt;).&lt;/p&gt;&#10;&lt;p&gt;As a bonus, here’s a simple command line to turn an Excel worksheet into a csv file, something I have to do fairly often when setting up processing of data from other people:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssconvert --export-type&lt;span style="color:#f92672"&gt;=&lt;/span&gt;Gnumeric_stf:stf_assistant -O &lt;span style="color:#e6db74"&gt;&amp;#39;sheet=&amp;#34;sheet_name&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; separator=, quoting-mode=&amp;#34;auto&amp;#34; eol=&amp;#34;unix&amp;#34;&amp;#39;&lt;/span&gt; input_file output_file&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Replace &lt;code&gt;sheet_name&lt;/code&gt;, &lt;code&gt;input_file&lt;/code&gt;, and &lt;code&gt;output_file&lt;/code&gt; with your own values.&lt;/p&gt;</description></item><item><title>OpenPicus FlyPort</title><link>https://blog.kempj.co.uk/2010/11/openpicus-flyport/</link><pubDate>Tue, 23 Nov 2010 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2010/11/openpicus-flyport/</guid><description>&lt;p&gt;I recently obtained an OpenPicus FlyPort module and StarterKit Nest. I have a use in mind for the devices, but for now they are quite fun to play around with.&lt;/p&gt;&#10;&lt;p&gt;For information see:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="http://www.openpicus.com/index.htm"&gt;OpenPicus website&lt;/a&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="http://www.openpicus.com/flyport.htm"&gt;FlyPort module page&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="http://www.openpicus.com/nests.htm"&gt;StarterKit nest page&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="http://openpicus.blogspot.com/"&gt;OpenPicus blog&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The main attraction with these devices (for me) was that you aren’t buying the individual parts (which, let’s face it, are much cheaper), nor are you even buying them mounted on a fancy PCB. You are buying a complete product. The currently available software includes the full TCP/IP and Wifi stacks and a web server application that allows both displaying of input values and control of output values from a web browser anywhere on your network. Upcoming software includes an IDE targeted at the capabilities of the devices, with a wizard that looks like it will be capable of generating a lot of the code needed for a variety of uses (see &lt;a href="http://www.openpicus.com/idegrande.jpg"&gt;this screenshot&lt;/a&gt;). A Bluetooth based module is also scheduled for release towards the end of 2010.&lt;/p&gt;&#10;&lt;p&gt;I’m always on the lookout for fun new development kits, and this fit the bill quite nicely.&lt;/p&gt;</description></item><item><title>GSS CO2 Sensor Tech Docs</title><link>https://blog.kempj.co.uk/2010/05/gss-co2-sensor-tech-docs/</link><pubDate>Thu, 13 May 2010 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2010/05/gss-co2-sensor-tech-docs/</guid><description>&lt;p&gt;GSS have released a whole load of new technical documents related to using their C20 CO2 sensor. I was a bit worried when I noticed that the original user guide had disappeared a while ago, but now it’s back, it’s revised, and it has some friends. &lt;a href="http://www.gassensing.co.uk/technical-downloads.asp"&gt;Enjoy&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Python tips – Simple sensor data handling 2</title><link>https://blog.kempj.co.uk/2010/05/python-tips-simple-sensor-data-handling-2/</link><pubDate>Mon, 10 May 2010 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2010/05/python-tips-simple-sensor-data-handling-2/</guid><description>&lt;p&gt;&lt;a href="https://blog.kempj.co.uk/2010/04/python-tips-simple-sensor-data-handling/"&gt;Last time&lt;/a&gt;, I described a simple way to take a series of data samples grouped by timestamp and reorganise them to group by the sensor from which they came. This time I will describe a simple way to read the data in from a file. Note that I will leave out error checking for the purpose of clarity, but this is always something which should be considered.&lt;/p&gt;</description></item><item><title>Python tips – Simple sensor data handling</title><link>https://blog.kempj.co.uk/2010/04/python-tips-simple-sensor-data-handling/</link><pubDate>Thu, 15 Apr 2010 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2010/04/python-tips-simple-sensor-data-handling/</guid><description>&lt;p&gt;Say you have a system which collects data from a group of sensors. Let’s have three sensors giving integer values for the sake of argument, but this doesn’t affect what I’m about to show you. The easiest way to store this data (assuming you want some history) is as a list of tuples, so if the data you get from the sensors is &lt;tt&gt;(1, 5, 3)&lt;/tt&gt; at t=0, &lt;tt&gt;(2, 5, 3)&lt;/tt&gt; at t=1, &lt;tt&gt;(2, 4, 4)&lt;/tt&gt; at t=2, and &lt;tt&gt;(2, 5, 2)&lt;/tt&gt; at t=3 then you would be storing&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;), (&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;), (&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;), (&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;)]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>GSS C20 CO2 Sensor</title><link>https://blog.kempj.co.uk/2009/12/gss-c20-co2-sensor/</link><pubDate>Sat, 05 Dec 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/12/gss-c20-co2-sensor/</guid><description>&lt;p&gt;This post discusses the C20 CO2 sensor from &lt;a href="http://www.gassensing.co.uk/"&gt;GSS&lt;/a&gt; (Gas Sensing Solutions). It appears to be distributed by &lt;a href="http://www.airmonitors.co.uk/gases"&gt;Air Monitors&lt;/a&gt; and &lt;a href="http://europaenvironmental.com/co2_monitor"&gt;Europa Environmental&lt;/a&gt; as the “Miniature CO2 sensor”. Specifically, I will discuss the differences between the datasheet and the actual implementation on the device.&lt;/p&gt;</description></item><item><title>Gumstix Verdex and USB flash</title><link>https://blog.kempj.co.uk/2009/12/gumstix-verdex-and-usb-flash/</link><pubDate>Thu, 03 Dec 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/12/gumstix-verdex-and-usb-flash/</guid><description>&lt;p&gt;This article details the (fairly simple) process of connecting and using a USB flash drive with a &lt;a href="http://www.blogger.com/articles/gumstix-devices"&gt;Gumstix&lt;/a&gt; Verdex device. The Verdex already supports being a USB host, so the main work is in making the physical connection itself.&lt;/p&gt;</description></item><item><title>Python tips – Reverse iteration</title><link>https://blog.kempj.co.uk/2009/10/python-tips-reverse-iteration/</link><pubDate>Sun, 25 Oct 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/10/python-tips-reverse-iteration/</guid><description>&lt;p&gt;This post, the first in what will be a sporadic series, relates to a mistake I saw recently when looking at through some Python code. The author had used the following method to iterate backwards through a list:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(len(foo)):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print foo[&lt;span style="color:#f92672"&gt;-&lt;/span&gt;i]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It wasn’t a print in the original, it was something else which would have been far harder to spot had it introduced subtle errors into the results of the code. Given Python’s ability to index from the end of a list using negative indices, this seems to be a suitable solution. The problem here is that &lt;tt&gt;foo[-0]&lt;/tt&gt; isn’t the last item in the list, &lt;tt&gt;foo[-1]&lt;/tt&gt; is. The correct code the author was looking for was:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; item &lt;span style="color:#f92672"&gt;in&lt;/span&gt; reversed(foo):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print item&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or, if you need the index of the item as well:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i,value &lt;span style="color:#f92672"&gt;in&lt;/span&gt; enumerate(reversed(foo)):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print i,item&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Simple DHCP Server Setup</title><link>https://blog.kempj.co.uk/2009/08/simple-dhcp-server-setup/</link><pubDate>Mon, 24 Aug 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/08/simple-dhcp-server-setup/</guid><description>&lt;p&gt;In this post I will discuss a simple way to set up a DHCP server for a small network. By “small network” in this case I mean examples such as a home network with a few machines on, or a group of &lt;a href="http://www.gumstix.com/"&gt;Gumstix&lt;/a&gt; devices communicating with a PC over BNEP PAN connections. If you’ve read my previous posts then you’ll know that the latter is my main interest, and that anything I say here is based on my use of Ubuntu. Originally, I was going to talk about the use of gadmin-dhcpd from the &lt;a href="http://gadmintools.flippedweb.com/"&gt;Gadmin&lt;/a&gt; set of tools, but in the end I decided that manual configuration isn’t actually hard enough to warrant a graphical tool (for my purposes at least).&lt;/p&gt;</description></item><item><title>Linux Ethernet Bridging</title><link>https://blog.kempj.co.uk/2009/08/linux-ethernet-bridging/</link><pubDate>Thu, 06 Aug 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/08/linux-ethernet-bridging/</guid><description>&lt;p&gt;Ethernet bridging allows automated routing between multiple interfaces on your computer. They don’t necessarily have to be of the same type, as long as they carry IP protocol traffic. For instance, two Bluetooth BNEP PAN connections and a normal 100BASE-T Ethernet interface can be bridged together. This allows a host on one of the PAN connections to communicate with a host somewhere on the Ethernet network without any extra effort from you, as long as they share a common subnet.&lt;/p&gt;&#10;&lt;p&gt;My own use of this type of bridging is entirely with BNEP PAN connections to allow &lt;a href="http://www.gumstix.com/"&gt;Gumstix&lt;/a&gt; devices to talk to each other via the emulated Ethernet network without regard to which devices are master or slave or how the packets are being routed in the underlying PAN. In this scheme, I have one Gumstix device running Ethernet bridging as the master of the PAN, with a PC and several other Gumstix devices as slaves. It doesn’t matter that all traffic is routed via the network master as this is hidden several layers below my view.&lt;/p&gt;</description></item><item><title>Gumstix Boot Scripts</title><link>https://blog.kempj.co.uk/2009/08/gumstix-boot-scripts/</link><pubDate>Wed, 05 Aug 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/08/gumstix-boot-scripts/</guid><description>&lt;p&gt;This post covers the basics of setting up a script to run at boot on a &lt;a href="http://www.gumstix.com/"&gt;Gumstix&lt;/a&gt; device (with Buildroot or OE). As the Gumstix devices use Linux as their OS of choice, this method will apply to any Linux machine running similar versions of things, though your particular distribution may have a preferred method (for instance Ubuntu now uses upstart). I’m considering this article to be Gumstix specific as most System V based distributions will have a series of scripts enabling you to manage startup scripts more easily. This article is still applicable if you want to perform the task manually though.&lt;/p&gt;</description></item><item><title>BNEP PAN Connections with BlueZ 4.x</title><link>https://blog.kempj.co.uk/2009/08/bnep-pan-connections-with-bluez-4-x/</link><pubDate>Mon, 03 Aug 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/08/bnep-pan-connections-with-bluez-4-x/</guid><description>&lt;p&gt;When Ubuntu adopted BlueZ 4.x as its Bluetooth suite of choice a lot of things broke, especially if you were doing more than just connecting to your phone. Unfortunately for us, we were doing a lot more than that. This mean that under Intrepid we had to force a downgrade to the Hardy version of BlueZ (3.26 or 3.29), an option which vanished with Jaunty as the package installation threw errors.&lt;/p&gt;&#10;&lt;p&gt;Despite a lot of discussion of this issue, it seems to be quite hard to find a real solution where someone has said “install this, tweak this, that’ll fix it for you”. However, today I successfully created a PAN network between my desktop and a Gumstix device using BlueZ 4.x, and here’s how I did it.&lt;/p&gt;</description></item><item><title>Interfacing: B530 CO2 sensor and Gumstix</title><link>https://blog.kempj.co.uk/2009/02/interfacing-b530-co2-sensor-and-gumstix/</link><pubDate>Mon, 09 Feb 2009 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2009/02/interfacing-b530-co2-sensor-and-gumstix/</guid><description>&lt;p&gt;The group obtained some &lt;a href="http://www.elti.co.kr/new/eng/co2-sensor-module-b530.htm"&gt;B530&lt;/a&gt; CO&lt;sub&gt;2&lt;/sub&gt; sensors (produced by &lt;a href="http://www.elti.co.kr/new/board/emain.html"&gt;ELT, Inc.&lt;/a&gt;) to interface to some Arch Rock nodes as part of another project. The datasheet is located &lt;a href="http://www.elti.co.kr/new/board/bbs/download.php?bo_table=e_data&amp;amp;wr_id=1&amp;amp;no=0"&gt;here&lt;/a&gt;. As a first iteration of my own CO2 sensing setup I borrowed one of the devices to connect to a Verdex Gumstix device. This article gives an overview of how I achieved this, along with some hints and gotchas related to using the sensor.&lt;/p&gt;</description></item><item><title>Gumstix RFCOMM</title><link>https://blog.kempj.co.uk/2008/01/gumstix-rfcomm/</link><pubDate>Wed, 30 Jan 2008 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2008/01/gumstix-rfcomm/</guid><description>&lt;p&gt;Before I start the main post, I finally have a decent pic of one of the sensor boards I created. There are a couple more chips on the bottom as well, not shown.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/SBW001.jpg" alt="My new sensor board"&gt;&lt;/p&gt;&#10;&lt;p&gt;Now, onto the post proper. I recently had to set up a &lt;a href="http://www.gumstix.com/"&gt;Gumstix&lt;/a&gt; device (in this case an old &lt;a href="http://gumstix.com/store/catalog/product_info.php?products_id=137"&gt;Connex 400xm-bt&lt;/a&gt; with an &lt;a href="http://www.gumstix.com/store/catalog/product_info.php?cPath=31&amp;amp;products_id=158"&gt;Audiostix2&lt;/a&gt; expansion) to grab readings from a sensor. The sensor used a serial connection over Bluetooth’s rfcomm. I wrote my application to open and read from &lt;tt&gt;/dev/rfcomm0&lt;/tt&gt; and tested it on the PC, everything worked fine (almost) first time. The only setup that had to be done was&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rfcomm bind &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &amp;lt;device address&amp;gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;though the trailing 1 is optional for the most part. I cross-compiled the code and moved it onto the Connex, whereupon I got a load of errors. The channel being in use/busy, and permission denied opening the serial device were the more common ones that popped up. It is certainly an odd experience getting permission denied when you’re root&amp;hellip; Anyway, after googling on the matter I discovered something that should really have been obvious: rfcomm0 is reserved for creating a serial connection to the Connex for the purpose of a remote shell. I quickly switched over to rfcomm1 and everything was happy.&lt;/p&gt;&#10;&lt;p&gt;There you go, a simple but very annoying problem with a quick but not initially obvious fix. Hope this saves someone half an hour of their life.&lt;/p&gt;</description></item><item><title>My First PCBs</title><link>https://blog.kempj.co.uk/2007/09/my-first-pcbs/</link><pubDate>Tue, 18 Sep 2007 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2007/09/my-first-pcbs/</guid><description>&lt;p&gt;Today (actually yesterday when I post this, it’s 11:59 as I type) I took delivery of the first professionally fabricated PCBs designed by me. No problems at all during the process, which is rather good considering it was my first real experience of the schematic -&amp;gt; layout flow, including having to make custom schematic symbols and component footprints. They are slightly larger than I was hoping for, but they are the first revision and I was a bit worried how close the tolerances were for &lt;a href="http://pcbtrain.co.uk/"&gt;PCBTrain&lt;/a&gt;‘s prototyping service. Things looked closer on the screen than they do in real life or I would have shaved a few millimeters off here and there. Anyway, pictures as soon as I get them.&lt;/p&gt;&#10;&lt;p&gt;Edit:&#10;It occurs to me that there was a whole new prototype between the last one I showed you and this one. It used our fancy new Gumstix expansion boards (designed in-house) and was a LOT more stable than my “home-made” versions. Pic below, it’s a lot neater is it not?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/new_prototype.jpg" alt="New prototype using custom Gumstix expansion board"&gt;&lt;/p&gt;</description></item><item><title>Expanding Requirements</title><link>https://blog.kempj.co.uk/2007/06/expanding-requirements/</link><pubDate>Fri, 08 Jun 2007 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2007/06/expanding-requirements/</guid><description>&lt;p&gt;This is always something to watch out for. Requirements in a software project have a habit of expanding out of control. Someone thinks “feature x would be nice here”, someone else thinks “feature y would make my life easier” and before you know it they’re both coming back with “why does this run so slowly? And why are there all these extra confusing features? I only wanted a couple of those!”.&lt;/p&gt;</description></item><item><title>Changing Buildroot Revision</title><link>https://blog.kempj.co.uk/2007/05/changing-buildroot-revision/</link><pubDate>Sat, 05 May 2007 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2007/05/changing-buildroot-revision/</guid><description>&lt;p&gt;As promised, the first in a line of (hopefully) useful posts. Today we cover three of the main effects of switching from one revision of the Gumstix buildroot to another. This can happen if you upgrade deliberately, or if you order a new batch and they happen to ship with a different revision.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Binary Incompatibility&lt;/strong&gt; – I’m not sure as to the minimum set of changes required to make binaries incompatible with the system, but if you change Buildroot revision it is something to look out for. For example, I am developing on both r773 and r1161 and you can guarantee binaries compiled for one won’t work on the other. You may get messages such as “unrecognised character : ]” or just an outright “you fool, what are you doing?” (both paraphrased).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Module Renaming&lt;/strong&gt; – If I use the revisions mentioned above again, I can draw on the example of the sound modules. The sound driver in r773 was pxa-ac97, whereas in r1161 you use snd-pxa2xx-ac97, snd-pcm-oss, and snd-mixer-oss. If you’re not expecting it then that sort of change can really throw you.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Different Default Applications&lt;/strong&gt; – Sometimes applications are added to or removed from the Buildroot default build. For example, in r773 you had brec and bplay (the basis of various of our demos due to their ease of use), whereas these are not included by default in r1161. Applications may also be compiled to a different place within the Buildroot, Python is an example of this between r773 and r1161.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Those are the three main effects that I have come across, feel free to mention other ones in the comments section (or to correct my paraphrased error messages if you so wish =P ).&lt;/p&gt;</description></item><item><title>New Prototype</title><link>https://blog.kempj.co.uk/2007/02/new-prototype/</link><pubDate>Fri, 09 Feb 2007 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2007/02/new-prototype/</guid><description>&lt;p&gt;Here’s some pics of prototype 2, freshly made today.&lt;/p&gt;&#10;&lt;p&gt;These first two are of the interface board stuck on the back of our favourite expansion, the Audiostix2 (with the Connex board attached obviously).&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/board1.png" alt="Prototype top view"&gt;&#10;&lt;img src="https://blog.kempj.co.uk/images/board2.png" alt="Prototype connector view"&gt;&lt;/p&gt;&#10;&lt;p&gt;And here’s a pic with the sensors attached. That’s eight of the ones you saw last time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/sensors.png" alt="Prototype with sensors attached"&gt;&lt;/p&gt;&#10;&lt;p&gt;Sorry about the pngs =P&lt;/p&gt;</description></item><item><title>The Importance Of Planning</title><link>https://blog.kempj.co.uk/2007/01/the-importance-of-planning/</link><pubDate>Fri, 05 Jan 2007 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2007/01/the-importance-of-planning/</guid><description>&lt;p&gt;So I’m working on the next version of my Visualiser, and by version I mean Uber Rewrite Of Ultimate Doom. The weaknesses of the original are becoming rapidly apparent and there comes a point where you just have to cut your losses and use your experience to start over. So I have a set of goals in terms of how I go about coding this new one so I don’t repeat history. I know most of these are common sense taught to us early on, but how many pay attention seriously unless made to by company policy? Turns out having things bite you on the ass is quite a motivation.&lt;/p&gt;</description></item><item><title>Ooo... Hardware...</title><link>https://blog.kempj.co.uk/2006/12/ooo-hardware/</link><pubDate>Tue, 12 Dec 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/12/ooo-hardware/</guid><description>&lt;p&gt;So my last post was related to software, let’s go the opposite end this time. The pictures below are essentially a prototype of a prototype, a single data gathering chip hooked up to the ever popular Audiostix2 board (with a big green “1” stuck on it =P ), hopefully soon there will be much much more.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/gumstix_sensor_prototype_all.jpg" alt="Prototype sensor attached to Audiostix2"&gt;&#10;&lt;img src="https://blog.kempj.co.uk/images/gumstix_sensor_prototype_sensor.jpg" alt="Prototype sensor"&gt;&lt;/p&gt;&#10;&lt;p&gt;If you feel like wanting more info then&amp;hellip; tough I guess =P Note how the pictures are conveniently low res enough to not reveal any part numbers or suchlike, that’s entirely coincedence I assure you.&lt;/p&gt;</description></item><item><title>Alive!</title><link>https://blog.kempj.co.uk/2006/12/alive/</link><pubDate>Sun, 10 Dec 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/12/alive/</guid><description>&lt;p&gt;This is my first post here in a very long time :-O I finally bothered to take a screenshot of my WSN Visualiser with its latest feature: actual lighting so you’re not relying on colouring surfaces to make them look 3D (that’s blown out of the water when you’re using colour for something else like in the screenie).&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://blog.kempj.co.uk/images/vis.png" alt="Visualiser screenshot"&gt;&lt;/p&gt;&#10;&lt;p&gt;Obviously it’s not perfect yet, and I won’t even get started on manually generating normals, but it works and it looks much cooler than it used to. And yes, that black blob is a single lonely node marker, poor little guy.&lt;/p&gt;</description></item><item><title>Mobile Computing</title><link>https://blog.kempj.co.uk/2006/11/mobile-computing/</link><pubDate>Fri, 10 Nov 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/11/mobile-computing/</guid><description>&lt;p&gt;The guys over &lt;a href="http://www.proxflyer.com/"&gt;here&lt;/a&gt; have taken the concept of mobile computing to a whole new level. A 3 gram flying computer… I have images of one being flown up to sit on someone’s roof while it hacks their wifi connection. &lt;em&gt;evil grin&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Stackless Python</title><link>https://blog.kempj.co.uk/2006/11/stackless-python/</link><pubDate>Sun, 05 Nov 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/11/stackless-python/</guid><description>&lt;p&gt;&lt;a href="http://holdenweb.blogspot.com/2006/11/stackless-python-continues-to-amaze.html"&gt;&amp;hellip; for Some Value of “Magic”: Stackless Python Continues to Amaze&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Just thought I’d link over to this post for anyone who likes doing cool things with Python&lt;/p&gt;</description></item><item><title>Wireless Fun</title><link>https://blog.kempj.co.uk/2006/10/wireless-fun/</link><pubDate>Mon, 16 Oct 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/10/wireless-fun/</guid><description>&lt;p&gt;Apparently transferring hordes of small files (14MB total) to an embedded device via ethernet emulated over Bluetooth (up to 300ms ping) is a slow process. Who would have thought? Next time I need to bother using the USB connection, ethernet emulated over USB is so much faster.&lt;/p&gt;&#10;&lt;p&gt;On a side note, is there anything that ethernet &lt;em&gt;isn’t&lt;/em&gt; emulated over?&lt;/p&gt;&#10;&lt;p&gt;Update:&lt;br/&gt;&#10;I’m doing my third ethernet-over-Blutooth transfer now, why do I punish myself like this? Is doing it remotely from another room really that much of a bonus?&lt;/p&gt;&#10;&lt;p&gt;Remotely = ssh session to the machine in the other lab that the Gumstix have their Bluetooth connection to. It’s quite fun to ssh into that machine and then use that to ssh into the ‘stix, though the latency starts getting very noticable.&lt;/p&gt;</description></item><item><title>Talking ‘Stix</title><link>https://blog.kempj.co.uk/2006/10/talking-stix/</link><pubDate>Wed, 04 Oct 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/10/talking-stix/</guid><description>&lt;figure class="float-small"&gt;&lt;img src="https://blog.kempj.co.uk/images/commdir.png"&gt;&#10;&lt;/figure&gt;&#10;&lt;p&gt;To your left (in compliant browsers), you are looking at the direction of connection establishment (does that phrase make sense?) in my test network for the Gumstix and their Bluetooth adapters. After many failed attempts to have the Master connect to the Listener and have the Slaves connect to it (host down/device busy/etc), I gave in and let the Master initiate all the connections, which worked first time and was completely repeatable for once. This also gives me more centralised control over things, as only the Master needs any config files telling it the addresses of the Slaves, rather than each Slave needing to know the address of the Master. Below is the output (slightly edited for clarity) I was very happy to see.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;PC (00:0A:94:13:CE:8D)&lt;/p&gt;&#10;&lt;p&gt;$ ./listener&lt;br/&gt;&#10;Waiting for connections on port 1&lt;br/&gt;&#10;Master connected: 00:80:37:27:03:8C&lt;br/&gt;&#10;Slave announced: 00:80:37:27:03:86&lt;/p&gt;&#10;&lt;p&gt;Master (00:80:37:27:03:8C)&lt;/p&gt;&#10;&lt;p&gt;# ./master&lt;br/&gt;&#10;Connected to listener at 00:0A:94:13:CE:8D&lt;br/&gt;&#10;Connected to slave 0 at 00:80:37:27:03:86&lt;br/&gt;&#10;Relaying slave address&lt;/p&gt;&#10;&lt;p&gt;Slave (00:80:37:27:03:86)&lt;/p&gt;&#10;&lt;p&gt;# ./slave&lt;br/&gt;&#10;Waiting for connections&lt;br/&gt;&#10;Accepted connection from 00:80:37:27:03:8C&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>Extreme Python</title><link>https://blog.kempj.co.uk/2006/09/extreme-python/</link><pubDate>Wed, 27 Sep 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/09/extreme-python/</guid><description>&lt;p&gt;So if you ever want a function in Python that can generate all the prime numbers up to &lt;em&gt;n&lt;/em&gt; and for some reason you want to do it in one line of code you need not look any further than this. Of course, once you’ve used this code sample you may feel dirty, and documenting it in a nice way is a challenge left for the reader.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;primes&lt;/span&gt;(n): &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; filter(&lt;span style="color:#66d9ef"&gt;lambda&lt;/span&gt; num : &lt;span style="color:#f92672"&gt;not&lt;/span&gt; bool(filter(&lt;span style="color:#66d9ef"&gt;lambda&lt;/span&gt; x : num &lt;span style="color:#f92672"&gt;%&lt;/span&gt; x&lt;span style="color:#f92672"&gt;==&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, range(&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, num &lt;span style="color:#f92672"&gt;/&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;))), range(&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;, n))&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I have Sarah to blame for the inspiration for this one (section 10.2.3 of her 112CR notes =P), though she at least used a couple more lines to split it into two functions and some more lines for documentation since it was possible with her example. Completely self-contained functional programming for the win, and as a bonus due to my version being a single line it’s easily turned into another lambda function and embedded into something else, I’m sure there’s probably a competition out there for getting things done in a single line of code.&lt;/p&gt;&#10;&lt;p&gt;Edit:&lt;br/&gt;&#10;As an aside, I quite like random.Random().random(), it has something of a feeling of deja vu about it.&lt;/p&gt;</description></item><item><title>Linux + Python + USB = win</title><link>https://blog.kempj.co.uk/2006/09/linux-python-usb-win/</link><pubDate>Tue, 19 Sep 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/09/linux-python-usb-win/</guid><description>&lt;p&gt;My first in-lab update! Last (academic) year I spent an annoying amount of time attempting to get a mote and a PC to talk to each other with absolutely no luck. Well, no coherent luck, I was getting random bits of data but never useful bits. That was using C++, a serial port, and NesC for the mote software (written by someone else). Using our cool new Gumstix means I switched to using Python (on both ends) and a USB port, a much more up-to-date and friendly combination indeed. It took approximately 5 mins to get the PC talking to the stick. That’s right, 5 minutes. Now I can concentrate on making it do useful things rather than making it work. Win.&lt;/p&gt;&#10;&lt;p&gt;Edit:&lt;br/&gt;&#10;And now they can communicate via Bluetooth as well as USBNet. Yay for developer-friendly things.&lt;/p&gt;</description></item><item><title>New Toys</title><link>https://blog.kempj.co.uk/2006/09/new-toys/</link><pubDate>Sat, 16 Sep 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/09/new-toys/</guid><description>&lt;p&gt;Well I’m back at Uni so I guess it’s time to get back to this blog and talk about things I’m doing =P The thing I’m liking most right now is playing with the new &lt;a href="http://www.gumstix.com/"&gt;Gumstix&lt;/a&gt; devices. I haven’t done too much with them yet but they show a lot of promise. Who can argue with a computer roughly the size of a stick of gum (guess where the name comes from) that runs Linux and has little expansion boards to give it USB, Ethernet, audio, Bluetooth and other such abilities. Because it runs Linux, which is nice and handy, you can run most programs you’ve written straight on it (using a very helpful remote shell), obviously you have to use a cross-compiler when compiling them but that’s no problem with the handy GCC toolchain they supply. Even nicer is sticking the Python interpreter on there and doing something a little more high-level. Working on a little something for them this weekend, whether it’s possible or not I don’t yet know, more info if it works.&lt;/p&gt;</description></item><item><title>Securing your code</title><link>https://blog.kempj.co.uk/2006/05/securing-your-code/</link><pubDate>Sat, 20 May 2006 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/2006/05/securing-your-code/</guid><description>&lt;p&gt;&lt;a href="http://www.xbox-linux.org/wiki/17_Mistakes_Microsoft_Made_in_the_Xbox_Security_System"&gt;This&lt;/a&gt; article on the Xbox-Linux site provides a background of all the exploits found for the Xbox to run non-Microsoft code, but more interestingly it finishes off by giving some &lt;em&gt;very&lt;/em&gt; good guidelines for implementing security in any system. Well worth reading in my opinion, especially if you are working on making secure software/hardware.&lt;/p&gt;&#10;&lt;p&gt;As a related note, the article reveals that Microsoft’s “don’t talk to anyone outside, don’t compromise” policy played a very large part in the downfall of the Xbox security.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;But the Xbox Linux Project did not blindly release this hack. The first savegame proof of concept exploit had been finished in January 2003. After that, a lot of energy was invested in finding out a way to free the Xbox for homebrew development and Linux, but not allowing game copies. Microsoft was contacted, but without any success. They just ignored the problem.&lt;/p&gt;&#10;&lt;p&gt;Finally in July, the hack was released, with heavy obfuscation, and lockout code for non-Linux use. It was obvious that this would only slow down the “hacking of the hack”, so eventually, people would be able to use this vulnerability for copied games, but since Microsoft showed no interest in finding a solution, there was no other option than full disclosure. The suggestion of the Xbox Linux Project would have been to work together with Microsoft to silently close the security holes and, in return, work on a method to let homebrew and Linux run on the Xbox.&lt;/p&gt;&#10;&lt;p&gt;[…]&lt;/p&gt;&#10;&lt;p&gt;Microsoft refused to talk about the savegame and font vulnerabilities. If we had been bad hackers, we could have released both of them as-is, immediately making it possible to run copies on Xboxes without the use of a modchip. Instead, we sought contact to Microsoft: We would have preferred to see a backdoor for Linux in the Xbox security system, instead of a solution based on our findings that would allow running copies. But as they refused to talk, we were forced to release the exploits, and they were lucky we heavily obfuscated our solutions so in order to slow down people interested in using it for copies.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>Modelica socket communication (Part 1: socket library, code listing)</title><link>https://blog.kempj.co.uk/modelica-socket-communication-part-1-socket-library/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/modelica-socket-communication-part-1-socket-library/</guid><description>&lt;p&gt;This page lists the code referred to in my blog post &lt;a href="https://blog.kempj.co.uk/2013/12/20131216-modelica-socket-communication-part-1-socket-library/"&gt;here&lt;/a&gt;).&lt;/p&gt;&#10;&lt;p&gt;&lt;tt&gt;Socket.c&lt;/tt&gt; contains the following (note that this hasn&amp;rsquo;t been tested under Windows).&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#ifdef _WIN32&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;#34;winsock2.h&amp;#34;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#else&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;sys/types.h&amp;gt;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#endif&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#include&lt;/span&gt; &lt;span style="color:#75715e"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span style="color:#75715e"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; s &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt; receive_buffer[&lt;span style="color:#ae81ff"&gt;255&lt;/span&gt;];&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;startup&lt;/span&gt;()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#ifdef _WIN32&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; WSADATA wsa;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;WSAStartup&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;MAKEWORD&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;), &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;wsa);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#else&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#endif&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;create_socket&lt;/span&gt;(&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;char&lt;/span&gt;&lt;span style="color:#f92672"&gt;*&lt;/span&gt; ip_address, &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; port)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#ifdef _WIN32&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; SOCKADDR_IN addr;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#else&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; sockaddr_in addr;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#endif&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; s &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;socket&lt;/span&gt;(AF_INET, SOCK_STREAM, &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;memset&lt;/span&gt;(&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;addr, &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;sizeof&lt;/span&gt;(addr));&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; addr.sin_family &lt;span style="color:#f92672"&gt;=&lt;/span&gt; AF_INET;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; addr.sin_port &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;htons&lt;/span&gt;(port); &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; addr.sin_addr.s_addr &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;inet_addr&lt;/span&gt;(ip_address); &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;#&lt;/span&gt;ifdef _WIN32&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;connect&lt;/span&gt;(s, (&lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; SOCKADDR&lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;addr, &lt;span style="color:#66d9ef"&gt;sizeof&lt;/span&gt;(addr)) &lt;span style="color:#f92672"&gt;==&lt;/span&gt; INVALID_SOCKET)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#else&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;connect&lt;/span&gt;(s, (&lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; sockaddr&lt;span style="color:#f92672"&gt;*&lt;/span&gt;)&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;addr, &lt;span style="color:#66d9ef"&gt;sizeof&lt;/span&gt;(addr)) &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#endif&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;void&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;send_message&lt;/span&gt;(&lt;span style="color:#66d9ef"&gt;char&lt;/span&gt;&lt;span style="color:#f92672"&gt;*&lt;/span&gt; buf)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;send&lt;/span&gt;(s, buf, &lt;span style="color:#a6e22e"&gt;strlen&lt;/span&gt;(buf), &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;char&lt;/span&gt;&lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;receive_message&lt;/span&gt;()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;recv&lt;/span&gt;(s, receive_buffer, &lt;span style="color:#ae81ff"&gt;255&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; receive_buffer;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;cleanup&lt;/span&gt;()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#ifdef _WIN32&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;WSACleanup&lt;/span&gt;();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#endif&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>OpenModelica and Python via CORBA (Part 3: Python wrapper, code listing)</title><link>https://blog.kempj.co.uk/openmodelica-and-python-via-corba-part-3-python-wrapper/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/openmodelica-and-python-via-corba-part-3-python-wrapper/</guid><description>&lt;p&gt;(omc.py)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; os&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; getpass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; omniORB &lt;span style="color:#f92672"&gt;import&lt;/span&gt; CORBA&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; idl._GlobalIDL &lt;span style="color:#66d9ef"&gt;as&lt;/span&gt; _GlobalIDL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;OMCError&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;Exception&lt;/span&gt;):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pass&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;OMCServerDownError&lt;/span&gt;(OMCError):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__init__&lt;/span&gt;(self, filename):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;filename &lt;span style="color:#f92672"&gt;=&lt;/span&gt; filename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__str__&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Could not find file &amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;filename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;InvalidOMCServerRefError&lt;/span&gt;(OMCError):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pass&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;OMC&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__init__&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;pass&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;connect&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; orb &lt;span style="color:#f92672"&gt;=&lt;/span&gt; CORBA&lt;span style="color:#f92672"&gt;.&lt;/span&gt;ORB_init([&lt;span style="color:#e6db74"&gt;&amp;#34;-ORBInitRef&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;mico-local-orb=corbaloc::localhost:0/mico-local-orb&amp;#34;&lt;/span&gt;], CORBA&lt;span style="color:#f92672"&gt;.&lt;/span&gt;ORB_ID)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; omc_objid_file &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;/tmp/openmodelica.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.objid&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; getpass&lt;span style="color:#f92672"&gt;.&lt;/span&gt;getuser()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; omc_corba_uri &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;file:///&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; omc_objid_file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# See if the omc server is running&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;not&lt;/span&gt; os&lt;span style="color:#f92672"&gt;.&lt;/span&gt;path&lt;span style="color:#f92672"&gt;.&lt;/span&gt;isfile(omc_objid_file):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;raise&lt;/span&gt; OMCServerDownError(omc_objid_file)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; objid_file &lt;span style="color:#f92672"&gt;=&lt;/span&gt; open(omc_objid_file)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ior &lt;span style="color:#f92672"&gt;=&lt;/span&gt; objid_file&lt;span style="color:#f92672"&gt;.&lt;/span&gt;readline()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; objid_file&lt;span style="color:#f92672"&gt;.&lt;/span&gt;close()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; mico_obj &lt;span style="color:#f92672"&gt;=&lt;/span&gt; orb&lt;span style="color:#f92672"&gt;.&lt;/span&gt;resolve_initial_references(&lt;span style="color:#e6db74"&gt;&amp;#34;RootPOA&amp;#34;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; obj &lt;span style="color:#f92672"&gt;=&lt;/span&gt; orb&lt;span style="color:#f92672"&gt;.&lt;/span&gt;string_to_object(ior)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; omc &lt;span style="color:#f92672"&gt;=&lt;/span&gt; obj&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_narrow(_GlobalIDL&lt;span style="color:#f92672"&gt;.&lt;/span&gt;OmcCommunication)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; omc &lt;span style="color:#f92672"&gt;is&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;None&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;raise&lt;/span&gt; InvalidOMCServerRefError&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;omc &lt;span style="color:#f92672"&gt;=&lt;/span&gt; omc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;_send_command&lt;/span&gt;(self, command):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;omc&lt;span style="color:#f92672"&gt;.&lt;/span&gt;sendExpression(command)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_current_directory&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;cd()&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;clear&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;clear()&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip() &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;true&amp;#39;&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;list_classes&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;list()&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;list_class&lt;/span&gt;(self, classname):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;list(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;)&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; classname)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;list_variables&lt;/span&gt;(self):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;listVariables()&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;load_file&lt;/span&gt;(self, filename):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;loadFile(&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;)&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; filename)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip() &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;true&amp;#39;&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;plot&lt;/span&gt;(self, variable):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;plot(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;)&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; variable)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip() &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;true&amp;#39;&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;simulate&lt;/span&gt;(self, classname, &lt;span style="color:#f92672"&gt;**&lt;/span&gt;args):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; options &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#39;, &lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; (k, v) &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; k,v &lt;span style="color:#f92672"&gt;in&lt;/span&gt; args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;iteritems()]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; options &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;join(options)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;_send_command(&lt;span style="color:#e6db74"&gt;&amp;#39;simulate(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%s%s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;)&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;%&lt;/span&gt; (classname, options))&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip()&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Plotting hardware stats via plotly (code listing)</title><link>https://blog.kempj.co.uk/plotting-hardware-stats-via-plotly/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.kempj.co.uk/plotting-hardware-stats-via-plotly/</guid><description>&lt;p&gt;This page lists the code referred to in my blog post &lt;a href="https://blog.kempj.co.uk/2014/02/plotting-hardware-stats-via-plotly/"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Temperature/usage stats based on:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&amp;amp;t=22180&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# http://rollcode.com/use-python-get-raspberry-pis-temperature/&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; subprocess &lt;span style="color:#f92672"&gt;import&lt;/span&gt; PIPE, Popen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; psutil&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; datetime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; plotly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; time&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; calendar&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;USERNAME &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;APIKEY &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;api_key&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_cpu_temp&lt;/span&gt;():&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tempFile &lt;span style="color:#f92672"&gt;=&lt;/span&gt; open(&lt;span style="color:#e6db74"&gt;&amp;#34;/sys/class/thermal/thermal_zone0/temp&amp;#34;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cpu_temp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; tempFile&lt;span style="color:#f92672"&gt;.&lt;/span&gt;read()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tempFile&lt;span style="color:#f92672"&gt;.&lt;/span&gt;close()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; float(cpu_temp&lt;span style="color:#f92672"&gt;.&lt;/span&gt;strip()) &lt;span style="color:#f92672"&gt;/&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1000.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_gpu_temp&lt;/span&gt;():&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; process &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Popen([&lt;span style="color:#e6db74"&gt;&amp;#39;vcgencmd&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;measure_temp&amp;#39;&lt;/span&gt;], stdout&lt;span style="color:#f92672"&gt;=&lt;/span&gt;PIPE)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; output, _error &lt;span style="color:#f92672"&gt;=&lt;/span&gt; process&lt;span style="color:#f92672"&gt;.&lt;/span&gt;communicate()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; float(output[output&lt;span style="color:#f92672"&gt;.&lt;/span&gt;index(&lt;span style="color:#e6db74"&gt;&amp;#39;=&amp;#39;&lt;/span&gt;) &lt;span style="color:#f92672"&gt;+&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:output&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rindex(&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;)])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_ram_used&lt;/span&gt;():&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; psutil&lt;span style="color:#f92672"&gt;.&lt;/span&gt;phymem_usage()&lt;span style="color:#f92672"&gt;.&lt;/span&gt;percent&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_cpu_usage&lt;/span&gt;():&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; psutil&lt;span style="color:#f92672"&gt;.&lt;/span&gt;cpu_percent()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;filename &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;cam1_test&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;layout &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;title&amp;#39;&lt;/span&gt; : &lt;span style="color:#e6db74"&gt;&amp;#39;Camera 1 hardware&amp;#39;&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;xaxis&amp;#39;&lt;/span&gt; : {&lt;span style="color:#e6db74"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;Time&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;type&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;date&amp;#39;&lt;/span&gt;},&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;yaxis&amp;#39;&lt;/span&gt; : {&lt;span style="color:#e6db74"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;Temperature (deg. C)&amp;#39;&lt;/span&gt;},&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;yaxis2&amp;#39;&lt;/span&gt; : {&lt;span style="color:#e6db74"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;% u&lt;/span&gt;&lt;span style="color:#e6db74"&gt;sage&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;side&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;right&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;overlaying&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;},&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;showlegend&amp;#39;&lt;/span&gt; : &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;legend&amp;#39;&lt;/span&gt; : {&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt; : &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt; : &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;},&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;py &lt;span style="color:#f92672"&gt;=&lt;/span&gt; plotly&lt;span style="color:#f92672"&gt;.&lt;/span&gt;plotly(username_or_email&lt;span style="color:#f92672"&gt;=&lt;/span&gt;USERNAME, key&lt;span style="color:#f92672"&gt;=&lt;/span&gt;APIKEY)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;py&lt;span style="color:#f92672"&gt;.&lt;/span&gt;layout(layout, filename&lt;span style="color:#f92672"&gt;=&lt;/span&gt;filename)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;camera_started &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;end_time &lt;span style="color:#f92672"&gt;=&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utcnow() &lt;span style="color:#f92672"&gt;+&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timedelta(minutes &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;6&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curr_time &lt;span style="color:#f92672"&gt;=&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utcnow()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;expected_update &lt;span style="color:#f92672"&gt;=&lt;/span&gt; curr_time &lt;span style="color:#f92672"&gt;+&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timedelta()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; curr_time &lt;span style="color:#f92672"&gt;&amp;lt;=&lt;/span&gt; end_time:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cpu_temp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;: [curr_time], &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;: [get_cpu_temp()], &lt;span style="color:#e6db74"&gt;&amp;#39;type&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;scatter&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;mode&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;lines&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;CPU temperature&amp;#39;&lt;/span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; gpu_temp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;: [curr_time], &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;: [get_gpu_temp()], &lt;span style="color:#e6db74"&gt;&amp;#39;type&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;scatter&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;mode&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;lines&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;GPU temperature&amp;#39;&lt;/span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ram_used &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;: [curr_time], &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;: [get_ram_used()], &lt;span style="color:#e6db74"&gt;&amp;#39;type&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;scatter&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;mode&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;lines&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;RAM usage&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;yaxis&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;y2&amp;#39;&lt;/span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; cpu_load &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;: [curr_time], &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;: [get_cpu_usage()], &lt;span style="color:#e6db74"&gt;&amp;#39;type&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;scatter&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;mode&amp;#39;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;lines&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;CPU usage&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;yaxis&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;y2&amp;#39;&lt;/span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; _cpu_load &lt;span style="color:#f92672"&gt;=&lt;/span&gt; cpu_load[&lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;][&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; _cpu_load &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;75&lt;/span&gt; &lt;span style="color:#f92672"&gt;and&lt;/span&gt; &lt;span style="color:#f92672"&gt;not&lt;/span&gt;(camera_started):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; layout[&lt;span style="color:#e6db74"&gt;&amp;#39;annotations&amp;#39;&lt;/span&gt;] &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [{&lt;span style="color:#e6db74"&gt;&amp;#39;text&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;Camera enabled&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;xref&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;yref&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;y2&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;:calendar&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timegm(curr_time&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utctimetuple())&lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1000&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;:_cpu_load, &lt;span style="color:#e6db74"&gt;&amp;#39;ax&amp;#39;&lt;/span&gt;:&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;ay&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;showarrow&amp;#39;&lt;/span&gt;:&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;arrowhead&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;7&lt;/span&gt;}]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; py&lt;span style="color:#f92672"&gt;.&lt;/span&gt;layout(layout, filename&lt;span style="color:#f92672"&gt;=&lt;/span&gt;filename)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; end_time &lt;span style="color:#f92672"&gt;=&lt;/span&gt; curr_time &lt;span style="color:#f92672"&gt;+&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timedelta(minutes &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;6&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; camera_started &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; _cpu_load &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;50&lt;/span&gt; &lt;span style="color:#f92672"&gt;and&lt;/span&gt; camera_started:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; layout[&lt;span style="color:#e6db74"&gt;&amp;#39;annotations&amp;#39;&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append({&lt;span style="color:#e6db74"&gt;&amp;#39;text&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;Camera disabled&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;xref&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;yref&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;y2&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;:calendar&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timegm(curr_time&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utctimetuple())&lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1000&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;y&amp;#39;&lt;/span&gt;:_cpu_load, &lt;span style="color:#e6db74"&gt;&amp;#39;ax&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;ay&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;showarrow&amp;#39;&lt;/span&gt;:&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;arrowhead&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;7&lt;/span&gt;})&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; py&lt;span style="color:#f92672"&gt;.&lt;/span&gt;layout(layout, filename&lt;span style="color:#f92672"&gt;=&lt;/span&gt;filename)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; end_time &lt;span style="color:#f92672"&gt;=&lt;/span&gt; curr_time &lt;span style="color:#f92672"&gt;+&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timedelta(minutes &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; camera_started &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; response &lt;span style="color:#f92672"&gt;=&lt;/span&gt; py&lt;span style="color:#f92672"&gt;.&lt;/span&gt;plot([cpu_temp, gpu_temp, ram_used, cpu_load], filename&lt;span style="color:#f92672"&gt;=&lt;/span&gt;filename, fileopt&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;extend&amp;#39;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print curr_time&lt;span style="color:#f92672"&gt;.&lt;/span&gt;isoformat(&lt;span style="color:#e6db74"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; expected_update &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;timedelta(seconds &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;30&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; time&lt;span style="color:#f92672"&gt;.&lt;/span&gt;sleep((expected_update &lt;span style="color:#f92672"&gt;-&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utcnow())&lt;span style="color:#f92672"&gt;.&lt;/span&gt;total_seconds()) &lt;span style="color:#75715e"&gt;# Compensate for the loop taking some time&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; curr_time &lt;span style="color:#f92672"&gt;=&lt;/span&gt; datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;datetime&lt;span style="color:#f92672"&gt;.&lt;/span&gt;utcnow()&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>