<?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; port</title>
	<atom:link href="http://www.alfersoft.com.ar/blog/tag/port/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>How to create two wired virtual serial ports on Linux?</title>
		<link>http://www.alfersoft.com.ar/blog/2010/02/19/how-to-create-two-wired-virtual-serial-ports-on-linux/</link>
		<comments>http://www.alfersoft.com.ar/blog/2010/02/19/how-to-create-two-wired-virtual-serial-ports-on-linux/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:18:32 +0000</pubDate>
		<dc:creator>fvicente</dc:creator>
				<category><![CDATA[Linux FAQ]]></category>
		<category><![CDATA[Programming FAQ]]></category>
		<category><![CDATA[bridged]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[null-modem]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[rs-232]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[wired]]></category>

		<guid isPermaLink="false">http://www.alfersoft.com.ar/blog/?p=134</guid>
		<description><![CDATA[To create two bridged virtual serial ports use the following command: socat -d -d pty,raw,echo=0 pty,raw,echo=0 The output will show you which are the virtual ports (or pseudo terminals) created, e.g.: 2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/3 2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/4 2010/02/19 16:16:33 socat[9662] N starting data transfer loop with FDs [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="FAQ" src="http://www.alfersoft.com.ar/files/question.png" alt="" width="48" height="48" /></p>
<p>To create two bridged virtual serial ports use the following command:<br />
<code><br />
socat -d -d pty,raw,echo=0 pty,raw,echo=0<br />
</code></p>
<p>The output will show you which are the virtual ports (or pseudo terminals) created, e.g.:<br />
<code><br />
2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/3<br />
2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/4<br />
2010/02/19 16:16:33 socat[9662] N starting data transfer loop with FDs [3,3] and [5,5]<br />
</code></p>
<p>Note: if you are using Ubuntu and you do not have this command, try:<br />
<code><br />
sudo apt-get install socat<br />
</code></p>
<h6><a title="Lock" href="http://commons.wikimedia.org/wiki/File:Gnome-dialog-question.svg" target="_blank">Image source</a></h6>
]]></content:encoded>
			<wfw:commentRss>http://www.alfersoft.com.ar/blog/2010/02/19/how-to-create-two-wired-virtual-serial-ports-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
	</channel>
</rss>

