<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nAnL - hacken, kracken, kacken &#187; Tech</title>
	<atom:link href="http://nanl.de/blog/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://nanl.de/blog</link>
	<description></description>
	<lastBuildDate>Fri, 16 Dec 2011 16:59:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PostgreSQL &#8211; altering table name does not update references to its primary key and sequence automatically</title>
		<link>http://nanl.de/blog/2011/10/postgresql-altering-table-name-screws-up-references-to-its-primary-key-and-sequence/</link>
		<comments>http://nanl.de/blog/2011/10/postgresql-altering-table-name-screws-up-references-to-its-primary-key-and-sequence/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 10:27:42 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[English articles]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=609</guid>
		<description><![CDATA[During a setup of multiple PostgreSQL instances, replicating content via the replication framework Slony-I, I had to manually create the very same SQL schema to every Postgres node &#8211; as Slony just replicates the payload data and not the actual SQL schemas. I was creating tables like this on every node: CREATE TABLE x ( [...]]]></description>
			<content:encoded><![CDATA[<p>During a setup of multiple PostgreSQL instances, replicating content via the replication framework <a title="Slony-I" href="http://slony.info/" target="_blank">Slony-I</a>, I had to manually create the very same SQL schema to every Postgres node &#8211; as Slony just replicates the payload data and not the actual SQL schemas.</p>
<p>I was creating tables like this on every node:</p>
<blockquote><p>CREATE TABLE <strong>x</strong> (<br />
id             SERIAL PRIMARY KEY,<br />
content   VARCHAR(255) DEFAULT NULL<br />
);</p></blockquote>
<p>but decided after half of having those nodes I already configured to rename the table from &#8216;<strong>x</strong>&#8216; to &#8216;<strong>y</strong>&#8216; using the &#8216;<strong>ALTER TABLE</strong>&#8216; command</p>
<blockquote><p>ALTER TABLE <strong>x</strong> RENAME TO <strong>y</strong>;</p></blockquote>
<p>and continued creating the schemas on the remaining nodes with the following command:</p>
<blockquote><p>CREATE TABLE <strong>y</strong> (<br />
id             SERIAL PRIMARY KEY,<br />
content   VARCHAR(255) DEFAULT NULL<br />
);</p></blockquote>
<p>After finally having provided the schema to all nodes I started the replication daemons and got thrown errors from half of the nodes that replication doesn&#8217;t work properly since the schema doesn&#8217;t match the one on the master replication server:</p>
<blockquote><p>CESTERROR  remoteWorkerThread_1: &#8220;select &#8220;_db&#8221;.setAddTable_int(1, 3, &#8216;&#8221;public&#8221;.&#8221;y&#8221;&#8216;, &#8216;x_pkey&#8217;, &#8216;Table public.y with primary key&#8217;); &#8221; PGRES_FATAL_ERROR ERROR:  Slony-I: setAddTable_int(): table &#8220;public&#8221;.&#8221;y&#8221; has no index x_pkey</p></blockquote>
<p>All of the non-working nodes were those, I first created the table <strong>x</strong> on and later renamed it<strong> </strong>to <strong>y</strong>, instead of just directly creating table <strong>y</strong> like I did on the others.</p>
<p>Looking at the global table definitions &#8211; including the automatically co-created sequence &#8211; you can see that the table did get renamed, but the sequence didn&#8217;t:</p>
<p>Table <strong>y</strong> directly created:</p>
<blockquote><p>postgres=# \d<br />
List of relations<br />
Schema |      Name      |   Type   |  Owner<br />
&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-<br />
public | <strong>y</strong>              | table    | postgres<br />
public | <strong>y_id_seq</strong>       | sequence | postgres<br />
(4 rows)</p></blockquote>
<p>Table <strong>x</strong> created and altered to be named <strong>y</strong>:</p>
<blockquote><p>postgres=# \d<br />
List of relations<br />
Schema |      Name      |   Type   |  Owner<br />
&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-<br />
public | <strong>y</strong>              | table    | postgres<br />
public | <strong>x_id_seq</strong>       | sequence | postgres<br />
(4 rows)</p></blockquote>
<p>That <em>normally</em> doesn&#8217;t cause any trouble, since the reference of table <strong>y</strong> (formerly <strong>x</strong>) to the sequence <strong>x_id_seq</strong> is still valid. However since replication requires the very exact same schema on every node this actually <strong>is</strong> causing trouble. However that&#8217;s not the error mentioned in the error message above, which is referring to the <strong>primary key</strong>.</p>
<p>Diff&#8217;ing the actual schemas shows up more differences:</p>
<blockquote><p>                                  Table &#8220;public.y&#8221;<br />
Column  |          Type          |                   Modifiers<br />
&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
- id      | integer                | not null default nextval(&#8216;<strong>x_id_seq</strong>&#8216;::regclass)<br />
+ id      | integer                | not null default nextval(&#8216;<strong>y_id_seq</strong>&#8216;::regclass)<br />
content | character varying(255) | default NULL::character varying<br />
Indexes:<br />
-    &#8220;<strong>x_pkey</strong>&#8221; PRIMARY KEY, btree (id)<br />
+    &#8220;<strong>y_pkey</strong>&#8221; PRIMARY KEY, btree (id)</p></blockquote>
<p>The reference to the sequence and and name of the reference to the value of the primary key were <strong>NOT</strong> updated by altering the table name to match again. This separation of table-name and references might be a feature, however I find it hard to imagine a use-case where it makes sense using the sequence and/or primary key of another table. <em><strong>UPDATE:</strong> I just got told that it indeed might make sense sharing one sequence among several tables</em>.</p>
<p>Also sequence and primary key were created inside / co-created by the &#8216;<strong>CREATE TABLE</strong>&#8216; statement, so at least I&#8217;d find it more consistent if both would be <strong>always</strong> reference by <strong>this</strong> table, by means of the table they got originally created with.</p>
<p>Looking for information, hints or documentation about this behaviour wasn&#8217;t fruitful as well.</p>
<p>So personally I&#8217;d really like to really see those reference updated &#8211; by changing the tables name - automatically.  I&#8217;d like to see at least a <strong>NOTICE</strong> that primary key and sequence are still haveing the name of / are referring to it&#8217;s old values and need to be updated / re-created to match again.</p>
<p><strong><em>Conclusion:</em> Make sure &#8211; when altering table names in Postgres &#8211; references to primary key and sequence are getting updated as well &#8211; manually! Primary key and sequence are NOT tied together with the table they got created with!<br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/10/postgresql-altering-table-name-screws-up-references-to-its-primary-key-and-sequence/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LinuxInput devices (in Qt embedded) &#8211; take care!</title>
		<link>http://nanl.de/blog/2011/06/linuxinput-devices-in-qt-embedded-take-care/</link>
		<comments>http://nanl.de/blog/2011/06/linuxinput-devices-in-qt-embedded-take-care/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 01:06:01 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=586</guid>
		<description><![CDATA[I&#8217;m currently working on an embedded project based on Linux which involves a graphical user interface based on Qt. In our case Qt accesses framebuffer as well as the LinuxInput devices directly &#8211; there is no further layer (DirectFB, Xorg, Wayland, etc.) in between. In this quite common scenario I noticed that Qt is treating [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on an embedded project based on Linux which involves a graphical user interface based on Qt.</p>
<p>In our case Qt accesses framebuffer as well as the LinuxInput devices directly &#8211; there is no further layer (DirectFB, Xorg, Wayland, etc.) in between.</p>
<p>In this quite common scenario I noticed that Qt is treating the LinuxInput devices in a quite counterintuitive way which may lead into severe security problems.<br />
The embedded device we are using in this particular project has a keyboard which to the userland is exposed as LinuxInput device.</p>
<p>Everything worked quite well, however our Qt application crashed once due to a programming error (our fault) and I was shown the underlying UNIX console which<strong> reflected every single keystroke I did inside the Qt application &#8211; all typing input within the Qt application also got passed to other applications / underlying shells!</strong></p>
<p><strong>An exposed root shell to the active TTY &#8211; possibly hidden by the GUI &#8211; is therewith also capturing all input.</strong> Since almost all linux (embedded) distributions are exposing login prompts / shells to all TTYs by default, this scenario is far from being unlikely.</p>
<p>My expected behavior would have been: the Qt application is opening the LinuxInput devices exclusively, so that <strong>only</strong> the Qt application receives data from the input devices.</p>
<p>After some research and asking around I got pointed to the EVIOCGRAB IOCTL implemented in the LinuxInput subsystem.</p>
<p>As stated in $(LINUX_KERNEL)/include/input/linux.h:</p>
<blockquote><p>@grab: input handle that currently has the device grabbed (via<br />
EVIOCGRAB ioctl). When a handle grabs a device it becomes sole<br />
recipient for all input events coming from the device</p></blockquote>
<p>This means: When opening LinuxInput devices they&#8217;re not grabbed, they&#8217;re<strong> not opened exclusively by default</strong>.</p>
<p>Okay, I got it <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So let&#8217;s just find the magic option / command which tells Qt to set up an EVIOCGRAB with an appropriate argument on the going-to-be-used LinuxInput device. Since I didn&#8217;t find any documentation I grep&#8217;ed through the Qt source:</p>
<blockquote><p>&gt; ~/src/qt.git$ git grep EVIOCGRAB<br />
&gt; ~/src/qt.git$</p></blockquote>
<p>nothing&#8230; so I took a closer look into how Qt implemented support for LinuxInput devices (src/gui/embedded/qkbdlinuxinput_qws.cpp) &#8211; still nothing&#8230;</p>
<p>So I implemented support for telling Qt to open LinuxInput devices exclusively by optionally passing an &#8216;grab&#8217;-argument to the LinuxInput drivers inside Qt.</p>
<p>And here it is &#8211; a patch which adds support for passing another parameter named &#8216;grab&#8217; to the LinuxInput device driver of Qt &#8211; to specify whether the device should be opened exclusively (grabbed) or not.</p>
<blockquote><p><a href="https://dev.openwrt.org/browser/packages/Xorg/lib/qt4/patches/500-allow-device-grabbing.patch?rev=26780">https://dev.openwrt.org/browser/packages/Xorg/lib/qt4/patches/500-allow-device-grabbing.patch?rev=26780</a></p></blockquote>
<p><strong>Conclusion: Take care when using Qt and its LinuxInput drivers &#8211; all input might be received and used by other applications as well &#8211; including shells running on TTYs.</strong></p>
<p>&nbsp;</p>
<p><strong>UPDATE:</strong> The patch finally git committed and went upstream. Grabbing can now be configured since Qt version 4.8 (http://www.qt.gitorious.org/qt/qt/commit/947aaa79b05adec527c7500e36766c7ff19f118d/diffs)</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/06/linuxinput-devices-in-qt-embedded-take-care/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RFM12 &#8211; kernel patches</title>
		<link>http://nanl.de/blog/2011/04/rfm12-kernel-patches/</link>
		<comments>http://nanl.de/blog/2011/04/rfm12-kernel-patches/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 05:32:26 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=569</guid>
		<description><![CDATA[Since I got asked several times about the pin mappings and wirings between the rfm12 modules and GPIOs of the devices providing them (in my case the Netgear WGT634U router / the Qi NanoNote) I&#8217;d like to try making some things clearer: In Linux the use of buses is tried to get as abstracted as [...]]]></description>
			<content:encoded><![CDATA[<p>Since I got asked several times about the pin mappings and wirings between the rfm12 modules and GPIOs of the devices providing them (in my case the <a href="http://nanl.de/blog/2011/01/rfm12-under-linux-and-remote-controlled-power-sockets/">Netgear WGT634U router</a> / the <a href="http://nanl.de/blog/2011/02/ben-nanonote-able-to-control-radio-power-sockets/">Qi NanoNote</a>) I&#8217;d like to try making some things clearer:</p>
<p>In Linux the use of buses is tried to get as abstracted as possible &#8211; the idea is that the actual boards (or call it whatever you like as devices, platforms etc) define and expose the capability of buses and its properties.</p>
<p>In our case the rfm12 kernel module requires the availability of an SPI bus &#8211; it doesn&#8217;t matter how it is implemented (native SPI bus, SPI over GPIOs or any other way of implementation). The client module &#8211; the kernel module implementing an driver for the actual rfm12 hardware &#8211; simply doesn&#8217;t care and doesn&#8217;t need to know about that.</p>
<p>That&#8217;s the reason why the actual <a href="https://github.com/mirko/rfm12-ASK-for-linux">rfm12 code</a> doesn&#8217;t contain any GPIO &lt;-&gt; rfm12 hardware mappings &#8211; the rfm12 code is just using an existing and otherwise exposed SPI bus.</p>
<p>The actual wiring / mapping and setup of the SPI bus is done within the platform / board / device code, which is located below <em>arch/${ARCH}/${BOARD}</em> &#8211; a common place for code like that is <em>arch/${ARCH}/${BOARD}/setup.c</em>.</p>
<p>This project however seemed to have raised some interest and I got asked quite a few times about the board specific changes I made &#8211; so here they are now:<br />the <a href="https://github.com/mirko/rfm12-ASK-for-linux/tree/master/patches/openwrt/target/linux">kernel patches</a> which provide SPI buses on both boards, including GPIO mappings.</p>
<p>Since both targets I used the rfm12 module and driver on are running OpenWrt, I created both patches against the Linux vanilla tree having OpenWrt specific kernel patches already applied.</p>
<p>Changes however are small and clear, so they should be easy to understand and adapt.</p>
<p>The wiring I used to get the rfm12 module working on the NanoNote working by the way is the following:<br />
<code><br />
GPIO | PIN on SD port | PIN on module | purpose / description<br />
=====|================|===============|=================================<br />
108  | D12 (1)        | MISO / SDO    | SPI: master input slave output<br />
109  | D13 (2)        | nIRQ          | interrupt<br />
104  | D08 (3)        | (unused)      | (unused)<br />
X    | VDD (4)        | VDD           | power<br />
105  | D09 (5)        | MOSI / SDI    | SPI: master output slave input<br />
X    | VSS (6)        | GND (1+2)     | ground<br />
106  | D10 (7)        | SCK           | SPI: clock<br />
107  | D11 (8)        | nSEL          | SPI: chip select<br />
</code></p>
<p>There needs to be a resistor (10-100kOhm) between pin FSK (if used) of<br />
the rfm12 module and VDD as pullup &#8211; however when just using ASK it isn&#8217;t needed anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/04/rfm12-kernel-patches/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GDB behaves strange while debugging threads</title>
		<link>http://nanl.de/blog/2011/02/gdb-behaves-strange-when-debugging-threads/</link>
		<comments>http://nanl.de/blog/2011/02/gdb-behaves-strange-when-debugging-threads/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 18:08:50 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=556</guid>
		<description><![CDATA[While debugging issues involving binaries on a system running Linux, having a debugger such as GDB available is quite helpful. However while working on a certain project we recently experienced quite some issues debugging applications involving threads. Debugging the application on my local workstation worked quite fine, however on OpenWrt-targets &#8211; ARM as well as [...]]]></description>
			<content:encoded><![CDATA[<p>While debugging issues involving binaries on a system running Linux, having a debugger such as GDB available is quite helpful.</p>
<p>However while working on a certain project we recently experienced quite some issues debugging applications involving <strong>threads</strong>.</p>
<p>Debugging the application on my local workstation worked quite fine, however on OpenWrt-targets &#8211; ARM as well as MIPS &#8211; it behaved rather strange: stack corruptions, missing traces, weird signals got issued&#8230;</p>
<p>After quite some time of debugging the debug issue, we found out the issue is caused by a <strong>stripped version of libpthread.so</strong>.</p>
<p>Stripped &#8211; not in the sense of a more lightweight but compatible version of the pthread library &#8211; but stripped by the utility &#8220;strip&#8221;, which purges all debug- and &#8220;other unneeded&#8221; symbols out of binaries to reduce their size, which usually is applied on all binaries by the OpenWrt framework automatically.</p>
<p>Usually binaries stripped by &#8220;strip&#8221; are still fully-fledged binaries, still usable with GDB (however without debugging symbols available of course). Applying strip on libpthread.so* however, it seems to strip out also stuff needed by GDB following and tracing threads. Without these symbols / meta-information not needed for running the actual application, but for tracking its threads, GDB results in mentioned issues above.</p>
<p>One might ask why someone is debugging binaries without debug symbols compiled in &#8211; reasons are obvious:</p>
<ul>
<li>there&#8217;s not enough storage available</li>
<li>there&#8217;s not enough RAM available</li>
<li>using gdbserver and having the binaries with debug symbols compiled in on another machine communicating with gdbserver</li>
</ul>
<p>To check whether an object got stripped or not is quite easy using the &#8220;file&#8221; util:</p>
<blockquote><p>$ file build_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so<br />
build_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), <strong>stripped</strong></p></blockquote>
<blockquote><p>$ file staging_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so<br />
staging_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), <strong>not stripped</strong></p></blockquote>
<p><strong>Long story short: </strong>When debugging applications involving threads, always use a non-stripped version of libpthread.so, even if debug symbols are not needed!</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/02/gdb-behaves-strange-when-debugging-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ben NanoNote able to control radio power sockets</title>
		<link>http://nanl.de/blog/2011/02/ben-nanonote-able-to-control-radio-power-sockets/</link>
		<comments>http://nanl.de/blog/2011/02/ben-nanonote-able-to-control-radio-power-sockets/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 03:17:51 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=527</guid>
		<description><![CDATA[The Ben NanoNote is now able to switch radio controlled power sockets, too! The rfm12 433MHz module, produced by HopeRF,  is attached to the microSD port of the Ben NanoNote, which pins are exposed via an microSD card dummy adapter. The System-on-a-chip used inside the Ben NanoNote (ingenic JZ47XX) allows us to put the microSD [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The <a href="http://www.qi-hardware.com/products/ben-nanonote/">Ben NanoNote</a> is now able to switch radio controlled power sockets, too!</strong></p>
<p>The <a href="http://www.hoperf.com/rf_fsk/rfm12.htm">rfm12 433MHz module, produced by HopeRF</a>,  is attached to the microSD port of the Ben NanoNote, which pins are exposed via an microSD card dummy adapter.</p>
<div class="wp-caption alignnone" style="width: 503px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_microsd1.jpg"><img title="rfm12_microsd" src="http://nanl.de/blog/wp-content/uploads/rfm12_microsd1.jpg" alt="" width="493" height="439" /></a><p class="wp-caption-text">rfm12 module attached to a microSD dummy</p></div>
<p>The System-on-a-chip used inside the Ben NanoNote (ingenic JZ47XX) allows us to put the microSD pins into GPIO mode, so we can <a href="http://nanl.de/blog/2011/01/rfm12-under-linux-and-remote-controlled-power-sockets/">(as already done for the first device, the Netgear WGT634u router, I connected an rfm12-module to)</a> create and export an SPI bus on top of them to be able communicating with the module.</p>
<p>That way there&#8217;s no need of opening the device and/or soldering anything anywhere &#8211; the module is attached directly to the microSD dummy which gets simply inserted into microSD slot of the NanoNote.</p>
<div id="attachment_528" class="wp-caption alignnone" style="width: 491px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote1.jpg"><img class="size-full wp-image-528" title="rfm12_nanonote" src="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote1.jpg" alt="" width="481" height="322" /></a><p class="wp-caption-text">rfm12 module attached to NanoNote running ncurses UI for switching power sockets</p></div>
<p>I wrote a basic but fully working ncurses frontend using the rfm12 library listing configured devices waiting for getting switched.</p>
<p>There&#8217;s also a ready-to-use XMLRPC daemon available which exposes all configured devices and provides functions for controlling them, so UIs for controlling devices are not limited to run on the same system the rfm12 module is installed on.</p>
<div id="attachment_539" class="wp-caption alignnone" style="width: 510px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote_ncurses-ui1.jpg"><img class="size-full wp-image-539" title="rfm12_nanonote_ncurses-ui" src="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote_ncurses-ui1.jpg" alt="" width="500" height="417" /></a><p class="wp-caption-text">ncurses UI for switching configured radio controlled power sockets on the Ben NanoNote</p></div>
<p>I&#8217;ve also written a little GUI in python using the qt4 toolkit, connecting to the master via XML-RPC:</p>
<div id="attachment_540" class="wp-caption alignnone" style="width: 520px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_pyqt-ui1.jpg"><img class="size-full wp-image-540" title="rfm12_pyqt-ui" src="http://nanl.de/blog/wp-content/uploads/rfm12_pyqt-ui1.jpg" alt="" width="510" height="135" /></a><p class="wp-caption-text">switching radio controlled power via a GUI using pyqt4</p></div>
<p>Several other frontends are work-in-progress as e.g. a GUI for the Android platform, as well as one based on qt4/QML being able to run e.g. on phones running Meego/Maemo as operating system &#8211; both using the XML-RPC interface.</p>
<p>So all major parts of the project are mostly finished now and the API is more or less fix.</p>
<p>The the whole project now consists of (a rough overview):</p>
<ol>
<li>the kernel module which communicates with the actual hardware (so the rfm12 module) and exposes a character device to userspace</li>
<li>the rfm12 library which</li>
<ul>
<li>connects to the kernel module</li>
<li>contains the device type specific data and code to modulate signals which control the actual power sockets</li>
<li>provides functions for reading / writing configuration files and controlling / switching devices</li>
</ul>
<li>applications using the library and its functions for actual controlling of devices, which could be / already are:</li>
<ul>
<li>UI applications linked directly against librfm12 (an ncurses frontend (shown above) is available yet)</li>
<li>daemons providing network interfaces (a daemon exporting functionality via XMLRPC is available yet , one doing the same but using JSON-RPC as underlying rpc method is going to be implemented soon)</li>
</ul>
<li>UIs running on different machines, using these RPC services  (e.g. above pyqt4  frontend; android- and qml-frontends are work-in-progress)</li>
</ol>
<p>Devices are getting configured via configuration files, describing the <strong>product type</strong> of the device, a <strong>name</strong> and the actual <strong>code </strong>which is used to identify devices of a certain product type group.</p>
<p>The config used by the applications shown on the photos / screenshots above just looks this:</p>
<blockquote>
<div id="_mcePaste">[socket_A]</div>
<div id="_mcePaste">label = &#8220;one&#8221;</div>
<div id="_mcePaste">product = &#8220;P801B&#8221;</div>
<div id="_mcePaste">code = &#8220;1111110000&#8243;</div>
<div id="_mcePaste">[socket_B]</div>
<div id="_mcePaste">label = &#8220;two&#8221;</div>
<div id="_mcePaste">product = &#8220;2272&#8243;</div>
<div id="_mcePaste">code = &#8220;1111110000&#8243;</div>
<div id="_mcePaste">[socket_C]</div>
<div id="_mcePaste">label = &#8220;three&#8221;</div>
<div id="_mcePaste">product = &#8220;2272&#8243;</div>
<div id="_mcePaste">code = &#8220;1111101000&#8243;</div>
</blockquote>
<p>One of the tasks I&#8217;m working on right now, is <strong>state sharing</strong>. While the list of configured devices and it&#8217;s states (on/off) is already shared among all XML-RPC clients (so having switched a unit in one client, others will fetch the changed state next time they poll/refresh), the state is not yet shared between several processes invoking the librfm12.</p>
<p>Issue is: Every process linked against librfm12 creates its own list of devices, including states &#8211; so every process has its own copy. Changes done in one process are not shared among others. This could be solved using IPC (System V shared memory, sockets every instance connects to, etc.).</p>
<p>That&#8217;s it &#8211; feedback and/or participation is highly appreciated!</p>
<div id="attachment_544" class="wp-caption alignnone" style="width: 599px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote_radiosockets1.jpg"><br />
<img class="size-full wp-image-544 " style="padding: 0px; margin: 0px; border: 0px none initial;" title="rfm12_nanonote_radiosockets" src="http://nanl.de/blog/wp-content/uploads/rfm12_nanonote_radiosockets1.jpg" alt="" width="589" height="335" /></a><p class="wp-caption-text">Ben NanoNote having an rfm12 module attached via microSD-port and several types of radio controlled power sockets</p></div>
<p>Source Code is still available on github: <a href="  Ben NanoNote having an rfm12 module attached via microSD-port and several types of radio controlled power sockets ">https://github.com/mirko/rfm12-ASK-for-linux</a> <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/02/ben-nanonote-able-to-control-radio-power-sockets/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>RFM12 under Linux and remote controlled power sockets</title>
		<link>http://nanl.de/blog/2011/01/rfm12-under-linux-and-remote-controlled-power-sockets/</link>
		<comments>http://nanl.de/blog/2011/01/rfm12-under-linux-and-remote-controlled-power-sockets/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 15:17:59 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=490</guid>
		<description><![CDATA[Currently I&#8217;m working on a project communicating and transmitting signals over the air with an 433 MHz radio module called &#8220;rfm12&#8220;, produced by HopeRF, soldered onto devices capable of running OpenWrt and having at least 3 accessible GPIO&#8217;s. Short story long: These radio modules are capable of sending / receiving over the ISM frequency band, [...]]]></description>
			<content:encoded><![CDATA[<p>Currently I&#8217;m working on a project communicating and transmitting signals over the air with an 433 MHz radio module called &#8220;<a href="http://www.hoperf.com/rf_fsk/rfm12.htm">rfm12</a>&#8220;, produced by HopeRF, soldered onto devices capable of running OpenWrt and having at least 3 accessible GPIO&#8217;s.</p>
<p><strong>Short story long:</strong></p>
<p>These radio modules are capable of sending / receiving over the ISM frequency band, as e.g. 433 MHz or 868 MHz and just cost about 5 Euros.</p>
<div id="attachment_515" class="wp-caption alignnone" style="width: 499px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_module1.jpg"><img class="size-full wp-image-515" title="RFM12 module" src="http://nanl.de/blog/wp-content/uploads/rfm12_module1.jpg" alt="" width="489" height="234" /></a><p class="wp-caption-text">RFM12 module</p></div>
<div id="attachment_500" class="wp-caption alignnone" style="width: 502px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_and_adapterboard1.jpg"><img class="size-large wp-image-500" title="RFM12 and adaptor board" src="http://nanl.de/blog/wp-content/uploads/rfm12_and_adapterboard1-1024x535.jpg" alt="" width="492" height="256" /></a><p class="wp-caption-text">RFM12 module soldered onto eval board</p></div>
<p>The idea was to get the module working on several embedded boards running Linux, e.g. routers, microcomputers such as the <a href="http://en.qi-hardware.com/wiki/Ben_NanoNote" target="_blank">NanoNote</a>, etc. via a generic software interface.</p>
<p>The rfm12 module is controlled via the 4-wire protocol <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a> which basically is based on toggling pins between the machine&#8217;s logic-levels (high/low) at an individual non-specified clock-speed (<a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus</a>).</p>
<p>Since most of mentioned boards do not own a native SPI bus, but several <a href="http://en.wikipedia.org/wiki/General_Purpose_Input/Output">GPIO&#8217;s</a> (most LED&#8217;s are connected via GPIO&#8217;s on such devices), SPI can be &#8220;emulated&#8221; by toggling these GPIO&#8217;s in a specific way (also called &#8220;<a href="http://en.wikipedia.org/wiki/Bit-banging">bitbanging</a>&#8220;).</p>
<p><strong>That way there&#8217;s no need for any other electronic peripherals such as microcontrollers, semiconductors, resistors, etc. &#8211; the chip is directly connected with the board &#8211; everything is done in software.</strong></p>
<p>Inspired by the project &#8220;<a href="http://www.ethersex.de/index.php/Ethersex">ethersex</a>&#8221;  &#8211; a project programming and maintaining a software for Atmel AVR  micro-controllers used for home- / building automation &#8211; and <a href="http://ethersex.de/index.php/Funk2Duo">an approach  of soldering the module onto a specific router, communicating via SPI over GPIO&#8217;s</a> (however used code is rather old, unmaintained and board-specific)  &#8211; the idea came up to write a generic linux kernel module to support the module from within linux directly.</p>
<p>Based on the ideas realised with the ethersex project, I decided to aim my project on being able to switch remote controlled power sockets of which I own several (to each other incompatible) modules.</p>
<p>Because the rfm12 module is (only) capable of doing FM (modulating payload data on top of the frequency), but lot&#8217;s of devices are controlled via AM (most remote controlled power sockets included), we emulate AM by simply turning the module on and off in a specific sequence.</p>
<p>Since this operation is timing critical and needs to be atomic, we need to do basic stuff in the kernel space rather than from userspace.</p>
<p>The whole project is going to consist of 4 major parts:</p>
<ul>
<li>the rfm12 driver as kernel module which provides an API (accessible via a character device) to the userspace</li>
<li>an userspace library which contains all the information and protocol (meta)data for such remote controllable devices, providing an (more or less) generic interface and configuration of devices</li>
<li>an actual application using the library, so controlling the devices &#8211; maybe exporting the available functions via RPC (json, xml, etc.) to provide network access</li>
<li>a remote usable UI (for mobile devices as phones (android/meego), web-related, qt/gtk&#8230;)</li>
</ul>
<p>My testing device is an old Netgear WGT634U I had in spare which has a broadcom 47xx SoC working in and 4 unused GPIO&#8217;s available.</p>
<div id="attachment_505" class="wp-caption alignnone" style="width: 485px"><a href="http://nanl.de/blog/wp-content/uploads/rfm12_wgt634u1.jpg"><img class="size-full wp-image-505" title="Netgear WGT634U + RFM12 module" src="http://nanl.de/blog/wp-content/uploads/rfm12_wgt634u1.jpg" alt="" width="475" height="467" /></a><p class="wp-caption-text">RFM12 module directly connected to a Netgear WGT634U router</p></div>
<p>Implemented yet is support for the most common radio controlled sockets sold &#8211; the ones which have a 2272/2262 IC built in (including these Chinese versions which get on fire &#8211; <a href="http://ec.europa.eu/consumers/dyna/rapex/create_rapex.cfm?rx_id=142" target="_blank">http://ec.europa.eu/consumers/dyna/rapex/create_rapex.cfm?rx_id=142</a> #25) and the ones using an P801B chip.</p>
<div id="attachment_517" class="wp-caption alignnone" style="width: 528px"><a href="http://nanl.de/blog/wp-content/uploads/radio_controlled_power_sockets1.jpg"><img class="size-full wp-image-517" title="Radio controlled power sockets" src="http://nanl.de/blog/wp-content/uploads/radio_controlled_power_sockets1.jpg" alt="" width="518" height="286" /></a><p class="wp-caption-text">radio controlled power sockets: 2272, P801B, 2262</p></div>
<p>I also have a set of radio controlled <a href="http://www.pollin.de/shop/dt/NTY0OTQ0OTk-/Haustechnik/Installationsmaterial/Schalter_Steckdosen/Funk_Dimmer_Set_HouseLight_FD_UP003.html">dimmers</a> which protocol I&#8217;m going to implement soon&#8230;</p>
<p>For now the source code is hosted on github: <a href="https://github.com/mirko/rfm12-ASK-for-linux">https://github.com/mirko/rfm12-ASK-for-linux</a> &#8211; there&#8217;s no project site yet but will be created if the project is growing / interest is getting raised <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>UPDATE</strong>: In case you&#8217;re willing to participate, you&#8217;re more than welcome! Just drop me an email&#8230; There&#8217;s lot&#8217;s of stuff I&#8217;d like to see implemented, especially usable (G)UI&#8217;s&#8230; but for sure it&#8217;s not just about me: patches, feedback, enhancements and feature-requests (in a certain extent) are highly appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2011/01/rfm12-under-linux-and-remote-controlled-power-sockets/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>comments, twitter&#8230;</title>
		<link>http://nanl.de/blog/2010/09/comments-twitter/</link>
		<comments>http://nanl.de/blog/2010/09/comments-twitter/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 10:14:24 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[Bali (Indonesia)]]></category>
		<category><![CDATA[Brussels (Belgium)]]></category>
		<category><![CDATA[Dalian (china)]]></category>
		<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[German articles]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[My life]]></category>
		<category><![CDATA[Openmoko]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Taipei (Taiwan)]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Trips]]></category>
		<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=467</guid>
		<description><![CDATA[I recognized just a few hours ago, there were comments written, which needed to be approved&#8230; Did so now and tried to respond to them &#8211; sorry for the delay and thanks a lot for your input/contributions! As most people reading my blog do know already anyway and I no longer feel ashamed of using [...]]]></description>
			<content:encoded><![CDATA[<p>I recognized just a few hours ago, there were comments written, which needed to be approved&#8230;</p>
<p>Did so now and tried to respond to them &#8211; sorry for the delay and thanks a lot for your input/contributions!</p>
<p>As most people reading my blog do know already anyway and I no longer feel ashamed of using it&#8230;</p>
<p>My twitter username: <strong>foobarbablub</strong> &#8211; respectively the twitter page: <a href="http://twitter.com/foobarblablub">http://twitter.com/foobarblablub</a></p>
<p>Polluting the twitter cloud with statements / impressions I don&#8217;t think they&#8217;re worth a whole blog post&#8230; most tweets are <strong>not</strong> related to technical / computer stuff by the way &#8211; used language is mostly English&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2010/09/comments-twitter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>trip trip &#8211; hurra!</title>
		<link>http://nanl.de/blog/2010/08/trip-trip-hurra/</link>
		<comments>http://nanl.de/blog/2010/08/trip-trip-hurra/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 00:31:32 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[Bali (Indonesia)]]></category>
		<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[My life]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Trips]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=376</guid>
		<description><![CDATA[Long time no news&#8230; some things happened which weren&#8217;t worth a particular post (or I was just too lazy), so I&#8217;ll try to summarize of a few things which happen(ed): == tech stuff OpenWrt is still my focus &#8211; the qt4 package now got libX11 support (besides DirectFB / linuxfb, both accessed by the QWS-part) [...]]]></description>
			<content:encoded><![CDATA[<p>Long time no news&#8230;</p>
<p>some things happened which weren&#8217;t worth a particular post (or I was just too lazy), so I&#8217;ll try to summarize of a few things which happen(ed):</p>
<p>== tech stuff</p>
<p>OpenWrt is still my focus &#8211; the qt4 package now got libX11 support (besides DirectFB / linuxfb, both accessed by the <a href="http://qt.nokia.com/products/platform/qt-for-embedded-linux#compact-efficient-windowing-system" target="_blank">QWS-part</a>) &#8211; thanks a lot to Michael Büsch at this point!</p>
<p>I&#8217;m also very interested in the new features of qt4.7 &#8211; especially the <a href="http://labs.trolltech.com/page/Projects/Graphics/Kinetic/DeclarativeUI" target="_blank">declarative UI</a> part of qt4.7 called <a href="http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeintroduction.html">QML</a> &#8211; an approach of designing UIs in a declarative way, means, from the UI&#8217;s point of view (more in the mentioned links above).</p>
<p>I&#8217;m curious about how/whether it can/will be used/accepted by &#8220;native&#8221; designers to write fully functional GUI applications.</p>
<p>It&#8217;s approach is looking quite promising to me &#8211; the language style as well as the implementation &#8211; really curious about how it&#8217;ll do on embedded devices without graphics acceleration. After some talks to qt developers GL support is not required; a number of animations, effects and transitions were optimized for software processing and should be even smoother than rendered via GL.</p>
<p>First usecase is going to be a picture frame, which has the same SoC built in (<a href="http://www.ingenic.cn/eng/productServ/AppPro/JZ4740/pfCustomPage.aspx" target="_blank">Ingenic JZ4740</a>) as the NanoNote and therewith is pretty well supported.</p>
<p>The picture-frame is an <a href="http://www.amazon.com/Sungale-ID800WT-Cyberus-8-Inch-Digital/dp/B002F9N7W2" target="_blank">ID800WT</a> manufactured by Sungale.</p>
<p>Before somebody is going to think, whether I want to promote/support/recommend this brand/product:</p>
<p><strong>From the board </strong><strong>layout&#8217;s point of view it is the worst product sold in Germany I&#8217;ve ever seen! And it&#8217;s too expensive! And the company violates the GPL!<br />
</strong></p>
<p>Take a look at the board by yourself:</p>
<div id="attachment_391" class="wp-caption alignnone" style="width: 310px"><a href="http://nanl.de/blog/wp-content/uploads/sungale_pictureframe_ID800WT_board_2008-03__cut1.jpg"><img class="size-medium wp-image-391" title="Sungale pictureframe ID800WT board" src="http://nanl.de/blog/wp-content/uploads/sungale_pictureframe_ID800WT_board_2008-03__cut1-300x181.jpg" alt="Sungale pictureframe ID800WT board" width="300" height="181" /></a><p class="wp-caption-text">Sungale pictureframe ID800WT board</p></div>
<p>The USB Wifi-stick got hot-glued onto the board, it seems they even   unsoldered the USB-socket manually (because it looks really charred all   around) and connected it with some random wires to a SMD-chip which in   fact is an USB-hub. Around there&#8217;s hot-glue all around, partially   charred, partially way too much. This is really the worst in Germany   sold product ever!</p>
<p>However it serves the purpose &#8211; has supported wifi (atheros), an 800&#215;600-display, a touchscreen, USB-host, etc.</p>
<p>After my holidays I&#8217;ll try to evaluate and play around with qt4.7-features on that device on top of OpenWrt.</p>
<p>== trips</p>
<p>After almost one week spent in Croatia, Split, participating at the &#8220;nothing will happen&#8221; conference &#8211; which was really amazing and organized by very nice people &#8211; I&#8217;m going to travel to Bali for one month, leaving in two days.</p>
<p>Actually I wanted to go to Burma (Myanmar), however I mixed them up and  booked my flight to Bali, Indonesia&#8230; anyway &#8211; more beach and sea this  time&#8230;</p>
<p>This is going to be my third trip to Asia and I&#8217;m really looking forward to it &#8211; this time for holiday, backpacking without any fixed plans.</p>
<p>Actually I also didn&#8217;t want to take a computer with me &#8211; still I bought an EeePC 1015. Resolution is disappointing, however price, weight, battery life (about 8 fucking hours!) and site serve the purpose of just having a terminal perfectly.</p>
<p>See you there <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><del datetime="2010-08-27T22:20:58+00:00"></del></p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2010/08/trip-trip-hurra/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>QT/KDE on OpenWrt</title>
		<link>http://nanl.de/blog/2010/02/qtkde-on-openwrt/</link>
		<comments>http://nanl.de/blog/2010/02/qtkde-on-openwrt/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 21:28:52 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[English articles]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[qi-hardware]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=345</guid>
		<description><![CDATA[As you may know OpenWrt&#8217;s collection of ported packages is continuesly growing. Many graphical stuff gets ported, as well as graphical desktops and toolkits (lxde, xfce, gnome based on GTK2 &#8211; e17 based on the enlightenment foundation libraries &#8211; etc.). However there was no approach yet to port the last missing Desktop &#8220;KDE&#8221; and underlying [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know OpenWrt&#8217;s collection of ported packages is continuesly growing.</p>
<p>Many graphical stuff gets ported, as well as graphical desktops and toolkits (lxde, xfce, gnome based on GTK2 &#8211; e17 based on the enlightenment foundation libraries &#8211; etc.).</p>
<p>However there was no approach yet to port the last missing Desktop &#8220;KDE&#8221; and underlying Toolkit &#8220;QT&#8221;.</p>
<p>That&#8217;s why I went to &#8220;Tokamak 4&#8243; this weekend, a meeting organized and founded by the KDE foundation, intended to communicate and hack together related to several KDE software projects.</p>
<p>We were about 25 people from all over the world and I really enjoyed the stay and nice, friendly and mixed party &#8211; surprisingly I was the only one not using KDE (however not for a special reason &#8211; just got used to my current environment) <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>They showed lot&#8217;s of interest in the UCI-System (Unified Configuration Interface) OpenWrt is using.<br />
It&#8217;s a simple, human-readable, easy-to-parse configuration file format and library OpenWrt uses for services to make it easy writing Administration Interfaces for them (e.g. the webinterface &#8220;LuCI&#8221;).<br />
We were spinning around about KDE Plasma applets which will list available OpenWrt-devices ready to get administrated right through native applications.</p>
<p>Key deal for me however was to get in touch with people who know the QT/KDE architecture very well, for sure promoting a bit OpenWrt, qi-hardware and it&#8217;s concept of open hardware and why I think having QT/KDE support within OpenWrt is opening lot&#8217;s of opportunities for both projects.</p>
<p>Since QT is able to use DirectFB (a very powerful but light abstraction for the linux framebuffer) &#8211; and therefore does not require a X11 system necessarily &#8211; it would be also great for limited hardware such as the Ben NanoNote (32MB of RAM) where I got GTK2-based apps running on top of DirectFB quite some time ago.</p>
<p>I expected to get basic support for QT within OpenWrt done this weekend, however I underestimated the size and complexity of QT &#8211; never touched QT-code before.<br />
I realized QT is not just a toolkit as GTK2 is, but a whole framework which tries to abstract as much as possible from the underlying system. It features own backends for multimedia, sound, graphics, even networking &#8211; to achieve a stable API and platform compatibility without the need of code modifications, no matter which backends or systems are used below.</p>
<p>In which way the typical issues of such a abstraction-concept &#8211; such as getting bloated, having performance issues, being feature-limited as you&#8217;re usually just able to support the least common denominator of all supported backends, etc. &#8211; I&#8217;ve no idea yet &#8211; maybe they found a way, will find that out sooner or later.</p>
<p>They also use &#8220;qmake&#8221; as build-system which is structured quite different than e.g. GNU make, so this got another temporary road blocker as I used qmake never before and had to dig in first.</p>
<p>Back to the port of QT to OpenWrt: I&#8217;m having promise to see the first basic QT based application running on a OpenWrt supported device within the next days.</p>
<p>Will let you know <img src='http://nanl.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2010/02/qtkde-on-openwrt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; fooled me once again&#8230;</title>
		<link>http://nanl.de/blog/2010/01/php-fooled-me-once-again/</link>
		<comments>http://nanl.de/blog/2010/01/php-fooled-me-once-again/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 18:22:40 +0000</pubDate>
		<dc:creator>mirko</dc:creator>
				<category><![CDATA[English articles]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://nanl.de/blog/?p=291</guid>
		<description><![CDATA[I was asked to take a look at several free and opensource software web-projects which are capable for so called &#8220;ISP configuration management&#8221;, managing web-, mail-, database-servers, etc. &#8211; handling clients, resellers and admins and having specialized frontends for them&#8230; Anyway&#8230; I trigerred a weird bug in one of the projects where I got into [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to take a look at several free and opensource software web-projects which are capable for so called &#8220;ISP configuration management&#8221;, managing web-, mail-, database-servers, etc. &#8211; handling clients, resellers and admins and having specialized frontends for them&#8230;</p>
<p>Anyway&#8230; I trigerred a weird bug in one of the projects where I got into an if-condition where I shouldn&#8217;t get into&#8230; which not just caused a weird behaviour of the application but was also a big security hole in this special case.</p>
<p>The code was something like that (simplified and not tested):</p>
<p><code><br />
get_sql($value) {<br />
&nbsp;&nbsp; if ($ret = mysql_query ("SELECT * FROM `table` WHERE foo='%s'"),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mysql_real_escape_string($value))<br />
&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp; return $ret;<br />
&nbsp;&nbsp; }<br />
&nbsp;&nbsp; else<br />
&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp; return false;<br />
&nbsp;&nbsp; }<br />
}<br />
<br />
$result = get_sql($foo);<br />
if (count($result) &gt; 0) {<br />
&nbsp;&nbsp; // privileged area...<br />
}<br />
</code><br />
Ugly code &#8211; anyway&#8230; how it was expected to behave by the author?<br />
1) function <code>get_sql()</code> gets executed and therefore a sql-query<br />
2) <code>get_sql()</code> returns an array of results<br />
3) the number of results is checked via <code>count($result)</code> and when the result-array is greater than <code>0</code> jump into the if-block</p>
<p>Okay, so far so good&#8230;</p>
<p>However &#8211; I finally found out the SQL-query in <code>get_sql()</code> fails because of a typo.<br />
No error was thrown in the above code &#8211; so what&#8217;s happening?<br />
1) function <code>get_sql()</code> gets executed and therefore a sql-query<br />
2) <code>get_sql()</code> returns the boolean <code>false</code>, because the sql-query failed<br />
3) <code>count($result)</code>, evaluated <code>count(false)</code> is called</p>
<p>As the software just did behave different and didn&#8217;t throw an error an intermediate result is:</p>
<p><code>count()</code> applied on a boolean is <strong>valid</strong> !</p>
<p>So what&#8217;s <code>count(false)</code> going to return?</p>
<p><strong>1</strong>! &#8211; the integer <strong>one</strong>!</p>
<p><code>count(false)</code> is <strong>1</strong> and in PHP therefore <strong>true</strong>!</p>
<p>Proof:<br />
<code><br />
$ php<br />
&lt;? echo count(false); ?&gt;<br />
1<br />
$<br />
</code></p>
<p>Even better: this behaviour is kind of &#8220;documented&#8221; within an example at <a href="http://php.net/manual/en/function.count.php">http://php.net/manual/en/function.count.php</a> without any comment.</p>
<p>Okay, now guess:<br />
What&#8217;s <code>count(true)</code> returning? And this is <strong>not</strong> documented!</p>
<p><strong>1</strong>! &#8211; the integer <strong>one</strong>!</p>
<p>PHP &#8211; dine in hell&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://nanl.de/blog/2010/01/php-fooled-me-once-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

