<?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 &#187; Linux</title>
	<atom:link href="http://www.cyberz.org/blog/tag/linux/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>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>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>
		<item>
		<title>Using samba with autofs on Fedora 9</title>
		<link>http://www.cyberz.org/blog/2008/09/07/using-samba-with-autofs-on-fedora-9/</link>
		<comments>http://www.cyberz.org/blog/2008/09/07/using-samba-with-autofs-on-fedora-9/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 14:55:54 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Samba]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=26</guid>
		<description><![CDATA[Mount a samba share on]]></description>
			<content:encoded><![CDATA[<p>Mount a samba share on the fly without having it mounted statically at boot via the /etc/fstab file can bring you the advantage of an unpainful boot in case of unavailability of the samba server like in the following common scenarios:</p>
<ul>
<li>laptop: you mount your pc share at home, but when you move it becomes unavailable</li>
<li>workstation: you mount the share of your workmate &#8211; but when he/she goes on holiday his/her workstation stays off</li>
</ul>
<p><span id="more-26"></span></p>
<p>Using autofs this can be accomplished easily following these steps:</p>
<ol>
<li>Set <code>/auto</code> under the control of autofs adding this line to <code>/etc/auto.master</code>:<br/><br/><code>/auto            /etc/auto.auto    --timeout=5 --ghost</code><br/><br/></li>
<li>Point <code>directory</code> to a samba share <code>//server/share</code> in <code>/etc/auto.auto</code>:<br/><br/><code>directory              -fstype=cifs,credentials=/etc/smb.auth         ://server/share</code> <i>(directory is a child directory of /auto)</i><br/><br/></li>
<li>Store access credentials to the samba share in <code>/etc/smb.auth</code>:<br/><br/><code>username=yourusername<br />
password=youpassword</code><br/><br/></li>
<li>Secure the password file:<br/><br/><code># chmod 600 /etc/smb.auth</code><br/><br/></li>
<li>Start autofs:<br/><br/><code># /etc/init.d/autofs start<br />
Starting automount:                                        [  OK  ]</code><br/><br/></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2008/09/07/using-samba-with-autofs-on-fedora-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MusicBrainz not working with Amarok on Fedora 8</title>
		<link>http://www.cyberz.org/blog/2008/04/13/musicbrainz-not-working-with-amarok-on-fedora-8/</link>
		<comments>http://www.cyberz.org/blog/2008/04/13/musicbrainz-not-working-with-amarok-on-fedora-8/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 10:14:05 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Amarok]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/2008/04/13/musicbrainz-not-working-with-amarok-on-fedora-8/</guid>
		<description><![CDATA[On my Fedora 8 system]]></description>
			<content:encoded><![CDATA[<p>On my Fedora 8 system with Amarok I was trying to fill an mp3&#8242;s tag header using MusicBrainz, getting the following error:</p>
<p><a href="http://www.cyberz.org/blog/wp-content/uploads/2008/04/amarok.png"><img class="alignnone size-full wp-image-18" title="Amarok MusicBrainz issue" src="http://www.cyberz.org/blog/wp-content/uploads/2008/04/amarok.png" alt="" width="500" height="131" /></a></p>
<p><code>Tunepimp (MusicBrainz tagging library) returned the following error: "Fingerprinting of .mp3 files is not supported."</code></p>
<p>To make it work, just <code>yum install libtunepimp-extras-nonfree</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2008/04/13/musicbrainz-not-working-with-amarok-on-fedora-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH X11 forwarding issue</title>
		<link>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/</link>
		<comments>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 21:38:53 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/</guid>
		<description><![CDATA[Recently I&#8217;ve been in an]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been in an awkward situation with ssh and X11 forwarding, where ssh using the classic -Y (or -X) switch wasn&#8217;t working (DISPLAY was not set):</p>
<p><code>[andrea@duncan ~]$ ssh -Y root@thufir<br />
root@thufir's password:<br />
Last login: Sat Apr 12 23:30:09 2008 from ***<br />
[root@thufir ~]# echo $DISPLAY<br />
[root@thufir ~]#</code></p>
<p>If you are experiencing the same and your <em>sshd_config</em> looks fine (which means TCP and X11 forwarding is already enabled) then the answer is missing <em>xauth</em>!</p>
<p>On RedHat <code>yum install xauth</code> will do the trick</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
