<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>fede.tft&#039;s Blog</title>
	<atom:link href="http://fedetft.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fedetft.wordpress.com</link>
	<description>A blog (mostly) about embedded development</description>
	<lastBuildDate>Wed, 27 Feb 2013 21:44:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='fedetft.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>fede.tft&#039;s Blog</title>
		<link>http://fedetft.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://fedetft.wordpress.com/osd.xml" title="fede.tft&#039;s Blog" />
	<atom:link rel='hub' href='http://fedetft.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Synchronization primitives in Miosix</title>
		<link>http://fedetft.wordpress.com/2012/10/06/synchronization-primitives-in-miosix/</link>
		<comments>http://fedetft.wordpress.com/2012/10/06/synchronization-primitives-in-miosix/#comments</comments>
		<pubDate>Sat, 06 Oct 2012 14:39:26 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Miosix]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=222</guid>
		<description><![CDATA[A small and backwards compatible change in Miosix 1.61 made me think about low-level synchronization primitives, and the fact that doumentation on how to use them was lacking. So, here&#8217;s a page dedicated to this topic.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=222&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A small and backwards compatible change in Miosix 1.61 made me think about low-level synchronization primitives, and the fact that doumentation on how to use them was lacking. So, here&#8217;s a <a href="http://www.webalice.it/fede.tft/miosix/sync.html" target="_blank">page</a> dedicated to this topic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=222&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2012/10/06/synchronization-primitives-in-miosix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>
	</item>
		<item>
		<title>Better code completion for Miosix</title>
		<link>http://fedetft.wordpress.com/2012/04/06/better-code-completion-for-miosix/</link>
		<comments>http://fedetft.wordpress.com/2012/04/06/better-code-completion-for-miosix/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 19:29:49 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Miosix]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=213</guid>
		<description><![CDATA[For those who are using Miosix with the Netbeans IDE, there is an interesting new feature: support for configurations. Netbeans is the IDE I&#8217;m using to develop Miosix, and the kernel comes with a folder containing a Netbeans project to manage its sources. While code completion in Netbeans is good, the IDE often got confused [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=213&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>For those who are using Miosix with the Netbeans IDE, there is an interesting new feature: support for configurations. Netbeans is the IDE I&#8217;m using to develop Miosix, and the kernel comes with a folder containing a Netbeans project to manage its sources. While code completion in Netbeans is good, the IDE often got confused by the existence of multiple supported architectures, so code completion would not work for resolving symbols in the board support packages, at least until now.</p>
<p>Now a new configuration has been added for each supported board, with the predefined macros reflecting those in Makefile.inc, so that code completion now works also for board specific files.</p>
<p>To select the board you&#8217;re currently using, right click on the project, and select your board among those listed under &#8220;Set Configuration&#8221;. Note that this does not eliminate the need to edit the Makefile.inc to build the kernel for a specific board.</p>
<p><a href="https://fedetft.files.wordpress.com/2012/04/netbeans-config.png"><img class="size-full wp-image" src="https://fedetft.files.wordpress.com/2012/04/netbeans-config.png?w=522" alt="Image" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=213&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2012/04/06/better-code-completion-for-miosix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>

		<media:content url="https://fedetft.files.wordpress.com/2012/04/netbeans-config.png?w=522" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>
	</item>
		<item>
		<title>Miosix 1.60 is out</title>
		<link>http://fedetft.wordpress.com/2012/02/12/miosix-1-60-is-out/</link>
		<comments>http://fedetft.wordpress.com/2012/02/12/miosix-1-60-is-out/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 10:55:36 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Miosix]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=209</guid>
		<description><![CDATA[Latest changes include preliminary support for the STM32F4 microcontrollers, and the stm32f4discovery board.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=209&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Latest changes include preliminary support for the STM32F4 microcontrollers, and the stm32f4discovery board.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=209&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2012/02/12/miosix-1-60-is-out/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>
	</item>
		<item>
		<title>Using a DMA capable SPI as an LCD controller</title>
		<link>http://fedetft.wordpress.com/2011/11/30/using-a-dma-capable-spi-as-an-lcd-controller/</link>
		<comments>http://fedetft.wordpress.com/2011/11/30/using-a-dma-capable-spi-as-an-lcd-controller/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 11:54:15 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DMA]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[microcontrollers]]></category>
		<category><![CDATA[Miosix]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=206</guid>
		<description><![CDATA[What if you have a graphic display without an embedded controller, and you want to drive it with an ARM microcontroller? Turns out that if a DMA is available, the task is not so impossible as it first seems. If you&#8217;re interested, read the article on my website here.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=206&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>What if you have a graphic display without an embedded controller, and you want to drive it with an ARM microcontroller? Turns out that if a DMA is available, the task is not so impossible as it first seems.</p>
<p><img src="http://www.webalice.it/fede.tft/spi_as_lcd_controller/image_test_small.jpeg" alt="" /></p>
<p>If you&#8217;re interested, read the article on my website <a href="http://www.webalice.it/fede.tft/spi_as_lcd_controller/spi_as_lcd_controller.html">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=206&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/11/30/using-a-dma-capable-spi-as-an-lcd-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>

		<media:content url="http://www.webalice.it/fede.tft/spi_as_lcd_controller/image_test_small.jpeg" medium="image" />
	</item>
		<item>
		<title>Mxgui</title>
		<link>http://fedetft.wordpress.com/2011/09/22/mxgui/</link>
		<comments>http://fedetft.wordpress.com/2011/09/22/mxgui/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 11:50:12 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[3D rendering]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[Miosix]]></category>
		<category><![CDATA[Mxgui]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=203</guid>
		<description><![CDATA[Ok, here&#8217;s the new library for Miosix: Mxgui. As the name suggests, it&#8217;a a GUI library for microcontrollers, designed to work with the Miosix kernel. Source code is here, while documentation here. What can it be used for? 3D rendering on a microcontroller, for example. Mxgui examples from fede.tft on Vimeo.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=203&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Ok, here&#8217;s the new library for Miosix: Mxgui. As the name suggests, it&#8217;a a GUI library for microcontrollers, designed to work with the Miosix kernel.</p>
<p>Source code is <a href="http://gitorious.org/miosix-kernel/mxgui">here</a>, while documentation <a href="http://www.webalice.it/fede.tft/miosix/mxgui_1.00/index.html">here</a>.</p>
<p>What can it be used for? 3D rendering on a microcontroller, for example.</p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/29385744' width='400' height='265' frameborder='0'></iframe></div>
<p><a href="http://vimeo.com/29385744">Mxgui examples</a> from <a href="http://vimeo.com/fedetft">fede.tft</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/203/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=203&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/09/22/mxgui/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>
	</item>
		<item>
		<title>Serial port classes moved to Gitorious</title>
		<link>http://fedetft.wordpress.com/2011/07/11/serial-port-classes-moved-to-gitorious/</link>
		<comments>http://fedetft.wordpress.com/2011/07/11/serial-port-classes-moved-to-gitorious/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 10:08:00 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=200</guid>
		<description><![CDATA[When I first published this article about using serial port with C++ I didn&#8217;t expect it to become one of the main reasons people visit my website. Over time, thanks to many comments, bug reports and suggestion, the serial port classes have been modified significantly, to the point that releasing them in a .tar.gz file [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=200&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>When I first published <a href="http://www.webalice.it/fede.tft/serial_port/serial_port.html">this</a> article about using serial port with C++ I didn&#8217;t expect it to become one of the main reasons people visit my website. Over time, thanks to many comments, bug reports and suggestion, the serial port classes have been modified significantly, to the point that releasing them in a .tar.gz file is no longer a good idea.</p>
<p>I&#8217;ve therefore decided to create a git repository at <a href="https://gitorious.org/serial-port">http://gitorious.org/serial-port</a> where you can get the latest version of my serial port classes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=200&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/07/11/serial-port-classes-moved-to-gitorious/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>
	</item>
		<item>
		<title>Improving battery lifetime of Le Dominoux</title>
		<link>http://fedetft.wordpress.com/2011/04/26/improving-battery-lifetime-of-le-dominoux/</link>
		<comments>http://fedetft.wordpress.com/2011/04/26/improving-battery-lifetime-of-le-dominoux/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 12:52:36 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=177</guid>
		<description><![CDATA[Some time ago I saw on Hack a Day this post about Le Dominoux, an electronic based version of dominoes. At first it didn&#8217;t seem much fun, but watching the video I quickly changed my opinion. In the end, the author also measures the power consumption of the device when the led is not lit, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=177&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Some time ago I saw on Hack a Day <a href="http://hackaday.com/2011/03/01/endless-fun-with-led-dominoes/">this</a> post about Le Dominoux, an electronic based version of dominoes. At first it didn&#8217;t seem much fun, but watching the video I quickly changed my opinion.</p>
<p>In the end, the author also measures the power consumption of the device when the led is not lit, showing it&#8217;s around 100uA, and it&#8217;s from there that I thought this little device might be improved a bit.</p>
<p>Now, since this device was designed for a 555 contest, the author <strong>had</strong> to use a 555 IC, and given this constraint I think he has done a good job in optimizing it for low power, using a CMOS variant of the 555 and high brightness leds.</p>
<p>But set aside that constraint, it would be easy to optimize it event further. First of all let&#8217;s check the battery lifetime of the original device. Since the power cosumption when the led is lit (probably 5 to 10mA) differs greatly from the standby value of 100uA, battery lifetime largely depends on how much you play with it, but an upper bound is easy to calculate, and it&#8217;s 200mAh (CR2032 battery capacity) / 100uA = 2000h / 24 = 83 days. This isn&#8217;t very good since even if you almost never play with it, after ~80 days the battery is dead.</p>
<p>One possibility to improve it is to use standard 40xx CMOS logic gates to design the one shot timer, like this:</p>
<p><a href="http://fedetft.files.wordpress.com/2011/03/led-sch.png"><img class="alignnone size-medium wp-image-180" title="led-sch" src="http://fedetft.files.wordpress.com/2011/03/led-sch.png?w=300&#038;h=139" alt="" width="300" height="139" /></a></p>
<p>The fun of CMOS gates is that other than being very versatile, they draw next to zero current when they&#8217;re not switching. I built this circuit to measure the power consumption, ant that&#8217;s the result:</p>
<p><a href="http://fedetft.files.wordpress.com/2011/03/led2.jpg"><img class="alignnone size-medium wp-image-184" title="led" src="http://fedetft.files.wordpress.com/2011/03/led2.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>As you can see, it is drawing just 4uA. The actual standby current depends on how much light is shining on the phototransistor. For example in the dark it draws just 1uA, while if a bright light is pointed at the phototransistor it draws up to 300uA, which is 3V(battery voltage) /10K(R3). This happens also in the original author&#8217;s schematic, since the input stage with the phototransistor and the 10K resistor is the same, so that&#8217;s no worse than the original circuit. Anyway, in normal ambient light conditions very few light reaches the phototransistor, and the current is very low, around 5uA.</p>
<p>This gives an upper bound to the battery lifetime of 200mAh / 5uA = 40000h / 24 / 365 = 4.5 years!</p>
<p>Last notes about this circuit:</p>
<ul>
<li>it uses the same number of components as the original one, just replaces the 555 with a 4011.</li>
<li>you have to connect pin 7 of the 4011 to ground, and pin 14 to Vcc, even if in the schematic these connections are omitted.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=177&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/04/26/improving-battery-lifetime-of-le-dominoux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>

		<media:content url="http://fedetft.files.wordpress.com/2011/03/led-sch.png?w=300" medium="image">
			<media:title type="html">led-sch</media:title>
		</media:content>

		<media:content url="http://fedetft.files.wordpress.com/2011/03/led2.jpg?w=300" medium="image">
			<media:title type="html">led</media:title>
		</media:content>
	</item>
		<item>
		<title>Fail over fail</title>
		<link>http://fedetft.wordpress.com/2011/01/07/fail-over-fail/</link>
		<comments>http://fedetft.wordpress.com/2011/01/07/fail-over-fail/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 13:47:49 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=169</guid>
		<description><![CDATA[Even more rant this time. To go on programming microcontrollers as I&#8217;ve always done I have to disable two programs, gpsd and modem-manager (see my previous post) because hardware manufacturers fail. The first one, gpsd is done. To fix the second one without killing/removing NetworkManager I have to contact ModemManager developers. To do so I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=169&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Even more rant this time.</p>
<p>To go on programming microcontrollers as I&#8217;ve always done I have to disable two programs, gpsd and modem-manager (see my previous post) because hardware manufacturers fail. The first one, gpsd is done. To fix the second one without killing/removing NetworkManager I have to contact ModemManager developers. To do so I have to register to launchpad. To do so I have to get an OpenId. To do so I have to&#8230; find a way to avoid another fail:</p>
<p><a href="http://fedetft.files.wordpress.com/2011/01/failoverfail.png"><img class="alignnone size-medium wp-image-170" title="failoverfail" src="http://fedetft.files.wordpress.com/2011/01/failoverfail.png?w=300&#038;h=190" alt="" width="300" height="190" /></a></p>
<p>See on the bottom of that webpage? &#8220;Type the two words into the field below&#8221;. I&#8217;d be glad to do that if there were two words, and one field. The HTML source of the page seems to indicate that a sort of captcha is supposed to be there, bu there isn&#8217;t&#8230; and without it I can&#8217;t complete the registration&#8230;</p>
<p>But wait, there&#8217;s more fail:</p>
<p>A quick look at <a href="http://openid.net/get-an-openid/">http://openid.net/get-an-openid/</a> and I found out that since I have a wordpress blog I already have an OpenId. I tried to log in with that, but it failed. A look at the FAQs for launchpad and:</p>
<p>&#8220;<strong>Can I log into Launchpad with my existing OpenID?</strong></p>
<p>Not at this time.  Launchpad is currently an OpenID Provider (OP) and not a consumer (RP).&#8221;</p>
<p>And that, in my opinion, is fail.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=169&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/01/07/fail-over-fail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>

		<media:content url="http://fedetft.files.wordpress.com/2011/01/failoverfail.png?w=300" medium="image">
			<media:title type="html">failoverfail</media:title>
		</media:content>
	</item>
		<item>
		<title>Linux today: too much plug and play</title>
		<link>http://fedetft.wordpress.com/2011/01/07/linux-today-too-much-plug-and-play/</link>
		<comments>http://fedetft.wordpress.com/2011/01/07/linux-today-too-much-plug-and-play/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 11:39:12 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[gpsd]]></category>
		<category><![CDATA[GSM]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ModemManager]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=157</guid>
		<description><![CDATA[This title is probably not what you&#8217;d expect. Usually people complain for the opposite reason: they buy some hardware, connect it to Linux and it does nothing, so they have to spend time in forums to see what can be done even if manufacturers don&#8217;t officially support Linux. In my case, it&#8217;s the plug and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=157&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This title is probably not what you&#8217;d expect. Usually people complain for the opposite reason: they buy some hardware, connect it to Linux and it does nothing, so they have to spend time in forums to see what can be done even if manufacturers don&#8217;t officially support Linux.</p>
<p>In my case, it&#8217;s the plug and play system itself that is causing me problems, because it incorrectly identifies a device as another type of device&#8230;</p>
<p>But let&#8217;s start from the beginning. I&#8217;m an embedded developer, and therefore I deal with microcontrollers. Often, the easiest way to debug, program, and communicate with a microcontroller is a serial port. Given that serial ports disappeared from computers long ago, USB to serial adapters have been introduced to solve this problem. These are all tiny chips like the FT232 or PL2303 that connect upstream as USB and downstream as serial ports.</p>
<p>These chips can be used either as standalone products, like the blue dongle at the left of this picture which is PL2303 based</p>
<p><a href="http://www.webalice.it/fede.tft/fonera/Cavo_seriale-small.jpg"><img class="alignnone" title="USB/serial converter" src="http://www.webalice.it/fede.tft/fonera/Cavo_seriale-small.jpg" alt="" width="234" height="128" /></a></p>
<p>or directly embedded into the device. For example, the Miosix board that I designed has an FT232 on board. It&#8217;s the chip at the bottom right, next to the USB connector</p>
<p><a href="http://www.webalice.it/fede.tft/miosix/miosix_board.jpg"><img class="alignnone" title="Miosix board" src="http://www.webalice.it/fede.tft/miosix/miosix_board.jpg" alt="" width="640" height="522" /></a></p>
<p>Now, both these devices identify as serial ports, using the default VID and PID (which are the identifiers of the USB protocol) of the manufacturer. They do so because they <strong>are</strong> serial ports, the first one is obvious to see, but also the second, since I don&#8217;t need any program to automatically start when I plug one of those, just to sit there and wait till I open screen or minicom to watch debug messages and the like.</p>
<p>Now, I&#8217;ve recently upgraded my computer to Fedora 14. It works very well, except for serial ports. At first I noticed that immediately after connecting a USB/serial device, trying to talk to it resulted in errors. &#8220;Device ore resource busy&#8221;, it said. Retrying after a couple of seconds fixed this, but then it looks like the bootloader of the microcontroller (the first program that starts) has been upset by something, so the first programming cycle failed, the next one went well, and all the subsequent too. At least until the USB/serial adapter is disconnected and reattached, in this case the issue presents again.</p>
<p>What could it be?, I thought. Maybe a bug in the kernel driver for serial ports? It turned out to be something entirely different.</p>
<p>To understand what was happening, first we have to talk about crappy GPS mice and GSM usb sticks. Both have someting in common: those who manufacture the GSM/GPS module are different from people who design the final product. The GSM/GPS modules, for convenience, spit out their data through a serial port. But given that PCs have USB ports only, final product designers add an USB/serial converter into the device. Now, the issue is, that they don&#8217;t care about changing the default VID and PID of the USB/serial adapter. Therefore when plugged to a PC they appear as serial ports despite their products are <strong>not</strong> serial ports. A GPS can only understand NMEA sentences (plus some weird binary protocol), while a GSM &#8220;internet key&#8221; can only understand AT commands. And what&#8217;s worse, they require plug and play, they require a program that attaches to these devices as soon as they&#8217;re plugged in.</p>
<p>Linux on the other side, is growing fast even as a desktop operating system. So it&#8217;s natural that it is starting to support more and more hardware, in the easiest possible way. But how can it cope with GSM/GPS USB sticks?</p>
<p>Simple: for GPSes there&#8217;s a program, <a href="http://gpsd.berlios.de/">gpsd</a>, that when a new device is connected, its VID and PID are checked against a list of devices, and if matches it tries to send NMEA sentences. If it responds, ok, otherwise the device is discarded. The same happens for GSM devices, there&#8217;s another program: <a href="https://launchpad.net/modemmanager">ModemManager</a> that does the same thing with AT commands.</p>
<p>But given that most devices appear as a PL2303 serial port, how can these programs know if after the PL2303 there&#8217;s a GPS unit, a GSM &#8220;internet key&#8221;, or none of these? Simple, they don&#8217;t. They try for a while to talk and if the device on the other side doesn&#8217;t seem to be what they expect, they give up.</p>
<p>This explains why trying to connect my USB/serial adapter to the PC and immedately open screen or minicom resulted in &#8220;device or resource busy&#8221;, while retrying a couple of seconds later worked.</p>
<p>The issue I&#8217;m having with the bootloader, is instead caused by the fact that these little program don&#8217;t just open the serial port and listen, they open the port and <strong>talk</strong>! The bootloader of my board probably gets upset by AT commands, or NMEA sentences or both.</p>
<p>But then I wonder, does a GPS unit like AT commands, or conversely, does a GSM internet key like NMEA sentences? This is trouble waiting to happen. Also on Windows, I suppose. Assume one buys a cheap GSM unit that identifies as a PL2303, and a cheap internet key that identifies too as PL2303, what does the <strong>official</strong> Windows drivers that come with them do? Conflict, I guess.</p>
<p>The first attempt to fix <strong>my issue</strong> has been to uninstall gpsd and modem-manager. Unfortunately, on Fedora, the <strong>whole</strong> KDE depends on gpsd, so it can&#8217;t be unistalled. I therefore contacted the gpsd developers on the mailing list. They have been very helpful in finding a workaround (they even blogged about it as I&#8217;m doing now, <a href="http://esr.ibiblio.org/?p=2849">here</a>), which is to download the gpsd sources and issue these commands:</p>
<p><code>./configure<br />
make udev-uninstall</code></p>
<p>which leaves gpsd installed, but removes udev rules that cause the plug and play. It&#8217;s also interesting that if I ever buy a GPS unit I can still start gpsd manually. Nice.</p>
<p>The fun thing is that gpsd developers were not aware that some other opensource project, ModemManager, was lurking for the same USB VID and PIDs&#8230;</p>
<p>I still haven&#8217;t found a way to disable modem-manager. It is a daemon, but it auto-respawns when killed, there&#8217;s no &#8220;service modem-manager stop&#8221; and trying to uninstall it would also get rid of NetworkManager.</p>
<p>Ofcouse, the only way to fix the <strong>whole problem</strong> is that hardware manufacturers should change the VID and PID so that a GPS, a GSM modem and a serial port can be uniquely identified&#8230;</p>
<p><strong>Update:</strong></p>
<p>I found a way to disable modem-manager while leaving NetworkManager:</p>
<p><code>sudo service NetworkManager stop<br />
sudo killall modem-manager<br />
cd /usr/sbin<br />
sudo rm modem-manager<br />
sudo service NetworkManager start</code></p>
<p>Ofcourse any GSM internet key would probably stop working, but for now It&#8217;s enough. I can finally connect an USB/serial adapter and nothing is trying to speak with it by default. Finally.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=157&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2011/01/07/linux-today-too-much-plug-and-play/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>

		<media:content url="http://www.webalice.it/fede.tft/fonera/Cavo_seriale-small.jpg" medium="image">
			<media:title type="html">USB/serial converter</media:title>
		</media:content>

		<media:content url="http://www.webalice.it/fede.tft/miosix/miosix_board.jpg" medium="image">
			<media:title type="html">Miosix board</media:title>
		</media:content>
	</item>
		<item>
		<title>Handling PNG images in C++</title>
		<link>http://fedetft.wordpress.com/2010/10/05/handling-png-images-in-cpp/</link>
		<comments>http://fedetft.wordpress.com/2010/10/05/handling-png-images-in-cpp/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 12:44:48 +0000</pubDate>
		<dc:creator>fedetft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fedetft.wordpress.com/?p=139</guid>
		<description><![CDATA[This blog post is about png++, one of my favourite C++ libraries. It&#8217;s a wrapper of libpng in C++ that allows to handle PNG images so easily that you&#8217;ll never want to use bare libpng again. All you need to start is to add these two lines in you source files: #include "png++/png.hpp" using namespace [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=139&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This blog post is about <a href="http://savannah.nongnu.org/projects/pngpp/">png++</a>, one of my favourite C++ libraries.</p>
<p>It&#8217;s a wrapper of libpng in C++ that allows to handle PNG images so easily that you&#8217;ll never want to use bare libpng again.</p>
<p>All you need to start is to add these two lines in you source files:</p>
<pre>#include "png++/png.hpp"
using namespace png;</pre>
<p>This is the code to open an existing image:</p>
<pre>image img("image.png");</pre>
<p>The code to make a new image from scratch differs only in the parameter passed to image&#8217;s constructor:</p>
<pre>image img(1024,768);</pre>
<p>The image class has the get_pixel() and set_pixel() memeber functions to access the individual pixels:</p>
<pre>rgb_pixel pixel=img.get_pixel(0,0);
pixel.red=min(255,pixel.red+10); //Increase red color of pixel
img.set_pixel(0,0,pixel);</pre>
<p>The image height and width can be obtained with intuitive get_height() and get_width() memeber functions:</p>
<pre>for(int i=0;i&lt;img.get_width();i++)
{
    for(int j=0;j&lt;img.get_height();j++)
    {
        //Do something
    }
}</pre>
<p>The image can be written to file with the write() memebr function:</p>
<pre>img.write("new_image.png");</pre>
<p>Also, this library is header-only. What does it means? That you do not have to compile the library to start playing with it, just exptract the library in the folder where you have your source code, and include the header file &#8220;png.hpp&#8221;, just that.</p>
<p>Lastly, here is an example code including CMake scripts to show the capabilities of the library. <a href="http://www.webalice.it/fede.tft/png++/png++.tar.gz">png++.tar.gz</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fedetft.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fedetft.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fedetft.wordpress.com&#038;blog=9307626&#038;post=139&#038;subd=fedetft&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fedetft.wordpress.com/2010/10/05/handling-png-images-in-cpp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/4b9ef427bcef86466f959fbeb29a4928?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">fedetft</media:title>
		</media:content>
	</item>
	</channel>
</rss>
