<?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>Doswa &#187; Linux</title>
	<atom:link href="http://doswa.com/blog/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://doswa.com/blog</link>
	<description>Programming, physics, mathematics</description>
	<lastBuildDate>Sat, 28 Aug 2010 16:20:04 +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>AVRDUDE 5.10 with FTDI bitbang on Linux</title>
		<link>http://doswa.com/blog/2010/08/24/avrdude-5-10-with-ftdi-bitbang/</link>
		<comments>http://doswa.com/blog/2010/08/24/avrdude-5-10-with-ftdi-bitbang/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 19:35:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://doswa.com/blog/?p=460</guid>
		<description><![CDATA[Programming an ATmega168 using SparkFun&#8217;s FTDI Basic Breakout. This guide works for other FT232R-based devices as well. First, install the dependencies. On Ubuntu 10.04, this should take care of all of them: sudo apt-get install patch build-essential libreadline-dev libncurses-dev libusb-dev &#8230; <a href="http://doswa.com/blog/2010/08/24/avrdude-5-10-with-ftdi-bitbang/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://doswa.com/blog/wp-content/uploads/2010/08/ftdi.jpg" alt="" title="ftdi" width="628" height="374" class="aligncenter size-full wp-image-461" /></p>
<p><i>Programming an ATmega168 using <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9115">SparkFun&#8217;s FTDI Basic Breakout</a>. This guide works for other FT232R-based devices as well.</i></p>
<p><span id="more-460"></span></p>
<p>First, install the dependencies. On Ubuntu 10.04, this should take care of all of them:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">patch</span> build-essential libreadline-dev libncurses-dev libusb-dev libftdi-dev <span style="color: #c20cb9; font-weight: bold;">automake</span> <span style="color: #c20cb9; font-weight: bold;">autoconf</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> build-dep avrdude avrdude-doc</pre></div></div>

<p>Next, create a working directory for the build and cd into it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> avrdude
<span style="color: #7a0874; font-weight: bold;">cd</span> avrdude</pre></div></div>

<p>Now download the D2xx driver from FTDI. Only download the one that corresponds to your OS (either 64 bit or 32 bit).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># For 64-bit:</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.ftdichip.com<span style="color: #000000; font-weight: bold;">/</span>Drivers<span style="color: #000000; font-weight: bold;">/</span>D2XX<span style="color: #000000; font-weight: bold;">/</span>Linux<span style="color: #000000; font-weight: bold;">/</span>libftd2xx0.4.16_x86_64.tar.gz
<span style="color: #666666; font-style: italic;"># For 32-bit:</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.ftdichip.com<span style="color: #000000; font-weight: bold;">/</span>Drivers<span style="color: #000000; font-weight: bold;">/</span>D2XX<span style="color: #000000; font-weight: bold;">/</span>Linux<span style="color: #000000; font-weight: bold;">/</span>libftd2xx0.4.16.tar.gz</pre></div></div>

<p>Download AVRDUDE and the <a href="http://savannah.nongnu.org/patch/?6886">FTDI bitbang patches</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.savannah.gnu.org<span style="color: #000000; font-weight: bold;">/</span>releases-noredirect<span style="color: #000000; font-weight: bold;">/</span>avrdude<span style="color: #000000; font-weight: bold;">/</span>avrdude-5.10.tar.gz
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">8</span> <span style="color: #000000;">7</span> <span style="color: #000000;">6</span> <span style="color: #000000;">5</span> <span style="color: #000000;">4</span> <span style="color: #000000;">3</span> <span style="color: #000000;">2</span> <span style="color: #000000;">1</span> <span style="color: #000000;">0</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> patch-<span style="color: #007800;">$i</span>.diff http:<span style="color: #000000; font-weight: bold;">//</span>savannah.nongnu.org<span style="color: #000000; font-weight: bold;">/</span>patch<span style="color: #000000; font-weight: bold;">/</span>download.php?<span style="color: #007800;">file_id</span>=<span style="color: #000000;">1851</span><span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Extract everything, put the drivers into place, and apply the patches:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzf avrdude-5.10.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xzf libftd2xx<span style="color: #000000; font-weight: bold;">*</span>.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> avrdude-<span style="color: #000000;">5.10</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> ..<span style="color: #000000; font-weight: bold;">/</span>patch-<span style="color: #000000; font-weight: bold;">*</span>.diff; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">patch</span> <span style="color: #660033;">-p0</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$file</span>; <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>libftd2xx<span style="color: #000000; font-weight: bold;">*/</span>static_lib<span style="color: #000000; font-weight: bold;">/*</span> .
<span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>libftd2xx<span style="color: #000000; font-weight: bold;">*/*</span>.h .
<span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>libftd2xx<span style="color: #000000; font-weight: bold;">*/*</span>.cfg .</pre></div></div>

<p>Configure and compile AVRDUDE.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #007800;">CFLAGS</span>=<span style="color: #ff0000;">&quot;-g -O2 -DSUPPORT_FT245R&quot;</span> <span style="color: #007800;">LIBS</span>=<span style="color: #ff0000;">&quot;./libftd2xx.a.0.4.16 -lpthread&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>If you&#8217;re using <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9115">SparkFun&#8217;s FTDI Basic Breakout</a> board, you can use the following to update your AVRDUDE configuration. If you&#8217;re using some other FTDI breakout board, you&#8217;ll need to modify the miso, sck, mosi, and reset options. FTDI has a listing of which bits correspond to which pins <a href="http://www.ftdichip.com/Documents/AppNotes/AN232B-01_BitBang.pdf">on page 1 of the bit-bang mode datasheet</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'
programmer
  id    = &quot;ftdi&quot;;
  desc  = &quot;SparkFun FTDI Basic Breakout&quot;;
  type  = ft245r;
  miso  = 1;  # RXD
  sck   = 3;  # CTS
  mosi  = 0;  # TXD
  reset = 4;  # DTR
;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> avrdude.conf;</pre></div></div>

<p>If you&#8217;re using SparkFun&#8217;s FTDI Basic Breakout, you can make your connections as follows. Otherwise, make your connections according to the pins you chose in the previous step (more details <a href="http://doswa.com/blog/2009/12/20/sparkfuns-ftdi-basic-breakout-as-an-avr-programmer/">in my previous post on the subject</a>).</p>
<pre>FTDI -> MCU (ATmega168 PDIP pin)
--------------------------------
DTR -> RESET (1)
RXI -> MISO (18)
TXO -> MOSI (17)
5V -> VCC (7 &#038; 20)
CTS -> SCK (19)
GND -> GND (8 &#038; 22)</pre>
<p>Now try it out to make sure everything worked. On Ubuntu, sudo is required because of the default permissions applied to USB devices. The `-B 1` option sets the programming speed to the lowest possible. You can omit that option if your AVR is clocked higher than 8MHz. If this runs successfully, your AVR&#8217;s high fuse byte should be printed to the terminal in hexadecimal.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> .<span style="color: #000000; font-weight: bold;">/</span>avrdude <span style="color: #660033;">-C</span> avrdude.conf <span style="color: #660033;">-c</span> ftdi <span style="color: #660033;">-p</span> m168 <span style="color: #660033;">-P</span> ft0 <span style="color: #660033;">-U</span> hfuse:r:-:h <span style="color: #660033;">-B</span> <span style="color: #000000;">1</span></pre></div></div>

<p>If everything worked well, you can now install AVRDUDE.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># If you're using Ubuntu, you can use checkinstall to build a .deb package and install it:</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> checkinstall
<span style="color: #666666; font-style: italic;"># Otherwise, just use `make install`:</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>You should now be able to use AVRDUDE without specifying a configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> avrdude <span style="color: #660033;">-c</span> ftdi <span style="color: #660033;">-p</span> m168 <span style="color: #660033;">-P</span> ft0 <span style="color: #660033;">-U</span> hfuse:r:-:h <span style="color: #660033;">-B</span> <span style="color: #000000;">1</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doswa.com/blog/2010/08/24/avrdude-5-10-with-ftdi-bitbang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kaoss Guitar (Update 1)</title>
		<link>http://doswa.com/blog/2010/04/18/kaoss-guitar-day-1/</link>
		<comments>http://doswa.com/blog/2010/04/18/kaoss-guitar-day-1/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 10:32:47 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[kaoss guitar]]></category>

		<guid isPermaLink="false">http://doswa.com/blog/?p=402</guid>
		<description><![CDATA[For a while, a friend and I have been planning to build a specialized MIDI controller into a guitar to control a Korg Kaoss Pad KP2. The idea came from the guitar used by Matt Bellamy of Muse (check out &#8230; <a href="http://doswa.com/blog/2010/04/18/kaoss-guitar-day-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For a while, a friend and I have been planning to build a specialized MIDI controller into a guitar to control a Korg <a href="http://en.wikipedia.org/wiki/Kaoss_Pad">Kaoss Pad</a> KP2. The idea came from the guitar used by Matt Bellamy of Muse (check out <a href="http://www.youtube.com/watch?v=h1cZDQFgHH8">a video of it</a>).<br />
<span id="more-402"></span></p>
<p>We ordered the electronics for the guitar from <a href="http://sparkfun.com">SparkFun Electronics</a> and <a href="http://digikey.com">Digi-Key</a>. When the project is over, I plan to add up the total cost and post a bill of materials. I suspect it will total to around $100.</p>
<p>Today we tested out <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8448">the 4.3&#8243; touchpad from SparkFun</a> using an Arduino. I have just finished setting up an ATmega328P on a breadboard and got a basic blink program running. The final product will be running on a plain AVR without the Arduino libraries/bootloader.</p>
<p>One problem I ran into using my <a href="http://doswa.com/blog/2009/12/20/sparkfuns-ftdi-basic-breakout-as-an-avr-programmer/">FTDI programmer</a> was the clock rate. A fresh ATmega328P comes running at 1 MHz, significantly lower than the default 16 MHz on Arduino-prepared ATmegas. As a result, I kept getting errors like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">david<span style="color: #000000; font-weight: bold;">@</span>second:~$ avrdude <span style="color: #660033;">-c</span> ftdi <span style="color: #660033;">-p</span> atmega168 <span style="color: #660033;">-P</span> ft0
avrdude: BitBang OK 
avrdude: pin assign miso <span style="color: #000000;">1</span> sck <span style="color: #000000;">3</span> mosi <span style="color: #000000;">0</span> reset <span style="color: #000000;">4</span>
avrdude: drain OK 
&nbsp;
 ft245r:  bitclk <span style="color: #000000;">230400</span> -<span style="color: #000000; font-weight: bold;">&gt;</span> ft baud <span style="color: #000000;">115200</span>
avrdude: ft245r_program_enable: failed
avrdude: initialization failed, <span style="color: #007800;">rc</span>=-<span style="color: #000000;">1</span>
         Double check connections and try again, or use <span style="color: #660033;">-F</span> to override
         this check.
&nbsp;
&nbsp;
avrdude done.  Thank you.</pre></div></div>

<p>Eventually I found AVRDUDE&#8217;s <code>-B</code> option. It adjusts the clock rate that&#8217;s fed into the SCK pin on the AVR. I found that a value of <code>-B 76800</code> works well, but if you&#8217;re running into this problem, I recommend starting with <code>-B 1</code> and going up until it stops working. To be explicit, this is the command that I found works:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">david<span style="color: #000000; font-weight: bold;">@</span>second:~$ avrdude <span style="color: #660033;">-c</span> ftdi <span style="color: #660033;">-p</span> atmega168 <span style="color: #660033;">-P</span> ft0 <span style="color: #660033;">-B</span> <span style="color: #000000;">76800</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doswa.com/blog/2010/04/18/kaoss-guitar-day-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wacom Jitter Fix (for Linux)</title>
		<link>http://doswa.com/blog/2010/01/01/wacom-jitter-fix-for-linux/</link>
		<comments>http://doswa.com/blog/2010/01/01/wacom-jitter-fix-for-linux/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 03:07:14 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://doswa.com/blog/?p=351</guid>
		<description><![CDATA[My Wacom Bamboo Fun tablet has been exceptionally jittery on my Lenovo ThinkPad. I assume this is probably caused by EM noise from the computer (though I&#8217;m not sure). [Update: it's actually caused by a noisy power supply.] Today I &#8230; <a href="http://doswa.com/blog/2010/01/01/wacom-jitter-fix-for-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My Wacom Bamboo Fun tablet has been exceptionally jittery on my Lenovo ThinkPad. I assume this is probably caused by EM noise from the computer (though I&#8217;m not sure). [<strong>Update:</strong> it's actually caused by a noisy power supply.] Today I decided I should try to fix that.</p>
<p>Here&#8217;s an image to demonstrate the problem (click to enlarge):<br />
<a href="http://doswa.com/blog/wp-content/uploads/2010/01/lines1.png"><img src="http://doswa.com/blog/wp-content/uploads/2010/01/lines1.png" alt="lines1" title="lines1" width="472" height="302" class="aligncenter size-full wp-image-359" /></a><br />
<span id="more-351"></span></p>
<p>On Ubuntu, there&#8217;s a package called <code>wacom-tools</code> that includes a configuration utility named <code>xsetwacom</code>. The <code>xsetwacom</code> utility has a couple parameters to help against noise: <code>RawSample</code> and <code>Suppress</code>. <code>RawSample</code> allows you to adjust the number of samples taken from the tablet before the coordinates are committed to the mouse pointer on screen. <code>Suppress</code> prevents the mouse pointer from moving unless it has been moved by a given amount. So, all you need to do is tune those parameters to something that works well for your setup. I found the following to be acceptable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xsetwacom <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #ff0000;">&quot;Wacom BambooFun 4x5&quot;</span> RawSample <span style="color: #000000;">9</span>
xsetwacom <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #ff0000;">&quot;Wacom BambooFun 4x5&quot;</span> Suppress <span style="color: #000000;">10</span></pre></div></div>

<p><em>Note that those commands are specifically for the Wacom BambooFun 4&#215;5 tablet. You will probably need to replace that part with something else. You can find out what you should replace it with by executing this command and looking over its output:</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xidump <span style="color: #660033;">--list</span></pre></div></div>

<p>Now, I wanted these commands to be run automatically every time I logged in, so I created a small script at <code>~/.local/bin/wacom_init</code> and put the following in it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
xsetwacom <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #ff0000;">&quot;Wacom BambooFun 4x5&quot;</span> RawSample <span style="color: #000000;">9</span>
xsetwacom <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #ff0000;">&quot;Wacom BambooFun 4x5&quot;</span> Suppress <span style="color: #000000;">10</span></pre></div></div>

<p>Finally, I went in my menu to System &gt; Preferences &gt; Startup Applications and created an entry to automatically run the command <code>/home/david/.local/bin/wacom_init</code>.</p>
<p>All done!</p>
]]></content:encoded>
			<wfw:commentRss>http://doswa.com/blog/2010/01/01/wacom-jitter-fix-for-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python/Unix Calculator</title>
		<link>http://doswa.com/blog/2010/01/01/calculator/</link>
		<comments>http://doswa.com/blog/2010/01/01/calculator/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 02:50:38 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://doswa.com/blog/?p=343</guid>
		<description><![CDATA[david@second:~$ cat /home/david/.local/bin/= #!/usr/bin/env python __import__&#40;&#34;sys&#34;&#41;.argv&#91;1:&#93; and __import__&#40;&#34;subprocess&#34;&#41;.Popen&#40;&#40;&#34;bc&#34;,&#34;-lq&#34;&#41;,? stdin=__import__&#40;&#34;subprocess&#34;&#41;.PIPE&#41;.communicate&#40;&#34; &#34;.join&#40;__import__&#40;&#34;sys&#34;&#41;? .argv&#91;1:&#93;+&#91;&#34;\n&#34;&#93;&#41;&#41; or __import__&#40;&#34;os&#34;&#41;.waitpid&#40;__import__&#40;&#34;subprocess&#34;&#41;? .Popen&#40;&#40;&#34;bc&#34;,&#34;-lq&#34;&#41;&#41;.pid,0&#41; david@second:~$ = '5*5 + 5' 30 david@second:~$ = 3+1 4 last*2 8 david@second:~$]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">david@second:~$ cat /home/david/.<span style="color: black;">local</span>/bin/=
<span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;sys&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;subprocess&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;bc&quot;</span>,<span style="color: #483d8b;">&quot;-lq&quot;</span><span style="color: black;">&#41;</span>,<span style="color: #66cc66;">?</span>
stdin=<span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;subprocess&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;sys&quot;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>
.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>+<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;os&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">waitpid</span><span style="color: black;">&#40;</span><span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;subprocess&quot;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span>
.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;bc&quot;</span>,<span style="color: #483d8b;">&quot;-lq&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">pid</span>,<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
david@second:~$ = <span style="color: #483d8b;">'5*5 + 5'</span>
<span style="color: #ff4500;">30</span>
david@second:~$ =
<span style="color: #ff4500;">3</span>+<span style="color: #ff4500;">1</span>
<span style="color: #ff4500;">4</span>
last<span style="color: #66cc66;">*</span><span style="color: #ff4500;">2</span>
<span style="color: #ff4500;">8</span>
david@second:~$</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doswa.com/blog/2010/01/01/calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino 0017 on 64-bit Ubuntu 9.04 and 9.10</title>
		<link>http://doswa.com/blog/2009/10/29/arduino-0017-on-64-bit-ubuntu-904/</link>
		<comments>http://doswa.com/blog/2009/10/29/arduino-0017-on-64-bit-ubuntu-904/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 05:11:28 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://doswa.com/blog/?p=245</guid>
		<description><![CDATA[Edit: This post isn&#8217;t really relevant anymore—Arduino 0018 has a 64 bit binary. Original post follows. Update 2009-12-25: these instructions work on both 9.10 Karmic and 9.04 Jaunty. Install all dependencies: sudo apt-get install sun-java6-jre gcc-avr avr-libc ia32-libs librxtx-java Download &#8230; <a href="http://doswa.com/blog/2009/10/29/arduino-0017-on-64-bit-ubuntu-904/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em><strong>Edit:</strong> This post isn&#8217;t really relevant anymore—Arduino 0018 has a 64 bit binary. Original post follows.</em><br />
<span id="more-245"></span></p>
<hr />
<p><img src="http://doswa.com/blog/wp-content/uploads/2009/06/arduino-64-bit.png" alt="arduino-64-bit" title="arduino-64-bit" width="502" height="157" class="alignnone size-full wp-image-142" /></p>
<p><strong>Update 2009-12-25</strong>: these instructions work on both 9.10 Karmic and 9.04 Jaunty.</p>
<hr />
<ol>
<li>Install all dependencies:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> sun-java6-jre gcc-avr avr-libc ia32-libs librxtx-java</pre></div></div>

</li>
<li>Download 32-bit version of Arduino 0017: <a href="http://arduino.googlecode.com/files/arduino-0017.tgz">[download]</a></li>
<li>Extract it and navigate to the <code>lib/</code> directory. Delete <code>RXTXcomm.jar</code> and <code>librxtxSerial.so</code>.</li>
<li>Go back to the main directory and open the <code>arduino</code> script in a text editor. Replace its contents with:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">APPDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(dirname -- &quot;${0}&quot;)</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> LIB <span style="color: #000000; font-weight: bold;">in</span> \
    java<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>rt.jar \
    java<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>tools.jar \
    lib<span style="color: #000000; font-weight: bold;">/*</span>.jar \
    ;
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">CLASSPATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${CLASSPATH}</span>:<span style="color: #007800;">${APPDIR}</span>/<span style="color: #007800;">${LIB}</span>:/usr/share/java/RXTXcomm.jar&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">export</span> CLASSPATH
&nbsp;
<span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib:<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`/</span>lib:<span style="color: #800000;">${LD_LIBRARY_PATH}</span>
<span style="color: #7a0874; font-weight: bold;">export</span> LD_LIBRARY_PATH
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${APPDIR}</span>/java/bin:<span style="color: #007800;">${PATH}</span>&quot;</span>
&nbsp;
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base</pre></div></div>

</li>
<hr />
<p><b>Note:</b><br />
The Serial Monitor in the Arduino IDE doesn&#8217;t work. As a replacement, you can install <i>screen</i> with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">screen</span></pre></div></div>

<p>To start <i>screen</i> for use with an Arduino, run this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ttyUSB0 <span style="color: #000000;">9600</span></pre></div></div>

<p>Replace <code>/dev/ttyUSB0</code> with the location of your serial port and <code>9600</code> with the baud rate you&#8217;re using.</p>
<p>To quit <i>screen</i>, press Ctrl-a then press k. You must quit <i>screen</i> before you can upload a program via the Arduino IDE.</p>
]]></content:encoded>
			<wfw:commentRss>http://doswa.com/blog/2009/10/29/arduino-0017-on-64-bit-ubuntu-904/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
