<?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>Steven Harms &#187; admin</title>
	<atom:link href="http://www.sharms.org/blog/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharms.org/blog</link>
	<description>Life, Linux and Technology</description>
	<lastBuildDate>Tue, 24 Aug 2010 18:25: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>Terminator color palettes</title>
		<link>http://www.sharms.org/blog/2010/08/terminator-color-palettes/</link>
		<comments>http://www.sharms.org/blog/2010/08/terminator-color-palettes/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 18:25:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=757</guid>
		<description><![CDATA[Bored of the normal everyday terminal colors? These can be easily changed by right clicking on the terminal window, clicking preferences and changing the colors: You can see how my terminal colors are different than standard: If you want to know where this information is stored on your filesystem: #!/bin/bash cat ~/.config/terminator/config My current palette: [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/11/workspaces/' rel='bookmark' title='Permanent Link: Workspaces'>Workspaces</a></li>
<li><a href='http://www.sharms.org/blog/2007/03/making-openbsd-more-friendly/' rel='bookmark' title='Permanent Link: Making OpenBSD more friendly'>Making OpenBSD more friendly</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Bored of the normal everyday terminal colors?  These can be easily changed by right clicking on the terminal window, clicking preferences and changing the colors:</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/2010/08/terminator-2.jpg"><img src="http://www.sharms.org/blog/wp-content/uploads/2010/08/terminator-2.jpg" alt="" title="terminator-2" width="737" height="542" class="alignnone size-full wp-image-758" /></a></p>
<p>You can see how my terminal colors are different than standard:</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/2010/08/terminator-1.jpg"><img src="http://www.sharms.org/blog/wp-content/uploads/2010/08/terminator-1.jpg" alt="" title="terminator-1" width="686" height="390" class="alignnone size-full wp-image-759" /></a></p>
<p>If you want to know where this information is stored on your filesystem:</p>
<pre class="brush: sh">
#!/bin/bash
cat ~/.config/terminator/config
</pre>
<p>My current palette:</p>
<pre class="brush: sh">
palette = &quot;#2e3436:#cc0000:#4e9a06:#c4a000:#c48dff:#75507b:#06989a:#d3d7cf:#555753:#e52222:#a6e32d:#fc951e:#3465a4:#fa2573:#67d9f0:#f2f2f2&quot;
</pre>
<p>The same can be done for gnome-terminal, but that stores it&#8217;s defaults in gconf.  You can retrieve them using gconftool-2:</p>
<pre class="brush: sh">
#!/bin/bash
gconftool-2 --all-entries /apps/gnome-terminal/profiles/Default
</pre>
<p>This is fun as these colors carry over into Vim etc, so when you are not using the graphical versions, you can still spice up your syntax highlighting.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/11/workspaces/' rel='bookmark' title='Permanent Link: Workspaces'>Workspaces</a></li>
<li><a href='http://www.sharms.org/blog/2007/03/making-openbsd-more-friendly/' rel='bookmark' title='Permanent Link: Making OpenBSD more friendly'>Making OpenBSD more friendly</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/08/terminator-color-palettes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stylish desktop, new search engines</title>
		<link>http://www.sharms.org/blog/2010/08/stylish-desktop-new-search-engines/</link>
		<comments>http://www.sharms.org/blog/2010/08/stylish-desktop-new-search-engines/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 16:28:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=750</guid>
		<description><![CDATA[My Desktop Read Seif&#8217;s post on his desktop, so I copied most of that style (original post) : I actually enabled compiz for the first time in a long time, and AMD&#8217;s linux drivers have come a long way since my critical posts a few years ago about them. Great to see the whole stack [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2007/04/looking-for-help/' rel='bookmark' title='Permanent Link: Looking for help'>Looking for help</a></li>
<li><a href='http://www.sharms.org/blog/2008/05/using-ssh-to-access-internal-network-sites-from-an-external-network/' rel='bookmark' title='Permanent Link: Using SSH to access internal network sites from an external network'>Using SSH to access internal network sites from an external network</a></li>
<li><a href='http://www.sharms.org/blog/2009/03/make-your-bash-shell-cool-again/' rel='bookmark' title='Permanent Link: Make your bash shell cool again'>Make your bash shell cool again</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>My Desktop</strong><br />
Read Seif&#8217;s post on his desktop, so I copied most of that style (<a href="http://seilo.geekyogre.com/2010/08/my-sexy-desktop/">original post</a>) :</p>
<p><a href="http://www.sharms.org/img/desktop-aug142010/desktop-full.png"><img src="http://www.sharms.org/img/desktop-aug142010/desktop-small.jpg" alt="Desktop" /></a></p>
<p>I actually enabled compiz for the first time in a long time, and AMD&#8217;s linux drivers have come a long way since my critical posts a few years ago about them.  Great to see the whole stack improving.</p>
<p><strong>Default Search Engine</strong><br />
This week I switched over my default search engine to <a href="http://www.duckduckgo.com">Duck Duck Go</a>.</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/2010/08/nduck.v104.png"><br />
<img src="http://www.sharms.org/blog/wp-content/uploads/2010/08/nduck.v104.png" alt="" title="nduck.v104" width="200" height="132" class="alignnone size-full wp-image-751" /></a></p>
<p>I really like it&#8217;s clean interface, and their attention to privacy and technology enthusiasm.</p>
<p><strong>New Home Page</strong><br />
In addition, I updated<a href="http://www.sharms.org"> my generic landing page</a> using Python / <a href="http://flash.pocoo.org">Flask</a> to pull feeds etc, I really like the simplicity of Flask and the well thought out design / documentation.  I also published the source on github.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2007/04/looking-for-help/' rel='bookmark' title='Permanent Link: Looking for help'>Looking for help</a></li>
<li><a href='http://www.sharms.org/blog/2008/05/using-ssh-to-access-internal-network-sites-from-an-external-network/' rel='bookmark' title='Permanent Link: Using SSH to access internal network sites from an external network'>Using SSH to access internal network sites from an external network</a></li>
<li><a href='http://www.sharms.org/blog/2009/03/make-your-bash-shell-cool-again/' rel='bookmark' title='Permanent Link: Make your bash shell cool again'>Make your bash shell cool again</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/08/stylish-desktop-new-search-engines/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using Apache to decrypt SSL pages</title>
		<link>http://www.sharms.org/blog/2010/07/using-apache-to-decrypt-ssl-pages/</link>
		<comments>http://www.sharms.org/blog/2010/07/using-apache-to-decrypt-ssl-pages/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 18:50:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=744</guid>
		<description><![CDATA[Although you should almost never have a decent rationale for doing this, at some point I needed to do it, and documentation was scarce. The basic idea is we have a website &#8211; https://www.securewebsite.com and our clients cannot use https (ssl), so we need to decrypt it to http for them. In order to accomplish [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Although you should almost never have a decent rationale for doing this, at some point I needed to do it, and documentation was scarce.  The basic idea is we have a website &#8211; <em>https://www.securewebsite.com</em> and our clients cannot use https (ssl), so we need to decrypt it to http for them.  </p>
<p>In order to accomplish this, Apache 2.x is needed, along with mod_ssl and mod_proxy.  Here is the magic:</p>
<pre class="brush: xml">
&lt;VirtualHost virtualhostipaddress:443&gt;
        SSLProxyEngine on
        #SSLProxyCACertificateFile /etc/apache2/ssl/google.crt
        SSLEngine on
        RequestHeader set Front-End-Https &quot;On&quot;
        ServerName testing

        #SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCertificateFile /etc/apache2/ssl.crt
        SSLCertificateKeyFile /etc/apache2/ssl.key
        #LogLevel debug

        ErrorLog /var/log/apache2/ssl_proxy_error.log
        CustomLog /var/log/apache2/ssl_proxy_access.log combined

        &lt;Proxy *&gt;
                Order deny,allow
                Allow from all
        &lt;/Proxy&gt;

        ProxyVia On
        ProxyRequests Off
        ProxyPreserveHost Off
        ProxyPass / https://www.securewebsite.com:443/
        ProxyPassReverse / https://www.securewebsite.com:443/

        #SetEnvIf User-Agent &quot;.*MSIE.*&quot; nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch &quot;MSIE [1-4]&quot; nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch &quot;MSIE [5-9]&quot; ssl-unclean-shutdown
&lt;/VirtualHost&gt;
</pre>
<p>Obviously replace <b>virtualhostipaddress</b> with the ip you want to bind to and <b>securewebsite.com</b> with the actual website.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/07/using-apache-to-decrypt-ssl-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux guru needed</title>
		<link>http://www.sharms.org/blog/2010/07/linux-guru-needed/</link>
		<comments>http://www.sharms.org/blog/2010/07/linux-guru-needed/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 19:22:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=740</guid>
		<description><![CDATA[I have another position open, it&#8217;s a contract position for 3 months atleast. Pays great, will need to come onsite to Cincinnati. Skills we need: Administration &#8211; familiar with Apache / SSL / SSH / Kickstart or autoyast / rsync / hardening etc Virtualization &#8211; xen RPM creation Perl (Catalyst is a plus) PHP (Symfony [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2010/02/looking-for-someone-to-give-me-a-hand/' rel='bookmark' title='Permanent Link: Looking for someone to give me a hand'>Looking for someone to give me a hand</a></li>
<li><a href='http://www.sharms.org/blog/2008/08/got-skills-email-me/' rel='bookmark' title='Permanent Link: Got skills?  Email me'>Got skills?  Email me</a></li>
<li><a href='http://www.sharms.org/blog/2007/06/novell-linux-client-on-ubuntu-redux/' rel='bookmark' title='Permanent Link: Novell Linux Client on Ubuntu redux'>Novell Linux Client on Ubuntu redux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I have another position open, it&#8217;s a contract position for 3 months atleast.  Pays great, will need to come onsite to Cincinnati.</p>
<p><strong>Skills we need:</strong></p>
<ul>
<li>Administration &#8211; familiar with Apache / SSL / SSH / Kickstart or autoyast / rsync / hardening etc</li>
<li>Virtualization &#8211; xen</li>
<li>RPM creation</li>
<li>Perl (Catalyst is a plus)</li>
<li>PHP (Symfony is a plus)</li>
<li>Python (Django is a plus)</li>
<li>C</li>
<li>Compiling kernels, making slight adjustments to drivers etc</li>
<li>Thin client experience is a plus</li>
<li>Software distribution (ZLM / Altiris)</li>
<li>Bash scripting</li>
<li>Javascript / Jquery</li>
<li>HTML / CSS</li>
<li>Rest</li>
<li>XML / JSON / Yaml</li>
<li>Git / Bazaar / Svn</li>
<li>Having a github or launchpad account is a plus</li>
</ul>
<p>If you think you fit the bill email me ASAP as it is an immediate opening, and I will put you in touch with my HR department.  You can find my email through Launchpad or Google.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2010/02/looking-for-someone-to-give-me-a-hand/' rel='bookmark' title='Permanent Link: Looking for someone to give me a hand'>Looking for someone to give me a hand</a></li>
<li><a href='http://www.sharms.org/blog/2008/08/got-skills-email-me/' rel='bookmark' title='Permanent Link: Got skills?  Email me'>Got skills?  Email me</a></li>
<li><a href='http://www.sharms.org/blog/2007/06/novell-linux-client-on-ubuntu-redux/' rel='bookmark' title='Permanent Link: Novell Linux Client on Ubuntu redux'>Novell Linux Client on Ubuntu redux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/07/linux-guru-needed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers</title>
		<link>http://www.sharms.org/blog/2010/07/sles-sp1-and-novell-suse-autoyast-with-intel-dell-raid-controllers/</link>
		<comments>http://www.sharms.org/blog/2010/07/sles-sp1-and-novell-suse-autoyast-with-intel-dell-raid-controllers/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 20:06:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=735</guid>
		<description><![CDATA[When using an Intel raid controller, you have two options: let the raid controller handle the raid, or run a linux software raid (md). If you want to run a linux software raid, and use autoyast, a prompt box will popup during the middle of the installation. This becomes a problem if you are imaging [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/09/sles-sled-10-with-intel-965-graphics/' rel='bookmark' title='Permanent Link: SLES / SLED 10 with Intel 965 Graphics'>SLES / SLED 10 with Intel 965 Graphics</a></li>
<li><a href='http://www.sharms.org/blog/2007/06/dell-d620-love/' rel='bookmark' title='Permanent Link: Dell D620 Love'>Dell D620 Love</a></li>
<li><a href='http://www.sharms.org/blog/2007/11/adventures-in-dual-head-for-dell-d620-with-intel/' rel='bookmark' title='Permanent Link: Adventures in 3D Dual Head for Dell D620 with intel'>Adventures in 3D Dual Head for Dell D620 with intel</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When using an Intel raid controller, you have two options: let the raid controller handle the raid, or run a linux software raid (md).  If you want to run a linux software raid, and use autoyast, a prompt box will popup during the middle of the installation.  This becomes a problem if you are imaging several thousand Linux systems.</p>
<p>Add this to your bootup options (in our case PXE config, but you can type it manually also from the installation CD prompt):</p>
<pre class="brush: sh">
libstorage_imsm_driver=mdadm
</pre>
<p>That is all there is to it.  To configure the rest of autoyast, you can check out Uwe Gansert&#8217;s website as he maintains it: <a href="http://www.suse.com/~ug/">http://www.suse.com/~ug/</a></p>
<p>Other hard to find resources when tracking these things down:</p>
<ul>
<li><a href="http://svn.opensuse.org/viewvc/yast/trunk">Yast2 SVN Repository</a></li>
<li><a href="http://gitorious.org/opensuse">OpenSUSE Git Repository</a></li>
</ul>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/09/sles-sled-10-with-intel-965-graphics/' rel='bookmark' title='Permanent Link: SLES / SLED 10 with Intel 965 Graphics'>SLES / SLED 10 with Intel 965 Graphics</a></li>
<li><a href='http://www.sharms.org/blog/2007/06/dell-d620-love/' rel='bookmark' title='Permanent Link: Dell D620 Love'>Dell D620 Love</a></li>
<li><a href='http://www.sharms.org/blog/2007/11/adventures-in-dual-head-for-dell-d620-with-intel/' rel='bookmark' title='Permanent Link: Adventures in 3D Dual Head for Dell D620 with intel'>Adventures in 3D Dual Head for Dell D620 with intel</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/07/sles-sp1-and-novell-suse-autoyast-with-intel-dell-raid-controllers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming using IOCTL to interface with Linux kernel drivers</title>
		<link>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/</link>
		<comments>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 19:14:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=721</guid>
		<description><![CDATA[IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module. From a programming perspective, having the linux kernel source is a prerequisite. In this example, I cloned the main kernel: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux Once I had [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/07/programming-in-c-converting-an-integer-to-binary-int-to-bin/' rel='bookmark' title='Permanent Link: Programming in C: Converting an Integer to Binary (int to bin)'>Programming in C: Converting an Integer to Binary (int to bin)</a></li>
<li><a href='http://www.sharms.org/blog/2009/07/fun-stuff/' rel='bookmark' title='Permanent Link: MMap to null'>MMap to null</a></li>
<li><a href='http://www.sharms.org/blog/2008/12/why/' rel='bookmark' title='Permanent Link: Why?'>Why?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module.  </p>
<p>From a programming perspective, having the linux kernel source is a prerequisite.  In this example, I cloned the main kernel:</p>
<pre class="brush: sh">
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux
</pre>
<p>Once I had the source, I specifically wanted to see exactly how I could interface with the driver called <strong>usblp</strong>.  I was using a USB to parallel port converter, and wanted to see if there was any way to force it to operate differently as we needed a non-printer device to work with it.</p>
<p>After opening the kernel source, I found the driver file itself which was under <strong>/drivers/usb/class/usblp.c</strong>.  In this file I found a section of information about which IOCTLs it supported, and put them in a header file for my program called usblp-hack.h:</p>
<pre class="brush: c">
#ifndef USBLP_HACK_H
#define USBLP_HACK_H

#include &lt;linux/ioctl.h&gt;

/* ioctls: */
#define IOCNR_GET_DEVICE_ID     1
#define IOCNR_GET_PROTOCOLS     2
#define IOCNR_SET_PROTOCOL      3
#define IOCNR_HP_SET_CHANNEL        4
#define IOCNR_GET_BUS_ADDRESS       5
#define IOCNR_GET_VID_PID       6
#define IOCNR_SOFT_RESET        7
/* Get device_id string: */
#define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_DEVICE_ID, len)
/* The following ioctls were added for http://hpoj.sourceforge.net: */
/* Get two-int array:
 * [0]=current protocol (1=7/1/1, 2=7/1/2, 3=7/1/3),
 * [1]=supported protocol mask (mask&amp;(1&lt;&lt;n)!=0 means 7/1/n supported): */
#define LPIOC_GET_PROTOCOLS(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_PROTOCOLS, len)
/* Set protocol (arg: 1=7/1/1, 2=7/1/2, 3=7/1/3): */
#define LPIOC_SET_PROTOCOL _IOC(_IOC_WRITE, &#039;P&#039;, IOCNR_SET_PROTOCOL, 0)
/* Set channel number (HP Vendor-specific command): */
#define LPIOC_HP_SET_CHANNEL _IOC(_IOC_WRITE, &#039;P&#039;, IOCNR_HP_SET_CHANNEL, 0)
/* Get two-int array: [0]=bus number, [1]=device address: */
#define LPIOC_GET_BUS_ADDRESS(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_BUS_ADDRESS, len)
/* Get two-int array: [0]=vendor ID, [1]=product ID: */
#define LPIOC_GET_VID_PID(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_VID_PID, len)
/* Perform class specific soft reset */
#define LPIOC_SOFT_RESET _IOC(_IOC_NONE, &#039;P&#039;, IOCNR_SOFT_RESET, 0)
#endif
</pre>
<p>There are plenty of hints on usage here, and I was able to grab a little more info after searching for some of those defines in google code search.  Using these IOCTLs I wanted to know exactly which modes the USB to parallel converter supported, and try to set it in mode 3, which I hoped would give me more options for talking to the device.</p>
<p>Here is my usblp-hack.c which was able to probe and update these settings, although in my case mode 3 didn&#8217;t work, but shows an example of exactly how to do it:</p>
<pre class="brush: c">
#include &quot;usblp-hack.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;fcntl.h&gt;		/* open */
#include &lt;unistd.h&gt;		/* exit */
#include &lt;sys/ioctl.h&gt;		/* ioctl */

main()
{
	int fd;
	int twoints[2];

	fd = open(&quot;/dev/usblp0&quot;, O_RDONLY | O_NONBLOCK);
	if (fd &lt; 0) {
		printf(&quot;Cannot open device.\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &amp;twoints) &gt;= 0)
		printf(&quot;Great success: %d / %d\n&quot;, twoints[0], twoints[1]);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SET_PROTOCOL, 2) &gt;= 0)
		printf(&quot;set protocol to version 2\n&quot;);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &amp;twoints) &gt;= 0)
		printf(&quot;Great success: %d / %d\n&quot;, twoints[0], twoints[1]);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SOFT_RESET) &gt;= 0)
	{
		printf(&quot;Success reset device\n&quot;);
	} else {
		printf(&quot;Could not reset device\n&quot;);
		exit(-1);
	}

	close(fd);
	exit(0);
}
</pre>
<p>You can compile the above example just using gcc:</p>
<pre class="brush: sh">
gcc -o usblp-hack usblp-hack.c
</pre>
<p>You can see in the example above I was able to probe the device to see what mode it was currently in and supports (<strong>LPIOC_GET_PROTOCOLS</strong>), attempt to set the device mode (<strong>LPIOC_SET_PROTOCOL</strong>), and soft reset the device (<strong>LPIOC_SOFT_RESET</strong>).</p>
<p>So in the end, nothing here too complex or mind blowing, but if you are just getting your feet wet it might take you a minute to dig this sort of information up.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/07/programming-in-c-converting-an-integer-to-binary-int-to-bin/' rel='bookmark' title='Permanent Link: Programming in C: Converting an Integer to Binary (int to bin)'>Programming in C: Converting an Integer to Binary (int to bin)</a></li>
<li><a href='http://www.sharms.org/blog/2009/07/fun-stuff/' rel='bookmark' title='Permanent Link: MMap to null'>MMap to null</a></li>
<li><a href='http://www.sharms.org/blog/2008/12/why/' rel='bookmark' title='Permanent Link: Why?'>Why?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.567 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-10 17:51:31 -->
