<?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>AlferSoft Blog &#187; code</title>
	<atom:link href="http://www.alfersoft.com.ar/blog/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alfersoft.com.ar/blog</link>
	<description>Explaining this blog in a few words since 1999</description>
	<lastBuildDate>Wed, 01 Feb 2012 22:36:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Code optimization for RXTX parallel port implementation</title>
		<link>http://www.alfersoft.com.ar/blog/2008/05/26/code-optimization-for-rxtx/</link>
		<comments>http://www.alfersoft.com.ar/blog/2008/05/26/code-optimization-for-rxtx/#comments</comments>
		<pubDate>Tue, 27 May 2008 02:02:13 +0000</pubDate>
		<dc:creator>fvicente</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[rxtx]]></category>

		<guid isPermaLink="false">http://www.alfersoft.com.ar/blog/?p=6</guid>
		<description><![CDATA[RXTX is a native lib providing serial and parallel communication for the Java Development Toolkit (JDK). All deliverables are under the gnu LGPL license. The native part is developed in C. If you are using the parallel port functions of this project for version rxtx-2.1-7r2 or older, you may be interested in this code optimization, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.alfersoft.com.ar/files/db25.jpg" alt="DB-25 Connector" width="300" height="225" /></p>
<p><a title="RXTX" href="http://www.rxtx.org/" target="_blank">RXTX</a> is a native lib providing serial and parallel communication for the Java Development Toolkit (JDK). All deliverables are under the gnu LGPL license. The native part is developed in C.</p>
<p>If you are using the parallel port functions of this project for version rxtx-2.1-7r2 or older, you may be interested in this code optimization, it is a small change but it may improve the resource usage in certain cases.</p>
<p><span id="more-6"></span></p>
<p>Let&#8217;s take a look to readArray function in ParallelImp.c, this is a summary of the current implementation:</p>
<pre class="brush: cpp; title: ; notranslate">

buffer = (unsigned char *)malloc( sizeof( unsigned char ) * length );
bytes = read_byte_array( fd, buffer, length, threshold, timeout );
for( i = 0; i &lt; bytes; i++ ) body[ i + offset ] = buffer[ i ];
free( buffer );
</pre>
<p>In C we can increment the output buffer pointer to the position we want to start to write (offset) directly, avoiding the necessity of allocating a new buffer and copying the contents, for example:</p>
<pre class="brush: cpp; title: ; notranslate">

//buffer = (unsigned char *)malloc( sizeof( unsigned char ) * length );
buffer = body+offset
bytes = read_byte_array( fd, buffer, length, threshold, timeout );
//for( i = 0; i &lt; bytes; i++ ) body[ i + offset ] = buffer[ i ];
//free( buffer );
</pre>
<p>This kind optimization can be also applied to the writeArray function in the same source file.</p>
<p>I&#8217;m going to send this information to the RXTX project mailing list, hopefully it will be available in next version!</p>
<h6><a title="db25 picture" href="http://commons.wikimedia.org/wiki/Image:Scsi_extern_db25_st.jpg" target="_blank">picture source</a></h6>
]]></content:encoded>
			<wfw:commentRss>http://www.alfersoft.com.ar/blog/2008/05/26/code-optimization-for-rxtx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Visual Studio solutions to SCons</title>
		<link>http://www.alfersoft.com.ar/blog/2008/05/23/converting-visual-studio-solutions-to-scons/</link>
		<comments>http://www.alfersoft.com.ar/blog/2008/05/23/converting-visual-studio-solutions-to-scons/#comments</comments>
		<pubDate>Fri, 23 May 2008 23:19:46 +0000</pubDate>
		<dc:creator>fvicente</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scons]]></category>

		<guid isPermaLink="false">http://www.alfersoft.com.ar/blog/?p=5</guid>
		<description><![CDATA[A python script to convert Microsoft Visual Studio 2005 solution files (*.sln) and the associated project files (*.vcproj) into a set of SCons files (SConstruct and SConscript). This script is similar to my previous post Sln2Make but instead of generating Makefiles it creates SCons scripts. The class Sln2SCons does all the work, parses the sln [...]]]></description>
			<content:encoded><![CDATA[<p>A python script to convert Microsoft Visual Studio 2005 solution files (*.sln) and the associated project files (*.vcproj) into a set of SCons files (SConstruct and SConscript).</p>
<p><span id="more-5"></span></p>
<p>This script is similar to my previous post Sln2Make but instead of generating Makefiles it creates SCons scripts. The class Sln2SCons does all the work, parses the sln and vcproj files and generates a main SConstruct and one SConscript for every project in the solution. To use it, just instantiate the class with the following parameters:</p>
<p><code>Sln2SCons(</code><code>slnpath</code><code>, exlist, dirrepl, librepl, outdir)</code></p>
<p>where:</p>
<ul>
<li>slnpath is the path to the solution file</li>
<li>exlist an optional list of files to exclude, optionally you can pass an alternative script name to be included from the main SConstruct: [[script_to_exclude, alt_script], &#8230;]</li>
<li>dirrepl a list of directory replacement rules</li>
<li>librepl library name replacement rules (when win library name doesn&#8217;t match OS&#8217;s library name)</li>
<li>outdir is the output directory for the SConstruct</li>
</ul>
<p>example:</p>
<pre class="brush: python; title: ; notranslate">

# custom scripts
exlist = [('../extsrc/apr/SConscript', 'extsrc/apr/SConscript.py')]
# special directory replacement rules
dirrepl = []
# special library name replacement rules (when win library name doesn't match OS's library name)
librepl = []
Sln2SCons(&quot;../winnt/test.sln&quot;, exlist, dirrepl, librepl, &quot;../&quot;)
</pre>
<p>To correct the path case, I&#8217;ve used a script published by Moshe Zadka <a title="Case Correction in Python" href="http://mail.python.org/pipermail/python-list/2000-June/038502.html">here</a>.<br />
Use this code at your own risk, it is released under BSD license.</p>
<p>The source is in Google Code now, <a title="sln2scons on Google Code" href="http://code.google.com/p/sln2scons/" target="_blank">here is the link</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alfersoft.com.ar/blog/2008/05/23/converting-visual-studio-solutions-to-scons/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

