<?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>Mon, 02 Apr 2012 08:12:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Multi-lun autoloader with VMware ESXi 5.0 with Adaptec SCSI HBA</title>
		<link>http://www.cyberz.org/blog/2012/03/16/multi-lun-autoloader-with-vmware-esxi-5-0-with-adaptec-scsi-hba/</link>
		<comments>http://www.cyberz.org/blog/2012/03/16/multi-lun-autoloader-with-vmware-esxi-5-0-with-adaptec-scsi-hba/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 10:41:35 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=268</guid>
		<description><![CDATA[VMware ESXi 5 is not]]></description>
			<content:encoded><![CDATA[<p>VMware ESXi 5 is not able to handle multi-lun devices by default, so many SCSI autoloaders are not supported as-is (as HP StorageWorks LTOs), showing only the tape drive or media changer but not both:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2012/03/esxi_multilun1.png"><img class="alignnone  wp-image-278" title="esxi_multilun1" src="http://www.cyberz.org/blog/wp-content/uploads/2012/03/esxi_multilun1.png" alt="" width="589" height="286" /></a></p>
<p><span id="more-268"></span></p>
<p>To have it work in ESXi it&#8217;s enough to:</p>
<ol>
<ol>
<li>Get a multi-LUN aware SCSI controller. Notice that many RAID controllers can&#8217;t handle multi-lun targets. I&#8217;ve used an Adaptec 29320.</li>
<li>Run the following on ESXi:
<pre>esxcli storage nmp satp rule add --satp VMW_SATP_LOCAL --driver="aic79xx" --description="Specific rule for Adaptec Card"</pre>
</li>
<li>Issue a bus rescan</li>
</ol>
</ol>
<p>After that you should be able to see both the tape and the autoloader, as show in the following image:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2012/03/esxi_multilun2.png"><img class="alignnone  wp-image-279" title="esxi_multilun2" src="http://www.cyberz.org/blog/wp-content/uploads/2012/03/esxi_multilun2.png" alt="" width="587" height="285" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2012/03/16/multi-lun-autoloader-with-vmware-esxi-5-0-with-adaptec-scsi-hba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proguard on MacOSX</title>
		<link>http://www.cyberz.org/blog/2011/02/21/proguard-on-macosx/</link>
		<comments>http://www.cyberz.org/blog/2011/02/21/proguard-on-macosx/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 11:47:03 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=253</guid>
		<description><![CDATA[While executing proguard (via maven2)]]></description>
			<content:encoded><![CDATA[<p>While executing proguard (via maven2) on MacOSX Snow Leopard, I&#8217;ve got the following error:</p>
<p><code>[proguard] Error: Can't read [/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/rt.jar] (No such file or directory)</code></p>
<p>That happens because the Java bundled with MacOSX doesn&#8217;t provide a standard library configuration, that is the rt.jar has been moved and renamed to classes.jar. To fix the issue simply symlink rt.jar to the corresponding classes.jar file:</p>
<p><code>localhost:~ root# cd /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/<br />
localhost:lib root# ln -sf ../../Classes/classes.jar rt.jar<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2011/02/21/proguard-on-macosx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Solaris 11 Express: bind an iSCSI target to an IP</title>
		<link>http://www.cyberz.org/blog/2011/01/30/solaris-11-express-bind-iscsi-to-ip/</link>
		<comments>http://www.cyberz.org/blog/2011/01/30/solaris-11-express-bind-iscsi-to-ip/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 16:41:04 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=247</guid>
		<description><![CDATA[Lately I wanted to bring]]></description>
			<content:encoded><![CDATA[<p>Lately I wanted to bring the advantages of ZFS (on Solaris 11 Express) to a Linux box using iSCSI. After following the Oracle guide, I&#8217;ve noticed an unexpected behaviour when discovering the iSCSI targets (from a CentOS host):</p>
<pre>[root@zimbra ~]#  iscsiadm -m discovery -t sendtargets -p 192.168.64.10
192.168.64.10:3260,1 iqn.2011-01.org.cyberz:storage:mail
<strong>192.168.64.106:3260,1 iqn.2011-01.org.cyberz:storage:mail
...</strong>
[root@zimbra ~]#</pre>
<p>That is, the iSCSI target was bound to all the avaible interfaces (including ip addresses of zones).</p>
<p><span id="more-247"></span></p>
<p>To avoid this behavior it&#8217;s enough to create a &#8220;target portal group&#8221;, assign a specific interface to it and then bind targets to the tpg. Follows an example:</p>
<pre>root@scytale:~# itadm create-tpg tpg-scytale 192.168.64.10:3260
root@scytale:~# itadm list-target
TARGET NAME                                                  STATE    SESSIONS
iqn.2011-01.org.cyberz:storage:mail                          online   1
root@scytale:~# itadm modify-target -t tpg-scytale iqn.2011-01.org.cyberz:storage:mail
Target iqn.2011-01.org.cyberz:storage:mail successfully modified
root@scytale:~#</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2011/01/30/solaris-11-express-bind-iscsi-to-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenWRT on TP-Link TL-WR743ND</title>
		<link>http://www.cyberz.org/blog/2011/01/02/openwrt-on-tp-link-tl-wr743nd/</link>
		<comments>http://www.cyberz.org/blog/2011/01/02/openwrt-on-tp-link-tl-wr743nd/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 00:19:59 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=234</guid>
		<description><![CDATA[TP-Link TL-WR743ND is the PoE]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2011/01/TL-WR743ND.jpg"><img class="alignleft size-thumbnail wp-image-243" title="TP-Link TL-WR743ND" src="http://www.cyberz.org/blog/wp-content/uploads/2011/01/TL-WR743ND-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>TP-Link TL-WR743ND is the PoE brother of the common TL-WR741ND wireless router which is supported flawlessly by <a href="http://www.openwrt.org">openwrt</a>. Since I&#8217;ve got one WR743ND, I wanted to convert it into a useful OpenWRT router but I figured out that, unfortunately, the WR743ND is not supported by OpenWRT (at least officially). Given the similarity to the supported WR741ND, I&#8217;ve decided to hack it a bit to get it work with OpenWRT.</p>
<p><span id="more-234"></span>The first step is to get a working serial console. The procedure is similar to the one shown in the <a href="http://wiki.openwrt.org/toh/tp-link/tl-wr741nd">openwrt&#8217;s page dedicated to the WR741ND</a> with the exception that (at least on the WR743ND which I got) the capacitor C496 and the resistor R610 were missing, so it was necessary to:</p>
<ol>
<li>Shortcut the C496 pins</li>
<li>Solder a 2.7K resistor in place of R610 (I think short circuit would work as well &#8212; untested)</li>
</ol>
<p>Follows a photo (low resolution, sorry) indicating where the soldering should be made:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2011/01/TP743ND_Console.jpg"><img class="aligncenter size-medium wp-image-241" title="TP743ND Serial Console" src="http://www.cyberz.org/blog/wp-content/uploads/2011/01/TP743ND_Console-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Be aware that this hack requires some attention given the tiny dimension of SMD components.</p>
<p>Next step is to connect to the console via a serial cable and level converter. In my case I&#8217;ve assembled some circuitry with a MAX232 which was externally powered with 5v. Since the TX pin of the router is providing a positive level at 3.3v there is no issue with the MAX232 which is able to recognize the logic level, on contrary with the RX line we should care to not send +5v to the router which is using 3.3v logic levels (it may burn the router?). To accomplish that I&#8217;ve used a zener diode shunt to clamp the signal at 3.3v.</p>
<p>The whole thing was connected via a Profilic 232-to-USB adapter.</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2011/01/01012011026.jpg"><img class="aligncenter size-medium wp-image-242" title="MAX232" src="http://www.cyberz.org/blog/wp-content/uploads/2011/01/01012011026-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>To test  the serial link connection, just boot the router and blind type <em>tpl</em> when the autoboot prompt is shown. The U-Boot loader will show a &gt; prompt:</p>
<pre>U-Boot 1.1.4 (Jan 18 2010 - 14:26:54)

AP91 (ar7240) U-boot
DRAM:
sri
#### TAP VALUE 1 = a, 2 = b
32 MB
id read 0x100000ff
flash size 4194304, sector count = 64
Flash:  4 MB
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   ag7240_enet_initialize...
No valid address in Flash. Using fixed address
: cfg1 0xf cfg2 0x7014
eth0: 00:03:7f:09:0b:ad
eth0 up
No valid address in Flash. Using fixed address
: cfg1 0xf cfg2 0x7214
eth1: 00:03:7f:09:0b:ad
ATHRS26: resetting s26
ATHRS26: s26 reset done
eth1 up
eth0, eth1
Autobooting in 1 seconds
<strong>tlp</strong>
ar7240&gt;</pre>
<p>Now that the console is working it&#8217;s time to proceed with the flashing. Download <em>openwrt-ar71xx-tl-wr741nd-v1-squashfs-factory.bin</em> from the OpenWRT website and have it published by a tftp server in your local network. Then connect the router to such a network and issue the following commands (here the tftp server is 192.168.1.45):</p>
<pre>ar7240&gt; <strong>setenv ipaddr 192.168.1.60</strong>
ar7240&gt; <strong>setenv serverip 192.168.1.45</strong>
ar7240&gt; <strong>printenv</strong>
bootargs=console=ttyS0,115200 root=31:02 rootfstype=jffs2 init=/sbin/init mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),2752k(rootfs),896k(uImage),64k(NVRAM),64k(ART)
bootcmd=bootm 0x9f020000
bootdelay=1
baudrate=115200
ethaddr=0x00:0xaa:0xbb:0xcc:0xdd:0xee
stdin=serial
stdout=serial
stderr=serial
ethact=eth0
serverip=192.168.1.45
ipaddr=192.168.1.60

Environment size: 357/65532 bytes
ar7240&gt; <strong>tftpboot 0x80000000 openwrt-ar71xx-tl-wr741nd-v1-squashfs-factory.bin</strong>
dup 1 speed 1000
Using eth1 device
TFTP from server 192.168.1.45; our IP address is 192.168.1.60
Filename 'openwrt-ar71xx-tl-wr741nd-v1-squashfs-factory.bin'.
Load address: 0x80000000
Loading: #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 #################################################################
 ######################################################
done
Bytes transferred = 3932160 (3c0000 hex)
ar7240&gt; <strong>erase 0x9f020000 +0x3c0000</strong>

First 0x2 last 0x3d sector size 0x10000
 61
Erased 60 sectors
ar7240&gt; <strong>cp.b 0x80000000 0x9f020000 0x3c0000</strong>
Copy to Flash... write addr: 9f020000
done
ar7240&gt; <strong>bootm 0x9f020000</strong>
## Booting image at 9f020000 ...
 Uncompressing Kernel Image ... OK

Starting kernel ...

Linux version 2.6.32.10 (openwrt@wrt1.marcant.net) (gcc version 4.3.3 (GCC) ) #20 Tue Apr 6 15:01:26 CEST 2010
bootconsole [early0] enabled
CPU revision is: 00019374 (MIPS 24Kc)
Atheros AR7240 rev 2, CPU:350.000 MHz, AHB:175.000 MHz, DDR:350.000 MHz
Determined physical RAM map:
 memory: 02000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Zone PFN ranges:
 Normal   0x00000000 -&gt; 0x00002000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
 0: 0x00000000 -&gt; 0x00002000
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128
Kernel command line: rootfstype=squashfs,yaffs,jffs2 noinitrd console=ttyS0,115200 board=TL-WR741ND
PID hash table entries: 128 (order: -3, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)</pre>
<p>Enjoy your new OpenWRT router!</p>
<p><em>NOTE</em>: in case you would like to use the WT743ND as an access point and not as a router, OpenWRT documentation suggest to simply ignore the WAN interface and connect the AP via a LAN port. Unfortunately If you&#8217;re willing to use PoE the WAN port is the only port capable to receive power! In my case I successfully connected the PoE pins from the WAN to the first LAN port, having the router powered-on via PoE on the first LAN port (thus acting as an access point).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2011/01/02/openwrt-on-tp-link-tl-wr743nd/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CadSoft Eagle and Fedora Linux x86_64</title>
		<link>http://www.cyberz.org/blog/2010/11/28/cadsoft-eagle-and-fedora-linux-x86_64/</link>
		<comments>http://www.cyberz.org/blog/2010/11/28/cadsoft-eagle-and-fedora-linux-x86_64/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 22:16:58 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=231</guid>
		<description><![CDATA[CadSoft&#8217;s Eagle (a well known]]></description>
			<content:encoded><![CDATA[<p>CadSoft&#8217;s Eagle (a well known CAD tool for designing PCBs) is not compatible as-is with Linux 64 bit. In my case, after a fresh Fedora 14 install, I was getting this error:</p>
<p><code><br />
# sh eagle-lin-5.10.0.run<br />
eagle-lin-5.10.0.run: /tmp/eagle-setup.3778/eagle-5.10.0/bin/eagle: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory<br />
</code></p>
<p>To get the thing done it&#8217;s enough to install the proper 32 bit libraries. On Fedora use yum to update the openssl package and then install the needed packages:</p>
<p><code><br />
# yum update openssl<br />
# yum install glibc.i686 libXrender.i686 libXrandr.i686 libXcursor.i686 freetype.i686 fontconfig.i686 libXi.i686 libpng.i686 openssl.i686 crypto.i686 libjpeg-turbo.i686 libstdc++.i686<br />
</code></p>
<p>Eagle is compiled with openssl 0.9.8, Fedora 14 ships with openssl 1.0, so we need to cheat a bit with symlinks:</p>
<p><code><br />
# ln -s /usr/lib/libssl.so.10 /usr/lib/libssl.so.0.9.8<br />
# ln -s /lib/libcrypto.so.10 /lib/libcrypto.so.0.9.8<br />
</code></p>
<p>Now your system is ready to run the Eagle installer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2010/11/28/cadsoft-eagle-and-fedora-linux-x86_64/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>2</slash:comments>
		</item>
		<item>
		<title>I2C Anemometer: cheap wind data logger</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><strong><em>(Update on 18 Sep 2010)</em></strong></p>
<p>Finally I had some time to assembly the prototype board of the anemometer. Follows the schematic and the board layout:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_schematic.png"><img class="aligncenter size-medium wp-image-212" title="i2c_schematic" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_schematic-300x164.png" alt="" width="300" height="164" /></a><br />
<a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c.png"><img class="aligncenter size-medium wp-image-211" title="i2c" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c-300x267.png" alt="" width="300" height="267" /></a></p>
<p>The board is rather simple and is based on a PCF8574 providing to the I<sup>2</sup>C the output of a CD 4040 counter. A dip switch is provided to select the PCF8574 address and some leds for power on and wind activity.</p>
<p>Some photos of the prototype follow:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_proto_pcb.jpg"><img class="aligncenter size-medium wp-image-214" title="i2c_proto_pcb" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_proto_pcb-300x231.jpg" alt="" width="300" height="231" /></a><br />
<a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_proto_assembled.jpg"><img class="aligncenter size-medium wp-image-220" title="i2c_proto_assembled" src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/i2c_proto_assembled-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The DIP switch was not soldered thus the circuit will have the address 0&#215;27. After blowing the anemometer the green led was blinking and a scan on the i2c bus showed that the PCF 8574 was correctly detected. It was time to put the anemometer on the roof:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2010/06/17102010063.jpg"><img src="http://www.cyberz.org/blog/wp-content/uploads/2010/06/17102010063-225x300.jpg" alt="" title="Anemometer on the roof" width="225" height="300" class="aligncenter size-medium wp-image-225" /></a><br />
<strong><em>(Update on 27 Sep 2010)</em></strong></p>
<p>After the hardware, it came the time to write the software. Due to the disappointing I<sup>2</sup>C support of perl (CPAN couldn&#8217;t find Device::SMBus), I&#8217;ve decided to switch to C(++) to get the thing done using the i2c-dev interface available from Linux kernel. The program, named windlogd (wind-logger-daemon) reads the counter values and output the current speed, as show in the following:</p>
<pre>
[root@kynes windlogd]# ./windlogd -s 0x27 -d /dev/i2c-1
Thu Oct 21 10:53:56 2010: samples 108,  92: freq 5.333 Hz, wind speed 3.378 m/s
Thu Oct 21 10:53:59 2010: samples 124, 108: freq 5.333 Hz, wind speed 3.378 m/s
Thu Oct 21 10:54:02 2010: samples 140, 124: freq 5.333 Hz, wind speed 3.378 m/s
Thu Oct 21 10:54:05 2010: samples 160, 140: freq 6.667 Hz, wind speed 4.156 m/s
</pre>
<p>The transfer function between the anemometer is defined in the source (see the TF_* defines). The -d argument sets the bus to be used (defaults to i2c-0), while -s is mandatory and is the device address (can be expressed both in decimal and hexadecimal using the 0x prefix).</p>
<p>You can <a href="http://www.cyberz.org/projects/windlogd">download the source (for Linux) here</a>.</p>
]]></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" _mce_src="/projects/SVGPan/tiger.svg" classid="image/svg+xml" width="800" height="800"><![endif]--><!--[if !IE]>&#8211;><object id="testSVG" data="/projects/SVGPan/tiger.svg">type=&#8221;image/svg+xml&#8221; width=&#8221;800&#8243; height=&#8221;800&#8243;&gt;<!--<![endif]-->&nbsp;<br />
<h1>No SVG support at all!</h1>
<p>&nbsp;</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>&nbsp;</p>
<p>The source of this project is now hosted on Google Code, so there you can find the <a href="http://svgpan.googlecode.com">latest version</a>.</p>
<p>&nbsp;</p>
<p><strong>If you found this code useful please consider donating!</strong></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="VWFAFW2GHURE4">
<input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110429-1/en_US/i/scr/pixel.gif" width="1" height="1"></form>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
	</channel>
</rss>

