<?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>cosminaru blog &#187; GeekStyle</title>
	<atom:link href="http://cosminaru.ro/blog/category/geekstyle/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosminaru.ro/blog</link>
	<description>home</description>
	<lastBuildDate>Wed, 19 May 2010 08:03:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Extreme geekness: Atmel AVR</title>
		<link>http://cosminaru.ro/blog/2009/03/11/extreme-geekness-atmel-avr/</link>
		<comments>http://cosminaru.ro/blog/2009/03/11/extreme-geekness-atmel-avr/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 22:04:27 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[GeekStyle]]></category>

		<guid isPermaLink="false">http://cosminaru.ro/blog/?p=152</guid>
		<description><![CDATA[If you think that the previous posts certified my geekness. you ain&#8217;t seen shit.
This time it involves some electrical wiring, soldering, low-level C/C++ programming and lots of smoking: my first Atmel AVR project. Yeah baby, that&#8217;s what I&#8217;m talkin&#8217; about.
I&#8217;ve ran into this technology a couple of years ago when I coded a desktop application [...]]]></description>
			<content:encoded><![CDATA[<p>If you think that the <a href="http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/">previous</a> <a href="http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/">posts</a> certified my geekness. you ain&#8217;t seen shit.<br />
This time it involves some electrical wiring, soldering, low-level C/C++ programming and lots of smoking: my first Atmel AVR project. Yeah baby, <a href="http://atmel.com/products/avr/default.asp">that&#8217;s</a> what I&#8217;m talkin&#8217; about.</p>
<p>I&#8217;ve ran into this technology a couple of years ago when I coded a desktop application to communicate with such a device. So I wasn&#8217;t really involved in designing the parts external to that.<br />
A couple of weeks ago I decided to try the real deal and implement something <em>inside</em> the AVR controller. Since I wanted to do something that is actually useful, I decided to make a digital thermometer.</p>
<p>At first I searched for some temperature sensors and it seems that there are many options in that area. So I had to do lots of digging to find out what would best fit for such solutions. In the end, I found out that there are both sensors and AVR controllers supporting the <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I²C</a> two wire interface. No, I didn&#8217;t have a clue about what that was before starting this. In fact I admit learning lots of the electronics basics with this project.<br />
Based on I²C is how I got to my winning candidates: <a href="http://atmel.com/dyn/products/product_card.asp?part_id=3303">ATmega168</a> and the <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2737">DS1621</a> sensor.</p>
<p>Obviously, the other part of the problem was getting the information displayed. I was aware of the (most obvious) options in that area from the beginning: LED display or LCD display. I knew that using an LED display will either use up my controller pins or force me to use some shift register to expand the number of outputs. Since I wanted to keep it simple I opted for an LCD device. I bought one that is a lot larger than necessary, but only because I also plan to use it for some other purposes.</p>
<p>This is how the whole thing looked like in it&#8217;s final phase.</p>
<p><a href="http://cosminaru.ro/blog/wp-content/uploads/2009/03/avr_temperature_011.jpg"><img src="http://cosminaru.ro/blog/wp-content/uploads/2009/03/avr_temperature_011-300x200.jpg" alt="" title="avr_temperature_01" width="300" height="200" class="alignnone size-medium wp-image-154" /></a></p>
<p>No, of course the board is not something I built. It&#8217;s the <a href="http://kanda.com/products/kanda/STK200.html">STK200</a> AVR starter kit from Kanda which is also an AVR programmer.<br />
I know how the whole thing looks messy, but I didn&#8217;t spent time in making it compact since that was not the actual purpose.</p>
<p>The TWI and the LCD interfaces didn&#8217;t seem impossible to code since it&#8217;s pretty standard and well documented stuff. But since I am a complete rookie on this, I didn&#8217;t want to spend too many nights re-inventing the wheel when there are lots of libraries taking care of the low-level communication. So I used <a href="http://jump.to/fleury">Peter Fleury</a>&#8217;s <a href="http://homepage.hispeed.ch/peterfleury/group__pfleury__lcd.html">LCD</a> and <a href="http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html">I²C master</a> libraries to handle the low-level protocols.</p>
<p>What I did have to clarify in detail though (even if it was fairly light) was the DS1621 specs where each of the commands and expected results are described. This however was the part that I found the most attractive and I believe that in general these are the parts that are worth the trouble: at a certain level of specs, you get the detailed description of what bits you have to wire and what you get back. No questions asked &#8211; (almost) always works as specified.</p>
<p>Once I&#8217;ve put all the pieces together and managed to display the actual temperature value, I had to somehow validate the output. Not that there is much to do about it. The thing is that if you managed to read some value from the sensor it usually means that you did your part of the deal and an error in the actual numerical value is (probably) not something you caused. This was however not the case since I have a multimeter that also does temperature measuring among other things.</p>
<p><a href="http://cosminaru.ro/blog/wp-content/uploads/2009/03/avr_temperature_02.jpg"><img src="http://cosminaru.ro/blog/wp-content/uploads/2009/03/avr_temperature_02-300x200.jpg" alt="" title="avr_temperature_02" width="300" height="200" class="alignnone size-medium wp-image-158" /></a></p>
<p>Yeah, I know, my place is pretty warm. In the winter I sometimes overreact with the heating. Anyways, the DS1621 also has an 0.5 degree error (at least that&#8217;s the spec value), as for the multimeter&#8217;s sensor I have no idea. Bottom line is that is good enough so I&#8217;m a happy panda.</p>
<p>I didn&#8217;t spend the time to draw the schematics of this, but if you are really interested drop me a note and I can send you some summary of what exactly is to be done.</p>
<p>It took me a while to learn everything since this doesn&#8217;t quite work like &#8220;learning a new framework for the platform you know for years&#8221;. But it&#8217;s definitely interesting and it&#8217;s definitely a new level of geekness for me. Fuck yeah.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2009/03/11/extreme-geekness-atmel-avr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Perl  geekness: getting the .class bytecode version</title>
		<link>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/</link>
		<comments>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 08:33:26 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[GeekStyle]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://cosminaru.ro/blog/?p=107</guid>
		<description><![CDATA[I&#8217;ve been looking for a decent tool to determine the byte code version for a Java .class file. You know, the one based on the numbers after the CAFEBABE magic (you can read more about this here or here).
There are some tools around for this, but most of them written in Java. I really don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a decent tool to determine the byte code version for a Java .class file. You know, the one based on the numbers after the CAFEBABE magic (you can read more about this <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#75883">here</a> or <a href="http://en.wikipedia.org/wiki/Class_(file_format)">here</a>).<br />
There <a href="http://alumnus.caltech.edu/~leif/opensource/bcver/index.html">are</a> <a href="http://www.rgagnon.com/javadetails/java-0544.html">some</a> <a href="http://www.javaworld.com/javaqa/2003-05/02-qa-0523-version.html?page=1#resources">tools</a> around for this, but most of them written in Java. I really don&#8217;t see the point in starting a JVM just to read 4 bytes from a file, so I wrote a short Perl script for this. Again, I am no Perl expert so this is probably not the best solution performance-wise and such.</p>
<h4>Usage</h4>
<p><strong>1.</strong> Running the script with no arguments &#8211; will result in scanning the current directory recursively for <em>.class</em> files. The results are grouped by directory and a total number of files is also displayed. Directories that do not contain any <em>.class</em> files will be ignored, in order to keep a clean output. Below is a short sample.</p>
<pre><code>cosmin@cosminaru:~/work/quizine$ <strong>bcversion.pl</strong>

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine (2 files)
	QuizineException.class -&gt; 1.6
	ApplicationContext.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/web (2 files)
	ErrorHandlerFilter.class -&gt; 1.6
	SessionContext.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/web/actions (1 files)
	ActionBase.class -&gt; 1.6
</code></pre>
<p><strong>2.</strong> If you provide one or more arguments, the script will only scan the content of these arguments. If the argument is a file then the byte code version is displayed for that file. If it is a directory then it will be scanned recursively, just like above.<br />
<strong>Note:</strong> The paths from the argument list should all be relative to the current directory in order for the script to work correctly.</p>
<pre><code>cosmin@cosminaru:~.../model/quiz$ <strong>bcversion.pl AbstractQuestion.class result</strong>
* AbstractQuestion.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/model/quiz/result (5 files)
	QuestionnaireResult.class -&gt; 1.6
	BooleanAnswer.class -&gt; 1.6
	AbstractAnswer.class -&gt; 1.6
	SingleChoiceAnswer.class -&gt; 1.6
	MultipleChoiceAnswer.class -&gt; 1.6
</code></pre>
<p>I&#8217;ll probably want to scan JAR files and directories containing JAR files. But the really poor Perl docs for reading ZIP buffers didn&#8217;t quite help me. If you think think you can give a hand with that, drop a note <img src='http://cosminaru.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h4>Download:</h4>
<p>You can get the script from <a href="http://cosminaru.ro/downloads/bcversion.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Currency conversions the geek way</title>
		<link>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/</link>
		<comments>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 12:38:02 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[GeekStyle]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/</guid>
		<description><![CDATA[There are many situations when I need to convert an amount of Euros to RON (Romanian Leu). There are a couple of sites that can do the conversion for you (even Google does this pretty well). However, none of them seem to be as accurate as the the National Bank of Romania, whose exchange rate [...]]]></description>
			<content:encoded><![CDATA[<p>There are many situations when I need to convert an amount of Euros to RON (Romanian Leu). There are a couple of sites that can do the conversion for you (even Google <a href="http://www.google.com/search?hl=en&amp;rlz=1B3GGGL_enRO244RO244&amp;q=100+euro+to+ron&amp;btnG=Search" target="_blank">does</a> this pretty well). However, none of them seem to be as accurate as the the <a href="http://www.bnr.ro/" target="_blank">National Bank of Romania</a>, whose exchange rate is the only one that has any relevance for me. So most of the times I have to open the calculator, go the BNR website and use the exchange rate provided <a href="http://www.bnr.ro/Ro/Info/" target="_blank">here</a>, an issue that doesn&#8217;t work very well for a lazy ass like me.</p>
<p>Fortunately, BNR also provides <a href="http://www.bnro.ro/nbrfxrates.xml" target="_blank">an XML</a> with the exchange rates for the most important currencies in a manner that is very easy to understand:<br />
<code><br />
...<br />
&lt;Rate currency="DKK"&gt;0.4926&lt;/Rate&gt;<br />
&lt;Rate currency="EGP"&gt;0.4291&lt;/Rate&gt;<br />
&lt;Rate currency="EUR"&gt;3.6747&lt;/Rate&gt;<br />
&lt;Rate currency="GBP"&gt;4.6020&lt;/Rate&gt;<br />
...</code></p>
<p>Luckily, Perl knows how to parse XMLs so we&#8217;re almost good to go. Now I am not Perl expert, nor want to become one very soon, but this sounded like something doable with a minimum amount effort.</p>
<p>What we need is to get the XML with an HTTP request, parse it and convert the given amount of money using the desired currency. So I created a tiny script <code>convert2ron.pl</code> that accepts two parameters: the currency identifier (EUR, USD, etc.) and the amount to be converted. I will not go into the details of how this script works as it&#8217;s pretty straight-forward (even for someone with a minimal understanding of Perl). So now I can convert all sorts of currencies to RON using calls like this:<br />
<code><br />
$ ./convert2ron.pl EUR 245<br />
</code></p>
<p>and get results like these:<br />
<code><br />
245 EUR = 900.30 RON</p>
<p>(rate is 3.6747)<br />
</code></p>
<p>Is this the geekiest way to do this, or what? And the geekness doesn&#8217;t stop here. Now I also have some scripts like <code>eur2ron.sh</code> and <code>usd2ron.sh</code> so I can do stuff like this all day:<br />
<code><br />
$ eur2ron 456<br />
</code><br />
So, if you want to convert international currencies to RON the geek way, here&#8217;s the download: <a href="http://cosminaru.ro/downloads/ron-convert.zip">http://cosminaru.ro/downloads/ron-convert.zip</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
