<?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>Heavygravity &#187; Programming</title>
	<atom:link href="http://www.heavygravity.com/category/computers/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heavygravity.com</link>
	<description></description>
	<lastBuildDate>Wed, 16 Feb 2011 23:13:10 +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>Forex trading: They are not on your side</title>
		<link>http://www.heavygravity.com/2011/02/17/forex-trading-they-are-not-on-your-side/</link>
		<comments>http://www.heavygravity.com/2011/02/17/forex-trading-they-are-not-on-your-side/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 23:13:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/?p=139</guid>
		<description><![CDATA[Recently, I have become enamored with the idea of trading currencies. Yes, there is a lot of spam in my inbox due to that kind of thing&#8230; but the reality is that forex trading can indeed work &#8211; if you are willing to learn a little bit. That is why I need to vent now. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I have become enamored with the idea of trading currencies.  Yes, there is a lot of spam in my inbox due to that kind of thing&#8230; but the reality is that forex trading can indeed work &#8211; if you are willing to learn a little bit.</p>
<p>That is why I need to vent now.   I know that my blog is not important to the google-sphere, but I still need to proclaim: </p>
<p>Alpari sucks.</p>
<p>TL;DR: They are a broker that will take your money.  Thats pretty much it.</p>
<p>They offer demo accounts, and if you (like me) are trying out algorithms, you can pretty much forget it.  During the most profitable time, you cannot trade.  They also disconnect you and dont let you log back in during very active moments.  It is not random, it is easy to see if you look at plots of the spread they vary on a per second basis.</p>
<p>My verdict?  As a broker, questionable.  As a demo account for testing&#8230; terrible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2011/02/17/forex-trading-they-are-not-on-your-side/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cuband.com &#8211; If you&#8217;re into Cuban Music</title>
		<link>http://www.heavygravity.com/2010/03/03/cubandcom-if-youre-into-cuban-music/</link>
		<comments>http://www.heavygravity.com/2010/03/03/cubandcom-if-youre-into-cuban-music/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 08:21:33 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2010/03/03/cubandcom-if-youre-into-cuban-music/</guid>
		<description><![CDATA[I recently had a chance to work on a Cuban Music website &#8211; http://www.cuband.com &#8211; and hope that it ends up working out.  It has a pretty big catalog of Cuban Music in MP3 format and targets a small market &#8211; people that are interested in the classics from Cuba and the newest sound from [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a chance to work on a Cuban Music website &#8211; <a target="_blank" title="Cuband.com - Your source of Cuban Music!" href="http://www.cuband.com">http://www.cuband.com</a> &#8211; and hope that it ends up working out.  It has a pretty big catalog of Cuban Music in MP3 format and targets a small market &#8211; people that are interested in the classics from Cuba and the newest sound from a whole bunch of genres.</p>
<p>There don&#8217;t appear to be too many other sites like this, and certainly none that are as easy to use.  If <a target="_blank" title="Cuband.com - Your source of Cuban Music!" href="http://www.cuband.com">Cuban Music</a> is your thing, then check out <a target="_blank" title="Cuband.com - Your source of Cuban Music!" href="http://www.cuband.com">cuband.com</a> today!</p>
<p>(Yeah, this is a shameless plug!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2010/03/03/cubandcom-if-youre-into-cuban-music/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypt Files and Directories Easily</title>
		<link>http://www.heavygravity.com/2007/11/15/encrypt-files-and-directories-easily/</link>
		<comments>http://www.heavygravity.com/2007/11/15/encrypt-files-and-directories-easily/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 15:00:26 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2007/11/15/encrypt-files-and-directories-easily/</guid>
		<description><![CDATA[I was recently looking for an easy way to encrypt individual files and directories (recursively), and I ran across the linux command mcrypt. This nifty little utility does just what I want, but doesn&#8217;t do anything fancy – it just does encryption on a single file or standard input. With a wee bitty script, however, [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently looking for an easy way to encrypt individual files and directories (recursively), and I ran across the linux command <strong>mcrypt</strong>.  This nifty little utility does just what I want, but doesn&#8217;t do anything fancy – it just does encryption on a single file or standard input.
</p>
<p>With a wee bitty script, however, you can encrypt anything you like quite easily.  You have to have <strong>mcrypt</strong> installed (and also <strong>tar</strong> &amp; <strong>bzip2</strong>, but you&#8217;ve likely got that already).  Check this out:
</p>
<p><span style="font-family:Courier New">#!/bin/bash<br />IFS=$&#8217;\n&#8217;<br />if [[ -z $3 ]]<br />then<br />   echo &#8220;Use: encrypt [file/directory] [password] [outputname]&#8220;<br />   exit<br />fi<br />echo &#8220;Encrypting $1 with password $2 into file $3&#8243;<br />tar -c $1 | mcrypt -p -q -k $2 &gt; $3<br />echo &#8220;Done with encryption.&#8221;<br />
</span></p>
<p>Save it as &#8220;encrypt.sh&#8221; or whatever other name floats your boat, give it execute permissions, and you&#8217;re all set.  It will tar, compress, and encrypt your file(s) and directories into whatever output file you specify.  Just make sure you don&#8217;t forget the password you use to encrypt the file with: there isn&#8217;t any easy way to find out what it was if you lose it.
</p>
<p>In order to decrypt your data, use this little script:
</p>
<p><span style="font-family:Courier New">#!/bin/bash<br />IFS=$&#8217;\n&#8217;<br />if [[ -z $2 ]]<br />then<br />   echo &#8220;Use: decrypt [file/directory] [password]&#8220;<br />   exit<br />fi<br />echo &#8220;Decrypting $1 with password $2&#8243;<br />cat $1 | mdecrypt -q -p -k $2 | tar –x<br />echo &#8220;Done with decryption.&#8221;<br />
</span></p>
<p>Save it as &#8220;decrypt.sh&#8221; and give it execute permissions, and now you can easily decrypt your data as well.  It can&#8217;t really get much easier than that!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2007/11/15/encrypt-files-and-directories-easily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Driver for the Hauppauge WinTV USB2</title>
		<link>http://www.heavygravity.com/2006/12/15/linux-driver-for-the-hauppauge-wintv-usb2/</link>
		<comments>http://www.heavygravity.com/2006/12/15/linux-driver-for-the-hauppauge-wintv-usb2/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 13:49:52 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2006/12/15/linux-driver-for-the-hauppauge-wintv-usb2/</guid>
		<description><![CDATA[First of all, this device does work fine in Linux. But unfortunately, this USB device won't be recognized by the Linux kernel and so you won't be able to watch all your Family Guy, Simpsons, or Aqua Teen Hunger Force episodes on your PC without adding one line of code to the kernel module driver [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, this device does work fine in Linux.  But unfortunately, this USB device won't be recognized by the Linux kernel and so you won't be able to watch all your Family Guy, Simpsons, or Aqua Teen Hunger Force episodes on your PC without adding one line of code to the kernel module driver (perhaps new kernels will eventually recognize it).</p>
<p>There are more than just one type of WinTV USB2 device: the one I have has "Model 42014 Rev D197 Lot # 4405" on the back of it.  If you do a 'lsusb', you should see this somewhere in the output:</p>
<div class="igBar"><span id="lcode-5"><a href="#" onclick="javascript:showPlainTxt('code-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-5">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bus <span style="color:#800000;color:#800000;">001</span> Device <span style="color:#800000;color:#800000;">005</span>: ID <span style="color:#800000;color:#800000;">2040</span>:<span style="color:#800000;color:#800000;">4201</span> Hauppauge </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The device ID is the problem : the driver for this particular model is looking for "2040:4200", not "2040:4201".  So, you simply need to edit the driver code and add the right number.  To do this, you need to have your kernel source installed and you'll have to know how to configure your kernel for your other hardware.  If you're up to the task, then take your favorite editor and open the file '/usr/src/linux/drivers/media/video/em28xx/em28xx-cards.c  '.  At about line 249 you'll see this:</p>
<div class="igBar"><span id="lc-6"><a href="#" onclick="javascript:showPlainTxt('c-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-6">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* table of devices that work with this driver */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">struct</span> usb_device_id em28xx_id_table <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0xeb1a, 0x2800<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2800_BOARD_UNKNOWN <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0xeb1a, 0x2820<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_MSI_VOX_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x0ccd, 0x0036<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_TERRATEC_CINERGY_250 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2304, 0x0208<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_PINNACLE_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2040, 0x4200<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2304, 0x0207<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_PINNACLE_DVC_90 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You'll want to change it to look like this:</p>
<div class="igBar"><span id="lc-7"><a href="#" onclick="javascript:showPlainTxt('c-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-7">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* table of devices that work with this driver */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">struct</span> usb_device_id em28xx_id_table <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0xeb1a, 0x2800<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2800_BOARD_UNKNOWN <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0xeb1a, 0x2820<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_MSI_VOX_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x0ccd, 0x0036<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_TERRATEC_CINERGY_250 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2304, 0x0208<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_PINNACLE_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2040, 0x4200<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2040, 0x4201<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2304, 0x0207<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_PINNACLE_DVC_90 <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You're simply inserting this line:</p>
<div class="igBar"><span id="lc-8"><a href="#" onclick="javascript:showPlainTxt('c-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-8">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span> USB_DEVICE<span style="color: #66cc66;">&#40;</span>0x2040, 0x4201<span style="color: #66cc66;">&#41;</span>, .<span style="color: #202020;">driver_info</span> = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 <span style="color: #66cc66;">&#125;</span>, </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Save the changes, then go back to your '/usr/src/linux' directory, and do a normal 'make' and make 'modules_install'.  As long as you're running the same kernel as the one you are compiling the modules for, you can now do a "modprobe em28xx" and you should be in business!  Of course, there are other modules you'll have to load (or compile into the kernel) to get video working in general (look at the 'Video For Linux' section); but this will at least get your hardware talking.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2006/12/15/linux-driver-for-the-hauppauge-wintv-usb2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using FIFOs in Linux</title>
		<link>http://www.heavygravity.com/2006/08/26/using-fifos-in-linux/</link>
		<comments>http://www.heavygravity.com/2006/08/26/using-fifos-in-linux/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 22:11:18 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2006/08/26/using-fifos-in-linux/</guid>
		<description><![CDATA[I ran into an interesting "feature" when using two FIFO's in Linux for bi-directional communication between two processes. Basically, I kept encountering a deadlock no matter what I did, and I couldn't figure out why. Here's the scenario: You have two separate processes (not necessarily parent/child) and two separate FIFO's. Although a FIFO can be [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an interesting "feature" when using two FIFO's in Linux for bi-directional communication between two processes.  Basically, I kept encountering a deadlock no matter what I did, and I couldn't figure out why.</p>
<p>Here's the scenario:  You have two separate processes (not necessarily parent/child) and two separate FIFO's.  Although a FIFO can be used for bi-directional communication, each one will be set up to be uni-directional: Process #1 will write to FIFO #1 and read from FIFO #2, while Process #2 will write to FIFO #2 and read from FIFO #1.  Doing things this way allows Process #1 to pass data to Process #2 via FIFO #1, and Process #2 can pass a result back to Process #1 via FIFO #2.  This provides an easy way to keep both processes synchronized, because each process will block when reading the FIFO streams.</p>
<p>Each process blocks when opening both FIFOs as well (during initialization, for example) until both a read and a writer are present (which is normal).  Once they are opened, Process #1 writes some data (a number, for example) to FIFO #1.  Process #2 should receive the data and return a value via FIFO #2.  However, no matter what I tried, the data never reached Process #2, and both processes were in deadlock.  But if only a single FIFO was used (where data was passed from Process #1 to Process #2 only), everything worked fine!</p>
<p>If you're now asking, "Just what the hell is a FIFO?", then stop reading here.  If you want to know what the problem was and the solution, keep reading.</p>
<p><span id="more-63"></span></p>
<p>This silly problem stumped me for some hours.  The internets didn't offer much help - apparently other people don't have this type of problem.</p>
<p>Here is the first example using a single FIFO that actually works.</p>
<div class="igBar"><span id="lc-13"><a href="#" onclick="javascript:showPlainTxt('c-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-13">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Server, single FIFO</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> argc, <span style="color: #993333;">char</span> **argv<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifo = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidout"</span>, <span style="color: #ff0000;">"w"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> s = <span style="color: #cc66cc;color:#800000;">123</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fwrite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lc-14"><a href="#" onclick="javascript:showPlainTxt('c-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-14">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Client, single FIFO</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> argc, <span style="color: #993333;">char</span> **argv<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifo = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidout"</span>, <span style="color: #ff0000;">"r"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> s;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fread<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Got value: %d<span style="color: #000099; font-weight: bold;">\n</span>"</span>, s<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifo<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The above two examples work fine.  However using two FIFOs for bi-directional communication (as in the examples below) does <strong>NOT</strong> work.  Why?</p>
<div class="igBar"><span id="lc-15"><a href="#" onclick="javascript:showPlainTxt('c-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-15">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Server, two FIFOs</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> argc, <span style="color: #993333;">char</span> **argv<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifoin = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidin"</span>, <span style="color: #ff0000;">"r"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifoout = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidout"</span>, <span style="color: #ff0000;">"w"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> s = <span style="color: #cc66cc;color:#800000;">123</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fwrite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifoout<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fread<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifoin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Got answer from client: %d<span style="color: #000099; font-weight: bold;">\n</span>"</span>, s<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifoin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifoout<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lc-16"><a href="#" onclick="javascript:showPlainTxt('c-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-16">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Client, two FIFOs</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> argc, <span style="color: #993333;">char</span> **argv<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifoout = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidin"</span>, <span style="color: #ff0000;">"w"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FILE * fifoin = fopen<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/tmp/cvalidout"</span>, <span style="color: #ff0000;">"r"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> s;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fread<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifoin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Got value: %d<span style="color: #000099; font-weight: bold;">\n</span>"</span>, s<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s = <span style="color: #cc66cc;color:#800000;">456</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fwrite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span>*<span style="color: #66cc66;">&#41;</span>&amp;s, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">1</span>, fifoout<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifoin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fclose<span style="color: #66cc66;">&#40;</span>fifoout<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<strong>The solution is this:</strong></p>
<p>I was using fread() and fwrite() calls in these examples.   The fwrite() call uses some kind of buffering.  So after every fwrite() call, you need to use the fflush() call so that the written data is actually committed.  That's all!  To make the server/client programs work, insert a fflush() after the fwrite() calls.</p>
<p>The reason that the first sample program I wrote works is because the server program writes the value to the pipe (which does not block) and then promptly ends.  When the process ends, the buffer is flushed automatically - which is what I didn't realize, and which is why I took so long to figure out what the hell was going on.  Geez.</p>
<p>Anyway, I hope someone else that runs into this same sillyness can find this post and save themselves a little bit of time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2006/08/26/using-fifos-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VisualODF</title>
		<link>http://www.heavygravity.com/2006/08/17/visualodf/</link>
		<comments>http://www.heavygravity.com/2006/08/17/visualodf/#comments</comments>
		<pubDate>Thu, 17 Aug 2006 09:10:23 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2006/08/17/visualodf/</guid>
		<description><![CDATA[I just added a project that I had recently been working on to my site. It's called "VisualODF". If you want the introduction, go here: VisualODF Introduction. If you'd like to see the documentation directly, click this link: VisualODF Documentation.What exactly is this thing? Without repeating the introduction, it is a framework (bunch of classes, [...]]]></description>
			<content:encoded><![CDATA[<p align="left">I just added a project that I had recently been working on to my site.  It's called "VisualODF".  If you want the introduction, go here: <a title="VisualODF Introduction" href="http://www.heavygravity.com/vodf/">VisualODF Introduction</a>.  If you'd like to see the documentation directly, click this link: <a title="VisualODF Documentation" href="http://www.heavygravity.com/visualodf/">VisualODF Documentation</a>.What exactly is this thing? Without repeating the <a title="VisualODF Introduction" href="http://www.heavygravity.com/vodf/">introduction</a>, it is a framework (bunch of classes, really, but I like to throw that word in) written in C++  that form the basis of an application for detecting objects from video streams in the context of a UAV mounted camera.  It does everything but the detection part: opening video streams, playing them, capturing frames, sending them to a video display and custom image processing algorithm, display of processed video frame, and display of obstacles on a TCAS-II type display as well as other custom widgets.</p>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<p align="left">It uses QT4, ffmpeg, and SDL to accomplish this.  Probably the most useful bits of the classes are the TCAS display itself, the widget plugins (TCAS widget, the so-called "pieDisplay" widget, and a video display widget), and the video-related classes. All of the classes use QT.</p>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<p align="left">The idea behind this was that it would allow a student to actually work on the detection algorithm part of the application, rather than trying to figure out how to open a video stream and grab frames from it or how to convert YUV to RGB.</p>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<p align="left">Hopefully a student somewhere will end up using this for something useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2006/08/17/visualodf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QT on Windows for Free (GPL)</title>
		<link>http://www.heavygravity.com/2005/04/23/qt-on-windows-for-free-gpl/</link>
		<comments>http://www.heavygravity.com/2005/04/23/qt-on-windows-for-free-gpl/#comments</comments>
		<pubDate>Sat, 23 Apr 2005 17:23:51 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.heavygravity.com/2005/04/23/qt-on-windows-for-free-gpl/</guid>
		<description><![CDATA[I didn't know this until just recently, but a version of Trolltech's QT for Windows exists without having to purchase a license. After doing programming with KDE and QT in a Linux environment and now switching back to working with Windows, I've often thought about how nice it would be to use QT under Windows [...]]]></description>
			<content:encoded><![CDATA[<p>I didn't know this until just recently, but a version of Trolltech's QT for Windows exists without having to purchase a license. After doing <a title="View product details at Amazon" href="http://www.amazon.com/exec/obidos/redirect?tag=heavygravity-20%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0596000642%2526tag=heavygravity-20%2526lcode=xm2%2526cID=2025%2526ccmID=165953%2526location=/o/ASIN/0596000642%25253FSubscriptionId=0EMV44A9A5YT1RVDGZ82">programming with KDE and QT</a> in a Linux environment and now switching back to working with Windows, I've often thought about how nice it would be to use QT under Windows - but I've always thought that you have to buy it. While buying it is not a bad idea, if you're doing something as a hobby or don't intend to sell your idea it's probably not an option. Using QT can enable you to easily write cross-platform applications that will work in at least Linux and Windows, and probably other Unices and OSX as well.</p>
<p>One place to find the GPL'd version of QT for Windows is <a href="http://sf.gds.tuwien.ac.at/q/qt/qtwin/">at the Vienna University of Technology</a>. There are probably other places that host it as well. The executable pretty much does everything automatically, and the "INSTALL" file will get you going in no-time. You'll be using Trolltech's "Designer" with your C++ IDE (I am using VC++ 6) for writing applications in minutes!</p>
<p>I also was able to easily get <a href="http://qwt.sourceforge.net/">the QWT plotting widgets</a> to compile and integrated with QT designer, which means that I should be able to compile code with QT depends in Linux <strong>and</strong> on my Windows install (in VMWare, that is). Neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heavygravity.com/2005/04/23/qt-on-windows-for-free-gpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

