<?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>cyberz.org</title>
	<atom:link href="http://www.cyberz.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberz.org/blog</link>
	<description>Andrea Leofreddi's homepage</description>
	<lastBuildDate>Tue, 10 Aug 2010 17:19:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Solaris 10 x64 and Symbios SYM22801 (and other LSI SCSI controllers)</title>
		<link>http://www.cyberz.org/blog/2010/07/24/solaris-10-x64-and-symbios-sym22801/</link>
		<comments>http://www.cyberz.org/blog/2010/07/24/solaris-10-x64-and-symbios-sym22801/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 19:33:13 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=194</guid>
		<description><![CDATA[Today I&#8217;ve discovered that the]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve discovered that the very common Symbios 22801 (aka Symbios Logic 53c875) SCSI controller is (unexpectedly) failing to be recognized by Solaris 10 on x64 hardware. In fact I was in the middle of the upgrade of my home backup infrastructure from an old DLT 20/40 to a newer DLT 40/80 to be connected to a Symbios card inside my Solaris box. Unfortunately after the reboot, the new card was unseen.</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2010/07/SYM22801.jpg"><img class="aligncenter size-medium wp-image-195" title="SYM22801" src="http://www.cyberz.org/blog/wp-content/uploads/2010/07/SYM22801-300x277.jpg" alt="" width="300" height="277" /></a><span id="more-194"></span>After some research on google I was able to find out that:</p>
<ol>
<li>The <strong>ncrs</strong> driver is not shipped with x64 kernel (yet it is for 32 bit version)</li>
<li>The default alias for PCI device 1000:000f (the Sym22801 card) is <strong>ncrs</strong></li>
<li>Another driver which supports the 53c875 controller, called <strong>glm</strong>, is shipped with Solaris 10 and available for both 32 and 64bit versions</li>
</ol>
<p>So, it is enough to point the 1000:000f alias to the glm driver, instead of ncrs, to have the controller recognized. That can be easily accomplished changing the following entry in /etc/driver_aliases:</p>
<p><code>ncrs "pci1000,f"</code><br />
to<br />
<code>glm "pci1000,f"</code></p>
<p>After that it is enough to reboot Solaris with device reconfiguration turned on (<code>touch /reconfigure</code> before rebooting) and check that the controller is recognized (<code>prtconf</code> or <code>cfgadm -al</code> can be used for that).</p>
<p><b>Update</b>: I had again the same issue with an LSI Logic 53C1010-66 Ultra160 SCSI dual HBA. In this case the missing driver is symhisl, whereas the line to tweak in /etc/driver_aliases is:</p>
<p><code>symhisl "pci1000,21"</code><br />
to<br />
<code>glm "pci1000,21"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2010/07/24/solaris-10-x64-and-symbios-sym22801/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I2C Anemometer: cheap wind data logger (Work In Progress)</title>
		<link>http://www.cyberz.org/blog/2010/06/19/i2c-anemometer-cheap-wind-data-logger/</link>
		<comments>http://www.cyberz.org/blog/2010/06/19/i2c-anemometer-cheap-wind-data-logger/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 18:26:02 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Domotics]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=138</guid>
		<description><![CDATA[Lately I&#8217;ve been wondering if]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been wondering if a wind-generator could help me lower my electricity bill (since my home server burns continuously some hundred watts per hour) in my town, <a href="http://www.comune.ponzanoromano.rm.it">Ponzano Romano</a>. So I came up to the idea that wind data logging is absolutely a must for any further reasoning about wind &#8211; that is I need an anemometer. On internet prices for those devices may vary, but I was unable to find anything below 150€ which I think is a bit too much for what is just an experiment for fun.</p>
<p>From the very interesting forum <a href="http://www.energeticambiente.it/">energeticaambiente</a> a post pointed me to the electronic italian magazine &#8220;Nuova Elettronica&#8221; that posted the following (relatively cheap) anemometer kit:</p>
<p><img class="aligncenter size-medium wp-image-139" title="Nuova Elettronica Anemometer kit lx1606" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/lx1606-300x168.jpg" alt="Nuova Elettronica Anemometer kit lx1606" width="300" height="168" /></p>
<p>The kit is fine but is not meeting my requirements for data logging, that is I have the need of a constant wind speed recording into my server; since it&#8217;s possible to buy only the anemometer (without the logic board) I went that way.</p>
<p><span id="more-138"></span>Moreover not so long time ago I&#8217;ve built some <a href="http://www.cyberz.org/blog/2009/06/08/some-applications-using-i2c/">I2C circuitry (look at the post on this website)</a>, so I thought that a I2C wind logger interface to the anemometer from Nuova Elettronica (which costs 30€) would be easy and very cheap to build, bringing total cost of the solution to around 40€. In case you need to assemble even the I2C-to-Parport adapter, then you need to add few € for it, but the total cost should be no more than 50€.</p>
<p>This is the schema that I plan to build:</p>
<p><img class="aligncenter size-full wp-image-140" title="I2C Wind data logger architecture" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2cwl_arch.jpg" alt="I2C Wind data logger architecture" width="528" height="340" /></p>
<p>For those who may be interested, there&#8217;s another cheap <a href="http://www.aprsworld.com/sensors/anemometer/">anemometer by APRS World</a> which is for sale at $65.</p>
<p>(some days after)</p>
<h2>Anemometer calibration</h2>
<p>After buying the anemometer I found out with disappointment that nor Nuova Elettronica nor the vendor (Master Motion Ahead) are publicly releasing the relation between the wind speed and the frequency; and my information request to both was kindly ignored. Nuova Elettronica&#8217;s kit employes a microcontroller to count the number of pulses and convert them to wind speed, so obviously they know the relation I&#8217;ve asked for. So, at this point, two alternatives showed up:</p>
<ol>
<li>Buy the rest of Nuova Elettronica kit and guess the speed/frequency relationship testing the kit with a known frequency generator.</li>
<li>Calibrate the anemometer on my own.</li>
</ol>
<p>Since the alternative 1 would raise the project budget of 30€, I opted for the 2nd: the whole process involves a car tour for some kilometers on a calm day (no wind) with the anemometer on top of the vehicle, monitored by my laptop. Since my laptop doesn&#8217;t have a parallel port, I figured out an alternative reading method for the calibration via the serial port (I already have an USB to RS232 converter which I use for serial console access with laptop). An old bluetooth GPS receiver (I have one from the pre-GPS smartphone era) will be used to acquire position/speed of the vehicle. I have in mind a short go and back trip in constant speed that would eventually neutralize the effect of a constant speed, uniform wind (if any &#8211; I plan to do that when there is NO wind at all).</p>
<p><strong><em>(Update on 26 June 2010)<br />
</em></strong></p>
<p>Today I had some free time to experiment what was the idea of the anemometer RS232 reading + gps positioning. I managed to install gpsd on my laptop (MacOSX), and I was lucky to find out <a title="Gpsd for MacOSX" href="http://trac.kismac-ng.org/wiki/gpsd" target="_blank">gpsdX</a>, a precompiled dmg package, thus avoiding compilation hell. Perl&#8217;s Net::GPSD relieved the data acquisition from gpsd, making the whole job trivial.</p>
<p>Then I made some tests with the USB to Serial adapter noticing that the RI pin can be kept high with a 1k pull-up resistor to RTS and ground (by the anemometer) to pin GND, all when a simple program is monitoring <em>/dev/tty.usbseria</em><em>l</em> for changes on the RI pin (using the TIOCMGET ioctl).</p>
<p>So I assembled some piece of software to make the whole thing work together:</p>
<ol>
<li><a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/riLogger.c">riLogger</a> is a simple C program that polls the serial state and notifies another program (which in this case will be windSpeed) sending a SIGUSR1 when the Ring Indicator bit changes.</li>
<li>windSpeed acquires data from gpsd, and counts the anemometer rounds (which are received as SIGUSR1 from riLogger), producing a CSV file containing both.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2010/06/19/i2c-anemometer-cheap-wind-data-logger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CyberzOrg::Event library: typesafe event handling in C++</title>
		<link>http://www.cyberz.org/blog/2010/05/25/cyberzorgevent-library-typesafe-event-handling-in-c/</link>
		<comments>http://www.cyberz.org/blog/2010/05/25/cyberzorgevent-library-typesafe-event-handling-in-c/#comments</comments>
		<pubDate>Tue, 25 May 2010 21:22:05 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=134</guid>
		<description><![CDATA[The following article is date]]></description>
			<content:encoded><![CDATA[<p><em>The following article is date back to Thu Dec 14 22:12:44 CET 2006</em></p>
<p>Event is a little library built on top of boost::signal and boost::mpl that allows the user to declare in a simple way an object that can emit events and allow connection of (type-safe) callbacks as event handler to them. Usage is pretty straightforward, as shown in test/hello.cc:</p>
<pre>#include &lt;iostream&gt;
#include "event.h"

enum { HELLO /* event type */ };

using namespace CyberzOrg::Event;

struct HelloEmitter
&nbsp;: Emitter&lt;
&nbsp;&nbsp;Event&lt;HELLO, void (const std::string &amp;)&gt;
&nbsp;&gt;
{ };

void callback(const std::string &amp;s) {
&nbsp;std::cout &lt;&lt; "Event HELLO: " &lt;&lt; s &lt;&lt; std::endl;
}

int main() {
&nbsp;HelloEmitter hello;

&nbsp;// preferred syntax (useful if event emitter has the event table depending on itself,
&nbsp;// in such case getSignal method is not directly visible).
&nbsp;getSignal&lt;HELLO&gt;(hello).connect(callback); // connect signal handler (callback)
&nbsp;getSignal&lt;HELLO&gt;(hello)("hello world"); // fire signal

&nbsp;// easy syntax
&nbsp;hello.getSignal&lt;HELLO&gt;().connect(callback); // connect signal handler (callback)
&nbsp;hello.getSignal&lt;HELLO&gt;()("hello world"); // fire signal
}</pre>
<p>You can look at <a href="http://cyberz.org/projects/event/event/">sources</a> or <a href="http://cyberz.org/projects/event/event-0.2.tar">download a tarball</a>. Any feedback is well accepted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2010/05/25/cyberzorgevent-library-typesafe-event-handling-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling the HP NetServer 5/133 LS2 LCD</title>
		<link>http://www.cyberz.org/blog/2010/05/22/controlling-the-hp-netserver-5133-ls2-lcd/</link>
		<comments>http://www.cyberz.org/blog/2010/05/22/controlling-the-hp-netserver-5133-ls2-lcd/#comments</comments>
		<pubDate>Fri, 21 May 2010 23:37:59 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=118</guid>
		<description><![CDATA[The following article is dated]]></description>
			<content:encoded><![CDATA[<p><em>The following article is dated back to Sat Dec 6 20:15:41 CET 2003</em></p>
<p>Some time ago, I got an old HP NetServer 5/133 LS2 (that I revived with FreeBSD):</p>
<p><img class="aligncenter size-medium wp-image-119" title="HP Netserver 5/133 LS2" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/netserver-300x245.jpg" alt="HP Netserver 5/133 LS2" width="300" height="245" /></p>
<p>After giving some progress informations during the boot process, I noticed that the front LCD display gets stuck with useless informations when the system is up and running, as shown here:</p>
<p><img class="aligncenter size-medium wp-image-120" title="HP NetServer 5/133 LS2 LCD Display" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/display-300x245.jpg" alt="HP NetServer 5/133 LS2 LCD Display" width="300" height="245" /></p>
<p>Since I wanted to put some meaningful text into the LCD, I started investigating around for a way to accomplish that.</p>
<p><span id="more-118"></span>I figured out (in HP&#8217;s forum) that there is some utility called LSECU that could help me. In fact the LSECU utility allows the user to setup some custom static string in the BIOS, but I was looking for a way to control the LCD from UNIX in order to show realtime status informations, so after some failed researches, I started thinking how to get it on my own.</p>
<p>Obviously the NetServer&#8217;s BIOS contains the code to change the LCD text because of the multiple updates being issued at boot time. So I started from the BIOS: googling a bit I found out that on the i386 architecture the BIOS starts at memory address 0xf0000 (and its size is 64k): so I wrote the following program to extract the BIOS to stdout.</p>
<p><code>int main() {<br />
FILE *f = fopen("/dev/mem", "r");<br />
char bios[0xffff];<br />
assert(f);<br />
fseek(f, 0xf0000, SEEK_CUR);<br />
fread(bios, 1, sizeof(bios), f);<br />
fwrite(bios, 1, sizeof(bios), stdout);<br />
}</code></p>
<p>Obviously only root can run that code (at -1 securelevel). Once I got the BIOS on a file, I went to Windows and downloaded some disassembler programs, as some friends of mine suggested (thanks to sand, Smilzo and tripz), and disassembled it. At first I looked for the string that was first showed by the BIOS, and I was able to find it at offset 0x6f26. Then I started looking for anything using that offset and got:</p>
<p><code>0000265D: 8CC8                         mov       ax,cs<br />
0000265F: 8ED8                         mov       ds,ax<br />
00002661: BE6F26                       mov       si,0266F<br />
00002664: E888FE                       call      0000024EF   -------- (5)</code></p>
<p>I don&#8217;t know much about x86 assembler, but this seems a call to function. Going to 0x24ef I found:</p>
<p><code>000024EF: 56                           push      si<br />
000024F0: 50                           push      ax<br />
000024F1: 9C                           pushf<br />
000024F2: FC                           cld<br />
000024F3: AC                           lodsb<br />
000024F4: 0AC0                         or        al,al<br />
000024F6: 7405                         je        0000024FD   -------- (3)<br />
000024F8: E88EFF                       call      000002489   -------- (4)<br />
000024FB: EBF6                         jmps      0000024F3   -------- (5)<br />
000024FD: 9D                           popf<br />
000024FE: 58                           pop       ax<br />
00002500: C3                           retn</code></p>
<p>This function seems to iterate through the string until its gets null. At each iteration the current character is loaded in al, and the 0&#215;2489 function is called. The 0&#215;2489 function looks like:</p>
<p><code>00002489: 52                           push      dx<br />
0000248A: E8DCFF                       call      000002469   -------- (1)<br />
...</code></p>
<p>Just pushes dx and calls 0&#215;2469 that contains:</p>
<p><code>00002469: 50                           push      ax<br />
0000246A: 33C0                         xor       ax,ax<br />
0000246C: B402                         mov       ah,002<br />
0000246E: E862FF                       call      0000023D3   -------- (1)<br />
00002471: 720D                         jb        000002480   -------- (2)<br />
00002473: 8AF0                         mov       dh,al<br />
00002475: 80E60F                       and       dh,00F<br />
00002478: 8AD0                         mov       dl,al<br />
0000247A: C0FA06                       sar       dl,006<br />
0000247D: 80E201                       and       dl,001<br />
00002480: 58                           pop       ax<br />
00002481: C3                           retn</code></p>
<p>This function does some stuff with ax and then calls 0x23d3:</p>
<p><code>000023D3: 51                           push      cx<br />
000023D4: 52                           push      dx<br />
000023D5: 50                           push      ax<br />
000023D6: B90600                       mov       cx,00006<br />
000023D9: E8BCF1                       call      000001598   -------- (1)<br />
000023DC: 58                           pop       ax<br />
000023DD: BA000E                       mov       dx,00E00<br />
000023E0: 80FC00                       cmp       ah,000<br />
000023E3: 7418                         je        0000023FD   -------- (2)<br />
000023E5: 80FC02                       cmp       ah,002<br />
000023E8: 7410                         je        0000023FA   -------- (3)<br />
000023EA: BA040E                       mov       dx,00E04<br />
000023ED: 80FC01                       cmp       ah,001<br />
000023F0: 740B                         je        0000023FD   -------- (4)<br />
000023F2: 80FC03                       cmp       ah,003<br />
000023F5: 7403                         je        0000023FA   -------- (5)<br />
000023F7: F9                           stc<br />
000023F8: EB04                         jmps      0000023FE   -------- (6)<br />
000023FA: EC                           in        al,dx<br />
000023FB: EB01                         jmps      0000023FE   -------- (7)<br />
000023FD: EE                           out       dx,al<br />
000023FE: 5A                           pop       dx<br />
000023FF: 59                           pop       cx<br />
00002400: C3                           retn</code></p>
<p>Finally I got what I was looking for: some data bus I/O operations (in and out). Looking at the code, it seems that I/O on LCD uses two I/O ports, 0xe00 and 0xe04 (as you can see these values are loaded into the dx register and then used by the in/out ops).</p>
<p>Given the I/O addresses, I could start writing something. With a little random data test, I was able to put some nonsense characters to the LCD:</p>
<p><img class="aligncenter" title="nonsense" src="../wp-content/uploads/2010/05/nonsense-300x245.jpg" alt="nonsense" width="300" height="245" /></p>
<p>Now It was time to understand how to write correctly data. It looked easier to me to open the NetServer instead than reversing the whole protocol from the BIOS code, so I took out the control panel&#8230;</p>
<p><img class="aligncenter size-medium wp-image-126" title="controlpanel" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/controlpanel-300x245.jpg" alt="controlpanel" width="300" height="245" /></p>
<p>&#8230;to get the LCD driver IC, after removing that metal block:</p>
<p><img class="aligncenter size-medium wp-image-125" title="inside1" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/inside1-300x245.jpg" alt="inside1" width="300" height="245" /><img class="aligncenter size-medium wp-image-124" title="inside2" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/inside2-300x245.jpg" alt="inside2" width="300" height="245" /></p>
<p>The IC is HD44780A00, a processor of the well documented and widely used HD44780 family. Using the HD44780 datasheet it was easy to discover that 0xe00 is used to send commands and 0xe04 is used to send data to the device, so I&#8217;ve written lcdw, a little program to write directly on your display. Using lcdw, it&#8217;s easy to put on the LCD some nice infos about system&#8217;s current status, like uptime or load average, as example:</p>
<p><img class="aligncenter size-medium wp-image-127" title="stats" src="http://www.cyberz.org/blog/wp-content/uploads/2010/05/stats-300x245.jpg" alt="stats" width="300" height="245" /></p>
<p>You can download <a href="http://www.cyberz.org/projects/lcd/lcdw/lcdw-0.21.tar">here</a> the sources of lcdw.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2010/05/22/controlling-the-hp-netserver-5133-ls2-lcd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVGPan: a Javascript SVG (Viewer) Pan/Zoom/Drag library</title>
		<link>http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/</link>
		<comments>http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 18:37:34 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=96</guid>
		<description><![CDATA[Some time ago the need]]></description>
			<content:encoded><![CDATA[<p>Some time ago the need for a browser-compatible vectorial language pushed me to consider the SVG markup language (I won&#8217;t say anything about Internet Explorer &#8211; it&#8217;s just unsupported there). The language itself is great, but, as a beginner, I was so disappointed about the fact that on the Internet I couldn&#8217;t find ANY library ready to use for panning and zooming features that I had to write one from scratch.</p>
<p>The SVGPan library features:</p>
<ol>
<li>Panning (pan à la Google maps) <em>(click on the white background and pan)</em></li>
<li>Zooming <em>(using the mouse wheel)</em></li>
<li>Element dragging <em>(click on a drawing element and drag it somewhere else)</em></li>
<li>Combinations of the above like zooming while dragging</li>
</ol>
<p>The resulting javascript library is published here, in the hope that someone can find it useful. The library itself is very small and easy to use; and it&#8217;s licensed under the BSD license. You can try a demo here</p>
<p><!--[if IE]><br />
<object id="testSVG" src="/projects/SVGPan/tiger.svg" classid="image/svg+xml" width="800" height="800"><br />
<![endif]--><br />
<!--[if !IE]>&#8211;><br />
<object id="testSVG" data="/projects/SVGPan/tiger.svg"<br />
        type="image/svg+xml" width="800" height="800"><br />
<!--<![endif]--></p>
<h1>No SVG support at all!</h1>
<p></object></p>
<p><span id="more-96"></span></p>
<p>You can also <a title="SVGPan example" href="http://www.cyberz.org/projects/SVGPan/tiger.svg" target="_blank">open the demo in a new page</a> and <a title="SVGPan library" href="http://www.cyberz.org/projects/SVGPan/SVGPan.js" target="_blank">download the SVGPan library here</a>.</p>
<p>The library itself requires a root group to be identified by the id <strong>viewport</strong>, which confines the SVGPan library effects, and the import of the javascript code as well. For example, to adapt the tiger drawing, it was necessary to add the following:</p>
<pre><strong>&lt;script xlink:href="SVGPan.js"/&gt;</strong>
&lt;g <strong>id="viewport"</strong> transform="translate(200,200)"&gt;...</pre>
<p>You may also try another <a href="http://www.cyberz.org/projects/SVGPan/tripleintegral.svg">SVG example (triple integral, from Wikipedia)</a>.</p>
<p>Zeng Xiaohui has provided a patch to support the mouse wheel on Safari/Chrome and fixed the browser scrollbar issue as well. Both patches have been merged into the latest version of SVGPan.</p>
<p><strong>Note that now this project is hosted on Google Code, so there you can find the <a href="http://svgpan.googlecode.com">latest version</a>.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Bode and Nyquist diagrams using GNU Octave</title>
		<link>http://www.cyberz.org/blog/2009/12/07/bode-and-nyquist-diagrams-using-gnu-octave/</link>
		<comments>http://www.cyberz.org/blog/2009/12/07/bode-and-nyquist-diagrams-using-gnu-octave/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 17:51:36 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=14</guid>
		<description><![CDATA[Using GNU Octave is easy]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://www.octave.org/">GNU Octave</a> is easy to plot Bode and Nyquist diagrams, as follows:</p>
<p><code>bode(zp([], [-1*i, i, -1], 1))</code></p>
<p><code>nyquist(zp([-0.5], [0.0, -0.2, -4], 1))</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/12/07/bode-and-nyquist-diagrams-using-gnu-octave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bacula mail changer script (aka poor man&#8217;s autoloader)</title>
		<link>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/</link>
		<comments>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 22:16:32 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Bacula]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=24</guid>
		<description><![CDATA[I enjoy Bacula for automated]]></description>
			<content:encoded><![CDATA[<p>I enjoy Bacula for automated home backups on DLT and DDS tape drives. Being used at home there&#8217;s no &#8211; obviously &#8211; big-dollar-company-manager to ask for an autoloader; and when the time of a tape change comes bacula lacks a simple way to request a manual tape change and just hangs up. So I managed to build a fake autoloader shell script, which, using emails, would emulate a real autoloader. This script, which I baptised <em>mail-changer</em>, features:</p>
<ul>
<li>email support</li>
<li>periodic email resend when tape change is needed</li>
<li>tape detection and check (if you&#8217;re supposed to insert tape 4 and you enter 5, the script will kindly refuse the tape, unload it and send a warning email message asking for the right one)</li>
</ul>
<p><span id="more-24"></span>To implement the third point (tape detection and check), it was necessary to extract the tape id from the bacula tape. That can be done looking at the bacula&#8217;s tape header structure:</p>
<p>The first structure stored is called &#8220;Block Header&#8221; and is 24 bytes long:</p>
<pre>   uint32_t CheckSum;                /* Block check sum */
   uint32_t BlockSize;               /* Block byte size including the header */
   uint32_t BlockNumber;             /* Block number */
   char ID[4] = "BB02";              /* Identification and block level */
   uint32_t VolSessionId;            /* Session Id for Job */
   uint32_t VolSessionTime;          /* Session Time for Job */</pre>
<p>Then a &#8220;Record Header&#8221; follows (12 bytes):</p>
<pre>  int32_t FileIndex;   /* File index supplied by File daemon */
  int32_t Stream;      /* Stream number supplied by File daemon */
  uint32_t DataSize;   /* size of following data record in bytes */</pre>
<p>Then a structure which is interesting for us, called &#8220;Volume Label&#8221; follows:</p>
<pre>  char Id[32];              /* Bacula 1.0 Immortal\n */
  uint32_t VerNum;          /* Label version number */
  /* VerNum 11 and greater Bacula 1.27 and later */
  btime_t   label_btime;    /* Time/date tape labeled */
  btime_t   write_btime;    /* Time/date tape first written */
  /* The following are 0 in VerNum 11 and greater */
  float64_t write_date;     /* Date this label written */
  float64_t write_time;     /* Time this label written */
  char VolName[128];        /* Volume name */
  char PrevVolName[128];    /* Previous Volume Name */
  char PoolName[128];       /* Pool name */
  char PoolType[128];       /* Pool type */
  char MediaType[128];      /* Type of this media */
  char HostName[128];       /* Host name of writing computer */
  char LabelProg[32];       /* Label program name */
  char ProgVersion[32];     /* Program version */
  char ProgDate[32];        /* Program build date/time */</pre>
<p>What is really important for us is the VolName field, which is at relative offset +56 from the beginning of the <em>Volume Label</em>. Adding 12 bytes of <em>Record Header</em> and 24 of <em>Block Header</em> makes 92 bytes.</p>
<p>Please note that mail-changer has been developed on Solaris 10 using CSW&#8217;s Bacula, you may need to work a bit to adapt it to your unix.</p>
<p>You can <a title="mail-changer script" href="/projects/mail-changer/mail-changer" target="_blank">download mail-changer here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some applications using I2C</title>
		<link>http://www.cyberz.org/blog/2009/06/08/some-applications-using-i2c/</link>
		<comments>http://www.cyberz.org/blog/2009/06/08/some-applications-using-i2c/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 21:49:43 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Domotics]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Parport]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=64</guid>
		<description><![CDATA[Parallel and serial ports are]]></description>
			<content:encoded><![CDATA[<p>Parallel and serial ports are disappearing from today&#8217;s pc making life harder for the people who wants to connect their home-made devices to a pc. The USB bus seems to be very appealing but it has the drawback of complexity while the I<sup>2</sup>C bus is very easy to implement and it&#8217;s widely supported by many devices, with the drawback of no direct pc connection (to be honest it&#8217;s used inside the pc, so somewhere on the motherboard there is a I<sup>2</sup>C bus, but yet I haven&#8217;t found any decent connection to the external world to use it &#8211; no, i won&#8217;t solder things on memory modules). Since the first way to start experimenting with I<sup>2</sup>C is building an I<sup>2</sup>C port, I&#8217;ve built a parport-to-i<sup>2</sup>c interface implementing the <a href="http://www.kosma.pl/hardware/i2c-parport/">I<sup>2</sup>C schematic made by Kosma Moczek</a> with the idea of replacing it with a more modern USB-to-I<sup>2</sup>C solution in the future.</p>
<p>So here it is the prototype of the parport to I<sup>2</sup>C interface:</p>
<p style="text-align: center;"><img class="size-medium wp-image-70 aligncenter" title="The i2c board" src="http://www.cyberz.org/blog/wp-content/uploads/2009/05/090520091-300x225.jpg" alt="The i2c board" width="300" height="225" /></p>
<p><span id="more-64"></span>To test the interface bus, some I<sup>2</sup>C device was needed. A common 24c04 eeprom was very easy to find, so I just setup some wires to have the 24c04 connect the bus (note the power cord powers up the parport board too). That is the result:</p>
<p style="text-align: center;"><img class="size-medium wp-image-73 aligncenter" title="The 24c04 eeprom" src="http://www.cyberz.org/blog/wp-content/uploads/2009/05/090520090011-300x225.jpg" alt="The 24c04 eeprom" width="300" height="225" /></p>
<p>Using the i2cdetect from lmsensors with the 24c04 unplugged, I was able to scan the I<sup>2</sup>C bus without results as expected:</p>
<p><code>[root@thufir ~]# i2cdetect -a 3<br />
WARNING! This program can confuse your I2C bus, cause data loss and worse!<br />
I will probe file /dev/i2c-3.<br />
I will probe address range 0x00-0x7f.<br />
Continue? [Y/n] y<br />
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f<br />
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
[root@thufir ~]#</code></p>
<p>Plugging the 24c04 eeprom in the i2c bus, a probe finds out something:</p>
<p><code>[root@thufir ~]# i2cdetect -a 3<br />
WARNING! This program can confuse your I2C bus, cause data loss and worse!<br />
I will probe file /dev/i2c-3.<br />
I will probe address range 0x00-0x7f.<br />
Continue? [Y/n] y<br />
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f<br />
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
50: 50 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
[root@thufir ~]#</code></p>
<p>The eeprom has been found at 0&#215;50-1 address, which is as expected (the 24c04 has the &#8217;1010 E2 E1 A8&#8242; address scheme, so in my case E2 and E1 were ground producing 1010000 and 1010001).</p>
<p>To be sure about the functionality of the port, I used the <a href="http://codesink.org/eeprog.html">eeprog program by Stefano Barbato</a> to test the 24c04.</p>
<p>Writing &#8220;hello world\n&#8221; on the first 12 bytes of the eeprom was fine:</p>
<p><code>[root@thufir eeprog-0.7.6]# echo hello world | ./eeprog -f /dev/i2c-3 0x50 -w 0:12<br />
eeprog 0.7.6, a 24Cxx EEPROM reader/writer<br />
Copyright (c) 2003-2004 by Stefano Barbato - All rights reserved.<br />
Bus: /dev/i2c-3, Address: 0x50, Mode: 8bit<br />
Writing stdin starting at address 0x0<br />
............</code></p>
<p>&#8230;and so was reading what&#8217;s inside the first 12 bytes of the eeprom (the &#8220;hello world\n&#8221; string which we have just written).</p>
<p><code><br />
[root@thufir eeprog-0.7.6]# ./eeprog -f /dev/i2c-3 0x50 -r 0:12<br />
eeprog 0.7.6, a 24Cxx EEPROM reader/writer<br />
Copyright (c) 2003-2004 by Stefano Barbato - All rights reserved.<br />
Bus: /dev/i2c-3, Address: 0x50, Mode: 8bit<br />
Reading 12 bytes from 0x0<br />
hello world<br />
[root@thufir eeprog-0.7.6]#<br />
</code></p>
<p>The i2c eeprom is working as expected. The eeprom was connected with a 3 meters cable. As of today I still have to buy some PCF8574 to start experimenting with some other circuits.</p>
<p><strong><em>(Update 26 June 2010)</em></strong>: I bought some PCF8574 but unfortunately I lost my I2C parport adapter, so I had to build a new one from scratch. This time I managed to fit it into the parallel cable box and I used a mini molex connector to have a common connection for all the I2C boards I plan to build.</p>
<p><a style="text-decoration: none;" href="http://www.cyberz.org/blog/wp-content/uploads/2009/06/26062010085.jpg"><img class="aligncenter size-medium wp-image-178" title="I2C Parport adapter (PCB front)" src="http://www.cyberz.org/blog/wp-content/uploads/2009/06/26062010085-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a style="text-decoration: none;" href="http://www.cyberz.org/blog/wp-content/uploads/2009/06/26062010088.jpg"><img class="aligncenter size-medium wp-image-181" title="I2C Parport adapter (complete)" src="http://www.cyberz.org/blog/wp-content/uploads/2009/06/26062010088-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2009/06/27062010090.jpg"><img class="aligncenter size-medium wp-image-188" title="Mini molex I2C connections" src="http://www.cyberz.org/blog/wp-content/uploads/2009/06/27062010090-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Since my purpose is to use I2C for domotics, cable length is very important. On the internet you may see that maximum length for I2C connections may vary depending on how many devices you connect and cable length, I was able to manage some tests with the 24C04 eeprom and everything worked fine with a 13 meters cable.</p>
<p>Then I assembled a test circuit for PCF8574 to test the bus with 2 devices connected (again with 13 meters cable). The PCF8574 board features a dip switch to select the address and 4 LED/bit connected to the lsb data output (in this case I was not interested in using the chip as an input).</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2009/06/27062010091.jpg"><img class="aligncenter size-medium wp-image-189" title="PCF8574 &quot;demo&quot; board" src="http://www.cyberz.org/blog/wp-content/uploads/2009/06/27062010091-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The whole thing worked fine (with both 24C04 and PCF8574 connected), as shown by i2cdetect:</p>
<p><code>[root@kynes ~]# i2cdetect -a 1<br />
WARNING! This program can confuse your I2C bus, cause data loss and worse!<br />
I will probe file /dev/i2c-1.<br />
I will probe address range 0x00-0x7f.<br />
Continue? [Y/n] y<br />
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f<br />
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --<br />
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
50: 50 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br />
[root@kynes ~]#<br />
</code></p>
<p>To check the PCF8574, the following &#8220;counter&#8221; script was executed:</p>
<p><code>A=0; while :; do ((A=A+1)); printf "%b", $A &gt; /sys/bus/i2c/devices/1-0027/write; echo Wrote $A; sleep 1; done</code></p>
<p>Leds were correcly blinking showing the binary representation of the bytes sent by the counter script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/06/08/some-applications-using-i2c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Code Review</title>
		<link>http://www.cyberz.org/blog/2009/02/18/code-review/</link>
		<comments>http://www.cyberz.org/blog/2009/02/18/code-review/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 18:34:45 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Delirium]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=55</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-54 aligncenter" title="qa" src="http://www.cyberz.org/blog/wp-content/uploads/2009/02/qa.jpg" alt="qa" width="422" height="398" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/02/18/code-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios nrpe and sudo: &#8220;NRPE: Unable to read output&#8221;</title>
		<link>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/</link>
		<comments>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:21:21 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Sudo]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=49</guid>
		<description><![CDATA[On CentOS 5 (and RedHat]]></description>
			<content:encoded><![CDATA[<p>On CentOS 5 (and RedHat EL as well), you can encounter the following behaviour when configuring an nrpe plugin with sudo:<br />
<code><br />
[andrea@feyd ~]$ /usr/lib/nagios/plugins/check_nrpe  -H 1.2.3.4 -c check_md_raid<br />
NRPE: Unable to read output<br />
</code><br />
<span id="more-49"></span><br />
Given that check_md_raid is defined as follows, in nrpe.conf:<br />
<code><br />
command[check_md_raid]=sudo /usr/local/bin/nagios_check_md_raid<br />
</code><br />
And given (for completeness) its relative /etc/sudoers line as follows:<br />
<code><br />
nagios    ALL=(ALL)   NOPASSWD:/usr/local/bin/nagios_check_md_raid<br />
</code><br />
Then the problem is in the requiretty options in /etc/sudoers, enabled by default on CentOS. Simply comment it as follows:<br />
<code><br />
#Defaults    requiretty<br />
</code><br />
After that the plugin should work as expected:<br />
<code><br />
[andrea@feyd ~]$ /usr/lib/nagios/plugins/check_nrpe  -H 1.2.3.4 -c check_md_raid<br />
RAID OK: All arrays OK [1 array checked]<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
